laag-libtiff 4.0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +57 -0
- data/LICENSE.txt +21 -0
- data/README.org +34 -0
- data/ext/laag/libtiff/extconf.rb +13 -0
- data/laag-libtiff.gemspec +20 -0
- data/lib/laag/libtiff.rb +29 -0
- data/vendor/gitlab.com/libtiff/libtiff/.appveyor.yml +109 -0
- data/vendor/gitlab.com/libtiff/libtiff/.cvsignore +4 -0
- data/vendor/gitlab.com/libtiff/libtiff/.travis.yml +34 -0
- data/vendor/gitlab.com/libtiff/libtiff/CMakeLists.txt +764 -0
- data/vendor/gitlab.com/libtiff/libtiff/COMMITTERS +19 -0
- data/vendor/gitlab.com/libtiff/libtiff/COPYRIGHT +21 -0
- data/vendor/gitlab.com/libtiff/libtiff/ChangeLog +8073 -0
- data/vendor/gitlab.com/libtiff/libtiff/HOWTO-RELEASE +119 -0
- data/vendor/gitlab.com/libtiff/libtiff/HOWTO-SECURITY-RELEASE +19 -0
- data/vendor/gitlab.com/libtiff/libtiff/Makefile.am +91 -0
- data/vendor/gitlab.com/libtiff/libtiff/Makefile.in +995 -0
- data/vendor/gitlab.com/libtiff/libtiff/Makefile.vc +58 -0
- data/vendor/gitlab.com/libtiff/libtiff/README +61 -0
- data/vendor/gitlab.com/libtiff/libtiff/README.vms +12 -0
- data/vendor/gitlab.com/libtiff/libtiff/RELEASE-DATE +1 -0
- data/vendor/gitlab.com/libtiff/libtiff/SConstruct +171 -0
- data/vendor/gitlab.com/libtiff/libtiff/TODO +12 -0
- data/vendor/gitlab.com/libtiff/libtiff/VERSION +1 -0
- data/vendor/gitlab.com/libtiff/libtiff/aclocal.m4 +1194 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/bmp2tiff.1.html +121 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/gif2tiff.1.html +141 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/ras2tiff.1.html +139 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/sgi2tiff.1.html +147 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/html/man/tiffsv.1.html +207 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/man/bmp2tiff.1 +85 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/man/gif2tiff.1 +81 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/man/ras2tiff.1 +96 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/man/sgi2tiff.1 +93 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/man/tiffsv.1 +142 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/bmp2tiff.c +937 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/gif2tiff.c +591 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/ras2tiff.c +338 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/rasterfile.h +44 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/sgi2tiff.c +337 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/sgisv.c +318 -0
- data/vendor/gitlab.com/libtiff/libtiff/archive/tools/ycbcr.c +168 -0
- data/vendor/gitlab.com/libtiff/libtiff/autogen.sh +8 -0
- data/vendor/gitlab.com/libtiff/libtiff/build/.cvsignore +1 -0
- data/vendor/gitlab.com/libtiff/libtiff/build/CMakeLists.txt +25 -0
- data/vendor/gitlab.com/libtiff/libtiff/build/Makefile.am +32 -0
- data/vendor/gitlab.com/libtiff/libtiff/build/Makefile.in +680 -0
- data/vendor/gitlab.com/libtiff/libtiff/build/README +3 -0
- data/vendor/gitlab.com/libtiff/libtiff/build/travis-ci +108 -0
- data/vendor/gitlab.com/libtiff/libtiff/commit +233 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/compile +347 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/config.guess +1526 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/config.sub +1658 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/depcomp +791 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/install-sh +507 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/ltmain.sh +11156 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/missing +215 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/mkinstalldirs +161 -0
- data/vendor/gitlab.com/libtiff/libtiff/config/test-driver +127 -0
- data/vendor/gitlab.com/libtiff/libtiff/configure +23612 -0
- data/vendor/gitlab.com/libtiff/libtiff/configure.ac +1112 -0
- data/vendor/gitlab.com/libtiff/libtiff/configure.com +1357 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/CMakeLists.txt +35 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/Makefile.am +31 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/Makefile.in +679 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/README +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/.cvsignore +5 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/CMakeLists.txt +34 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/Makefile.am +39 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/Makefile.in +652 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/Makefile.vc +28 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/README +142 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/addtiffo.c +181 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/tif_overview.c +916 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/tif_ovrcache.c +344 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/addtiffo/tif_ovrcache.h +103 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/.cvsignore +8 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/CMakeLists.txt +43 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/Makefile.am +46 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/Makefile.in +798 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/README +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-bi.c +91 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-grayscale.c +147 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-palette.c +284 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/tiff-rgb.c +201 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/CMakeLists.txt +29 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/Makefile.am +47 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/Makefile.in +516 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/README +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/patchlevel.h +8 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/xtiff.c +1290 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/dbs/xtiff/xtifficon.h +21 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/.cvsignore +5 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/CMakeLists.txt +35 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/Makefile.am +40 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/Makefile.in +650 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/README +25 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/iptcutil.c +954 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/test.iptc +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/iptcutil/test.txt +32 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/CMakeLists.txt +27 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/Makefile.am +29 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/Makefile.in +499 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/README +37 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/mfs/mfs_file.c +586 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/CMakeLists.txt +30 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/Makefile.am +32 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/Makefile.in +502 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/README +90 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_imageiter.c +525 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_imageiter.h +64 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_pdsdirread.c +1131 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/pds/tif_pdsdirwrite.c +971 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/CMakeLists.txt +28 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/Makefile.am +30 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/Makefile.in +500 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/README +10 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/ras2tif.c +254 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/ras/tif2ras.c +344 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/CMakeLists.txt +28 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/Makefile.am +30 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/Makefile.in +500 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/README +30 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/tiffstream.cpp +238 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/stream/tiffstream.h +70 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/CMakeLists.txt +32 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/Makefile.am +33 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/Makefile.in +503 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/README +132 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/listtif.c +39 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/maketif.c +77 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/xtif_dir.c +350 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/xtiffio.h +59 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/tags/xtiffiop.h +72 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/CMakeLists.txt +30 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Makefile.am +32 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Makefile.in +502 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Makefile.w95 +134 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/README.Tiffile +31 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/README.tiff2dib +51 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/Tiffile.cpp +449 -0
- data/vendor/gitlab.com/libtiff/libtiff/contrib/win_dib/tiff2dib.c +379 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/.cvsignore +5 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/BigTIFFProposal.html +99 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/CMakeLists.txt +87 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/Makefile.am +96 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/Makefile.in +798 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/TIFFTechNote2.html +707 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/addingtags.html +292 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffdesign.html +80 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr.html +77 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/esri.png +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/leica.png +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/safe.png +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bigtiffpr_images/weogeo.png +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/bugs.html +61 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/build.html +737 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/contrib.html +209 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/document.html +52 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images.html +41 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/CMakeLists.txt +46 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/Makefile.am +49 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/Makefile.in +572 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/back.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/bali.jpg +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/cat.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/cover.jpg +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/cramps.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/dave.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/info.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/jello.jpg +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/jim.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/note.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/oxford.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/quad.jpg +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/ring.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/smallliz.jpg +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/strike.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/images/warning.gif +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/index.html +122 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/internals.html +572 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/intro.html +68 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/libtiff.html +747 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/.cvsignore +2 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/CMakeLists.txt +108 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/HtmlDoc.cmake +50 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/Makefile.am +122 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/Makefile.in +642 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFClose.3tiff.html +87 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFDataWidth.3tiff.html +98 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFError.3tiff.html +106 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldDataType.3tiff.html +89 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldName.3tiff.html +86 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldPassCount.3tiff.html +98 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldReadCount.3tiff.html +101 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldTag.3tiff.html +88 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFieldWriteCount.3tiff.html +108 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFFlush.3tiff.html +113 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFGetField.3tiff.html +1969 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFOpen.3tiff.html +421 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFPrintDirectory.3tiff.html +225 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFRGBAImage.3tiff.html +319 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadDirectory.3tiff.html +218 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadEncodedStrip.3tiff.html +133 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadEncodedTile.3tiff.html +130 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRGBAImage.3tiff.html +301 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRGBAStrip.3tiff.html +208 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRGBATile.3tiff.html +261 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRawStrip.3tiff.html +109 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadRawTile.3tiff.html +111 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadScanline.3tiff.html +157 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFReadTile.3tiff.html +133 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFSetDirectory.3tiff.html +122 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFSetField.3tiff.html +1865 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWarning.3tiff.html +108 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteDirectory.3tiff.html +176 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteEncodedStrip.3tiff.html +153 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteEncodedTile.3tiff.html +147 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteRawStrip.3tiff.html +144 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteRawTile.3tiff.html +128 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteScanline.3tiff.html +206 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFWriteTile.3tiff.html +115 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFbuffer.3tiff.html +116 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFcodec.3tiff.html +116 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFcolor.3tiff.html +975 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFmemory.3tiff.html +110 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFquery.3tiff.html +148 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFsize.3tiff.html +95 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFstrip.3tiff.html +129 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFswab.3tiff.html +110 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/TIFFtile.3tiff.html +141 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/fax2ps.1.html +252 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/fax2tiff.1.html +607 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/index.html +64 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/libtiff.3tiff.html +1150 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/pal2rgb.1.html +189 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/ppm2tiff.1.html +141 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/raw2tiff.1.html +510 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/rgb2ycbcr.1.html +155 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/thumbnail.1.html +148 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2bw.1.html +161 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2pdf.1.html +609 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2ps.1.html +639 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiff2rgba.1.html +162 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffcmp.1.html +156 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffcp.1.html +569 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffcrop.1.html +684 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffdither.1.html +196 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffdump.1.html +145 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffgt.1.html +551 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffinfo.1.html +196 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffmedian.1.html +183 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffset.1.html +176 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/man/tiffsplit.1.html +102 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/misc.html +117 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/support.html +655 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/tools.html +137 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta007.html +112 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta016.html +122 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta018.html +84 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta024.html +139 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta028.html +146 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta029.html +86 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta031.html +94 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta032.html +90 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta033.html +82 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta034.html +68 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta035.html +63 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.4beta036.html +117 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.1.html +75 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.2.html +108 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.3.html +132 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.4.html +88 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.5.html +155 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.6-beta.html +185 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.5.7.html +259 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.6.0.html +434 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.6.1.html +199 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0.html +144 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0alpha.html +249 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0beta.html +162 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.0beta2.html +131 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.1.html +233 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.2.html +222 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.3.html +230 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.7.4.html +133 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.8.0.html +199 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.8.1.html +217 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.8.2.html +137 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.0.html +261 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.0beta.html +304 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.1.html +115 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.2.html +122 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.3.html +160 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.4.html +125 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v3.9.5.html +270 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.0.html +269 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.1.html +113 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.2.html +118 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.3.html +125 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.4.html +274 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.4beta.html +291 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.5.html +148 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.6.html +139 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.7.html +411 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.8.html +445 -0
- data/vendor/gitlab.com/libtiff/libtiff/html/v4.0.9.html +373 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff-4.pc.in +11 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/.cvsignore +22 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/CMakeLists.txt +165 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.am +154 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.in +966 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.lcc +129 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/Makefile.vc +102 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/SConstruct +73 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/libtiff.def +168 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/libtiff.map +4 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/libtiffxx.map +4 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/mkg3states.c +454 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/mkspans.c +82 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/t4.h +292 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_aux.c +376 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_close.c +140 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_codec.c +165 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_color.c +309 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_compress.c +304 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.h-vms +46 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.h.cmake.in +261 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.h.in +410 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.vc.h +137 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_config.wince.h +71 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dir.c +1767 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dir.h +309 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dirinfo.c +1070 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dirread.c +5803 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dirwrite.c +3024 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_dumpmode.c +143 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_error.c +88 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_extension.c +118 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_fax3.c +1648 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_fax3.h +540 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_fax3sm.c +1260 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_flush.c +118 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_getimage.c +3048 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_jbig.c +214 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_jpeg.c +2601 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_jpeg_12.c +69 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_luv.c +1765 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_lzma.c +495 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_lzw.c +1218 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_next.c +189 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_ojpeg.c +2563 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_open.c +725 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_packbits.c +311 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_pixarlog.c +1485 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_predict.c +881 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_predict.h +79 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_print.c +722 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_read.c +1572 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_stream.cxx +430 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_strip.c +389 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_swab.c +312 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_thunder.c +208 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_tile.c +322 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_unix.c +386 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_version.c +40 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_vms.c +611 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_warning.c +89 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_win32.c +476 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_wince.c +293 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_write.c +834 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tif_zip.c +476 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiff.h +681 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.h-vms +99 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.h.cmake.in +130 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.h.in +127 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.vc.h +161 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffconf.wince.h +121 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffio.h +560 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffio.hxx +49 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffiop.h +445 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffvers.h +9 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/tiffvers.h.in +9 -0
- data/vendor/gitlab.com/libtiff/libtiff/libtiff/uvcode.h +180 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/acinclude.m4 +851 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/ice_find_athena.m4 +187 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/libtool.m4 +8388 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/ltoptions.m4 +437 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/ltsugar.m4 +124 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/ltversion.m4 +23 -0
- data/vendor/gitlab.com/libtiff/libtiff/m4/lt~obsolete.m4 +99 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/.cvsignore +3 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/CMakeLists.txt +97 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/Makefile.am +94 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/Makefile.in +684 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFClose.3tiff +53 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFDataWidth.3tiff +74 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFError.3tiff +69 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldDataType.3tiff +53 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldName.3tiff +52 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldPassCount.3tiff +73 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldReadCount.3tiff +77 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldTag.3tiff +56 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFieldWriteCount.3tiff +88 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFFlush.3tiff +64 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFGetField.3tiff +229 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFOpen.3tiff +279 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFPrintDirectory.3tiff +70 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFRGBAImage.3tiff +286 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadDirectory.3tiff +164 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadEncodedStrip.3tiff +78 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadEncodedTile.3tiff +76 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRGBAImage.3tiff +218 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRGBAStrip.3tiff +170 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRGBATile.3tiff +171 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRawStrip.3tiff +64 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadRawTile.3tiff +65 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadScanline.3tiff +94 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFReadTile.3tiff +84 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFSetDirectory.3tiff +79 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFSetField.3tiff +217 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWarning.3tiff +70 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteDirectory.3tiff +138 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteEncodedStrip.3tiff +102 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteEncodedTile.3tiff +96 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteRawStrip.3tiff +96 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteRawTile.3tiff +84 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteScanline.3tiff +154 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFWriteTile.3tiff +77 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFbuffer.3tiff +77 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFcodec.3tiff +82 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFcolor.3tiff +268 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFmemory.3tiff +90 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFquery.3tiff +142 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFsize.3tiff +59 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFstrip.3tiff +99 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFswab.3tiff +80 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/TIFFtile.3tiff +131 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/fax2ps.1 +159 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/fax2tiff.1 +286 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/libtiff.3tiff +545 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/pal2rgb.1 +111 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/ppm2tiff.1 +105 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/raw2tiff.1 +196 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/rgb2ycbcr.1 +99 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/thumbnail.1 +90 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiff2bw.1 +94 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiff2pdf.1 +254 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiff2ps.1 +294 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiff2rgba.1 +97 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffcmp.1 +87 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffcp.1 +317 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffcrop.1 +571 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffdither.1 +135 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffdump.1 +81 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffgt.1 +245 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffinfo.1 +88 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffmedian.1 +112 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffset.1 +99 -0
- data/vendor/gitlab.com/libtiff/libtiff/man/tiffsplit.1 +69 -0
- data/vendor/gitlab.com/libtiff/libtiff/nmake.opt +229 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/.cvsignore +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/CMakeLists.txt +60 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/Makefile.am +35 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/Makefile.in +656 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/Makefile.vc +44 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/dummy.c +12 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/getopt.c +125 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/lfind.c +62 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/libport.h +60 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/snprintf.c +38 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/strcasecmp.c +51 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/strtoul.c +109 -0
- data/vendor/gitlab.com/libtiff/libtiff/port/strtoull.c +116 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/.cvsignore +12 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/CMakeLists.txt +382 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/Makefile.am +334 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/Makefile.in +1987 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/TiffSplitTest.cmake +34 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/TiffTest.cmake +63 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/TiffTestCommon.cmake +108 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/ascii_tag.c +177 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/check_tag.c +91 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/common.sh +122 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/custom_dir.c +247 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/README.txt +29 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/logluv-3c-16b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-1c-16b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-1c-8b.pgm +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-1c-8b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/minisblack-2c-8b-alpha.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/miniswhite-1c-1b.pbm +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/miniswhite-1c-1b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/palette-1c-1b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/palette-1c-4b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/palette-1c-8b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/quad-lzw-compat.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/quad-tile.jpg.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/rgb-3c-16b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/rgb-3c-8b.ppm +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/images/rgb-3c-8b.tiff +0 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/long_tag.c +156 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/ppm2tiff_pbm.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/ppm2tiff_pgm.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/ppm2tiff_ppm.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/raw_decode.c +304 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/rewrite_tag.c +344 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/short_tag.c +205 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/strip.c +290 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/strip_rw.c +157 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/test_arrays.c +829 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/test_arrays.h +63 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2bw-palette-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2bw-quad-lzw-compat.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2bw-rgb-3c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2pdf.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-EPS1.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-PS1.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-PS2.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2ps-PS3.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-logluv-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-minisblack-1c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-minisblack-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-minisblack-2c-8b-alpha.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-miniswhite-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-palette-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-palette-1c-4b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-palette-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-quad-tile.jpg.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-rgb-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiff2rgba-rgb-3c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-1d-fill.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-1d.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-2d-fill.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3-2d.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g3.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-g4.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-logluv.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-lzw-compat.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-split-join.sh +16 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-split.sh +13 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcp-thumbnail.sh +10 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-logluv-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-minisblack-1c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-minisblack-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-minisblack-2c-8b-alpha.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-miniswhite-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-palette-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-palette-1c-4b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-palette-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-quad-tile.jpg.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-rgb-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-R90-rgb-3c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-logluv-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-minisblack-1c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-minisblack-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-miniswhite-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-palette-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-palette-1c-4b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-palette-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-quad-tile.jpg.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-rgb-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-doubleflip-rgb-3c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-logluv-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-minisblack-1c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-minisblack-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-minisblack-2c-8b-alpha.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-miniswhite-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-palette-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-palette-1c-4b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-palette-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-quad-tile.jpg.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-rgb-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extract-rgb-3c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-logluv-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-minisblack-1c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-minisblack-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-minisblack-2c-8b-alpha.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-miniswhite-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-palette-1c-1b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-palette-1c-4b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-palette-1c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-quad-tile.jpg.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-rgb-3c-16b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffcrop-extractz14-rgb-3c-8b.sh +7 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffdump.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tiffinfo.sh +6 -0
- data/vendor/gitlab.com/libtiff/libtiff/test/tifftest.h +42 -0
- data/vendor/gitlab.com/libtiff/libtiff/tiff.spec +68 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/.cvsignore +27 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/CMakeLists.txt +125 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.am +138 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.in +955 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.lcc +133 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/Makefile.vc +52 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/fax2ps.c +463 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/fax2tiff.c +491 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/pal2rgb.c +438 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/ppm2tiff.c +397 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/raw2tiff.c +690 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/rgb2ycbcr.c +397 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/thumbnail.c +691 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2bw.c +501 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2pdf.c +5594 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2ps.c +3106 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiff2rgba.c +569 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffcmp.c +659 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffcp.c +1913 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffcrop.c +9231 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffdither.c +347 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffdump.c +889 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffgt.c +486 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffinfo.c +488 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffinfoce.c +472 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffmedian.c +918 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffset.c +356 -0
- data/vendor/gitlab.com/libtiff/libtiff/tools/tiffsplit.c +305 -0
- metadata +692 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
/* $Id: tif_next.c,v 1.19 2016-09-04 21:32:56 erouault Exp $ */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright (c) 1988-1997 Sam Leffler
|
5
|
+
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
6
|
+
*
|
7
|
+
* Permission to use, copy, modify, distribute, and sell this software and
|
8
|
+
* its documentation for any purpose is hereby granted without fee, provided
|
9
|
+
* that (i) the above copyright notices and this permission notice appear in
|
10
|
+
* all copies of the software and related documentation, and (ii) the names of
|
11
|
+
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
12
|
+
* publicity relating to the software without the specific, prior written
|
13
|
+
* permission of Sam Leffler and Silicon Graphics.
|
14
|
+
*
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
17
|
+
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
18
|
+
*
|
19
|
+
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
20
|
+
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
21
|
+
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
22
|
+
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
23
|
+
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
24
|
+
* OF THIS SOFTWARE.
|
25
|
+
*/
|
26
|
+
|
27
|
+
#include "tiffiop.h"
|
28
|
+
#ifdef NEXT_SUPPORT
|
29
|
+
/*
|
30
|
+
* TIFF Library.
|
31
|
+
*
|
32
|
+
* NeXT 2-bit Grey Scale Compression Algorithm Support
|
33
|
+
*/
|
34
|
+
|
35
|
+
#define SETPIXEL(op, v) { \
|
36
|
+
switch (npixels++ & 3) { \
|
37
|
+
case 0: op[0] = (unsigned char) ((v) << 6); break; \
|
38
|
+
case 1: op[0] |= (v) << 4; break; \
|
39
|
+
case 2: op[0] |= (v) << 2; break; \
|
40
|
+
case 3: *op++ |= (v); op_offset++; break; \
|
41
|
+
} \
|
42
|
+
}
|
43
|
+
|
44
|
+
#define LITERALROW 0x00
|
45
|
+
#define LITERALSPAN 0x40
|
46
|
+
#define WHITE ((1<<2)-1)
|
47
|
+
|
48
|
+
static int
|
49
|
+
NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
50
|
+
{
|
51
|
+
static const char module[] = "NeXTDecode";
|
52
|
+
unsigned char *bp, *op;
|
53
|
+
tmsize_t cc;
|
54
|
+
uint8* row;
|
55
|
+
tmsize_t scanline, n;
|
56
|
+
|
57
|
+
(void) s;
|
58
|
+
/*
|
59
|
+
* Each scanline is assumed to start off as all
|
60
|
+
* white (we assume a PhotometricInterpretation
|
61
|
+
* of ``min-is-black'').
|
62
|
+
*/
|
63
|
+
for (op = (unsigned char*) buf, cc = occ; cc-- > 0;)
|
64
|
+
*op++ = 0xff;
|
65
|
+
|
66
|
+
bp = (unsigned char *)tif->tif_rawcp;
|
67
|
+
cc = tif->tif_rawcc;
|
68
|
+
scanline = tif->tif_scanlinesize;
|
69
|
+
if (occ % scanline)
|
70
|
+
{
|
71
|
+
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
|
72
|
+
return (0);
|
73
|
+
}
|
74
|
+
for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
|
75
|
+
n = *bp++;
|
76
|
+
cc--;
|
77
|
+
switch (n) {
|
78
|
+
case LITERALROW:
|
79
|
+
/*
|
80
|
+
* The entire scanline is given as literal values.
|
81
|
+
*/
|
82
|
+
if (cc < scanline)
|
83
|
+
goto bad;
|
84
|
+
_TIFFmemcpy(row, bp, scanline);
|
85
|
+
bp += scanline;
|
86
|
+
cc -= scanline;
|
87
|
+
break;
|
88
|
+
case LITERALSPAN: {
|
89
|
+
tmsize_t off;
|
90
|
+
/*
|
91
|
+
* The scanline has a literal span that begins at some
|
92
|
+
* offset.
|
93
|
+
*/
|
94
|
+
if( cc < 4 )
|
95
|
+
goto bad;
|
96
|
+
off = (bp[0] * 256) + bp[1];
|
97
|
+
n = (bp[2] * 256) + bp[3];
|
98
|
+
if (cc < 4+n || off+n > scanline)
|
99
|
+
goto bad;
|
100
|
+
_TIFFmemcpy(row+off, bp+4, n);
|
101
|
+
bp += 4+n;
|
102
|
+
cc -= 4+n;
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
default: {
|
106
|
+
uint32 npixels = 0, grey;
|
107
|
+
tmsize_t op_offset = 0;
|
108
|
+
uint32 imagewidth = tif->tif_dir.td_imagewidth;
|
109
|
+
if( isTiled(tif) )
|
110
|
+
imagewidth = tif->tif_dir.td_tilewidth;
|
111
|
+
|
112
|
+
/*
|
113
|
+
* The scanline is composed of a sequence of constant
|
114
|
+
* color ``runs''. We shift into ``run mode'' and
|
115
|
+
* interpret bytes as codes of the form
|
116
|
+
* <color><npixels> until we've filled the scanline.
|
117
|
+
*/
|
118
|
+
op = row;
|
119
|
+
for (;;) {
|
120
|
+
grey = (uint32)((n>>6) & 0x3);
|
121
|
+
n &= 0x3f;
|
122
|
+
/*
|
123
|
+
* Ensure the run does not exceed the scanline
|
124
|
+
* bounds, potentially resulting in a security
|
125
|
+
* issue.
|
126
|
+
*/
|
127
|
+
while (n-- > 0 && npixels < imagewidth && op_offset < scanline)
|
128
|
+
SETPIXEL(op, grey);
|
129
|
+
if (npixels >= imagewidth)
|
130
|
+
break;
|
131
|
+
if (op_offset >= scanline ) {
|
132
|
+
TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld",
|
133
|
+
(long) tif->tif_row);
|
134
|
+
return (0);
|
135
|
+
}
|
136
|
+
if (cc == 0)
|
137
|
+
goto bad;
|
138
|
+
n = *bp++;
|
139
|
+
cc--;
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
tif->tif_rawcp = (uint8*) bp;
|
146
|
+
tif->tif_rawcc = cc;
|
147
|
+
return (1);
|
148
|
+
bad:
|
149
|
+
TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
|
150
|
+
(long) tif->tif_row);
|
151
|
+
return (0);
|
152
|
+
}
|
153
|
+
|
154
|
+
static int
|
155
|
+
NeXTPreDecode(TIFF* tif, uint16 s)
|
156
|
+
{
|
157
|
+
static const char module[] = "NeXTPreDecode";
|
158
|
+
TIFFDirectory *td = &tif->tif_dir;
|
159
|
+
(void)s;
|
160
|
+
|
161
|
+
if( td->td_bitspersample != 2 )
|
162
|
+
{
|
163
|
+
TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d",
|
164
|
+
td->td_bitspersample);
|
165
|
+
return (0);
|
166
|
+
}
|
167
|
+
return (1);
|
168
|
+
}
|
169
|
+
|
170
|
+
int
|
171
|
+
TIFFInitNeXT(TIFF* tif, int scheme)
|
172
|
+
{
|
173
|
+
(void) scheme;
|
174
|
+
tif->tif_predecode = NeXTPreDecode;
|
175
|
+
tif->tif_decoderow = NeXTDecode;
|
176
|
+
tif->tif_decodestrip = NeXTDecode;
|
177
|
+
tif->tif_decodetile = NeXTDecode;
|
178
|
+
return (1);
|
179
|
+
}
|
180
|
+
#endif /* NEXT_SUPPORT */
|
181
|
+
|
182
|
+
/* vim: set ts=8 sts=8 sw=8 noet: */
|
183
|
+
/*
|
184
|
+
* Local Variables:
|
185
|
+
* mode: c
|
186
|
+
* c-basic-offset: 8
|
187
|
+
* fill-column: 78
|
188
|
+
* End:
|
189
|
+
*/
|
@@ -0,0 +1,2563 @@
|
|
1
|
+
/* $Id: tif_ojpeg.c,v 1.69 2017-04-27 17:29:26 erouault Exp $ */
|
2
|
+
|
3
|
+
/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
|
4
|
+
specification is now totally obsolete and deprecated for new applications and
|
5
|
+
images. This file was was created solely in order to read unconverted images
|
6
|
+
still present on some users' computer systems. It will never be extended
|
7
|
+
to write such files. Writing new-style JPEG compressed TIFFs is implemented
|
8
|
+
in tif_jpeg.c.
|
9
|
+
|
10
|
+
The code is carefully crafted to robustly read all gathered JPEG-in-TIFF
|
11
|
+
testfiles, and anticipate as much as possible all other... But still, it may
|
12
|
+
fail on some. If you encounter problems, please report them on the TIFF
|
13
|
+
mailing list and/or to Joris Van Damme <info@awaresystems.be>.
|
14
|
+
|
15
|
+
Please read the file called "TIFF Technical Note #2" if you need to be
|
16
|
+
convinced this compression scheme is bad and breaks TIFF. That document
|
17
|
+
is linked to from the LibTiff site <http://www.remotesensing.org/libtiff/>
|
18
|
+
and from AWare Systems' TIFF section
|
19
|
+
<http://www.awaresystems.be/imaging/tiff.html>. It is also absorbed
|
20
|
+
in Adobe's specification supplements, marked "draft" up to this day, but
|
21
|
+
supported by the TIFF community.
|
22
|
+
|
23
|
+
This file interfaces with Release 6B of the JPEG Library written by the
|
24
|
+
Independent JPEG Group. Previous versions of this file required a hack inside
|
25
|
+
the LibJpeg library. This version no longer requires that. Remember to
|
26
|
+
remove the hack if you update from the old version.
|
27
|
+
|
28
|
+
Copyright (c) Joris Van Damme <info@awaresystems.be>
|
29
|
+
Copyright (c) AWare Systems <http://www.awaresystems.be/>
|
30
|
+
|
31
|
+
The licence agreement for this file is the same as the rest of the LibTiff
|
32
|
+
library.
|
33
|
+
|
34
|
+
IN NO EVENT SHALL JORIS VAN DAMME OR AWARE SYSTEMS BE LIABLE FOR
|
35
|
+
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
36
|
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
37
|
+
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
38
|
+
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
39
|
+
OF THIS SOFTWARE.
|
40
|
+
|
41
|
+
Joris Van Damme and/or AWare Systems may be available for custom
|
42
|
+
development. If you like what you see, and need anything similar or related,
|
43
|
+
contact <info@awaresystems.be>.
|
44
|
+
*/
|
45
|
+
|
46
|
+
/* What is what, and what is not?
|
47
|
+
|
48
|
+
This decoder starts with an input stream, that is essentially the JpegInterchangeFormat
|
49
|
+
stream, if any, followed by the strile data, if any. This stream is read in
|
50
|
+
OJPEGReadByte and related functions.
|
51
|
+
|
52
|
+
It analyzes the start of this stream, until it encounters non-marker data, i.e.
|
53
|
+
compressed image data. Some of the header markers it sees have no actual content,
|
54
|
+
like the SOI marker, and APP/COM markers that really shouldn't even be there. Some
|
55
|
+
other markers do have content, and the valuable bits and pieces of information
|
56
|
+
in these markers are saved, checking all to verify that the stream is more or
|
57
|
+
less within expected bounds. This happens inside the OJPEGReadHeaderInfoSecStreamXxx
|
58
|
+
functions.
|
59
|
+
|
60
|
+
Some OJPEG imagery contains no valid JPEG header markers. This situation is picked
|
61
|
+
up on if we've seen no SOF marker when we're at the start of the compressed image
|
62
|
+
data. In this case, the tables are read from JpegXxxTables tags, and the other
|
63
|
+
bits and pieces of information is initialized to its most basic value. This is
|
64
|
+
implemented in the OJPEGReadHeaderInfoSecTablesXxx functions.
|
65
|
+
|
66
|
+
When this is complete, a good and valid JPEG header can be assembled, and this is
|
67
|
+
passed through to LibJpeg. When that's done, the remainder of the input stream, i.e.
|
68
|
+
the compressed image data, can be passed through unchanged. This is done in
|
69
|
+
OJPEGWriteStream functions.
|
70
|
+
|
71
|
+
LibTiff rightly expects to know the subsampling values before decompression. Just like
|
72
|
+
in new-style JPEG-in-TIFF, though, or even more so, actually, the YCbCrsubsampling
|
73
|
+
tag is notoriously unreliable. To correct these tag values with the ones inside
|
74
|
+
the JPEG stream, the first part of the input stream is pre-scanned in
|
75
|
+
OJPEGSubsamplingCorrect, making no note of any other data, reporting no warnings
|
76
|
+
or errors, up to the point where either these values are read, or it's clear they
|
77
|
+
aren't there. This means that some of the data is read twice, but we feel speed
|
78
|
+
in correcting these values is important enough to warrant this sacrifice. Although
|
79
|
+
there is currently no define or other configuration mechanism to disable this behaviour,
|
80
|
+
the actual header scanning is build to robustly respond with error report if it
|
81
|
+
should encounter an uncorrected mismatch of subsampling values. See
|
82
|
+
OJPEGReadHeaderInfoSecStreamSof.
|
83
|
+
|
84
|
+
The restart interval and restart markers are the most tricky part... The restart
|
85
|
+
interval can be specified in a tag. It can also be set inside the input JPEG stream.
|
86
|
+
It can be used inside the input JPEG stream. If reading from strile data, we've
|
87
|
+
consistently discovered the need to insert restart markers in between the different
|
88
|
+
striles, as is also probably the most likely interpretation of the original TIFF 6.0
|
89
|
+
specification. With all this setting of interval, and actual use of markers that is not
|
90
|
+
predictable at the time of valid JPEG header assembly, the restart thing may turn
|
91
|
+
out the Achilles heel of this implementation. Fortunately, most OJPEG writer vendors
|
92
|
+
succeed in reading back what they write, which may be the reason why we've been able
|
93
|
+
to discover ways that seem to work.
|
94
|
+
|
95
|
+
Some special provision is made for planarconfig separate OJPEG files. These seem
|
96
|
+
to consistently contain header info, a SOS marker, a plane, SOS marker, plane, SOS,
|
97
|
+
and plane. This may or may not be a valid JPEG configuration, we don't know and don't
|
98
|
+
care. We want LibTiff to be able to access the planes individually, without huge
|
99
|
+
buffering inside LibJpeg, anyway. So we compose headers to feed to LibJpeg, in this
|
100
|
+
case, that allow us to pass a single plane such that LibJpeg sees a valid
|
101
|
+
single-channel JPEG stream. Locating subsequent SOS markers, and thus subsequent
|
102
|
+
planes, is done inside OJPEGReadSecondarySos.
|
103
|
+
|
104
|
+
The benefit of the scheme is... that it works, basically. We know of no other that
|
105
|
+
does. It works without checking software tag, or otherwise going about things in an
|
106
|
+
OJPEG flavor specific manner. Instead, it is a single scheme, that covers the cases
|
107
|
+
with and without JpegInterchangeFormat, with and without striles, with part of
|
108
|
+
the header in JpegInterchangeFormat and remainder in first strile, etc. It is forgiving
|
109
|
+
and robust, may likely work with OJPEG flavors we've not seen yet, and makes most out
|
110
|
+
of the data.
|
111
|
+
|
112
|
+
Another nice side-effect is that a complete JPEG single valid stream is build if
|
113
|
+
planarconfig is not separate (vast majority). We may one day use that to build
|
114
|
+
converters to JPEG, and/or to new-style JPEG compression inside TIFF.
|
115
|
+
|
116
|
+
A disadvantage is the lack of random access to the individual striles. This is the
|
117
|
+
reason for much of the complicated restart-and-position stuff inside OJPEGPreDecode.
|
118
|
+
Applications would do well accessing all striles in order, as this will result in
|
119
|
+
a single sequential scan of the input stream, and no restarting of LibJpeg decoding
|
120
|
+
session.
|
121
|
+
*/
|
122
|
+
|
123
|
+
#define WIN32_LEAN_AND_MEAN
|
124
|
+
#define VC_EXTRALEAN
|
125
|
+
|
126
|
+
#include "tiffiop.h"
|
127
|
+
#ifdef OJPEG_SUPPORT
|
128
|
+
|
129
|
+
/* Configuration defines here are:
|
130
|
+
* JPEG_ENCAP_EXTERNAL: The normal way to call libjpeg, uses longjump. In some environments,
|
131
|
+
* like eg LibTiffDelphi, this is not possible. For this reason, the actual calls to
|
132
|
+
* libjpeg, with longjump stuff, are encapsulated in dedicated functions. When
|
133
|
+
* JPEG_ENCAP_EXTERNAL is defined, these encapsulating functions are declared external
|
134
|
+
* to this unit, and can be defined elsewhere to use stuff other then longjump.
|
135
|
+
* The default mode, without JPEG_ENCAP_EXTERNAL, implements the call encapsulators
|
136
|
+
* here, internally, with normal longjump.
|
137
|
+
* SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent is
|
138
|
+
* conveniently available, but still it may be worthwhile to use _setjmp or sigsetjmp
|
139
|
+
* in place of plain setjmp. These macros will make it easier. It is useless
|
140
|
+
* to fiddle with these if you define JPEG_ENCAP_EXTERNAL.
|
141
|
+
* OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee
|
142
|
+
* instant processing, optimal streaming and optimal use of processor cache, but also big
|
143
|
+
* enough so as to not result in significant call overhead. It should be at least a few
|
144
|
+
* bytes to accommodate some structures (this is verified in asserts), but it would not be
|
145
|
+
* sensible to make it this small anyway, and it should be at most 64K since it is indexed
|
146
|
+
* with uint16. We recommend 2K.
|
147
|
+
* EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has
|
148
|
+
* absolutely no effect. That is why most people insist the EGYPTIANWALK is a bit silly.
|
149
|
+
*/
|
150
|
+
|
151
|
+
/* define LIBJPEG_ENCAP_EXTERNAL */
|
152
|
+
#define SETJMP(jbuf) setjmp(jbuf)
|
153
|
+
#define LONGJMP(jbuf,code) longjmp(jbuf,code)
|
154
|
+
#define JMP_BUF jmp_buf
|
155
|
+
#define OJPEG_BUFFER 2048
|
156
|
+
/* define EGYPTIANWALK */
|
157
|
+
|
158
|
+
#define JPEG_MARKER_SOF0 0xC0
|
159
|
+
#define JPEG_MARKER_SOF1 0xC1
|
160
|
+
#define JPEG_MARKER_SOF3 0xC3
|
161
|
+
#define JPEG_MARKER_DHT 0xC4
|
162
|
+
#define JPEG_MARKER_RST0 0XD0
|
163
|
+
#define JPEG_MARKER_SOI 0xD8
|
164
|
+
#define JPEG_MARKER_EOI 0xD9
|
165
|
+
#define JPEG_MARKER_SOS 0xDA
|
166
|
+
#define JPEG_MARKER_DQT 0xDB
|
167
|
+
#define JPEG_MARKER_DRI 0xDD
|
168
|
+
#define JPEG_MARKER_APP0 0xE0
|
169
|
+
#define JPEG_MARKER_COM 0xFE
|
170
|
+
|
171
|
+
#define FIELD_OJPEG_JPEGINTERCHANGEFORMAT (FIELD_CODEC+0)
|
172
|
+
#define FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH (FIELD_CODEC+1)
|
173
|
+
#define FIELD_OJPEG_JPEGQTABLES (FIELD_CODEC+2)
|
174
|
+
#define FIELD_OJPEG_JPEGDCTABLES (FIELD_CODEC+3)
|
175
|
+
#define FIELD_OJPEG_JPEGACTABLES (FIELD_CODEC+4)
|
176
|
+
#define FIELD_OJPEG_JPEGPROC (FIELD_CODEC+5)
|
177
|
+
#define FIELD_OJPEG_JPEGRESTARTINTERVAL (FIELD_CODEC+6)
|
178
|
+
|
179
|
+
static const TIFFField ojpegFields[] = {
|
180
|
+
{TIFFTAG_JPEGIFOFFSET,1,1,TIFF_LONG8,0,TIFF_SETGET_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGINTERCHANGEFORMAT,TRUE,FALSE,"JpegInterchangeFormat",NULL},
|
181
|
+
{TIFFTAG_JPEGIFBYTECOUNT,1,1,TIFF_LONG8,0,TIFF_SETGET_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH,TRUE,FALSE,"JpegInterchangeFormatLength",NULL},
|
182
|
+
{TIFFTAG_JPEGQTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGQTABLES,FALSE,TRUE,"JpegQTables",NULL},
|
183
|
+
{TIFFTAG_JPEGDCTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGDCTABLES,FALSE,TRUE,"JpegDcTables",NULL},
|
184
|
+
{TIFFTAG_JPEGACTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGACTABLES,FALSE,TRUE,"JpegAcTables",NULL},
|
185
|
+
{TIFFTAG_JPEGPROC,1,1,TIFF_SHORT,0,TIFF_SETGET_UINT16,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGPROC,FALSE,FALSE,"JpegProc",NULL},
|
186
|
+
{TIFFTAG_JPEGRESTARTINTERVAL,1,1,TIFF_SHORT,0,TIFF_SETGET_UINT16,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGRESTARTINTERVAL,FALSE,FALSE,"JpegRestartInterval",NULL},
|
187
|
+
};
|
188
|
+
|
189
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
190
|
+
#include <setjmp.h>
|
191
|
+
#endif
|
192
|
+
|
193
|
+
/* We undefine FAR to avoid conflict with JPEG definition */
|
194
|
+
|
195
|
+
#ifdef FAR
|
196
|
+
#undef FAR
|
197
|
+
#endif
|
198
|
+
|
199
|
+
/*
|
200
|
+
Libjpeg's jmorecfg.h defines INT16 and INT32, but only if XMD_H is
|
201
|
+
not defined. Unfortunately, the MinGW and Borland compilers include
|
202
|
+
a typedef for INT32, which causes a conflict. MSVC does not include
|
203
|
+
a conflicting typedef given the headers which are included.
|
204
|
+
*/
|
205
|
+
#if defined(__BORLANDC__) || defined(__MINGW32__)
|
206
|
+
# define XMD_H 1
|
207
|
+
#endif
|
208
|
+
|
209
|
+
/* Define "boolean" as unsigned char, not int, per Windows custom. */
|
210
|
+
#if defined(__WIN32__) && !defined(__MINGW32__)
|
211
|
+
# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
212
|
+
typedef unsigned char boolean;
|
213
|
+
# endif
|
214
|
+
# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
215
|
+
#endif
|
216
|
+
|
217
|
+
#include "jpeglib.h"
|
218
|
+
#include "jerror.h"
|
219
|
+
|
220
|
+
typedef struct jpeg_error_mgr jpeg_error_mgr;
|
221
|
+
typedef struct jpeg_common_struct jpeg_common_struct;
|
222
|
+
typedef struct jpeg_decompress_struct jpeg_decompress_struct;
|
223
|
+
typedef struct jpeg_source_mgr jpeg_source_mgr;
|
224
|
+
|
225
|
+
typedef enum {
|
226
|
+
osibsNotSetYet,
|
227
|
+
osibsJpegInterchangeFormat,
|
228
|
+
osibsStrile,
|
229
|
+
osibsEof
|
230
|
+
} OJPEGStateInBufferSource;
|
231
|
+
|
232
|
+
typedef enum {
|
233
|
+
ososSoi,
|
234
|
+
ososQTable0,ososQTable1,ososQTable2,ososQTable3,
|
235
|
+
ososDcTable0,ososDcTable1,ososDcTable2,ososDcTable3,
|
236
|
+
ososAcTable0,ososAcTable1,ososAcTable2,ososAcTable3,
|
237
|
+
ososDri,
|
238
|
+
ososSof,
|
239
|
+
ososSos,
|
240
|
+
ososCompressed,
|
241
|
+
ososRst,
|
242
|
+
ososEoi
|
243
|
+
} OJPEGStateOutState;
|
244
|
+
|
245
|
+
typedef struct {
|
246
|
+
TIFF* tif;
|
247
|
+
int decoder_ok;
|
248
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
249
|
+
JMP_BUF exit_jmpbuf;
|
250
|
+
#endif
|
251
|
+
TIFFVGetMethod vgetparent;
|
252
|
+
TIFFVSetMethod vsetparent;
|
253
|
+
TIFFPrintMethod printdir;
|
254
|
+
uint64 file_size;
|
255
|
+
uint32 image_width;
|
256
|
+
uint32 image_length;
|
257
|
+
uint32 strile_width;
|
258
|
+
uint32 strile_length;
|
259
|
+
uint32 strile_length_total;
|
260
|
+
uint8 samples_per_pixel;
|
261
|
+
uint8 plane_sample_offset;
|
262
|
+
uint8 samples_per_pixel_per_plane;
|
263
|
+
uint64 jpeg_interchange_format;
|
264
|
+
uint64 jpeg_interchange_format_length;
|
265
|
+
uint8 jpeg_proc;
|
266
|
+
uint8 subsamplingcorrect;
|
267
|
+
uint8 subsamplingcorrect_done;
|
268
|
+
uint8 subsampling_tag;
|
269
|
+
uint8 subsampling_hor;
|
270
|
+
uint8 subsampling_ver;
|
271
|
+
uint8 subsampling_force_desubsampling_inside_decompression;
|
272
|
+
uint8 qtable_offset_count;
|
273
|
+
uint8 dctable_offset_count;
|
274
|
+
uint8 actable_offset_count;
|
275
|
+
uint64 qtable_offset[3];
|
276
|
+
uint64 dctable_offset[3];
|
277
|
+
uint64 actable_offset[3];
|
278
|
+
uint8* qtable[4];
|
279
|
+
uint8* dctable[4];
|
280
|
+
uint8* actable[4];
|
281
|
+
uint16 restart_interval;
|
282
|
+
uint8 restart_index;
|
283
|
+
uint8 sof_log;
|
284
|
+
uint8 sof_marker_id;
|
285
|
+
uint32 sof_x;
|
286
|
+
uint32 sof_y;
|
287
|
+
uint8 sof_c[3];
|
288
|
+
uint8 sof_hv[3];
|
289
|
+
uint8 sof_tq[3];
|
290
|
+
uint8 sos_cs[3];
|
291
|
+
uint8 sos_tda[3];
|
292
|
+
struct {
|
293
|
+
uint8 log;
|
294
|
+
OJPEGStateInBufferSource in_buffer_source;
|
295
|
+
uint32 in_buffer_next_strile;
|
296
|
+
uint64 in_buffer_file_pos;
|
297
|
+
uint64 in_buffer_file_togo;
|
298
|
+
} sos_end[3];
|
299
|
+
uint8 readheader_done;
|
300
|
+
uint8 writeheader_done;
|
301
|
+
uint16 write_cursample;
|
302
|
+
uint32 write_curstrile;
|
303
|
+
uint8 libjpeg_session_active;
|
304
|
+
uint8 libjpeg_jpeg_query_style;
|
305
|
+
jpeg_error_mgr libjpeg_jpeg_error_mgr;
|
306
|
+
jpeg_decompress_struct libjpeg_jpeg_decompress_struct;
|
307
|
+
jpeg_source_mgr libjpeg_jpeg_source_mgr;
|
308
|
+
uint8 subsampling_convert_log;
|
309
|
+
uint32 subsampling_convert_ylinelen;
|
310
|
+
uint32 subsampling_convert_ylines;
|
311
|
+
uint32 subsampling_convert_clinelen;
|
312
|
+
uint32 subsampling_convert_clines;
|
313
|
+
uint32 subsampling_convert_ybuflen;
|
314
|
+
uint32 subsampling_convert_cbuflen;
|
315
|
+
uint32 subsampling_convert_ycbcrbuflen;
|
316
|
+
uint8* subsampling_convert_ycbcrbuf;
|
317
|
+
uint8* subsampling_convert_ybuf;
|
318
|
+
uint8* subsampling_convert_cbbuf;
|
319
|
+
uint8* subsampling_convert_crbuf;
|
320
|
+
uint32 subsampling_convert_ycbcrimagelen;
|
321
|
+
uint8** subsampling_convert_ycbcrimage;
|
322
|
+
uint32 subsampling_convert_clinelenout;
|
323
|
+
uint32 subsampling_convert_state;
|
324
|
+
uint32 bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */
|
325
|
+
uint32 lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */
|
326
|
+
OJPEGStateInBufferSource in_buffer_source;
|
327
|
+
uint32 in_buffer_next_strile;
|
328
|
+
uint32 in_buffer_strile_count;
|
329
|
+
uint64 in_buffer_file_pos;
|
330
|
+
uint8 in_buffer_file_pos_log;
|
331
|
+
uint64 in_buffer_file_togo;
|
332
|
+
uint16 in_buffer_togo;
|
333
|
+
uint8* in_buffer_cur;
|
334
|
+
uint8 in_buffer[OJPEG_BUFFER];
|
335
|
+
OJPEGStateOutState out_state;
|
336
|
+
uint8 out_buffer[OJPEG_BUFFER];
|
337
|
+
uint8* skip_buffer;
|
338
|
+
} OJPEGState;
|
339
|
+
|
340
|
+
static int OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap);
|
341
|
+
static int OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap);
|
342
|
+
static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags);
|
343
|
+
|
344
|
+
static int OJPEGFixupTags(TIFF* tif);
|
345
|
+
static int OJPEGSetupDecode(TIFF* tif);
|
346
|
+
static int OJPEGPreDecode(TIFF* tif, uint16 s);
|
347
|
+
static int OJPEGPreDecodeSkipRaw(TIFF* tif);
|
348
|
+
static int OJPEGPreDecodeSkipScanlines(TIFF* tif);
|
349
|
+
static int OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s);
|
350
|
+
static int OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc);
|
351
|
+
static int OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc);
|
352
|
+
static void OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc);
|
353
|
+
static int OJPEGSetupEncode(TIFF* tif);
|
354
|
+
static int OJPEGPreEncode(TIFF* tif, uint16 s);
|
355
|
+
static int OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s);
|
356
|
+
static int OJPEGPostEncode(TIFF* tif);
|
357
|
+
static void OJPEGCleanup(TIFF* tif);
|
358
|
+
|
359
|
+
static void OJPEGSubsamplingCorrect(TIFF* tif);
|
360
|
+
static int OJPEGReadHeaderInfo(TIFF* tif);
|
361
|
+
static int OJPEGReadSecondarySos(TIFF* tif, uint16 s);
|
362
|
+
static int OJPEGWriteHeaderInfo(TIFF* tif);
|
363
|
+
static void OJPEGLibjpegSessionAbort(TIFF* tif);
|
364
|
+
|
365
|
+
static int OJPEGReadHeaderInfoSec(TIFF* tif);
|
366
|
+
static int OJPEGReadHeaderInfoSecStreamDri(TIFF* tif);
|
367
|
+
static int OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif);
|
368
|
+
static int OJPEGReadHeaderInfoSecStreamDht(TIFF* tif);
|
369
|
+
static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id);
|
370
|
+
static int OJPEGReadHeaderInfoSecStreamSos(TIFF* tif);
|
371
|
+
static int OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif);
|
372
|
+
static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif);
|
373
|
+
static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif);
|
374
|
+
|
375
|
+
static int OJPEGReadBufferFill(OJPEGState* sp);
|
376
|
+
static int OJPEGReadByte(OJPEGState* sp, uint8* byte);
|
377
|
+
static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte);
|
378
|
+
static void OJPEGReadByteAdvance(OJPEGState* sp);
|
379
|
+
static int OJPEGReadWord(OJPEGState* sp, uint16* word);
|
380
|
+
static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem);
|
381
|
+
static void OJPEGReadSkip(OJPEGState* sp, uint16 len);
|
382
|
+
|
383
|
+
static int OJPEGWriteStream(TIFF* tif, void** mem, uint32* len);
|
384
|
+
static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len);
|
385
|
+
static void OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len);
|
386
|
+
static void OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len);
|
387
|
+
static void OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len);
|
388
|
+
static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len);
|
389
|
+
static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len);
|
390
|
+
static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len);
|
391
|
+
static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len);
|
392
|
+
static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len);
|
393
|
+
static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len);
|
394
|
+
|
395
|
+
#ifdef LIBJPEG_ENCAP_EXTERNAL
|
396
|
+
extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
|
397
|
+
extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image);
|
398
|
+
extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
|
399
|
+
extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines);
|
400
|
+
extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines);
|
401
|
+
extern void jpeg_encap_unwind(TIFF* tif);
|
402
|
+
#else
|
403
|
+
static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j);
|
404
|
+
static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image);
|
405
|
+
static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
|
406
|
+
static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines);
|
407
|
+
static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines);
|
408
|
+
static void jpeg_encap_unwind(TIFF* tif);
|
409
|
+
#endif
|
410
|
+
|
411
|
+
static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo);
|
412
|
+
static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo);
|
413
|
+
static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo);
|
414
|
+
static boolean OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo);
|
415
|
+
static void OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes);
|
416
|
+
static boolean OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired);
|
417
|
+
static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo);
|
418
|
+
|
419
|
+
int
|
420
|
+
TIFFInitOJPEG(TIFF* tif, int scheme)
|
421
|
+
{
|
422
|
+
static const char module[]="TIFFInitOJPEG";
|
423
|
+
OJPEGState* sp;
|
424
|
+
|
425
|
+
assert(scheme==COMPRESSION_OJPEG);
|
426
|
+
|
427
|
+
/*
|
428
|
+
* Merge codec-specific tag information.
|
429
|
+
*/
|
430
|
+
if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields))) {
|
431
|
+
TIFFErrorExt(tif->tif_clientdata, module,
|
432
|
+
"Merging Old JPEG codec-specific tags failed");
|
433
|
+
return 0;
|
434
|
+
}
|
435
|
+
|
436
|
+
/* state block */
|
437
|
+
sp=_TIFFmalloc(sizeof(OJPEGState));
|
438
|
+
if (sp==NULL)
|
439
|
+
{
|
440
|
+
TIFFErrorExt(tif->tif_clientdata,module,"No space for OJPEG state block");
|
441
|
+
return(0);
|
442
|
+
}
|
443
|
+
_TIFFmemset(sp,0,sizeof(OJPEGState));
|
444
|
+
sp->tif=tif;
|
445
|
+
sp->jpeg_proc=1;
|
446
|
+
sp->subsampling_hor=2;
|
447
|
+
sp->subsampling_ver=2;
|
448
|
+
TIFFSetField(tif,TIFFTAG_YCBCRSUBSAMPLING,2,2);
|
449
|
+
/* tif codec methods */
|
450
|
+
tif->tif_fixuptags=OJPEGFixupTags;
|
451
|
+
tif->tif_setupdecode=OJPEGSetupDecode;
|
452
|
+
tif->tif_predecode=OJPEGPreDecode;
|
453
|
+
tif->tif_postdecode=OJPEGPostDecode;
|
454
|
+
tif->tif_decoderow=OJPEGDecode;
|
455
|
+
tif->tif_decodestrip=OJPEGDecode;
|
456
|
+
tif->tif_decodetile=OJPEGDecode;
|
457
|
+
tif->tif_setupencode=OJPEGSetupEncode;
|
458
|
+
tif->tif_preencode=OJPEGPreEncode;
|
459
|
+
tif->tif_postencode=OJPEGPostEncode;
|
460
|
+
tif->tif_encoderow=OJPEGEncode;
|
461
|
+
tif->tif_encodestrip=OJPEGEncode;
|
462
|
+
tif->tif_encodetile=OJPEGEncode;
|
463
|
+
tif->tif_cleanup=OJPEGCleanup;
|
464
|
+
tif->tif_data=(uint8*)sp;
|
465
|
+
/* tif tag methods */
|
466
|
+
sp->vgetparent=tif->tif_tagmethods.vgetfield;
|
467
|
+
tif->tif_tagmethods.vgetfield=OJPEGVGetField;
|
468
|
+
sp->vsetparent=tif->tif_tagmethods.vsetfield;
|
469
|
+
tif->tif_tagmethods.vsetfield=OJPEGVSetField;
|
470
|
+
sp->printdir=tif->tif_tagmethods.printdir;
|
471
|
+
tif->tif_tagmethods.printdir=OJPEGPrintDir;
|
472
|
+
/* Some OJPEG files don't have strip or tile offsets or bytecounts tags.
|
473
|
+
Some others do, but have totally meaningless or corrupt values
|
474
|
+
in these tags. In these cases, the JpegInterchangeFormat stream is
|
475
|
+
reliable. In any case, this decoder reads the compressed data itself,
|
476
|
+
from the most reliable locations, and we need to notify encapsulating
|
477
|
+
LibTiff not to read raw strips or tiles for us. */
|
478
|
+
tif->tif_flags|=TIFF_NOREADRAW;
|
479
|
+
return(1);
|
480
|
+
}
|
481
|
+
|
482
|
+
static int
|
483
|
+
OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap)
|
484
|
+
{
|
485
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
486
|
+
switch(tag)
|
487
|
+
{
|
488
|
+
case TIFFTAG_JPEGIFOFFSET:
|
489
|
+
*va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format;
|
490
|
+
break;
|
491
|
+
case TIFFTAG_JPEGIFBYTECOUNT:
|
492
|
+
*va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format_length;
|
493
|
+
break;
|
494
|
+
case TIFFTAG_YCBCRSUBSAMPLING:
|
495
|
+
if (sp->subsamplingcorrect_done==0)
|
496
|
+
OJPEGSubsamplingCorrect(tif);
|
497
|
+
*va_arg(ap,uint16*)=(uint16)sp->subsampling_hor;
|
498
|
+
*va_arg(ap,uint16*)=(uint16)sp->subsampling_ver;
|
499
|
+
break;
|
500
|
+
case TIFFTAG_JPEGQTABLES:
|
501
|
+
*va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count;
|
502
|
+
*va_arg(ap,void**)=(void*)sp->qtable_offset;
|
503
|
+
break;
|
504
|
+
case TIFFTAG_JPEGDCTABLES:
|
505
|
+
*va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count;
|
506
|
+
*va_arg(ap,void**)=(void*)sp->dctable_offset;
|
507
|
+
break;
|
508
|
+
case TIFFTAG_JPEGACTABLES:
|
509
|
+
*va_arg(ap,uint32*)=(uint32)sp->actable_offset_count;
|
510
|
+
*va_arg(ap,void**)=(void*)sp->actable_offset;
|
511
|
+
break;
|
512
|
+
case TIFFTAG_JPEGPROC:
|
513
|
+
*va_arg(ap,uint16*)=(uint16)sp->jpeg_proc;
|
514
|
+
break;
|
515
|
+
case TIFFTAG_JPEGRESTARTINTERVAL:
|
516
|
+
*va_arg(ap,uint16*)=sp->restart_interval;
|
517
|
+
break;
|
518
|
+
default:
|
519
|
+
return (*sp->vgetparent)(tif,tag,ap);
|
520
|
+
}
|
521
|
+
return (1);
|
522
|
+
}
|
523
|
+
|
524
|
+
static int
|
525
|
+
OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
|
526
|
+
{
|
527
|
+
static const char module[]="OJPEGVSetField";
|
528
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
529
|
+
uint32 ma;
|
530
|
+
uint64* mb;
|
531
|
+
uint32 n;
|
532
|
+
const TIFFField* fip;
|
533
|
+
|
534
|
+
switch(tag)
|
535
|
+
{
|
536
|
+
case TIFFTAG_JPEGIFOFFSET:
|
537
|
+
sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64);
|
538
|
+
break;
|
539
|
+
case TIFFTAG_JPEGIFBYTECOUNT:
|
540
|
+
sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64);
|
541
|
+
break;
|
542
|
+
case TIFFTAG_YCBCRSUBSAMPLING:
|
543
|
+
sp->subsampling_tag=1;
|
544
|
+
sp->subsampling_hor=(uint8)va_arg(ap,uint16_vap);
|
545
|
+
sp->subsampling_ver=(uint8)va_arg(ap,uint16_vap);
|
546
|
+
tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor;
|
547
|
+
tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver;
|
548
|
+
break;
|
549
|
+
case TIFFTAG_JPEGQTABLES:
|
550
|
+
ma=(uint32)va_arg(ap,uint32);
|
551
|
+
if (ma!=0)
|
552
|
+
{
|
553
|
+
if (ma>3)
|
554
|
+
{
|
555
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JpegQTables tag has incorrect count");
|
556
|
+
return(0);
|
557
|
+
}
|
558
|
+
sp->qtable_offset_count=(uint8)ma;
|
559
|
+
mb=(uint64*)va_arg(ap,uint64*);
|
560
|
+
for (n=0; n<ma; n++)
|
561
|
+
sp->qtable_offset[n]=mb[n];
|
562
|
+
}
|
563
|
+
break;
|
564
|
+
case TIFFTAG_JPEGDCTABLES:
|
565
|
+
ma=(uint32)va_arg(ap,uint32);
|
566
|
+
if (ma!=0)
|
567
|
+
{
|
568
|
+
if (ma>3)
|
569
|
+
{
|
570
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JpegDcTables tag has incorrect count");
|
571
|
+
return(0);
|
572
|
+
}
|
573
|
+
sp->dctable_offset_count=(uint8)ma;
|
574
|
+
mb=(uint64*)va_arg(ap,uint64*);
|
575
|
+
for (n=0; n<ma; n++)
|
576
|
+
sp->dctable_offset[n]=mb[n];
|
577
|
+
}
|
578
|
+
break;
|
579
|
+
case TIFFTAG_JPEGACTABLES:
|
580
|
+
ma=(uint32)va_arg(ap,uint32);
|
581
|
+
if (ma!=0)
|
582
|
+
{
|
583
|
+
if (ma>3)
|
584
|
+
{
|
585
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JpegAcTables tag has incorrect count");
|
586
|
+
return(0);
|
587
|
+
}
|
588
|
+
sp->actable_offset_count=(uint8)ma;
|
589
|
+
mb=(uint64*)va_arg(ap,uint64*);
|
590
|
+
for (n=0; n<ma; n++)
|
591
|
+
sp->actable_offset[n]=mb[n];
|
592
|
+
}
|
593
|
+
break;
|
594
|
+
case TIFFTAG_JPEGPROC:
|
595
|
+
sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap);
|
596
|
+
break;
|
597
|
+
case TIFFTAG_JPEGRESTARTINTERVAL:
|
598
|
+
sp->restart_interval=(uint16)va_arg(ap,uint16_vap);
|
599
|
+
break;
|
600
|
+
default:
|
601
|
+
return (*sp->vsetparent)(tif,tag,ap);
|
602
|
+
}
|
603
|
+
fip = TIFFFieldWithTag(tif,tag);
|
604
|
+
if( fip == NULL ) /* shouldn't happen */
|
605
|
+
return(0);
|
606
|
+
TIFFSetFieldBit(tif,fip->field_bit);
|
607
|
+
tif->tif_flags|=TIFF_DIRTYDIRECT;
|
608
|
+
return(1);
|
609
|
+
}
|
610
|
+
|
611
|
+
static void
|
612
|
+
OJPEGPrintDir(TIFF* tif, FILE* fd, long flags)
|
613
|
+
{
|
614
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
615
|
+
uint8 m;
|
616
|
+
(void)flags;
|
617
|
+
assert(sp!=NULL);
|
618
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMAT))
|
619
|
+
fprintf(fd," JpegInterchangeFormat: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format);
|
620
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH))
|
621
|
+
fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format_length);
|
622
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES))
|
623
|
+
{
|
624
|
+
fprintf(fd," JpegQTables:");
|
625
|
+
for (m=0; m<sp->qtable_offset_count; m++)
|
626
|
+
fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]);
|
627
|
+
fprintf(fd,"\n");
|
628
|
+
}
|
629
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGDCTABLES))
|
630
|
+
{
|
631
|
+
fprintf(fd," JpegDcTables:");
|
632
|
+
for (m=0; m<sp->dctable_offset_count; m++)
|
633
|
+
fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]);
|
634
|
+
fprintf(fd,"\n");
|
635
|
+
}
|
636
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGACTABLES))
|
637
|
+
{
|
638
|
+
fprintf(fd," JpegAcTables:");
|
639
|
+
for (m=0; m<sp->actable_offset_count; m++)
|
640
|
+
fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->actable_offset[m]);
|
641
|
+
fprintf(fd,"\n");
|
642
|
+
}
|
643
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC))
|
644
|
+
fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc);
|
645
|
+
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL))
|
646
|
+
fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval);
|
647
|
+
if (sp->printdir)
|
648
|
+
(*sp->printdir)(tif, fd, flags);
|
649
|
+
}
|
650
|
+
|
651
|
+
static int
|
652
|
+
OJPEGFixupTags(TIFF* tif)
|
653
|
+
{
|
654
|
+
(void) tif;
|
655
|
+
return(1);
|
656
|
+
}
|
657
|
+
|
658
|
+
static int
|
659
|
+
OJPEGSetupDecode(TIFF* tif)
|
660
|
+
{
|
661
|
+
static const char module[]="OJPEGSetupDecode";
|
662
|
+
TIFFWarningExt(tif->tif_clientdata,module,"Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software");
|
663
|
+
return(1);
|
664
|
+
}
|
665
|
+
|
666
|
+
static int
|
667
|
+
OJPEGPreDecode(TIFF* tif, uint16 s)
|
668
|
+
{
|
669
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
670
|
+
uint32 m;
|
671
|
+
if (sp->subsamplingcorrect_done==0)
|
672
|
+
OJPEGSubsamplingCorrect(tif);
|
673
|
+
if (sp->readheader_done==0)
|
674
|
+
{
|
675
|
+
if (OJPEGReadHeaderInfo(tif)==0)
|
676
|
+
return(0);
|
677
|
+
}
|
678
|
+
if (sp->sos_end[s].log==0)
|
679
|
+
{
|
680
|
+
if (OJPEGReadSecondarySos(tif,s)==0)
|
681
|
+
return(0);
|
682
|
+
}
|
683
|
+
if isTiled(tif)
|
684
|
+
m=tif->tif_curtile;
|
685
|
+
else
|
686
|
+
m=tif->tif_curstrip;
|
687
|
+
if ((sp->writeheader_done!=0) && ((sp->write_cursample!=s) || (sp->write_curstrile>m)))
|
688
|
+
{
|
689
|
+
if (sp->libjpeg_session_active!=0)
|
690
|
+
OJPEGLibjpegSessionAbort(tif);
|
691
|
+
sp->writeheader_done=0;
|
692
|
+
}
|
693
|
+
if (sp->writeheader_done==0)
|
694
|
+
{
|
695
|
+
sp->plane_sample_offset=(uint8)s;
|
696
|
+
sp->write_cursample=s;
|
697
|
+
sp->write_curstrile=s*tif->tif_dir.td_stripsperimage;
|
698
|
+
if ((sp->in_buffer_file_pos_log==0) ||
|
699
|
+
(sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos))
|
700
|
+
{
|
701
|
+
sp->in_buffer_source=sp->sos_end[s].in_buffer_source;
|
702
|
+
sp->in_buffer_next_strile=sp->sos_end[s].in_buffer_next_strile;
|
703
|
+
sp->in_buffer_file_pos=sp->sos_end[s].in_buffer_file_pos;
|
704
|
+
sp->in_buffer_file_pos_log=0;
|
705
|
+
sp->in_buffer_file_togo=sp->sos_end[s].in_buffer_file_togo;
|
706
|
+
sp->in_buffer_togo=0;
|
707
|
+
sp->in_buffer_cur=0;
|
708
|
+
}
|
709
|
+
if (OJPEGWriteHeaderInfo(tif)==0)
|
710
|
+
return(0);
|
711
|
+
}
|
712
|
+
while (sp->write_curstrile<m)
|
713
|
+
{
|
714
|
+
if (sp->libjpeg_jpeg_query_style==0)
|
715
|
+
{
|
716
|
+
if (OJPEGPreDecodeSkipRaw(tif)==0)
|
717
|
+
return(0);
|
718
|
+
}
|
719
|
+
else
|
720
|
+
{
|
721
|
+
if (OJPEGPreDecodeSkipScanlines(tif)==0)
|
722
|
+
return(0);
|
723
|
+
}
|
724
|
+
sp->write_curstrile++;
|
725
|
+
}
|
726
|
+
sp->decoder_ok = 1;
|
727
|
+
return(1);
|
728
|
+
}
|
729
|
+
|
730
|
+
static int
|
731
|
+
OJPEGPreDecodeSkipRaw(TIFF* tif)
|
732
|
+
{
|
733
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
734
|
+
uint32 m;
|
735
|
+
m=sp->lines_per_strile;
|
736
|
+
if (sp->subsampling_convert_state!=0)
|
737
|
+
{
|
738
|
+
if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m)
|
739
|
+
{
|
740
|
+
sp->subsampling_convert_state+=m;
|
741
|
+
if (sp->subsampling_convert_state==sp->subsampling_convert_clines)
|
742
|
+
sp->subsampling_convert_state=0;
|
743
|
+
return(1);
|
744
|
+
}
|
745
|
+
m-=sp->subsampling_convert_clines-sp->subsampling_convert_state;
|
746
|
+
sp->subsampling_convert_state=0;
|
747
|
+
}
|
748
|
+
while (m>=sp->subsampling_convert_clines)
|
749
|
+
{
|
750
|
+
if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0)
|
751
|
+
return(0);
|
752
|
+
m-=sp->subsampling_convert_clines;
|
753
|
+
}
|
754
|
+
if (m>0)
|
755
|
+
{
|
756
|
+
if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0)
|
757
|
+
return(0);
|
758
|
+
sp->subsampling_convert_state=m;
|
759
|
+
}
|
760
|
+
return(1);
|
761
|
+
}
|
762
|
+
|
763
|
+
static int
|
764
|
+
OJPEGPreDecodeSkipScanlines(TIFF* tif)
|
765
|
+
{
|
766
|
+
static const char module[]="OJPEGPreDecodeSkipScanlines";
|
767
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
768
|
+
uint32 m;
|
769
|
+
if (sp->skip_buffer==NULL)
|
770
|
+
{
|
771
|
+
sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line);
|
772
|
+
if (sp->skip_buffer==NULL)
|
773
|
+
{
|
774
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
775
|
+
return(0);
|
776
|
+
}
|
777
|
+
}
|
778
|
+
for (m=0; m<sp->lines_per_strile; m++)
|
779
|
+
{
|
780
|
+
if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&sp->skip_buffer,1)==0)
|
781
|
+
return(0);
|
782
|
+
}
|
783
|
+
return(1);
|
784
|
+
}
|
785
|
+
|
786
|
+
static int
|
787
|
+
OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
788
|
+
{
|
789
|
+
static const char module[]="OJPEGDecode";
|
790
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
791
|
+
(void)s;
|
792
|
+
if( !sp->decoder_ok )
|
793
|
+
{
|
794
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized");
|
795
|
+
return 0;
|
796
|
+
}
|
797
|
+
if (sp->libjpeg_jpeg_query_style==0)
|
798
|
+
{
|
799
|
+
if (OJPEGDecodeRaw(tif,buf,cc)==0)
|
800
|
+
return(0);
|
801
|
+
}
|
802
|
+
else
|
803
|
+
{
|
804
|
+
if (OJPEGDecodeScanlines(tif,buf,cc)==0)
|
805
|
+
return(0);
|
806
|
+
}
|
807
|
+
return(1);
|
808
|
+
}
|
809
|
+
|
810
|
+
static int
|
811
|
+
OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc)
|
812
|
+
{
|
813
|
+
static const char module[]="OJPEGDecodeRaw";
|
814
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
815
|
+
uint8* m;
|
816
|
+
tmsize_t n;
|
817
|
+
uint8* oy;
|
818
|
+
uint8* ocb;
|
819
|
+
uint8* ocr;
|
820
|
+
uint8* p;
|
821
|
+
uint32 q;
|
822
|
+
uint8* r;
|
823
|
+
uint8 sx,sy;
|
824
|
+
if (cc%sp->bytes_per_line!=0)
|
825
|
+
{
|
826
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read");
|
827
|
+
return(0);
|
828
|
+
}
|
829
|
+
assert(cc>0);
|
830
|
+
m=buf;
|
831
|
+
n=cc;
|
832
|
+
do
|
833
|
+
{
|
834
|
+
if (sp->subsampling_convert_state==0)
|
835
|
+
{
|
836
|
+
if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0)
|
837
|
+
return(0);
|
838
|
+
}
|
839
|
+
oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_convert_ylinelen;
|
840
|
+
ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen;
|
841
|
+
ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen;
|
842
|
+
p=m;
|
843
|
+
for (q=0; q<sp->subsampling_convert_clinelenout; q++)
|
844
|
+
{
|
845
|
+
r=oy;
|
846
|
+
for (sy=0; sy<sp->subsampling_ver; sy++)
|
847
|
+
{
|
848
|
+
for (sx=0; sx<sp->subsampling_hor; sx++)
|
849
|
+
*p++=*r++;
|
850
|
+
r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor;
|
851
|
+
}
|
852
|
+
oy+=sp->subsampling_hor;
|
853
|
+
*p++=*ocb++;
|
854
|
+
*p++=*ocr++;
|
855
|
+
}
|
856
|
+
sp->subsampling_convert_state++;
|
857
|
+
if (sp->subsampling_convert_state==sp->subsampling_convert_clines)
|
858
|
+
sp->subsampling_convert_state=0;
|
859
|
+
m+=sp->bytes_per_line;
|
860
|
+
n-=sp->bytes_per_line;
|
861
|
+
} while(n>0);
|
862
|
+
return(1);
|
863
|
+
}
|
864
|
+
|
865
|
+
static int
|
866
|
+
OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc)
|
867
|
+
{
|
868
|
+
static const char module[]="OJPEGDecodeScanlines";
|
869
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
870
|
+
uint8* m;
|
871
|
+
tmsize_t n;
|
872
|
+
if (cc%sp->bytes_per_line!=0)
|
873
|
+
{
|
874
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read");
|
875
|
+
return(0);
|
876
|
+
}
|
877
|
+
assert(cc>0);
|
878
|
+
m=buf;
|
879
|
+
n=cc;
|
880
|
+
do
|
881
|
+
{
|
882
|
+
if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0)
|
883
|
+
return(0);
|
884
|
+
m+=sp->bytes_per_line;
|
885
|
+
n-=sp->bytes_per_line;
|
886
|
+
} while(n>0);
|
887
|
+
return(1);
|
888
|
+
}
|
889
|
+
|
890
|
+
static void
|
891
|
+
OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc)
|
892
|
+
{
|
893
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
894
|
+
(void)buf;
|
895
|
+
(void)cc;
|
896
|
+
sp->write_curstrile++;
|
897
|
+
if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0)
|
898
|
+
{
|
899
|
+
assert(sp->libjpeg_session_active!=0);
|
900
|
+
OJPEGLibjpegSessionAbort(tif);
|
901
|
+
sp->writeheader_done=0;
|
902
|
+
}
|
903
|
+
}
|
904
|
+
|
905
|
+
static int
|
906
|
+
OJPEGSetupEncode(TIFF* tif)
|
907
|
+
{
|
908
|
+
static const char module[]="OJPEGSetupEncode";
|
909
|
+
TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead");
|
910
|
+
return(0);
|
911
|
+
}
|
912
|
+
|
913
|
+
static int
|
914
|
+
OJPEGPreEncode(TIFF* tif, uint16 s)
|
915
|
+
{
|
916
|
+
static const char module[]="OJPEGPreEncode";
|
917
|
+
(void)s;
|
918
|
+
TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead");
|
919
|
+
return(0);
|
920
|
+
}
|
921
|
+
|
922
|
+
static int
|
923
|
+
OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
924
|
+
{
|
925
|
+
static const char module[]="OJPEGEncode";
|
926
|
+
(void)buf;
|
927
|
+
(void)cc;
|
928
|
+
(void)s;
|
929
|
+
TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead");
|
930
|
+
return(0);
|
931
|
+
}
|
932
|
+
|
933
|
+
static int
|
934
|
+
OJPEGPostEncode(TIFF* tif)
|
935
|
+
{
|
936
|
+
static const char module[]="OJPEGPostEncode";
|
937
|
+
TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead");
|
938
|
+
return(0);
|
939
|
+
}
|
940
|
+
|
941
|
+
static void
|
942
|
+
OJPEGCleanup(TIFF* tif)
|
943
|
+
{
|
944
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
945
|
+
if (sp!=0)
|
946
|
+
{
|
947
|
+
tif->tif_tagmethods.vgetfield=sp->vgetparent;
|
948
|
+
tif->tif_tagmethods.vsetfield=sp->vsetparent;
|
949
|
+
tif->tif_tagmethods.printdir=sp->printdir;
|
950
|
+
if (sp->qtable[0]!=0)
|
951
|
+
_TIFFfree(sp->qtable[0]);
|
952
|
+
if (sp->qtable[1]!=0)
|
953
|
+
_TIFFfree(sp->qtable[1]);
|
954
|
+
if (sp->qtable[2]!=0)
|
955
|
+
_TIFFfree(sp->qtable[2]);
|
956
|
+
if (sp->qtable[3]!=0)
|
957
|
+
_TIFFfree(sp->qtable[3]);
|
958
|
+
if (sp->dctable[0]!=0)
|
959
|
+
_TIFFfree(sp->dctable[0]);
|
960
|
+
if (sp->dctable[1]!=0)
|
961
|
+
_TIFFfree(sp->dctable[1]);
|
962
|
+
if (sp->dctable[2]!=0)
|
963
|
+
_TIFFfree(sp->dctable[2]);
|
964
|
+
if (sp->dctable[3]!=0)
|
965
|
+
_TIFFfree(sp->dctable[3]);
|
966
|
+
if (sp->actable[0]!=0)
|
967
|
+
_TIFFfree(sp->actable[0]);
|
968
|
+
if (sp->actable[1]!=0)
|
969
|
+
_TIFFfree(sp->actable[1]);
|
970
|
+
if (sp->actable[2]!=0)
|
971
|
+
_TIFFfree(sp->actable[2]);
|
972
|
+
if (sp->actable[3]!=0)
|
973
|
+
_TIFFfree(sp->actable[3]);
|
974
|
+
if (sp->libjpeg_session_active!=0)
|
975
|
+
OJPEGLibjpegSessionAbort(tif);
|
976
|
+
if (sp->subsampling_convert_ycbcrbuf!=0)
|
977
|
+
_TIFFfree(sp->subsampling_convert_ycbcrbuf);
|
978
|
+
if (sp->subsampling_convert_ycbcrimage!=0)
|
979
|
+
_TIFFfree(sp->subsampling_convert_ycbcrimage);
|
980
|
+
if (sp->skip_buffer!=0)
|
981
|
+
_TIFFfree(sp->skip_buffer);
|
982
|
+
_TIFFfree(sp);
|
983
|
+
tif->tif_data=NULL;
|
984
|
+
_TIFFSetDefaultCompressionState(tif);
|
985
|
+
}
|
986
|
+
}
|
987
|
+
|
988
|
+
static void
|
989
|
+
OJPEGSubsamplingCorrect(TIFF* tif)
|
990
|
+
{
|
991
|
+
static const char module[]="OJPEGSubsamplingCorrect";
|
992
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
993
|
+
uint8 mh;
|
994
|
+
uint8 mv;
|
995
|
+
_TIFFFillStriles( tif );
|
996
|
+
|
997
|
+
assert(sp->subsamplingcorrect_done==0);
|
998
|
+
if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) &&
|
999
|
+
(tif->tif_dir.td_photometric!=PHOTOMETRIC_ITULAB)))
|
1000
|
+
{
|
1001
|
+
if (sp->subsampling_tag!=0)
|
1002
|
+
TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag not appropriate for this Photometric and/or SamplesPerPixel");
|
1003
|
+
sp->subsampling_hor=1;
|
1004
|
+
sp->subsampling_ver=1;
|
1005
|
+
sp->subsampling_force_desubsampling_inside_decompression=0;
|
1006
|
+
}
|
1007
|
+
else
|
1008
|
+
{
|
1009
|
+
sp->subsamplingcorrect_done=1;
|
1010
|
+
mh=sp->subsampling_hor;
|
1011
|
+
mv=sp->subsampling_ver;
|
1012
|
+
sp->subsamplingcorrect=1;
|
1013
|
+
OJPEGReadHeaderInfoSec(tif);
|
1014
|
+
if (sp->subsampling_force_desubsampling_inside_decompression!=0)
|
1015
|
+
{
|
1016
|
+
sp->subsampling_hor=1;
|
1017
|
+
sp->subsampling_ver=1;
|
1018
|
+
}
|
1019
|
+
sp->subsamplingcorrect=0;
|
1020
|
+
if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0))
|
1021
|
+
{
|
1022
|
+
if (sp->subsampling_tag==0)
|
1023
|
+
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);
|
1024
|
+
else
|
1025
|
+
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);
|
1026
|
+
}
|
1027
|
+
if (sp->subsampling_force_desubsampling_inside_decompression!=0)
|
1028
|
+
{
|
1029
|
+
if (sp->subsampling_tag==0)
|
1030
|
+
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");
|
1031
|
+
else
|
1032
|
+
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);
|
1033
|
+
}
|
1034
|
+
if (sp->subsampling_force_desubsampling_inside_decompression==0)
|
1035
|
+
{
|
1036
|
+
if (sp->subsampling_hor<sp->subsampling_ver)
|
1037
|
+
TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver);
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
sp->subsamplingcorrect_done=1;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
static int
|
1044
|
+
OJPEGReadHeaderInfo(TIFF* tif)
|
1045
|
+
{
|
1046
|
+
static const char module[]="OJPEGReadHeaderInfo";
|
1047
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1048
|
+
assert(sp->readheader_done==0);
|
1049
|
+
sp->image_width=tif->tif_dir.td_imagewidth;
|
1050
|
+
sp->image_length=tif->tif_dir.td_imagelength;
|
1051
|
+
if isTiled(tif)
|
1052
|
+
{
|
1053
|
+
sp->strile_width=tif->tif_dir.td_tilewidth;
|
1054
|
+
sp->strile_length=tif->tif_dir.td_tilelength;
|
1055
|
+
sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_length;
|
1056
|
+
}
|
1057
|
+
else
|
1058
|
+
{
|
1059
|
+
sp->strile_width=sp->image_width;
|
1060
|
+
sp->strile_length=tif->tif_dir.td_rowsperstrip;
|
1061
|
+
sp->strile_length_total=sp->image_length;
|
1062
|
+
}
|
1063
|
+
if (tif->tif_dir.td_samplesperpixel==1)
|
1064
|
+
{
|
1065
|
+
sp->samples_per_pixel=1;
|
1066
|
+
sp->plane_sample_offset=0;
|
1067
|
+
sp->samples_per_pixel_per_plane=sp->samples_per_pixel;
|
1068
|
+
sp->subsampling_hor=1;
|
1069
|
+
sp->subsampling_ver=1;
|
1070
|
+
}
|
1071
|
+
else
|
1072
|
+
{
|
1073
|
+
if (tif->tif_dir.td_samplesperpixel!=3)
|
1074
|
+
{
|
1075
|
+
TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel);
|
1076
|
+
return(0);
|
1077
|
+
}
|
1078
|
+
sp->samples_per_pixel=3;
|
1079
|
+
sp->plane_sample_offset=0;
|
1080
|
+
if (tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)
|
1081
|
+
sp->samples_per_pixel_per_plane=3;
|
1082
|
+
else
|
1083
|
+
sp->samples_per_pixel_per_plane=1;
|
1084
|
+
}
|
1085
|
+
if (sp->strile_length<sp->image_length)
|
1086
|
+
{
|
1087
|
+
if (sp->strile_length%(sp->subsampling_ver*8)!=0)
|
1088
|
+
{
|
1089
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length");
|
1090
|
+
return(0);
|
1091
|
+
}
|
1092
|
+
sp->restart_interval=(uint16)(((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8)));
|
1093
|
+
}
|
1094
|
+
if (OJPEGReadHeaderInfoSec(tif)==0)
|
1095
|
+
return(0);
|
1096
|
+
sp->sos_end[0].log=1;
|
1097
|
+
sp->sos_end[0].in_buffer_source=sp->in_buffer_source;
|
1098
|
+
sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile;
|
1099
|
+
sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo;
|
1100
|
+
sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo;
|
1101
|
+
sp->readheader_done=1;
|
1102
|
+
return(1);
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
static int
|
1106
|
+
OJPEGReadSecondarySos(TIFF* tif, uint16 s)
|
1107
|
+
{
|
1108
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1109
|
+
uint8 m;
|
1110
|
+
assert(s>0);
|
1111
|
+
assert(s<3);
|
1112
|
+
assert(sp->sos_end[0].log!=0);
|
1113
|
+
assert(sp->sos_end[s].log==0);
|
1114
|
+
sp->plane_sample_offset=(uint8)(s-1);
|
1115
|
+
while(sp->sos_end[sp->plane_sample_offset].log==0)
|
1116
|
+
sp->plane_sample_offset--;
|
1117
|
+
sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source;
|
1118
|
+
sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile;
|
1119
|
+
sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos;
|
1120
|
+
sp->in_buffer_file_pos_log=0;
|
1121
|
+
sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo;
|
1122
|
+
sp->in_buffer_togo=0;
|
1123
|
+
sp->in_buffer_cur=0;
|
1124
|
+
while(sp->plane_sample_offset<s)
|
1125
|
+
{
|
1126
|
+
do
|
1127
|
+
{
|
1128
|
+
if (OJPEGReadByte(sp,&m)==0)
|
1129
|
+
return(0);
|
1130
|
+
if (m==255)
|
1131
|
+
{
|
1132
|
+
do
|
1133
|
+
{
|
1134
|
+
if (OJPEGReadByte(sp,&m)==0)
|
1135
|
+
return(0);
|
1136
|
+
if (m!=255)
|
1137
|
+
break;
|
1138
|
+
} while(1);
|
1139
|
+
if (m==JPEG_MARKER_SOS)
|
1140
|
+
break;
|
1141
|
+
}
|
1142
|
+
} while(1);
|
1143
|
+
sp->plane_sample_offset++;
|
1144
|
+
if (OJPEGReadHeaderInfoSecStreamSos(tif)==0)
|
1145
|
+
return(0);
|
1146
|
+
sp->sos_end[sp->plane_sample_offset].log=1;
|
1147
|
+
sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source;
|
1148
|
+
sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile;
|
1149
|
+
sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo;
|
1150
|
+
sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo;
|
1151
|
+
}
|
1152
|
+
return(1);
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
static int
|
1156
|
+
OJPEGWriteHeaderInfo(TIFF* tif)
|
1157
|
+
{
|
1158
|
+
static const char module[]="OJPEGWriteHeaderInfo";
|
1159
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1160
|
+
uint8** m;
|
1161
|
+
uint32 n;
|
1162
|
+
/* if a previous attempt failed, don't try again */
|
1163
|
+
if (sp->libjpeg_session_active != 0)
|
1164
|
+
return 0;
|
1165
|
+
sp->out_state=ososSoi;
|
1166
|
+
sp->restart_index=0;
|
1167
|
+
jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr));
|
1168
|
+
sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage;
|
1169
|
+
sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit;
|
1170
|
+
sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr);
|
1171
|
+
sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif;
|
1172
|
+
if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0)
|
1173
|
+
return(0);
|
1174
|
+
sp->libjpeg_session_active=1;
|
1175
|
+
sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0;
|
1176
|
+
sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource;
|
1177
|
+
sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer;
|
1178
|
+
sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData;
|
1179
|
+
sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart;
|
1180
|
+
sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource;
|
1181
|
+
sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr);
|
1182
|
+
if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0)
|
1183
|
+
return(0);
|
1184
|
+
if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_plane>1))
|
1185
|
+
{
|
1186
|
+
sp->libjpeg_jpeg_decompress_struct.raw_data_out=1;
|
1187
|
+
#if JPEG_LIB_VERSION >= 70
|
1188
|
+
sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE;
|
1189
|
+
#endif
|
1190
|
+
sp->libjpeg_jpeg_query_style=0;
|
1191
|
+
if (sp->subsampling_convert_log==0)
|
1192
|
+
{
|
1193
|
+
assert(sp->subsampling_convert_ycbcrbuf==0);
|
1194
|
+
assert(sp->subsampling_convert_ycbcrimage==0);
|
1195
|
+
sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8)*sp->subsampling_hor*8);
|
1196
|
+
sp->subsampling_convert_ylines=sp->subsampling_ver*8;
|
1197
|
+
sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor;
|
1198
|
+
sp->subsampling_convert_clines=8;
|
1199
|
+
sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines;
|
1200
|
+
sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines;
|
1201
|
+
sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuflen;
|
1202
|
+
sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen);
|
1203
|
+
if (sp->subsampling_convert_ycbcrbuf==0)
|
1204
|
+
{
|
1205
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1206
|
+
return(0);
|
1207
|
+
}
|
1208
|
+
sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf;
|
1209
|
+
sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen;
|
1210
|
+
sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen;
|
1211
|
+
sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_clines;
|
1212
|
+
sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*));
|
1213
|
+
if (sp->subsampling_convert_ycbcrimage==0)
|
1214
|
+
{
|
1215
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1216
|
+
return(0);
|
1217
|
+
}
|
1218
|
+
m=sp->subsampling_convert_ycbcrimage;
|
1219
|
+
*m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3);
|
1220
|
+
*m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines);
|
1221
|
+
*m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_convert_clines);
|
1222
|
+
for (n=0; n<sp->subsampling_convert_ylines; n++)
|
1223
|
+
*m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen;
|
1224
|
+
for (n=0; n<sp->subsampling_convert_clines; n++)
|
1225
|
+
*m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen;
|
1226
|
+
for (n=0; n<sp->subsampling_convert_clines; n++)
|
1227
|
+
*m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen;
|
1228
|
+
sp->subsampling_convert_clinelenout=((sp->strile_width+sp->subsampling_hor-1)/sp->subsampling_hor);
|
1229
|
+
sp->subsampling_convert_state=0;
|
1230
|
+
sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2);
|
1231
|
+
sp->lines_per_strile=((sp->strile_length+sp->subsampling_ver-1)/sp->subsampling_ver);
|
1232
|
+
sp->subsampling_convert_log=1;
|
1233
|
+
}
|
1234
|
+
}
|
1235
|
+
else
|
1236
|
+
{
|
1237
|
+
sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN;
|
1238
|
+
sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN;
|
1239
|
+
sp->libjpeg_jpeg_query_style=1;
|
1240
|
+
sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width;
|
1241
|
+
sp->lines_per_strile=sp->strile_length;
|
1242
|
+
}
|
1243
|
+
if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0)
|
1244
|
+
return(0);
|
1245
|
+
sp->writeheader_done=1;
|
1246
|
+
return(1);
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
static void
|
1250
|
+
OJPEGLibjpegSessionAbort(TIFF* tif)
|
1251
|
+
{
|
1252
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1253
|
+
assert(sp->libjpeg_session_active!=0);
|
1254
|
+
jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct)));
|
1255
|
+
sp->libjpeg_session_active=0;
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
static int
|
1259
|
+
OJPEGReadHeaderInfoSec(TIFF* tif)
|
1260
|
+
{
|
1261
|
+
static const char module[]="OJPEGReadHeaderInfoSec";
|
1262
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1263
|
+
uint8 m;
|
1264
|
+
uint16 n;
|
1265
|
+
uint8 o;
|
1266
|
+
if (sp->file_size==0)
|
1267
|
+
sp->file_size=TIFFGetFileSize(tif);
|
1268
|
+
if (sp->jpeg_interchange_format!=0)
|
1269
|
+
{
|
1270
|
+
if (sp->jpeg_interchange_format>=sp->file_size)
|
1271
|
+
{
|
1272
|
+
sp->jpeg_interchange_format=0;
|
1273
|
+
sp->jpeg_interchange_format_length=0;
|
1274
|
+
}
|
1275
|
+
else
|
1276
|
+
{
|
1277
|
+
if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size))
|
1278
|
+
sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format;
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
sp->in_buffer_source=osibsNotSetYet;
|
1282
|
+
sp->in_buffer_next_strile=0;
|
1283
|
+
sp->in_buffer_strile_count=tif->tif_dir.td_nstrips;
|
1284
|
+
sp->in_buffer_file_togo=0;
|
1285
|
+
sp->in_buffer_togo=0;
|
1286
|
+
do
|
1287
|
+
{
|
1288
|
+
if (OJPEGReadBytePeek(sp,&m)==0)
|
1289
|
+
return(0);
|
1290
|
+
if (m!=255)
|
1291
|
+
break;
|
1292
|
+
OJPEGReadByteAdvance(sp);
|
1293
|
+
do
|
1294
|
+
{
|
1295
|
+
if (OJPEGReadByte(sp,&m)==0)
|
1296
|
+
return(0);
|
1297
|
+
} while(m==255);
|
1298
|
+
switch(m)
|
1299
|
+
{
|
1300
|
+
case JPEG_MARKER_SOI:
|
1301
|
+
/* this type of marker has no data, and should be skipped */
|
1302
|
+
break;
|
1303
|
+
case JPEG_MARKER_COM:
|
1304
|
+
case JPEG_MARKER_APP0:
|
1305
|
+
case JPEG_MARKER_APP0+1:
|
1306
|
+
case JPEG_MARKER_APP0+2:
|
1307
|
+
case JPEG_MARKER_APP0+3:
|
1308
|
+
case JPEG_MARKER_APP0+4:
|
1309
|
+
case JPEG_MARKER_APP0+5:
|
1310
|
+
case JPEG_MARKER_APP0+6:
|
1311
|
+
case JPEG_MARKER_APP0+7:
|
1312
|
+
case JPEG_MARKER_APP0+8:
|
1313
|
+
case JPEG_MARKER_APP0+9:
|
1314
|
+
case JPEG_MARKER_APP0+10:
|
1315
|
+
case JPEG_MARKER_APP0+11:
|
1316
|
+
case JPEG_MARKER_APP0+12:
|
1317
|
+
case JPEG_MARKER_APP0+13:
|
1318
|
+
case JPEG_MARKER_APP0+14:
|
1319
|
+
case JPEG_MARKER_APP0+15:
|
1320
|
+
/* this type of marker has data, but it has no use to us (and no place here) and should be skipped */
|
1321
|
+
if (OJPEGReadWord(sp,&n)==0)
|
1322
|
+
return(0);
|
1323
|
+
if (n<2)
|
1324
|
+
{
|
1325
|
+
if (sp->subsamplingcorrect==0)
|
1326
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data");
|
1327
|
+
return(0);
|
1328
|
+
}
|
1329
|
+
if (n>2)
|
1330
|
+
OJPEGReadSkip(sp,n-2);
|
1331
|
+
break;
|
1332
|
+
case JPEG_MARKER_DRI:
|
1333
|
+
if (OJPEGReadHeaderInfoSecStreamDri(tif)==0)
|
1334
|
+
return(0);
|
1335
|
+
break;
|
1336
|
+
case JPEG_MARKER_DQT:
|
1337
|
+
if (OJPEGReadHeaderInfoSecStreamDqt(tif)==0)
|
1338
|
+
return(0);
|
1339
|
+
break;
|
1340
|
+
case JPEG_MARKER_DHT:
|
1341
|
+
if (OJPEGReadHeaderInfoSecStreamDht(tif)==0)
|
1342
|
+
return(0);
|
1343
|
+
break;
|
1344
|
+
case JPEG_MARKER_SOF0:
|
1345
|
+
case JPEG_MARKER_SOF1:
|
1346
|
+
case JPEG_MARKER_SOF3:
|
1347
|
+
if (OJPEGReadHeaderInfoSecStreamSof(tif,m)==0)
|
1348
|
+
return(0);
|
1349
|
+
if (sp->subsamplingcorrect!=0)
|
1350
|
+
return(1);
|
1351
|
+
break;
|
1352
|
+
case JPEG_MARKER_SOS:
|
1353
|
+
if (sp->subsamplingcorrect!=0)
|
1354
|
+
return(1);
|
1355
|
+
assert(sp->plane_sample_offset==0);
|
1356
|
+
if (OJPEGReadHeaderInfoSecStreamSos(tif)==0)
|
1357
|
+
return(0);
|
1358
|
+
break;
|
1359
|
+
default:
|
1360
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m);
|
1361
|
+
return(0);
|
1362
|
+
}
|
1363
|
+
} while(m!=JPEG_MARKER_SOS);
|
1364
|
+
if (sp->subsamplingcorrect)
|
1365
|
+
return(1);
|
1366
|
+
if (sp->sof_log==0)
|
1367
|
+
{
|
1368
|
+
if (OJPEGReadHeaderInfoSecTablesQTable(tif)==0)
|
1369
|
+
return(0);
|
1370
|
+
sp->sof_marker_id=JPEG_MARKER_SOF0;
|
1371
|
+
for (o=0; o<sp->samples_per_pixel; o++)
|
1372
|
+
sp->sof_c[o]=o;
|
1373
|
+
sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver);
|
1374
|
+
for (o=1; o<sp->samples_per_pixel; o++)
|
1375
|
+
sp->sof_hv[o]=17;
|
1376
|
+
sp->sof_x=sp->strile_width;
|
1377
|
+
sp->sof_y=sp->strile_length_total;
|
1378
|
+
sp->sof_log=1;
|
1379
|
+
if (OJPEGReadHeaderInfoSecTablesDcTable(tif)==0)
|
1380
|
+
return(0);
|
1381
|
+
if (OJPEGReadHeaderInfoSecTablesAcTable(tif)==0)
|
1382
|
+
return(0);
|
1383
|
+
for (o=1; o<sp->samples_per_pixel; o++)
|
1384
|
+
sp->sos_cs[o]=o;
|
1385
|
+
}
|
1386
|
+
return(1);
|
1387
|
+
}
|
1388
|
+
|
1389
|
+
static int
|
1390
|
+
OJPEGReadHeaderInfoSecStreamDri(TIFF* tif)
|
1391
|
+
{
|
1392
|
+
/* This could easily cause trouble in some cases... but no such cases have
|
1393
|
+
occurred so far */
|
1394
|
+
static const char module[]="OJPEGReadHeaderInfoSecStreamDri";
|
1395
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1396
|
+
uint16 m;
|
1397
|
+
if (OJPEGReadWord(sp,&m)==0)
|
1398
|
+
return(0);
|
1399
|
+
if (m!=4)
|
1400
|
+
{
|
1401
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DRI marker in JPEG data");
|
1402
|
+
return(0);
|
1403
|
+
}
|
1404
|
+
if (OJPEGReadWord(sp,&m)==0)
|
1405
|
+
return(0);
|
1406
|
+
sp->restart_interval=m;
|
1407
|
+
return(1);
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
static int
|
1411
|
+
OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif)
|
1412
|
+
{
|
1413
|
+
/* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */
|
1414
|
+
static const char module[]="OJPEGReadHeaderInfoSecStreamDqt";
|
1415
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1416
|
+
uint16 m;
|
1417
|
+
uint32 na;
|
1418
|
+
uint8* nb;
|
1419
|
+
uint8 o;
|
1420
|
+
if (OJPEGReadWord(sp,&m)==0)
|
1421
|
+
return(0);
|
1422
|
+
if (m<=2)
|
1423
|
+
{
|
1424
|
+
if (sp->subsamplingcorrect==0)
|
1425
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data");
|
1426
|
+
return(0);
|
1427
|
+
}
|
1428
|
+
if (sp->subsamplingcorrect!=0)
|
1429
|
+
OJPEGReadSkip(sp,m-2);
|
1430
|
+
else
|
1431
|
+
{
|
1432
|
+
m-=2;
|
1433
|
+
do
|
1434
|
+
{
|
1435
|
+
if (m<65)
|
1436
|
+
{
|
1437
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data");
|
1438
|
+
return(0);
|
1439
|
+
}
|
1440
|
+
na=sizeof(uint32)+69;
|
1441
|
+
nb=_TIFFmalloc(na);
|
1442
|
+
if (nb==0)
|
1443
|
+
{
|
1444
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1445
|
+
return(0);
|
1446
|
+
}
|
1447
|
+
*(uint32*)nb=na;
|
1448
|
+
nb[sizeof(uint32)]=255;
|
1449
|
+
nb[sizeof(uint32)+1]=JPEG_MARKER_DQT;
|
1450
|
+
nb[sizeof(uint32)+2]=0;
|
1451
|
+
nb[sizeof(uint32)+3]=67;
|
1452
|
+
if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) {
|
1453
|
+
_TIFFfree(nb);
|
1454
|
+
return(0);
|
1455
|
+
}
|
1456
|
+
o=nb[sizeof(uint32)+4]&15;
|
1457
|
+
if (3<o)
|
1458
|
+
{
|
1459
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data");
|
1460
|
+
_TIFFfree(nb);
|
1461
|
+
return(0);
|
1462
|
+
}
|
1463
|
+
if (sp->qtable[o]!=0)
|
1464
|
+
_TIFFfree(sp->qtable[o]);
|
1465
|
+
sp->qtable[o]=nb;
|
1466
|
+
m-=65;
|
1467
|
+
} while(m>0);
|
1468
|
+
}
|
1469
|
+
return(1);
|
1470
|
+
}
|
1471
|
+
|
1472
|
+
static int
|
1473
|
+
OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
|
1474
|
+
{
|
1475
|
+
/* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */
|
1476
|
+
/* TODO: the following assumes there is only one table in this marker... but i'm not quite sure that assumption is guaranteed correct */
|
1477
|
+
static const char module[]="OJPEGReadHeaderInfoSecStreamDht";
|
1478
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1479
|
+
uint16 m;
|
1480
|
+
uint32 na;
|
1481
|
+
uint8* nb;
|
1482
|
+
uint8 o;
|
1483
|
+
if (OJPEGReadWord(sp,&m)==0)
|
1484
|
+
return(0);
|
1485
|
+
if (m<=2)
|
1486
|
+
{
|
1487
|
+
if (sp->subsamplingcorrect==0)
|
1488
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
1489
|
+
return(0);
|
1490
|
+
}
|
1491
|
+
if (sp->subsamplingcorrect!=0)
|
1492
|
+
{
|
1493
|
+
OJPEGReadSkip(sp,m-2);
|
1494
|
+
}
|
1495
|
+
else
|
1496
|
+
{
|
1497
|
+
na=sizeof(uint32)+2+m;
|
1498
|
+
nb=_TIFFmalloc(na);
|
1499
|
+
if (nb==0)
|
1500
|
+
{
|
1501
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1502
|
+
return(0);
|
1503
|
+
}
|
1504
|
+
*(uint32*)nb=na;
|
1505
|
+
nb[sizeof(uint32)]=255;
|
1506
|
+
nb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
|
1507
|
+
nb[sizeof(uint32)+2]=(m>>8);
|
1508
|
+
nb[sizeof(uint32)+3]=(m&255);
|
1509
|
+
if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) {
|
1510
|
+
_TIFFfree(nb);
|
1511
|
+
return(0);
|
1512
|
+
}
|
1513
|
+
o=nb[sizeof(uint32)+4];
|
1514
|
+
if ((o&240)==0)
|
1515
|
+
{
|
1516
|
+
if (3<o)
|
1517
|
+
{
|
1518
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
1519
|
+
_TIFFfree(nb);
|
1520
|
+
return(0);
|
1521
|
+
}
|
1522
|
+
if (sp->dctable[o]!=0)
|
1523
|
+
_TIFFfree(sp->dctable[o]);
|
1524
|
+
sp->dctable[o]=nb;
|
1525
|
+
}
|
1526
|
+
else
|
1527
|
+
{
|
1528
|
+
if ((o&240)!=16)
|
1529
|
+
{
|
1530
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
1531
|
+
_TIFFfree(nb);
|
1532
|
+
return(0);
|
1533
|
+
}
|
1534
|
+
o&=15;
|
1535
|
+
if (3<o)
|
1536
|
+
{
|
1537
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
1538
|
+
_TIFFfree(nb);
|
1539
|
+
return(0);
|
1540
|
+
}
|
1541
|
+
if (sp->actable[o]!=0)
|
1542
|
+
_TIFFfree(sp->actable[o]);
|
1543
|
+
sp->actable[o]=nb;
|
1544
|
+
}
|
1545
|
+
}
|
1546
|
+
return(1);
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
static int
|
1550
|
+
OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id)
|
1551
|
+
{
|
1552
|
+
/* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */
|
1553
|
+
static const char module[]="OJPEGReadHeaderInfoSecStreamSof";
|
1554
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1555
|
+
uint16 m;
|
1556
|
+
uint16 n;
|
1557
|
+
uint8 o;
|
1558
|
+
uint16 p;
|
1559
|
+
uint16 q;
|
1560
|
+
if (sp->sof_log!=0)
|
1561
|
+
{
|
1562
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data");
|
1563
|
+
return(0);
|
1564
|
+
}
|
1565
|
+
if (sp->subsamplingcorrect==0)
|
1566
|
+
sp->sof_marker_id=marker_id;
|
1567
|
+
/* Lf: data length */
|
1568
|
+
if (OJPEGReadWord(sp,&m)==0)
|
1569
|
+
return(0);
|
1570
|
+
if (m<11)
|
1571
|
+
{
|
1572
|
+
if (sp->subsamplingcorrect==0)
|
1573
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data");
|
1574
|
+
return(0);
|
1575
|
+
}
|
1576
|
+
m-=8;
|
1577
|
+
if (m%3!=0)
|
1578
|
+
{
|
1579
|
+
if (sp->subsamplingcorrect==0)
|
1580
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data");
|
1581
|
+
return(0);
|
1582
|
+
}
|
1583
|
+
n=m/3;
|
1584
|
+
if (sp->subsamplingcorrect==0)
|
1585
|
+
{
|
1586
|
+
if (n!=sp->samples_per_pixel)
|
1587
|
+
{
|
1588
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of samples");
|
1589
|
+
return(0);
|
1590
|
+
}
|
1591
|
+
}
|
1592
|
+
/* P: Sample precision */
|
1593
|
+
if (OJPEGReadByte(sp,&o)==0)
|
1594
|
+
return(0);
|
1595
|
+
if (o!=8)
|
1596
|
+
{
|
1597
|
+
if (sp->subsamplingcorrect==0)
|
1598
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of bits per sample");
|
1599
|
+
return(0);
|
1600
|
+
}
|
1601
|
+
/* Y: Number of lines, X: Number of samples per line */
|
1602
|
+
if (sp->subsamplingcorrect)
|
1603
|
+
OJPEGReadSkip(sp,4);
|
1604
|
+
else
|
1605
|
+
{
|
1606
|
+
/* Y: Number of lines */
|
1607
|
+
if (OJPEGReadWord(sp,&p)==0)
|
1608
|
+
return(0);
|
1609
|
+
if (((uint32)p<sp->image_length) && ((uint32)p<sp->strile_length_total))
|
1610
|
+
{
|
1611
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected height");
|
1612
|
+
return(0);
|
1613
|
+
}
|
1614
|
+
sp->sof_y=p;
|
1615
|
+
/* X: Number of samples per line */
|
1616
|
+
if (OJPEGReadWord(sp,&p)==0)
|
1617
|
+
return(0);
|
1618
|
+
if (((uint32)p<sp->image_width) && ((uint32)p<sp->strile_width))
|
1619
|
+
{
|
1620
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width");
|
1621
|
+
return(0);
|
1622
|
+
}
|
1623
|
+
if ((uint32)p>sp->strile_width)
|
1624
|
+
{
|
1625
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width");
|
1626
|
+
return(0);
|
1627
|
+
}
|
1628
|
+
sp->sof_x=p;
|
1629
|
+
}
|
1630
|
+
/* Nf: Number of image components in frame */
|
1631
|
+
if (OJPEGReadByte(sp,&o)==0)
|
1632
|
+
return(0);
|
1633
|
+
if (o!=n)
|
1634
|
+
{
|
1635
|
+
if (sp->subsamplingcorrect==0)
|
1636
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data");
|
1637
|
+
return(0);
|
1638
|
+
}
|
1639
|
+
/* per component stuff */
|
1640
|
+
/* 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 */
|
1641
|
+
for (q=0; q<n; q++)
|
1642
|
+
{
|
1643
|
+
/* C: Component identifier */
|
1644
|
+
if (OJPEGReadByte(sp,&o)==0)
|
1645
|
+
return(0);
|
1646
|
+
if (sp->subsamplingcorrect==0)
|
1647
|
+
sp->sof_c[q]=o;
|
1648
|
+
/* H: Horizontal sampling factor, and V: Vertical sampling factor */
|
1649
|
+
if (OJPEGReadByte(sp,&o)==0)
|
1650
|
+
return(0);
|
1651
|
+
if (sp->subsamplingcorrect!=0)
|
1652
|
+
{
|
1653
|
+
if (q==0)
|
1654
|
+
{
|
1655
|
+
sp->subsampling_hor=(o>>4);
|
1656
|
+
sp->subsampling_ver=(o&15);
|
1657
|
+
if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) ||
|
1658
|
+
((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4)))
|
1659
|
+
sp->subsampling_force_desubsampling_inside_decompression=1;
|
1660
|
+
}
|
1661
|
+
else
|
1662
|
+
{
|
1663
|
+
if (o!=17)
|
1664
|
+
sp->subsampling_force_desubsampling_inside_decompression=1;
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
else
|
1668
|
+
{
|
1669
|
+
sp->sof_hv[q]=o;
|
1670
|
+
if (sp->subsampling_force_desubsampling_inside_decompression==0)
|
1671
|
+
{
|
1672
|
+
if (q==0)
|
1673
|
+
{
|
1674
|
+
if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver))
|
1675
|
+
{
|
1676
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values");
|
1677
|
+
return(0);
|
1678
|
+
}
|
1679
|
+
}
|
1680
|
+
else
|
1681
|
+
{
|
1682
|
+
if (o!=17)
|
1683
|
+
{
|
1684
|
+
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values");
|
1685
|
+
return(0);
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
}
|
1689
|
+
}
|
1690
|
+
/* Tq: Quantization table destination selector */
|
1691
|
+
if (OJPEGReadByte(sp,&o)==0)
|
1692
|
+
return(0);
|
1693
|
+
if (sp->subsamplingcorrect==0)
|
1694
|
+
sp->sof_tq[q]=o;
|
1695
|
+
}
|
1696
|
+
if (sp->subsamplingcorrect==0)
|
1697
|
+
sp->sof_log=1;
|
1698
|
+
return(1);
|
1699
|
+
}
|
1700
|
+
|
1701
|
+
static int
|
1702
|
+
OJPEGReadHeaderInfoSecStreamSos(TIFF* tif)
|
1703
|
+
{
|
1704
|
+
/* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */
|
1705
|
+
static const char module[]="OJPEGReadHeaderInfoSecStreamSos";
|
1706
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1707
|
+
uint16 m;
|
1708
|
+
uint8 n;
|
1709
|
+
uint8 o;
|
1710
|
+
assert(sp->subsamplingcorrect==0);
|
1711
|
+
if (sp->sof_log==0)
|
1712
|
+
{
|
1713
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data");
|
1714
|
+
return(0);
|
1715
|
+
}
|
1716
|
+
/* Ls */
|
1717
|
+
if (OJPEGReadWord(sp,&m)==0)
|
1718
|
+
return(0);
|
1719
|
+
if (m!=6+sp->samples_per_pixel_per_plane*2)
|
1720
|
+
{
|
1721
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data");
|
1722
|
+
return(0);
|
1723
|
+
}
|
1724
|
+
/* Ns */
|
1725
|
+
if (OJPEGReadByte(sp,&n)==0)
|
1726
|
+
return(0);
|
1727
|
+
if (n!=sp->samples_per_pixel_per_plane)
|
1728
|
+
{
|
1729
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data");
|
1730
|
+
return(0);
|
1731
|
+
}
|
1732
|
+
/* Cs, Td, and Ta */
|
1733
|
+
for (o=0; o<sp->samples_per_pixel_per_plane; o++)
|
1734
|
+
{
|
1735
|
+
/* Cs */
|
1736
|
+
if (OJPEGReadByte(sp,&n)==0)
|
1737
|
+
return(0);
|
1738
|
+
sp->sos_cs[sp->plane_sample_offset+o]=n;
|
1739
|
+
/* Td and Ta */
|
1740
|
+
if (OJPEGReadByte(sp,&n)==0)
|
1741
|
+
return(0);
|
1742
|
+
sp->sos_tda[sp->plane_sample_offset+o]=n;
|
1743
|
+
}
|
1744
|
+
/* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as per LibJpeg source */
|
1745
|
+
OJPEGReadSkip(sp,3);
|
1746
|
+
return(1);
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
static int
|
1750
|
+
OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)
|
1751
|
+
{
|
1752
|
+
static const char module[]="OJPEGReadHeaderInfoSecTablesQTable";
|
1753
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1754
|
+
uint8 m;
|
1755
|
+
uint8 n;
|
1756
|
+
uint32 oa;
|
1757
|
+
uint8* ob;
|
1758
|
+
uint32 p;
|
1759
|
+
if (sp->qtable_offset[0]==0)
|
1760
|
+
{
|
1761
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables");
|
1762
|
+
return(0);
|
1763
|
+
}
|
1764
|
+
sp->in_buffer_file_pos_log=0;
|
1765
|
+
for (m=0; m<sp->samples_per_pixel; m++)
|
1766
|
+
{
|
1767
|
+
if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1])))
|
1768
|
+
{
|
1769
|
+
for (n=0; n<m-1; n++)
|
1770
|
+
{
|
1771
|
+
if (sp->qtable_offset[m]==sp->qtable_offset[n])
|
1772
|
+
{
|
1773
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegQTables tag value");
|
1774
|
+
return(0);
|
1775
|
+
}
|
1776
|
+
}
|
1777
|
+
oa=sizeof(uint32)+69;
|
1778
|
+
ob=_TIFFmalloc(oa);
|
1779
|
+
if (ob==0)
|
1780
|
+
{
|
1781
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1782
|
+
return(0);
|
1783
|
+
}
|
1784
|
+
*(uint32*)ob=oa;
|
1785
|
+
ob[sizeof(uint32)]=255;
|
1786
|
+
ob[sizeof(uint32)+1]=JPEG_MARKER_DQT;
|
1787
|
+
ob[sizeof(uint32)+2]=0;
|
1788
|
+
ob[sizeof(uint32)+3]=67;
|
1789
|
+
ob[sizeof(uint32)+4]=m;
|
1790
|
+
TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET);
|
1791
|
+
p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
|
1792
|
+
if (p!=64)
|
1793
|
+
{
|
1794
|
+
_TIFFfree(ob);
|
1795
|
+
return(0);
|
1796
|
+
}
|
1797
|
+
if (sp->qtable[m]!=0)
|
1798
|
+
_TIFFfree(sp->qtable[m]);
|
1799
|
+
sp->qtable[m]=ob;
|
1800
|
+
sp->sof_tq[m]=m;
|
1801
|
+
}
|
1802
|
+
else
|
1803
|
+
sp->sof_tq[m]=sp->sof_tq[m-1];
|
1804
|
+
}
|
1805
|
+
return(1);
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
static int
|
1809
|
+
OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif)
|
1810
|
+
{
|
1811
|
+
static const char module[]="OJPEGReadHeaderInfoSecTablesDcTable";
|
1812
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1813
|
+
uint8 m;
|
1814
|
+
uint8 n;
|
1815
|
+
uint8 o[16];
|
1816
|
+
uint32 p;
|
1817
|
+
uint32 q;
|
1818
|
+
uint32 ra;
|
1819
|
+
uint8* rb;
|
1820
|
+
if (sp->dctable_offset[0]==0)
|
1821
|
+
{
|
1822
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables");
|
1823
|
+
return(0);
|
1824
|
+
}
|
1825
|
+
sp->in_buffer_file_pos_log=0;
|
1826
|
+
for (m=0; m<sp->samples_per_pixel; m++)
|
1827
|
+
{
|
1828
|
+
if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1])))
|
1829
|
+
{
|
1830
|
+
for (n=0; n<m-1; n++)
|
1831
|
+
{
|
1832
|
+
if (sp->dctable_offset[m]==sp->dctable_offset[n])
|
1833
|
+
{
|
1834
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegDcTables tag value");
|
1835
|
+
return(0);
|
1836
|
+
}
|
1837
|
+
}
|
1838
|
+
TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET);
|
1839
|
+
p=(uint32)TIFFReadFile(tif,o,16);
|
1840
|
+
if (p!=16)
|
1841
|
+
return(0);
|
1842
|
+
q=0;
|
1843
|
+
for (n=0; n<16; n++)
|
1844
|
+
q+=o[n];
|
1845
|
+
ra=sizeof(uint32)+21+q;
|
1846
|
+
rb=_TIFFmalloc(ra);
|
1847
|
+
if (rb==0)
|
1848
|
+
{
|
1849
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1850
|
+
return(0);
|
1851
|
+
}
|
1852
|
+
*(uint32*)rb=ra;
|
1853
|
+
rb[sizeof(uint32)]=255;
|
1854
|
+
rb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
|
1855
|
+
rb[sizeof(uint32)+2]=(uint8)((19+q)>>8);
|
1856
|
+
rb[sizeof(uint32)+3]=((19+q)&255);
|
1857
|
+
rb[sizeof(uint32)+4]=m;
|
1858
|
+
for (n=0; n<16; n++)
|
1859
|
+
rb[sizeof(uint32)+5+n]=o[n];
|
1860
|
+
p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
|
1861
|
+
if (p!=q)
|
1862
|
+
{
|
1863
|
+
_TIFFfree(rb);
|
1864
|
+
return(0);
|
1865
|
+
}
|
1866
|
+
if (sp->dctable[m]!=0)
|
1867
|
+
_TIFFfree(sp->dctable[m]);
|
1868
|
+
sp->dctable[m]=rb;
|
1869
|
+
sp->sos_tda[m]=(m<<4);
|
1870
|
+
}
|
1871
|
+
else
|
1872
|
+
sp->sos_tda[m]=sp->sos_tda[m-1];
|
1873
|
+
}
|
1874
|
+
return(1);
|
1875
|
+
}
|
1876
|
+
|
1877
|
+
static int
|
1878
|
+
OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif)
|
1879
|
+
{
|
1880
|
+
static const char module[]="OJPEGReadHeaderInfoSecTablesAcTable";
|
1881
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
1882
|
+
uint8 m;
|
1883
|
+
uint8 n;
|
1884
|
+
uint8 o[16];
|
1885
|
+
uint32 p;
|
1886
|
+
uint32 q;
|
1887
|
+
uint32 ra;
|
1888
|
+
uint8* rb;
|
1889
|
+
if (sp->actable_offset[0]==0)
|
1890
|
+
{
|
1891
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables");
|
1892
|
+
return(0);
|
1893
|
+
}
|
1894
|
+
sp->in_buffer_file_pos_log=0;
|
1895
|
+
for (m=0; m<sp->samples_per_pixel; m++)
|
1896
|
+
{
|
1897
|
+
if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1])))
|
1898
|
+
{
|
1899
|
+
for (n=0; n<m-1; n++)
|
1900
|
+
{
|
1901
|
+
if (sp->actable_offset[m]==sp->actable_offset[n])
|
1902
|
+
{
|
1903
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegAcTables tag value");
|
1904
|
+
return(0);
|
1905
|
+
}
|
1906
|
+
}
|
1907
|
+
TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET);
|
1908
|
+
p=(uint32)TIFFReadFile(tif,o,16);
|
1909
|
+
if (p!=16)
|
1910
|
+
return(0);
|
1911
|
+
q=0;
|
1912
|
+
for (n=0; n<16; n++)
|
1913
|
+
q+=o[n];
|
1914
|
+
ra=sizeof(uint32)+21+q;
|
1915
|
+
rb=_TIFFmalloc(ra);
|
1916
|
+
if (rb==0)
|
1917
|
+
{
|
1918
|
+
TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
1919
|
+
return(0);
|
1920
|
+
}
|
1921
|
+
*(uint32*)rb=ra;
|
1922
|
+
rb[sizeof(uint32)]=255;
|
1923
|
+
rb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
|
1924
|
+
rb[sizeof(uint32)+2]=(uint8)((19+q)>>8);
|
1925
|
+
rb[sizeof(uint32)+3]=((19+q)&255);
|
1926
|
+
rb[sizeof(uint32)+4]=(16|m);
|
1927
|
+
for (n=0; n<16; n++)
|
1928
|
+
rb[sizeof(uint32)+5+n]=o[n];
|
1929
|
+
p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
|
1930
|
+
if (p!=q)
|
1931
|
+
{
|
1932
|
+
_TIFFfree(rb);
|
1933
|
+
return(0);
|
1934
|
+
}
|
1935
|
+
if (sp->actable[m]!=0)
|
1936
|
+
_TIFFfree(sp->actable[m]);
|
1937
|
+
sp->actable[m]=rb;
|
1938
|
+
sp->sos_tda[m]=(sp->sos_tda[m]|m);
|
1939
|
+
}
|
1940
|
+
else
|
1941
|
+
sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15));
|
1942
|
+
}
|
1943
|
+
return(1);
|
1944
|
+
}
|
1945
|
+
|
1946
|
+
static int
|
1947
|
+
OJPEGReadBufferFill(OJPEGState* sp)
|
1948
|
+
{
|
1949
|
+
uint16 m;
|
1950
|
+
tmsize_t n;
|
1951
|
+
/* TODO: double-check: when subsamplingcorrect is set, no call to TIFFErrorExt or TIFFWarningExt should be made
|
1952
|
+
* in any other case, seek or read errors should be passed through */
|
1953
|
+
do
|
1954
|
+
{
|
1955
|
+
if (sp->in_buffer_file_togo!=0)
|
1956
|
+
{
|
1957
|
+
if (sp->in_buffer_file_pos_log==0)
|
1958
|
+
{
|
1959
|
+
TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET);
|
1960
|
+
sp->in_buffer_file_pos_log=1;
|
1961
|
+
}
|
1962
|
+
m=OJPEG_BUFFER;
|
1963
|
+
if ((uint64)m>sp->in_buffer_file_togo)
|
1964
|
+
m=(uint16)sp->in_buffer_file_togo;
|
1965
|
+
n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m);
|
1966
|
+
if (n==0)
|
1967
|
+
return(0);
|
1968
|
+
assert(n>0);
|
1969
|
+
assert(n<=OJPEG_BUFFER);
|
1970
|
+
assert(n<65536);
|
1971
|
+
assert((uint64)n<=sp->in_buffer_file_togo);
|
1972
|
+
m=(uint16)n;
|
1973
|
+
sp->in_buffer_togo=m;
|
1974
|
+
sp->in_buffer_cur=sp->in_buffer;
|
1975
|
+
sp->in_buffer_file_togo-=m;
|
1976
|
+
sp->in_buffer_file_pos+=m;
|
1977
|
+
break;
|
1978
|
+
}
|
1979
|
+
sp->in_buffer_file_pos_log=0;
|
1980
|
+
switch(sp->in_buffer_source)
|
1981
|
+
{
|
1982
|
+
case osibsNotSetYet:
|
1983
|
+
if (sp->jpeg_interchange_format!=0)
|
1984
|
+
{
|
1985
|
+
sp->in_buffer_file_pos=sp->jpeg_interchange_format;
|
1986
|
+
sp->in_buffer_file_togo=sp->jpeg_interchange_format_length;
|
1987
|
+
}
|
1988
|
+
sp->in_buffer_source=osibsJpegInterchangeFormat;
|
1989
|
+
break;
|
1990
|
+
case osibsJpegInterchangeFormat:
|
1991
|
+
sp->in_buffer_source=osibsStrile;
|
1992
|
+
break;
|
1993
|
+
case osibsStrile:
|
1994
|
+
if (!_TIFFFillStriles( sp->tif )
|
1995
|
+
|| sp->tif->tif_dir.td_stripoffset == NULL
|
1996
|
+
|| sp->tif->tif_dir.td_stripbytecount == NULL)
|
1997
|
+
return 0;
|
1998
|
+
|
1999
|
+
if (sp->in_buffer_next_strile==sp->in_buffer_strile_count)
|
2000
|
+
sp->in_buffer_source=osibsEof;
|
2001
|
+
else
|
2002
|
+
{
|
2003
|
+
sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile];
|
2004
|
+
if (sp->in_buffer_file_pos!=0)
|
2005
|
+
{
|
2006
|
+
if (sp->in_buffer_file_pos>=sp->file_size)
|
2007
|
+
sp->in_buffer_file_pos=0;
|
2008
|
+
else if (sp->tif->tif_dir.td_stripbytecount==NULL)
|
2009
|
+
sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos;
|
2010
|
+
else
|
2011
|
+
{
|
2012
|
+
if (sp->tif->tif_dir.td_stripbytecount == 0) {
|
2013
|
+
TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing");
|
2014
|
+
return(0);
|
2015
|
+
}
|
2016
|
+
sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile];
|
2017
|
+
if (sp->in_buffer_file_togo==0)
|
2018
|
+
sp->in_buffer_file_pos=0;
|
2019
|
+
else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size)
|
2020
|
+
sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos;
|
2021
|
+
}
|
2022
|
+
}
|
2023
|
+
sp->in_buffer_next_strile++;
|
2024
|
+
}
|
2025
|
+
break;
|
2026
|
+
default:
|
2027
|
+
return(0);
|
2028
|
+
}
|
2029
|
+
} while (1);
|
2030
|
+
return(1);
|
2031
|
+
}
|
2032
|
+
|
2033
|
+
static int
|
2034
|
+
OJPEGReadByte(OJPEGState* sp, uint8* byte)
|
2035
|
+
{
|
2036
|
+
if (sp->in_buffer_togo==0)
|
2037
|
+
{
|
2038
|
+
if (OJPEGReadBufferFill(sp)==0)
|
2039
|
+
return(0);
|
2040
|
+
assert(sp->in_buffer_togo>0);
|
2041
|
+
}
|
2042
|
+
*byte=*(sp->in_buffer_cur);
|
2043
|
+
sp->in_buffer_cur++;
|
2044
|
+
sp->in_buffer_togo--;
|
2045
|
+
return(1);
|
2046
|
+
}
|
2047
|
+
|
2048
|
+
static int
|
2049
|
+
OJPEGReadBytePeek(OJPEGState* sp, uint8* byte)
|
2050
|
+
{
|
2051
|
+
if (sp->in_buffer_togo==0)
|
2052
|
+
{
|
2053
|
+
if (OJPEGReadBufferFill(sp)==0)
|
2054
|
+
return(0);
|
2055
|
+
assert(sp->in_buffer_togo>0);
|
2056
|
+
}
|
2057
|
+
*byte=*(sp->in_buffer_cur);
|
2058
|
+
return(1);
|
2059
|
+
}
|
2060
|
+
|
2061
|
+
static void
|
2062
|
+
OJPEGReadByteAdvance(OJPEGState* sp)
|
2063
|
+
{
|
2064
|
+
assert(sp->in_buffer_togo>0);
|
2065
|
+
sp->in_buffer_cur++;
|
2066
|
+
sp->in_buffer_togo--;
|
2067
|
+
}
|
2068
|
+
|
2069
|
+
static int
|
2070
|
+
OJPEGReadWord(OJPEGState* sp, uint16* word)
|
2071
|
+
{
|
2072
|
+
uint8 m;
|
2073
|
+
if (OJPEGReadByte(sp,&m)==0)
|
2074
|
+
return(0);
|
2075
|
+
*word=(m<<8);
|
2076
|
+
if (OJPEGReadByte(sp,&m)==0)
|
2077
|
+
return(0);
|
2078
|
+
*word|=m;
|
2079
|
+
return(1);
|
2080
|
+
}
|
2081
|
+
|
2082
|
+
static int
|
2083
|
+
OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem)
|
2084
|
+
{
|
2085
|
+
uint16 mlen;
|
2086
|
+
uint8* mmem;
|
2087
|
+
uint16 n;
|
2088
|
+
assert(len>0);
|
2089
|
+
mlen=len;
|
2090
|
+
mmem=mem;
|
2091
|
+
do
|
2092
|
+
{
|
2093
|
+
if (sp->in_buffer_togo==0)
|
2094
|
+
{
|
2095
|
+
if (OJPEGReadBufferFill(sp)==0)
|
2096
|
+
return(0);
|
2097
|
+
assert(sp->in_buffer_togo>0);
|
2098
|
+
}
|
2099
|
+
n=mlen;
|
2100
|
+
if (n>sp->in_buffer_togo)
|
2101
|
+
n=sp->in_buffer_togo;
|
2102
|
+
_TIFFmemcpy(mmem,sp->in_buffer_cur,n);
|
2103
|
+
sp->in_buffer_cur+=n;
|
2104
|
+
sp->in_buffer_togo-=n;
|
2105
|
+
mlen-=n;
|
2106
|
+
mmem+=n;
|
2107
|
+
} while(mlen>0);
|
2108
|
+
return(1);
|
2109
|
+
}
|
2110
|
+
|
2111
|
+
static void
|
2112
|
+
OJPEGReadSkip(OJPEGState* sp, uint16 len)
|
2113
|
+
{
|
2114
|
+
uint16 m;
|
2115
|
+
uint16 n;
|
2116
|
+
m=len;
|
2117
|
+
n=m;
|
2118
|
+
if (n>sp->in_buffer_togo)
|
2119
|
+
n=sp->in_buffer_togo;
|
2120
|
+
sp->in_buffer_cur+=n;
|
2121
|
+
sp->in_buffer_togo-=n;
|
2122
|
+
m-=n;
|
2123
|
+
if (m>0)
|
2124
|
+
{
|
2125
|
+
assert(sp->in_buffer_togo==0);
|
2126
|
+
n=m;
|
2127
|
+
if ((uint64)n>sp->in_buffer_file_togo)
|
2128
|
+
n=(uint16)sp->in_buffer_file_togo;
|
2129
|
+
sp->in_buffer_file_pos+=n;
|
2130
|
+
sp->in_buffer_file_togo-=n;
|
2131
|
+
sp->in_buffer_file_pos_log=0;
|
2132
|
+
/* we don't skip past jpeginterchangeformat/strile block...
|
2133
|
+
* if that is asked from us, we're dealing with totally bazurk
|
2134
|
+
* data anyway, and we've not seen this happening on any
|
2135
|
+
* testfile, so we might as well likely cause some other
|
2136
|
+
* meaningless error to be passed at some later time
|
2137
|
+
*/
|
2138
|
+
}
|
2139
|
+
}
|
2140
|
+
|
2141
|
+
static int
|
2142
|
+
OJPEGWriteStream(TIFF* tif, void** mem, uint32* len)
|
2143
|
+
{
|
2144
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2145
|
+
*len=0;
|
2146
|
+
do
|
2147
|
+
{
|
2148
|
+
assert(sp->out_state<=ososEoi);
|
2149
|
+
switch(sp->out_state)
|
2150
|
+
{
|
2151
|
+
case ososSoi:
|
2152
|
+
OJPEGWriteStreamSoi(tif,mem,len);
|
2153
|
+
break;
|
2154
|
+
case ososQTable0:
|
2155
|
+
OJPEGWriteStreamQTable(tif,0,mem,len);
|
2156
|
+
break;
|
2157
|
+
case ososQTable1:
|
2158
|
+
OJPEGWriteStreamQTable(tif,1,mem,len);
|
2159
|
+
break;
|
2160
|
+
case ososQTable2:
|
2161
|
+
OJPEGWriteStreamQTable(tif,2,mem,len);
|
2162
|
+
break;
|
2163
|
+
case ososQTable3:
|
2164
|
+
OJPEGWriteStreamQTable(tif,3,mem,len);
|
2165
|
+
break;
|
2166
|
+
case ososDcTable0:
|
2167
|
+
OJPEGWriteStreamDcTable(tif,0,mem,len);
|
2168
|
+
break;
|
2169
|
+
case ososDcTable1:
|
2170
|
+
OJPEGWriteStreamDcTable(tif,1,mem,len);
|
2171
|
+
break;
|
2172
|
+
case ososDcTable2:
|
2173
|
+
OJPEGWriteStreamDcTable(tif,2,mem,len);
|
2174
|
+
break;
|
2175
|
+
case ososDcTable3:
|
2176
|
+
OJPEGWriteStreamDcTable(tif,3,mem,len);
|
2177
|
+
break;
|
2178
|
+
case ososAcTable0:
|
2179
|
+
OJPEGWriteStreamAcTable(tif,0,mem,len);
|
2180
|
+
break;
|
2181
|
+
case ososAcTable1:
|
2182
|
+
OJPEGWriteStreamAcTable(tif,1,mem,len);
|
2183
|
+
break;
|
2184
|
+
case ososAcTable2:
|
2185
|
+
OJPEGWriteStreamAcTable(tif,2,mem,len);
|
2186
|
+
break;
|
2187
|
+
case ososAcTable3:
|
2188
|
+
OJPEGWriteStreamAcTable(tif,3,mem,len);
|
2189
|
+
break;
|
2190
|
+
case ososDri:
|
2191
|
+
OJPEGWriteStreamDri(tif,mem,len);
|
2192
|
+
break;
|
2193
|
+
case ososSof:
|
2194
|
+
OJPEGWriteStreamSof(tif,mem,len);
|
2195
|
+
break;
|
2196
|
+
case ososSos:
|
2197
|
+
OJPEGWriteStreamSos(tif,mem,len);
|
2198
|
+
break;
|
2199
|
+
case ososCompressed:
|
2200
|
+
if (OJPEGWriteStreamCompressed(tif,mem,len)==0)
|
2201
|
+
return(0);
|
2202
|
+
break;
|
2203
|
+
case ososRst:
|
2204
|
+
OJPEGWriteStreamRst(tif,mem,len);
|
2205
|
+
break;
|
2206
|
+
case ososEoi:
|
2207
|
+
OJPEGWriteStreamEoi(tif,mem,len);
|
2208
|
+
break;
|
2209
|
+
}
|
2210
|
+
} while (*len==0);
|
2211
|
+
return(1);
|
2212
|
+
}
|
2213
|
+
|
2214
|
+
static void
|
2215
|
+
OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len)
|
2216
|
+
{
|
2217
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2218
|
+
assert(OJPEG_BUFFER>=2);
|
2219
|
+
sp->out_buffer[0]=255;
|
2220
|
+
sp->out_buffer[1]=JPEG_MARKER_SOI;
|
2221
|
+
*len=2;
|
2222
|
+
*mem=(void*)sp->out_buffer;
|
2223
|
+
sp->out_state++;
|
2224
|
+
}
|
2225
|
+
|
2226
|
+
static void
|
2227
|
+
OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len)
|
2228
|
+
{
|
2229
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2230
|
+
if (sp->qtable[table_index]!=0)
|
2231
|
+
{
|
2232
|
+
*mem=(void*)(sp->qtable[table_index]+sizeof(uint32));
|
2233
|
+
*len=*((uint32*)sp->qtable[table_index])-sizeof(uint32);
|
2234
|
+
}
|
2235
|
+
sp->out_state++;
|
2236
|
+
}
|
2237
|
+
|
2238
|
+
static void
|
2239
|
+
OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len)
|
2240
|
+
{
|
2241
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2242
|
+
if (sp->dctable[table_index]!=0)
|
2243
|
+
{
|
2244
|
+
*mem=(void*)(sp->dctable[table_index]+sizeof(uint32));
|
2245
|
+
*len=*((uint32*)sp->dctable[table_index])-sizeof(uint32);
|
2246
|
+
}
|
2247
|
+
sp->out_state++;
|
2248
|
+
}
|
2249
|
+
|
2250
|
+
static void
|
2251
|
+
OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len)
|
2252
|
+
{
|
2253
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2254
|
+
if (sp->actable[table_index]!=0)
|
2255
|
+
{
|
2256
|
+
*mem=(void*)(sp->actable[table_index]+sizeof(uint32));
|
2257
|
+
*len=*((uint32*)sp->actable[table_index])-sizeof(uint32);
|
2258
|
+
}
|
2259
|
+
sp->out_state++;
|
2260
|
+
}
|
2261
|
+
|
2262
|
+
static void
|
2263
|
+
OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len)
|
2264
|
+
{
|
2265
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2266
|
+
assert(OJPEG_BUFFER>=6);
|
2267
|
+
if (sp->restart_interval!=0)
|
2268
|
+
{
|
2269
|
+
sp->out_buffer[0]=255;
|
2270
|
+
sp->out_buffer[1]=JPEG_MARKER_DRI;
|
2271
|
+
sp->out_buffer[2]=0;
|
2272
|
+
sp->out_buffer[3]=4;
|
2273
|
+
sp->out_buffer[4]=(sp->restart_interval>>8);
|
2274
|
+
sp->out_buffer[5]=(sp->restart_interval&255);
|
2275
|
+
*len=6;
|
2276
|
+
*mem=(void*)sp->out_buffer;
|
2277
|
+
}
|
2278
|
+
sp->out_state++;
|
2279
|
+
}
|
2280
|
+
|
2281
|
+
static void
|
2282
|
+
OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len)
|
2283
|
+
{
|
2284
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2285
|
+
uint8 m;
|
2286
|
+
assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3);
|
2287
|
+
assert(255>=8+sp->samples_per_pixel_per_plane*3);
|
2288
|
+
sp->out_buffer[0]=255;
|
2289
|
+
sp->out_buffer[1]=sp->sof_marker_id;
|
2290
|
+
/* Lf */
|
2291
|
+
sp->out_buffer[2]=0;
|
2292
|
+
sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3;
|
2293
|
+
/* P */
|
2294
|
+
sp->out_buffer[4]=8;
|
2295
|
+
/* Y */
|
2296
|
+
sp->out_buffer[5]=(uint8)(sp->sof_y>>8);
|
2297
|
+
sp->out_buffer[6]=(sp->sof_y&255);
|
2298
|
+
/* X */
|
2299
|
+
sp->out_buffer[7]=(uint8)(sp->sof_x>>8);
|
2300
|
+
sp->out_buffer[8]=(sp->sof_x&255);
|
2301
|
+
/* Nf */
|
2302
|
+
sp->out_buffer[9]=sp->samples_per_pixel_per_plane;
|
2303
|
+
for (m=0; m<sp->samples_per_pixel_per_plane; m++)
|
2304
|
+
{
|
2305
|
+
/* C */
|
2306
|
+
sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m];
|
2307
|
+
/* H and V */
|
2308
|
+
sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m];
|
2309
|
+
/* Tq */
|
2310
|
+
sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m];
|
2311
|
+
}
|
2312
|
+
*len=10+sp->samples_per_pixel_per_plane*3;
|
2313
|
+
*mem=(void*)sp->out_buffer;
|
2314
|
+
sp->out_state++;
|
2315
|
+
}
|
2316
|
+
|
2317
|
+
static void
|
2318
|
+
OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len)
|
2319
|
+
{
|
2320
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2321
|
+
uint8 m;
|
2322
|
+
assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2);
|
2323
|
+
assert(255>=6+sp->samples_per_pixel_per_plane*2);
|
2324
|
+
sp->out_buffer[0]=255;
|
2325
|
+
sp->out_buffer[1]=JPEG_MARKER_SOS;
|
2326
|
+
/* Ls */
|
2327
|
+
sp->out_buffer[2]=0;
|
2328
|
+
sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2;
|
2329
|
+
/* Ns */
|
2330
|
+
sp->out_buffer[4]=sp->samples_per_pixel_per_plane;
|
2331
|
+
for (m=0; m<sp->samples_per_pixel_per_plane; m++)
|
2332
|
+
{
|
2333
|
+
/* Cs */
|
2334
|
+
sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m];
|
2335
|
+
/* Td and Ta */
|
2336
|
+
sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m];
|
2337
|
+
}
|
2338
|
+
/* Ss */
|
2339
|
+
sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0;
|
2340
|
+
/* Se */
|
2341
|
+
sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63;
|
2342
|
+
/* Ah and Al */
|
2343
|
+
sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0;
|
2344
|
+
*len=8+sp->samples_per_pixel_per_plane*2;
|
2345
|
+
*mem=(void*)sp->out_buffer;
|
2346
|
+
sp->out_state++;
|
2347
|
+
}
|
2348
|
+
|
2349
|
+
static int
|
2350
|
+
OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len)
|
2351
|
+
{
|
2352
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2353
|
+
if (sp->in_buffer_togo==0)
|
2354
|
+
{
|
2355
|
+
if (OJPEGReadBufferFill(sp)==0)
|
2356
|
+
return(0);
|
2357
|
+
assert(sp->in_buffer_togo>0);
|
2358
|
+
}
|
2359
|
+
*len=sp->in_buffer_togo;
|
2360
|
+
*mem=(void*)sp->in_buffer_cur;
|
2361
|
+
sp->in_buffer_togo=0;
|
2362
|
+
if (sp->in_buffer_file_togo==0)
|
2363
|
+
{
|
2364
|
+
switch(sp->in_buffer_source)
|
2365
|
+
{
|
2366
|
+
case osibsStrile:
|
2367
|
+
if (sp->in_buffer_next_strile<sp->in_buffer_strile_count)
|
2368
|
+
sp->out_state=ososRst;
|
2369
|
+
else
|
2370
|
+
sp->out_state=ososEoi;
|
2371
|
+
break;
|
2372
|
+
case osibsEof:
|
2373
|
+
sp->out_state=ososEoi;
|
2374
|
+
break;
|
2375
|
+
default:
|
2376
|
+
break;
|
2377
|
+
}
|
2378
|
+
}
|
2379
|
+
return(1);
|
2380
|
+
}
|
2381
|
+
|
2382
|
+
static void
|
2383
|
+
OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len)
|
2384
|
+
{
|
2385
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2386
|
+
assert(OJPEG_BUFFER>=2);
|
2387
|
+
sp->out_buffer[0]=255;
|
2388
|
+
sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index;
|
2389
|
+
sp->restart_index++;
|
2390
|
+
if (sp->restart_index==8)
|
2391
|
+
sp->restart_index=0;
|
2392
|
+
*len=2;
|
2393
|
+
*mem=(void*)sp->out_buffer;
|
2394
|
+
sp->out_state=ososCompressed;
|
2395
|
+
}
|
2396
|
+
|
2397
|
+
static void
|
2398
|
+
OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len)
|
2399
|
+
{
|
2400
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2401
|
+
assert(OJPEG_BUFFER>=2);
|
2402
|
+
sp->out_buffer[0]=255;
|
2403
|
+
sp->out_buffer[1]=JPEG_MARKER_EOI;
|
2404
|
+
*len=2;
|
2405
|
+
*mem=(void*)sp->out_buffer;
|
2406
|
+
}
|
2407
|
+
|
2408
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
2409
|
+
static int
|
2410
|
+
jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo)
|
2411
|
+
{
|
2412
|
+
if( SETJMP(sp->exit_jmpbuf) )
|
2413
|
+
return 0;
|
2414
|
+
else {
|
2415
|
+
jpeg_create_decompress(cinfo);
|
2416
|
+
return 1;
|
2417
|
+
}
|
2418
|
+
}
|
2419
|
+
#endif
|
2420
|
+
|
2421
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
2422
|
+
static int
|
2423
|
+
jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image)
|
2424
|
+
{
|
2425
|
+
if( SETJMP(sp->exit_jmpbuf) )
|
2426
|
+
return 0;
|
2427
|
+
else {
|
2428
|
+
jpeg_read_header(cinfo,require_image);
|
2429
|
+
return 1;
|
2430
|
+
}
|
2431
|
+
}
|
2432
|
+
#endif
|
2433
|
+
|
2434
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
2435
|
+
static int
|
2436
|
+
jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo)
|
2437
|
+
{
|
2438
|
+
if( SETJMP(sp->exit_jmpbuf) )
|
2439
|
+
return 0;
|
2440
|
+
else {
|
2441
|
+
jpeg_start_decompress(cinfo);
|
2442
|
+
return 1;
|
2443
|
+
}
|
2444
|
+
}
|
2445
|
+
#endif
|
2446
|
+
|
2447
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
2448
|
+
static int
|
2449
|
+
jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines)
|
2450
|
+
{
|
2451
|
+
if( SETJMP(sp->exit_jmpbuf) )
|
2452
|
+
return 0;
|
2453
|
+
else {
|
2454
|
+
jpeg_read_scanlines(cinfo,scanlines,max_lines);
|
2455
|
+
return 1;
|
2456
|
+
}
|
2457
|
+
}
|
2458
|
+
#endif
|
2459
|
+
|
2460
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
2461
|
+
static int
|
2462
|
+
jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines)
|
2463
|
+
{
|
2464
|
+
if( SETJMP(sp->exit_jmpbuf) )
|
2465
|
+
return 0;
|
2466
|
+
else {
|
2467
|
+
jpeg_read_raw_data(cinfo,data,max_lines);
|
2468
|
+
return 1;
|
2469
|
+
}
|
2470
|
+
}
|
2471
|
+
#endif
|
2472
|
+
|
2473
|
+
#ifndef LIBJPEG_ENCAP_EXTERNAL
|
2474
|
+
static void
|
2475
|
+
jpeg_encap_unwind(TIFF* tif)
|
2476
|
+
{
|
2477
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2478
|
+
LONGJMP(sp->exit_jmpbuf,1);
|
2479
|
+
}
|
2480
|
+
#endif
|
2481
|
+
|
2482
|
+
static void
|
2483
|
+
OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo)
|
2484
|
+
{
|
2485
|
+
char buffer[JMSG_LENGTH_MAX];
|
2486
|
+
(*cinfo->err->format_message)(cinfo,buffer);
|
2487
|
+
TIFFWarningExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg","%s",buffer);
|
2488
|
+
}
|
2489
|
+
|
2490
|
+
static void
|
2491
|
+
OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo)
|
2492
|
+
{
|
2493
|
+
char buffer[JMSG_LENGTH_MAX];
|
2494
|
+
(*cinfo->err->format_message)(cinfo,buffer);
|
2495
|
+
TIFFErrorExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg","%s",buffer);
|
2496
|
+
jpeg_encap_unwind((TIFF*)(cinfo->client_data));
|
2497
|
+
}
|
2498
|
+
|
2499
|
+
static void
|
2500
|
+
OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo)
|
2501
|
+
{
|
2502
|
+
(void)cinfo;
|
2503
|
+
}
|
2504
|
+
|
2505
|
+
static boolean
|
2506
|
+
OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo)
|
2507
|
+
{
|
2508
|
+
TIFF* tif=(TIFF*)cinfo->client_data;
|
2509
|
+
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
2510
|
+
void* mem=0;
|
2511
|
+
uint32 len=0U;
|
2512
|
+
if (OJPEGWriteStream(tif,&mem,&len)==0)
|
2513
|
+
{
|
2514
|
+
TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data");
|
2515
|
+
jpeg_encap_unwind(tif);
|
2516
|
+
}
|
2517
|
+
sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len;
|
2518
|
+
sp->libjpeg_jpeg_source_mgr.next_input_byte=mem;
|
2519
|
+
return(1);
|
2520
|
+
}
|
2521
|
+
|
2522
|
+
static void
|
2523
|
+
OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes)
|
2524
|
+
{
|
2525
|
+
TIFF* tif=(TIFF*)cinfo->client_data;
|
2526
|
+
(void)num_bytes;
|
2527
|
+
TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error");
|
2528
|
+
jpeg_encap_unwind(tif);
|
2529
|
+
}
|
2530
|
+
|
2531
|
+
#ifdef _MSC_VER
|
2532
|
+
#pragma warning( push )
|
2533
|
+
#pragma warning( disable : 4702 ) /* unreachable code */
|
2534
|
+
#endif
|
2535
|
+
static boolean
|
2536
|
+
OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired)
|
2537
|
+
{
|
2538
|
+
TIFF* tif=(TIFF*)cinfo->client_data;
|
2539
|
+
(void)desired;
|
2540
|
+
TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error");
|
2541
|
+
jpeg_encap_unwind(tif);
|
2542
|
+
return(0);
|
2543
|
+
}
|
2544
|
+
#ifdef _MSC_VER
|
2545
|
+
#pragma warning( pop )
|
2546
|
+
#endif
|
2547
|
+
|
2548
|
+
static void
|
2549
|
+
OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo)
|
2550
|
+
{
|
2551
|
+
(void)cinfo;
|
2552
|
+
}
|
2553
|
+
|
2554
|
+
#endif
|
2555
|
+
|
2556
|
+
|
2557
|
+
/*
|
2558
|
+
* Local Variables:
|
2559
|
+
* mode: c
|
2560
|
+
* c-basic-offset: 8
|
2561
|
+
* fill-column: 78
|
2562
|
+
* End:
|
2563
|
+
*/
|