├── .gitignore ├── BigImageProcess ├── BigImageProcess.cpp └── BigImageProcess.vcxproj ├── ClientSocket ├── ClientSocket.cpp ├── ClientSocket.vcxproj ├── ClientSocket.vcxproj.filters └── ClientSocket.vcxproj.user ├── DMG.sln ├── Edinburgh ├── Edinburgh.zip ├── labels.0.0.tn.jpg ├── labels.1.0.tn.jpg ├── labels.2.0.tn.jpg ├── labels.3.0.tn.jpg ├── labels.4.0.tn.jpg ├── labels.5.0.tn.jpg ├── labels.6.0.tn.jpg ├── labels.7.0.tn.jpg ├── labels.8.0.tn.jpg ├── out.0.0.0.tn.jpg ├── out.0.1.0.tn.jpg ├── out.1.0.0.tn.jpg ├── out.1.1.0.tn.jpg ├── pixels.0.0.tn.jpg ├── pixels.1.0.tn.jpg ├── pixels.2.0.tn.jpg ├── pixels.3.0.tn.jpg ├── pixels.4.0.tn.jpg ├── pixels.5.0.tn.jpg ├── pixels.6.0.tn.jpg ├── pixels.7.0.tn.jpg ├── pixels.8.0.tn.jpg ├── sharpen.0.0.0.tn.jpg ├── sharpen.0.1.0.tn.jpg ├── sharpen.1.0.0.tn.jpg ├── sharpen.1.1.0.tn.jpg ├── smooth.0.0.0.tn.jpg ├── smooth.0.1.0.tn.jpg ├── smooth.1.0.0.tn.jpg └── smooth.1.1.0.tn.jpg ├── FunctionBasis ├── FunctionData.h ├── FunctionData.inl ├── PPolynomial.h ├── PPolynomial.inl ├── Polynomial.h └── Polynomial.inl ├── JPEG ├── JPEG.vcxproj ├── JPEG.vcxproj.filters └── JPEG.vcxproj.user ├── LICENSE ├── LaplacianMatrix ├── LaplacianMatrix1D.h ├── LaplacianMatrix1D.inl ├── LaplacianMatrix2D.h ├── LaplacianMatrix2D.inl ├── SocketedMultigrid │ ├── MultigridProcess.h │ ├── MultigridProcess.inl │ ├── MultigridServer.h │ ├── MultigridServer.inl │ ├── MultigridThread.h │ ├── MultigridThread.inl │ ├── SocketData.h │ └── SocketData.inl ├── SocketedStreamingSolver.h ├── SocketedStreamingSolver.inl ├── StreamingSolver128.inl └── StreamingSolver128d.inl ├── LinearAlgebra ├── SparseMatrix.h ├── SparseMatrix.inl ├── Vector.h └── Vector.inl ├── Makefile ├── PNC3 ├── PNC3.zip ├── labels.0.tn.jpg ├── labels.1.tn.jpg ├── out.0.tn.jpg ├── out.1.tn.jpg ├── out.tn.jpg ├── pixels.0.tn.jpg └── pixels.1.tn.jpg ├── PNG ├── PNG.vcxproj ├── PNG.vcxproj.filters └── PNG.vcxproj.user ├── README.md ├── ServerSocket ├── ServerSocket.cpp ├── ServerSocket.vcxproj ├── ServerSocket.vcxproj.filters └── ServerSocket.vcxproj.user ├── TIFF ├── TIFF.vcxproj ├── TIFF.vcxproj.filters └── TIFF.vcxproj.user ├── Util ├── Array.h ├── Array.inl ├── BMPStream.inl ├── BaseMultiStreamIO.cpp ├── BaseMultiStreamIO.h ├── ChannelConverter.h ├── CmdLineParser.cpp ├── CmdLineParser.h ├── CmdLineParser.inl ├── Color.h ├── Color.inl ├── CompressedGridStream.h ├── CompressedGridStream.inl ├── GridStream.cpp ├── GridStream.h ├── GridStream.inl ├── Half │ ├── eLut.h │ ├── half.cpp │ ├── half.h │ └── toFloat.h ├── ImageStream.h ├── ImageStream.inl ├── JPEG │ ├── ckconfig.cpp │ ├── jcapimin.cpp │ ├── jcapistd.cpp │ ├── jccoefct.cpp │ ├── jccolor.cpp │ ├── jcdctmgr.cpp │ ├── jchuff.cpp │ ├── jchuff.h │ ├── jcinit.cpp │ ├── jcmainct.cpp │ ├── jcmarker.cpp │ ├── jcmaster.cpp │ ├── jcomapi.cpp │ ├── jconfig.h │ ├── jcparam.cpp │ ├── jcphuff.cpp │ ├── jcprepct.cpp │ ├── jcsample.cpp │ ├── jctrans.cpp │ ├── jdapimin.cpp │ ├── jdapistd.cpp │ ├── jdatadst.cpp │ ├── jdatasrc.cpp │ ├── jdcoefct.cpp │ ├── jdcolor.cpp │ ├── jdct.h │ ├── jddctmgr.cpp │ ├── jdhuff.cpp │ ├── jdhuff.h │ ├── jdinput.cpp │ ├── jdmainct.cpp │ ├── jdmarker.cpp │ ├── jdmaster.cpp │ ├── jdmerge.cpp │ ├── jdphuff.cpp │ ├── jdpostct.cpp │ ├── jdsample.cpp │ ├── jdtrans.cpp │ ├── jerror.cpp │ ├── jerror.h │ ├── jfdctflt.cpp │ ├── jfdctfst.cpp │ ├── jfdctint.cpp │ ├── jidctflt.cpp │ ├── jidctfst.cpp │ ├── jidctint.cpp │ ├── jidctred.cpp │ ├── jinclude.h │ ├── jmemmgr.cpp │ ├── jmemnobs.cpp │ ├── jmemsys.h │ ├── jmorecfg.h │ ├── jpegint.h │ ├── jpeglib.h │ ├── jquant1.cpp │ ├── jquant2.cpp │ ├── jutils.cpp │ └── jversion.h ├── JPGStream.inl ├── KROStream.inl ├── MemoryUsage.h ├── MultiStreamIO.cpp ├── MultiStreamIO.h ├── MultiStreamIO.inl ├── PFMStream.inl ├── PGMStream.inl ├── PNG │ ├── png.c │ ├── png.h │ ├── pngasmrd.h │ ├── pngconf.h │ ├── pngerror.c │ ├── pnggccrd.c │ ├── pngget.c │ ├── pngmem.c │ ├── pngpread.c │ ├── pngread.c │ ├── pngrio.c │ ├── pngrtran.c │ ├── pngrutil.c │ ├── pngset.c │ ├── pngtest.c │ ├── pngtrans.c │ ├── pngvcrd.c │ ├── pngwio.c │ ├── pngwrite.c │ ├── pngwtran.c │ └── pngwutil.c ├── PNGStream.inl ├── RAWStream.inl ├── Socket.cpp ├── Socket.h ├── Socket.inl ├── TIFF │ ├── Makefile.am │ ├── Makefile.in │ ├── Makefile.vc │ ├── SConstruct │ ├── libtiff.def │ ├── t4.h │ ├── tif_aux.c │ ├── tif_close.c │ ├── tif_codec.c │ ├── tif_color.c │ ├── tif_compress.c │ ├── tif_config.h │ ├── tif_config.h.in │ ├── tif_dir.c │ ├── tif_dir.h │ ├── tif_dirinfo.c │ ├── tif_dirread.c │ ├── tif_dirwrite.c │ ├── tif_dumpmode.c │ ├── tif_error.c │ ├── tif_extension.c │ ├── tif_fax3.c │ ├── tif_fax3.h │ ├── tif_fax3sm.c │ ├── tif_flush.c │ ├── tif_getimage.c │ ├── tif_jpeg.c │ ├── tif_luv.c │ ├── tif_lzw.c │ ├── tif_next.c │ ├── tif_ojpeg.c │ ├── tif_open.c │ ├── tif_packbits.c │ ├── tif_pixarlog.c │ ├── tif_predict.c │ ├── tif_predict.h │ ├── tif_print.c │ ├── tif_read.c │ ├── tif_stream.cxx │ ├── tif_strip.c │ ├── tif_swab.c │ ├── tif_thunder.c │ ├── tif_tile.c │ ├── tif_version.c │ ├── tif_warning.c │ ├── tif_win32.c │ ├── tif_write.c │ ├── tif_zip.c │ ├── tiff.h │ ├── tiffconf.h │ ├── tiffconf.h.in │ ├── tiffconf.h.vc │ ├── tiffio.h │ ├── tiffio.hxx │ ├── tiffiop.h │ ├── tiffvers.h │ └── uvcode.h ├── TIFStream.inl ├── Time.cpp ├── Time.h ├── Util.vcxproj ├── Util.vcxproj.filters ├── Util.vcxproj.user ├── XPlatform.cpp ├── XPlatform.h └── ZLIB │ ├── adler32.c │ ├── compress.c │ ├── crc32.c │ ├── deflate.c │ ├── deflate.h │ ├── gzio.c │ ├── infblock.c │ ├── infblock.h │ ├── infcodes.c │ ├── infcodes.h │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inftrees.c │ ├── inftrees.h │ ├── infutil.c │ ├── infutil.h │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── zconf.h │ ├── zlib.h │ ├── zutil.c │ └── zutil.h ├── ZLIB ├── Documentation │ ├── rfc-zlib.html │ ├── zlib Technical Details.mht │ ├── zlib Usage Example.mht │ ├── zlib general purpose compression library version 1_1_4.mht │ └── zpipe.c.txt ├── Make_vms.com ├── ZLIB.vcxproj ├── ZLIB.vcxproj.filters └── ZLIB.vcxproj.user ├── iGrid.html └── system.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | *.sdf 2 | *.suo 3 | *.opensdf 4 | *.bat 5 | /CVS/ 6 | /*/CVS/ 7 | /Obj/ 8 | /*/Obj/ 9 | /Debug/ 10 | /*/Debug/ 11 | /Release/ 12 | /*/Release/ 13 | /x64/ 14 | /*/x64/ 15 | *.zip 16 | -------------------------------------------------------------------------------- /ClientSocket/ClientSocket.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /ClientSocket/ClientSocket.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Edinburgh/Edinburgh.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/Edinburgh.zip -------------------------------------------------------------------------------- /Edinburgh/labels.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.2.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.2.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.3.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.3.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.4.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.4.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.5.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.5.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.6.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.6.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.7.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.7.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/labels.8.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/labels.8.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/out.0.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/out.0.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/out.0.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/out.0.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/out.1.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/out.1.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/out.1.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/out.1.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.2.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.2.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.3.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.3.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.4.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.4.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.5.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.5.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.6.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.6.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.7.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.7.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/pixels.8.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/pixels.8.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/sharpen.0.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/sharpen.0.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/sharpen.0.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/sharpen.0.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/sharpen.1.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/sharpen.1.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/sharpen.1.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/sharpen.1.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/smooth.0.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/smooth.0.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/smooth.0.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/smooth.0.1.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/smooth.1.0.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/smooth.1.0.0.tn.jpg -------------------------------------------------------------------------------- /Edinburgh/smooth.1.1.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Edinburgh/smooth.1.1.0.tn.jpg -------------------------------------------------------------------------------- /FunctionBasis/FunctionData.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | #ifndef FUNCTION_DATA_INCLUDED 30 | #define FUNCTION_DATA_INCLUDED 31 | 32 | 33 | #include "PPolynomial.h" 34 | 35 | template 36 | class FunctionData 37 | { 38 | int useDotRatios; 39 | int normalize; 40 | public: 41 | const static int DOT_FLAG; 42 | const static int D_DOT_FLAG; 43 | const static int D2_DOT_FLAG; 44 | const static int VALUE_FLAG; 45 | const static int D_VALUE_FLAG; 46 | 47 | int depth,res,res2; 48 | Real *dotTable,*dDotTable,*d2DotTable; 49 | Real *valueTables,*dValueTables; 50 | PPolynomial baseFunction; 51 | PPolynomial dBaseFunction; 52 | PPolynomial* baseFunctions; 53 | 54 | FunctionData(void); 55 | ~FunctionData(void); 56 | 57 | virtual void setDotTables(const int& flags); 58 | virtual void clearDotTables(const int& flags); 59 | 60 | virtual void setValueTables(const int& flags,const double& smooth=0); 61 | virtual void setValueTables(const int& flags,const double& valueSmooth,const double& normalSmooth); 62 | virtual void clearValueTables(void); 63 | 64 | void set(const int& maxDepth,const PPolynomial& F,const int& normalize,const int& useDotRatios=1); 65 | void reset(const int& maxDepth); 66 | Real dotProduct(const double& center1,const double& width1,const double& center2,const double& width2) const; 67 | Real dDotProduct(const double& center1,const double& width1,const double& center2,const double& width2) const; 68 | Real d2DotProduct(const double& center1,const double& width1,const double& center2,const double& width2) const; 69 | 70 | static inline int SymmetricIndex(const int& i1,const int& i2); 71 | static inline int SymmetricIndex(const int& i1,const int& i2,int& index); 72 | }; 73 | 74 | 75 | #include "FunctionData.inl" 76 | #endif // FUNCTION_DATA_INCLUDED 77 | -------------------------------------------------------------------------------- /FunctionBasis/Polynomial.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | #ifndef POLYNOMIAL_INCLUDED 30 | #define POLYNOMIAL_INCLUDED 31 | 32 | 33 | 34 | //template< int Degree , class Real=double > 35 | template< int Degree , class Real > 36 | class Polynomial 37 | { 38 | public: 39 | Real coefficients[Degree+1]; 40 | 41 | Polynomial( void ); 42 | template< int Degree2 , class Real2 > Polynomial( const Polynomial< Degree2 , Real2 >& P ); 43 | 44 | Real operator()(const Real& t) const; 45 | Real integral ( const Real& tMin , const Real& tMax ) const; 46 | Real integralSine ( const Real& tMin , const Real& tMax ) const; 47 | Real integralCosine ( const Real& tMin , const Real& tMax ) const; 48 | Real integralCosecant ( const Real& tMin , const Real& tMax , const int& samples ) const; 49 | Real integralSecant ( const Real& tMin , const Real& tMax , const int& samples ) const; 50 | Real integralSine ( const Real& a , const Real& tMin , const Real& tMax ) const; 51 | Real integralCosine ( const Real& a , const Real& tMin , const Real& tMax ) const; 52 | Real integralCosecant ( const Real& a , const Real& tMin , const Real& tMax , const int& samples ) const; 53 | Real integralSecant ( const Real& a , const Real& tMin , const Real& tMax , const int& samples ) const; 54 | Real integralCosecant ( const Real& a , const Real& tMin , const Real& tMax , bool noZero=false ) const; 55 | 56 | int operator == ( const Polynomial& p ) const; 57 | int operator != ( const Polynomial& p ) const; 58 | int isZero(void) const; 59 | void setZero(void); 60 | 61 | template< int Degree2 > Polynomial& operator = ( const Polynomial< Degree2 , Real > &p); 62 | Polynomial& operator += (const Polynomial& p); 63 | Polynomial& operator -= (const Polynomial& p); 64 | Polynomial operator - (void) const; 65 | Polynomial operator + (const Polynomial& p) const; 66 | Polynomial operator - (const Polynomial& p) const; 67 | template< int Degree2 > 68 | Polynomial< Degree+Degree2 , Real > operator * ( const Polynomial< Degree2 , Real >& p) const; 69 | 70 | Polynomial& operator += (const Real& s); 71 | Polynomial& operator -= (const Real& s); 72 | Polynomial& operator *= (const Real& s); 73 | Polynomial& operator /= (const Real& s); 74 | Polynomial operator + (const Real& s) const; 75 | Polynomial operator - (const Real& s) const; 76 | Polynomial operator * (const Real& s) const; 77 | Polynomial operator / (const Real& s) const; 78 | 79 | Polynomial scale(const Real& s) const; 80 | Polynomial shift(const Real& t) const; 81 | 82 | Polynomial< Degree-1 , Real > derivative(void) const; 83 | Polynomial< Degree+1 , Real > integral(void) const; 84 | 85 | void printnl(void) const; 86 | 87 | Polynomial& addScaled(const Polynomial& p,const Real& scale); 88 | 89 | static void Negate(const Polynomial& in,Polynomial& out); 90 | static void Subtract(const Polynomial& p1,const Polynomial& p2,Polynomial& q); 91 | static void Scale(const Polynomial& p,const Real& w,Polynomial& q); 92 | static void AddScaled(const Polynomial& p1,const Real& w1,const Polynomial& p2,const Real& w2,Polynomial& q); 93 | static void AddScaled(const Polynomial& p1,const Polynomial& p2,const Real& w2,Polynomial& q); 94 | static void AddScaled(const Polynomial& p1,const Real& w1,const Polynomial& p2,Polynomial& q); 95 | 96 | void getSolutions( const Real& c , std::vector& roots , const Real& EPS ) const; 97 | 98 | static Polynomial Cosecant( Real center ); 99 | static Polynomial XCscX( void ); 100 | static Real IntegratePolyCosecant( const Real& a , const Real& tMin , const Real& tMax , const int& polyDegree ); 101 | }; 102 | template< class Real > Real Bernoulli( int N ); 103 | 104 | #include "Polynomial.inl" 105 | #endif // POLYNOMIAL_INCLUDED 106 | -------------------------------------------------------------------------------- /JPEG/JPEG.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 mkazhdan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LaplacianMatrix/LaplacianMatrix2D.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPLACIAN_MATRIX_2D_INCLUDED 2 | #define LAPLACIAN_MATRIX_2D_INCLUDED 3 | #include "LaplacianMatrix/LaplacianMatrix1D.h" 4 | 5 | ////////////////////// 6 | // FiniteElements2D // 7 | ////////////////////// 8 | template 9 | class FiniteElements2D 10 | { 11 | public: 12 | template 13 | static bool UpSample ( Vector& in , Vector& out , int lowD1 , int lowD2 , int& highD1 , int& highD2 ); 14 | template 15 | static bool DownSample ( Vector& in , Vector& out , int highD1 , int highD2 , int& lowD1 , int& lowD2 ); 16 | template 17 | static bool UpSample ( const Data* in , Data* out , int lowD1 , int lowD2 , int& highD1 , int& highD2 ); 18 | template 19 | static bool DownSample ( const Data* in , Data* out , int highD1 , int highD2 , int& lowD1 , int& lowD2 ); 20 | 21 | static bool UpSample ( const Real* in , Real* out , int lowD1 , int lowD2 , int& highD1 , int& highD2 , int Channels ); 22 | static bool DownSample ( const Real* in , Real* out , int highD1 , int highD2 , int& lowD1 , int& lowD2 , int Channels ); 23 | 24 | static bool IsUpSamplable(int lowD1,int lowD2,int& highD1,int& highD2); 25 | static bool IsDownSamplable(int highD1,int highD2,int& lowD1,int& lowD2); 26 | static bool UpSampleMatrix(SparseMatrix& M,int lowD1,int lowD2,int& highD1,int& highD2); 27 | static bool DownSampleMatrix(SparseMatrix& M,int highD1,int highD2,int& lowD1,int& lowD2); 28 | 29 | static bool TensorMatrix(int inDim1,int outDim1,const SparseMatrix& m1,const SparseMatrix& m2,SparseMatrix& m); 30 | template 31 | static bool TensorMatrixMultiply(int inDim1,int outDim1,int inDim2,int outDim2,const SparseMatrix& m1,const SparseMatrix& m2,const Vector& in,Vector& out); 32 | template 33 | static bool TensorMatrixMultiply(int inDim1,int outDim1,int inDim2,int outDim2,const SparseMatrix& m1,const SparseMatrix& m2,const Data* in,Data* out); 34 | static bool TensorMatrixMultiply(int inDim1,int outDim1,int inDim2,int outDim2,const SparseMatrix& m1,const SparseMatrix& m2,const Real* in,Real* out,int Channels); 35 | static bool DotProductMatrix(int dim1,int dim2,SparseMatrix& m); 36 | static bool DotProductMatrix(int dim1,int dim2,SparseMatrix& m,Real min1,Real max1,Real min2,Real max2); 37 | static bool LaplacianMatrix(int dim1,int dim2,SparseMatrix& m,bool weakForm,bool negate=false); 38 | static bool LaplacianMatrix(int dim1,int dim2,SparseMatrix& m,Real min1,Real max1,Real min2,Real max2,bool weakForm,bool negate=false); 39 | static bool LaplacianMatrix(int dim1,int dim2,double iWeight , double gWeight , SparseMatrix& m,bool weakForm,bool negate=false); 40 | static bool LaplacianMatrix(int dim1,int dim2,double iWeight , double gWeight , SparseMatrix& m,Real min1,Real max1,Real min2,Real max2,bool weakForm,bool negate=false); 41 | static void StripDiagonal(const SparseMatrix& M,Vector >& D,bool clearDiagonal); 42 | 43 | template 44 | static bool Gradient(const Vector& in,Vector& dX,Vector& dY,int w,int h,int& ww,int& hh); 45 | template 46 | static bool Laplacian(const Vector& dX,const Vector& dY,Vector& out,int w,int h,int ww,int hh); 47 | 48 | class FullDivergenceStencil 49 | { 50 | public: 51 | class DivergenceStencil 52 | { 53 | public: 54 | Real values1[2*Degree1][2*Degree2+1]; 55 | Real values2[2*Degree1+1][2*Degree2]; 56 | }; 57 | DivergenceStencil caseTable[2*Degree1+1][2*Degree2+2]; 58 | }; 59 | static bool DivergenceStencil(int dim1,int dim2,FullDivergenceStencil& s); 60 | 61 | class FullMatrixStencil 62 | { 63 | public: 64 | class MatrixStencil 65 | { 66 | public: 67 | Real values[2*Degree1+1][2*Degree2+1]; 68 | }; 69 | MatrixStencil caseTable[2*Degree1+1][2*Degree2+1]; 70 | }; 71 | class FullPaddedMatrixStencil 72 | { 73 | public: 74 | class PaddedMatrixStencil 75 | { 76 | public: 77 | Real values[2*Degree1+1][2*Degree2+1]; 78 | }; 79 | PaddedMatrixStencil caseTable[2*Degree1+3][2*Degree2+3]; 80 | }; 81 | static bool BiLaplacianStencil( int dim1 , int dim2 , FullMatrixStencil& s , bool weakForm , bool negate=false ); 82 | static bool LaplacianStencil ( int dim1 , int dim2 , FullMatrixStencil& s , bool weakForm , bool negate=false ); 83 | static bool DotProductStencil ( int dim1 , int dim2 , FullMatrixStencil& s ); 84 | 85 | class FullProlongationStencil 86 | { 87 | public: 88 | class ProlongationStencil 89 | { 90 | public: 91 | Real values[Degree1+2][Degree2+2]; 92 | }; 93 | ProlongationStencil caseTable[2*Degree1+1][2*Degree2+1]; 94 | }; 95 | static bool ProlongationStencil(int lowD1,int lowD2,FullProlongationStencil &s,int& highD1,int& highD2); 96 | #if NEW_LAPLACIAN_CODE 97 | class FullRestrictionStencil 98 | { 99 | public: 100 | class RestrictionStencil 101 | { 102 | public: 103 | Real values[(Degree1+3)>>1][(Degree2+3)>>1]; 104 | }; 105 | RestrictionStencil caseTable[2*Degree1+2][2*Degree2+2]; 106 | }; 107 | static bool RestrictionStencil(int highD1,int highD2,FullRestrictionStencil &s,int& lowD1,int& lowD2); 108 | #endif // NEW_LAPLACIAN_CODE 109 | }; 110 | #include "LaplacianMatrix/LaplacianMatrix2D.inl" 111 | #endif // LAPLACIAN_MATRIX_INCLUDED -------------------------------------------------------------------------------- /LaplacianMatrix/SocketedMultigrid/MultigridThread.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTIGRID_PROCESS_INCLUDED 2 | #define MULTIGRID_PROCESS_INCLUDED 3 | 4 | #include "LaplacianMatrix/SocketedStreamingSolver.h" 5 | #include "LaplacianMatrix/SocketedMultigrid/SocketData.h" 6 | 7 | #define STREAMING_GRID_BUFFER_MULTIPLIER 2 8 | 9 | 10 | template< class PData > 11 | class ProcessPartition 12 | { 13 | public: 14 | class MyData 15 | { 16 | public: 17 | int width; 18 | std::vector< int > children; 19 | PData data; 20 | }; 21 | 22 | int startDepth , endDepth; 23 | std::vector< MyData > processData; 24 | 25 | void setBounds( int idx , int& start , int& stop ); 26 | int size( void ) const; 27 | void resize( int ); 28 | MyData& operator[] ( const int& idx ); 29 | const MyData& operator[] ( const int& idx ) const; 30 | static bool IsValidBandSize( int width , int height , int iters , int minSize ); 31 | }; 32 | 33 | template< class PData > 34 | class ProcessPartitionHierarchy 35 | { 36 | public: 37 | std::vector< ProcessPartition< PData > > levels; 38 | int size( void ) const; 39 | void resize( int ); 40 | ProcessPartition< PData >& operator[] ( const int& idx ); 41 | const ProcessPartition< PData >& operator[] ( const int& idx ) const; 42 | template< class TData > 43 | bool Initialize( const ProcessPartition< TData >& initialPartition , int height , int iters , int depths , bool repeat , int minSize , bool showPartition ); 44 | int leaves( const int& depth , const int& offset ) const; 45 | }; 46 | 47 | class ProcessingBlockData 48 | { 49 | public: 50 | ProcessData pData; 51 | Socket serverSocket; 52 | Pointer( Socket ) syncSockets; 53 | DataStream *leftStream , *rightStream; 54 | StreamingGrid *outHighX , *outHighP , *inHighB , *outLowR , *inLowX; 55 | ProcessingBlockData( void ) 56 | { 57 | outHighX = outHighP = inHighB = outLowR = inLowX = NULL; 58 | syncSockets = NullPointer< Socket >(); 59 | serverSocket = _INVALID_SOCKET_; 60 | leftStream = rightStream = NULL; 61 | } 62 | ~ProcessingBlockData( void ) 63 | { 64 | #if 0 65 | if( outHighX ) delete outHighX , outHighX = NULL; 66 | if( outHighP ) delete outHighP , outHighP = NULL; 67 | if( inHighB ) delete inHighB , inHighB = NULL; 68 | if( outLowR ) delete outLowR , outLowR = NULL; 69 | if( inLowX ) delete inLowX , inLowX = NULL; 70 | if( leftStream ) delete leftStream , leftStream = NULL; 71 | if( rightStream ) delete rightStream , rightStream = NULL; 72 | #endif 73 | } 74 | }; 75 | 76 | template< int PixelChannels , int LabelChannels , class StorageType , class SyncType , class PixelType , class LabelType > 77 | class MultigridThread 78 | { 79 | Pointer( SolverInfo< PixelChannels > ) _solverInfo; 80 | 81 | SocketedStreamingDivergence< PixelChannels , LabelChannels , PixelType , LabelType , StorageType , SyncType >* _sDivergence; 82 | SocketedMultiGridRestrictionNode< PixelChannels >* _sRestriction; 83 | Pointer( Pointer( SocketedMultiGridStreamingSolver< PixelChannels , StorageType , SyncType > ) ) _solvers; 84 | int _vCycles; 85 | bool _verbose , _outOfCore; 86 | int _periodicType; 87 | Pointer( ProcessingBlockData ) _blockData; 88 | int _blockCount; // Specifies how the hierarchy of depths is decomposed (depending on which other threads merge in at coarser levels) 89 | void _init( Pointer( ProcessingBlockData ) blockData , int blockCount , const class GlobalData& globalData , bool showProgress , bool inCore , bool lowPixels , bool pixels , bool labels , bool outGuess ); 90 | MultiStreamIOServer* multiStreamIOServer; 91 | public: 92 | StreamingGrid *lowPixels , *pixels , *labels , *outGuess; 93 | MultigridThread( void ); 94 | ~MultigridThread( void ); 95 | 96 | void Initialize( 97 | const std::vector< std::pair< LabelData< LabelType , LabelChannels > , GradientAverage< PixelChannels > > >& gradientAverage , 98 | MultiStreamIOServer* ioServer , 99 | Pointer( ProcessingBlockData ) blockData , int blockCount , 100 | const GlobalData& globalData , bool showProgress , bool inCore ); 101 | 102 | static int RunThread( void* ); 103 | }; 104 | 105 | #include "MultigridThread.inl" 106 | #endif // MULTIGRID_PROCESS_INCLUDED -------------------------------------------------------------------------------- /LinearAlgebra/Vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | #ifndef __VECTOR_HPP 30 | #define __VECTOR_HPP 31 | 32 | //#define Assert assert 33 | #define Assert(x) if(!(x)) exit(0); 34 | 35 | #include 36 | 37 | template 38 | class Vector 39 | { 40 | public: 41 | Vector(); 42 | Vector( const Vector& V ); 43 | Vector( size_t N ); 44 | Vector( size_t N, T* pV ); 45 | ~Vector(); 46 | 47 | const T& operator () (size_t i) const; 48 | T& operator () (size_t i); 49 | const T& operator [] (size_t i) const; 50 | T& operator [] (size_t i); 51 | 52 | void SetZero(); 53 | 54 | size_t Dimensions() const; 55 | void Resize( size_t N ); 56 | 57 | template< class Real > Vector operator * ( const Real& A ) const; 58 | template< class Real > Vector operator / ( const Real& A) const; 59 | Vector operator - (const Vector& V) const; 60 | Vector operator + (const Vector& V) const; 61 | 62 | template< class Real > Vector& operator *= ( const Real& A ); 63 | template< class Real > Vector& operator /= ( const Real& A ); 64 | Vector& operator += (const Vector& V); 65 | Vector& operator -= (const Vector& V); 66 | 67 | template 68 | Vector& AddScaled(const Vector& V,const T2& scale); 69 | template 70 | Vector& SubtractScaled(const Vector& V,const T2& scale); 71 | template 72 | static void Add(const Vector& V1,const T2& scale1,const Vector& V2,const T2& scale2,Vector& Out); 73 | template 74 | static void Add(const Vector& V1,const T2& scale1,const Vector& V2,Vector& Out); 75 | 76 | Vector operator - () const; 77 | 78 | Vector& operator = (const Vector& V); 79 | 80 | double Dot( const Vector& V ) const; 81 | double Length( void ) const; 82 | double SquareNorm( void ) const; 83 | 84 | 85 | template< class Real > static Real Dot( const Vector& v1 , const Vector& v2 , Real (*dot)( T , T ) ); 86 | template< class Real > static Real Dot2( const Vector& v1 , const Vector& v2 , Real (*dot)( T , T ) ); 87 | template< class Real > static Real Length( const Vector& v , Real (*dot)( T , T ) ); 88 | template< class Real > static Real SquareNorm( const Vector& v , Real (*dot)( T , T ) ); 89 | template< class Real > static Real Dot( const Vector& v1 , const Vector& v2 , Real (*dot)( const T& , const T& ) ); 90 | template< class Real > static Real Length( const Vector& v , Real (*dot)( const T& , const T& ) ); 91 | template< class Real > static Real SquareNorm( const Vector& v , Real (*dot)( const T& , const T& ) ); 92 | 93 | void Normalize(); 94 | 95 | T* m_pV; 96 | protected: 97 | size_t m_N; 98 | 99 | }; 100 | 101 | template 102 | class NVector 103 | { 104 | public: 105 | NVector(); 106 | NVector( const NVector& V ); 107 | NVector( size_t N ); 108 | NVector( size_t N, T* pV ); 109 | ~NVector(); 110 | 111 | const T* operator () (size_t i) const; 112 | T* operator () (size_t i); 113 | const T* operator [] (size_t i) const; 114 | T* operator [] (size_t i); 115 | 116 | void SetZero(); 117 | 118 | size_t Dimensions() const; 119 | void Resize( size_t N ); 120 | 121 | NVector operator * (const T& A) const; 122 | NVector operator / (const T& A) const; 123 | NVector operator - (const NVector& V) const; 124 | NVector operator + (const NVector& V) const; 125 | 126 | NVector& operator *= (const T& A); 127 | NVector& operator /= (const T& A); 128 | NVector& operator += (const NVector& V); 129 | NVector& operator -= (const NVector& V); 130 | 131 | NVector& AddScaled(const NVector& V,const T& scale); 132 | NVector& SubtractScaled(const NVector& V,const T& scale); 133 | static void Add(const NVector& V1,const T& scale1,const NVector& V2,const T& scale2,NVector& Out); 134 | static void Add(const NVector& V1,const T& scale1,const NVector& V2, NVector& Out); 135 | 136 | NVector operator - () const; 137 | 138 | NVector& operator = (const NVector& V); 139 | 140 | T Dot( const NVector& V ) const; 141 | 142 | T Length() const; 143 | 144 | T Norm( size_t Ln ) const; 145 | void Normalize(); 146 | 147 | T* m_pV; 148 | protected: 149 | size_t m_N; 150 | 151 | }; 152 | 153 | 154 | #include "Vector.inl" 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CLIENT_TARGET=Client 2 | SERVER_TARGET=Server 3 | BIG_IMAGE_PROCESS_TARGET=BigImageProcess 4 | SOURCE= \ 5 | Util/BaseMultiStreamIO.cpp \ 6 | Util/CmdLineParser.cpp \ 7 | Util/GridStream.cpp \ 8 | Util/Half/half.cpp \ 9 | Util/MultiStreamIO.cpp \ 10 | Util/Socket.cpp \ 11 | Util/Time.cpp \ 12 | Util/XPlatform.cpp 13 | 14 | CLIENT_SOURCE=$(SOURCE) ClientSocket/ClientSocket.cpp 15 | SERVER_SOURCE=$(SOURCE) ServerSocket/ServerSocket.cpp 16 | BIG_IMAGE_PROCESS_SOURCE=$(SOURCE) BigImageProcess/BigImageProcess.cpp 17 | 18 | COMPILER ?= gcc 19 | #COMPILER ?= clang 20 | 21 | ifeq ($(COMPILER),gcc) 22 | CFLAGS += -fpermissive -fopenmp -Wno-deprecated -msse2 --std=c++11 -Wno-unused-result -Wno-dangling-else -Wno-pointer-bool-conversion 23 | LFLAGS += -lgomp -lz -lpng -ltiff -ljpeg -lboost_thread -lboost_system -lpthread 24 | else 25 | CFLAGS += -fpermissive -Wno-deprecated -msse2 --std=c++11 -Wno-unused-result -Wno-dangling-else -Wno-pointer-bool-conversion 26 | LFLAGS += -lz -lpng -ltiff -ljpeg -lboost_thread -lboost_system -lpthread 27 | endif 28 | 29 | CFLAGS_DEBUG = -DDEBUG -g3 30 | LFLAGS_DEBUG = 31 | 32 | CFLAGS_RELEASE = -O3 -DRELEASE -funroll-loops -ffast-math 33 | LFLAGS_RELEASE = -O3 34 | 35 | SRC = ./ 36 | BIN = Bin/ 37 | BIN_O = ./ 38 | INCLUDE = /usr/include/ -I. 39 | 40 | ifeq ($(COMPILER),gcc) 41 | CC=gcc 42 | CXX=g++ 43 | else 44 | CC=clang 45 | CXX=clang++ 46 | endif 47 | 48 | MD=mkdir 49 | 50 | 51 | ##CLIENT_OBJECTS=$(addprefix $(BIN), $(addsuffix .o, $(basename $(CLIENT_SOURCE)))) 52 | ##SERVER_OBJECTS=$(addprefix $(BIN), $(addsuffix .o, $(basename $(SERVER_SOURCE)))) 53 | CLIENT_OBJECTS=$(addprefix $(BIN_O), $(addsuffix .o, $(basename $(CLIENT_SOURCE)))) 54 | SERVER_OBJECTS=$(addprefix $(BIN_O), $(addsuffix .o, $(basename $(SERVER_SOURCE)))) 55 | BIG_IMAGE_PROCESS_OBJECTS=$(addprefix $(BIN_O), $(addsuffix .o, $(basename $(BIG_IMAGE_PROCESS_SOURCE)))) 56 | 57 | all: CFLAGS += $(CFLAGS_RELEASE) 58 | all: LFLAGS += $(LFLAGS_RELEASE) 59 | all: $(BIN)$(CLIENT_TARGET) 60 | all: $(BIN)$(SERVER_TARGET) 61 | all: $(BIN)$(BIG_IMAGE_PROCESS_TARGET) 62 | 63 | debug: CFLAGS += $(CFLAGS_DEBUG) 64 | debug: LFLAGS += $(LFLAGS_DEBUG) 65 | debug: $(BIN)$(CLIENT_TARGET) 66 | debug: $(BIN)$(SERVER_TARGET) 67 | debug: $(BIN)$(BIG_IMAGE_PROCESS_TARGET) 68 | 69 | clean: 70 | rm -f $(BIN)$(CLIENT_TARGET) 71 | rm -f $(BIN)$(SERVER_TARGET) 72 | rm -f $(BIN)$(BIG_IMAGE_PROCESS_TARGET) 73 | rm -f $(CLIENT_OBJECTS) 74 | rm -f $(SERVER_OBJECTS) 75 | rm -f $(BIG_IMAGE_PROCESS_OBJECTS) 76 | 77 | $(BIN): 78 | mkdir -p $(BIN) 79 | 80 | $(BIN)$(CLIENT_TARGET): $(CLIENT_OBJECTS) 81 | mkdir -p $(BIN) 82 | $(CXX) -o $@ $(CLIENT_OBJECTS) $(LFLAGS) 83 | 84 | $(BIN)$(SERVER_TARGET): $(SERVER_OBJECTS) 85 | mkdir -p $(BIN) 86 | $(CXX) -o $@ $(SERVER_OBJECTS) $(LFLAGS) 87 | 88 | $(BIN)$(BIG_IMAGE_PROCESS_TARGET): $(BIG_IMAGE_PROCESS_OBJECTS) 89 | mkdir -p $(BIN) 90 | $(CXX) -o $@ $(BIG_IMAGE_PROCESS_OBJECTS) $(LFLAGS) 91 | 92 | $(BIN_O)%.o: $(SRC)%.c 93 | $(CC) -c -o $@ $(CFLAGS) -I$(INCLUDE) $< 94 | 95 | $(BIN_O)%.o: $(SRC)%.cpp 96 | $(CXX) -c -o $@ $(CFLAGS) -I$(INCLUDE) $< 97 | 98 | -------------------------------------------------------------------------------- /PNC3/PNC3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/PNC3.zip -------------------------------------------------------------------------------- /PNC3/labels.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/labels.0.tn.jpg -------------------------------------------------------------------------------- /PNC3/labels.1.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/labels.1.tn.jpg -------------------------------------------------------------------------------- /PNC3/out.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/out.0.tn.jpg -------------------------------------------------------------------------------- /PNC3/out.1.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/out.1.tn.jpg -------------------------------------------------------------------------------- /PNC3/out.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/out.tn.jpg -------------------------------------------------------------------------------- /PNC3/pixels.0.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/pixels.0.tn.jpg -------------------------------------------------------------------------------- /PNC3/pixels.1.tn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/PNC3/pixels.1.tn.jpg -------------------------------------------------------------------------------- /PNG/PNG.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | Source Files 58 | 59 | 60 | Source Files 61 | 62 | 63 | Source Files 64 | 65 | 66 | Source Files 67 | 68 | 69 | 70 | 71 | Header Files 72 | 73 | 74 | Header Files 75 | 76 | 77 | Header Files 78 | 79 | 80 | -------------------------------------------------------------------------------- /PNG/PNG.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /ServerSocket/ServerSocket.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /ServerSocket/ServerSocket.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /TIFF/TIFF.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Util/BaseMultiStreamIO.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008, Michael Kazhdan 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | #ifndef BASE_MULTI_STREAM_IO 29 | #define BASE_MULTI_STREAM_IO 30 | #include "XPlatform.h" 31 | #include 32 | 33 | // [WARNING] Apparently bad things can happen if the bufferMultiplier is set to one. Possibly related to the fact that rows can overflow buffers? 34 | 35 | class IOClient 36 | { 37 | public: 38 | static const int BYTES_PER_SECTOR; // The atomic size of a read/write operation (for some IO applications) 39 | static const int IO_BLOCK_SIZE; // A nice size for reads 40 | static long long ReadBytes , WriteBytes; // Total bytes read/written 41 | enum 42 | { 43 | NONE, // If there was no I/O that the client could do 44 | SUCCESS, // If the client succeeded in performing the I/O 45 | COMPLETE, // If the client won't need to do any more I/O 46 | }; 47 | 48 | friend class MultiStreamIOServer; 49 | CriticalSectionLock lock; // A locking devices so that the server doesn't step on the client's toes 50 | class MultiStreamIOServer* server; // The server responsible for processing the job requests (this should only be set by the server)! 51 | 52 | IOClient ( void ); 53 | ~IOClient( void ); 54 | 55 | void SetServer( class MultiStreamIOServer* server ); 56 | virtual int Service( void ) = 0; // The task the server asks the client to do 57 | }; 58 | 59 | class MultiStreamIOServer 60 | { 61 | ThreadHandle _ioThread; 62 | static int _IOThread( void* ); 63 | std::vector< IOClient* > _clients; 64 | CriticalSectionLock _pendingLock , _clientLock; 65 | IOClient* _pendingClient; 66 | bool _allowNewClients; 67 | public: 68 | MultiStreamIOServer ( void ); 69 | ~MultiStreamIOServer( void ); 70 | 71 | int clientNum( void ); 72 | virtual bool SetPending( IOClient* client ); 73 | virtual void AddClient ( IOClient* client ); 74 | }; 75 | #endif // BASE_MULTI_STREAM_IO -------------------------------------------------------------------------------- /Util/CmdLineParser.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | #ifndef CMD_LINE_PARSER_INCLUDED 30 | #define CMD_LINE_PARSER_INCLUDED 31 | #include 32 | #include 33 | 34 | 35 | #ifdef WIN32 36 | #ifndef strcasecmp 37 | #define strcasecmp _stricmp 38 | #endif // strcasecmp 39 | #endif // WIN32 40 | 41 | class cmdLineReadable{ 42 | public: 43 | bool set; 44 | char* name; 45 | cmdLineReadable(const char* name); 46 | virtual ~cmdLineReadable(void); 47 | virtual int read(char** argv,int argc); 48 | virtual void write( FILE* fp ) const; 49 | virtual void print( int offset=0 ); 50 | virtual void writeValue( char* str ); 51 | }; 52 | 53 | class cmdLineInt : public cmdLineReadable { 54 | public: 55 | int value; 56 | cmdLineInt(const char* name); 57 | cmdLineInt(const char* name,const int& v); 58 | int read(char** argv,int argc); 59 | void write( FILE* fp ) const; 60 | void print( int offset=0 ); 61 | void writeValue( char* str ); 62 | }; 63 | class cmdLineInts : public cmdLineReadable 64 | { 65 | public: 66 | int count; 67 | int* values; 68 | cmdLineInts(const char* name); 69 | ~cmdLineInts(void); 70 | int read( char** argv , int argc ); 71 | void write( FILE* fp ) const; 72 | void print( int offset=0 ); 73 | void writeValue( char* str ); 74 | }; 75 | 76 | template 77 | class cmdLineIntArray : public cmdLineReadable { 78 | public: 79 | int values[Dim]; 80 | cmdLineIntArray(const char* name); 81 | cmdLineIntArray(const char* name,const int v[Dim]); 82 | int read(char** argv,int argc); 83 | void write( FILE* fp ) const; 84 | void print( int offset=0 ); 85 | void writeValue( char* str ); 86 | }; 87 | 88 | class cmdLineFloat : public cmdLineReadable { 89 | public: 90 | float value; 91 | cmdLineFloat(const char* name); 92 | cmdLineFloat(const char* name,const float& f); 93 | int read(char** argv,int argc); 94 | void write( FILE* fp ) const; 95 | void print( int offset=0 ); 96 | void writeValue( char* str ); 97 | }; 98 | template 99 | class cmdLineFloatArray : public cmdLineReadable { 100 | public: 101 | double values[Dim]; 102 | cmdLineFloatArray(const char* name); 103 | cmdLineFloatArray(const char* name,const float f[Dim]); 104 | int read(char** argv,int argc); 105 | void write( FILE* fp ) const; 106 | void print( int offset=0 ); 107 | void writeValue( char* str ); 108 | }; 109 | class cmdLineString : public cmdLineReadable { 110 | public: 111 | char* value; 112 | cmdLineString( const char* name , const char* value=NULL ); 113 | ~cmdLineString(); 114 | int read(char** argv,int argc); 115 | void write( FILE* fp ) const; 116 | void print( int offset=0 ); 117 | void writeValue( char* str ); 118 | }; 119 | class cmdLineStrings : public cmdLineReadable { 120 | public: 121 | int count; 122 | char** values; 123 | cmdLineStrings(const char* name); 124 | ~cmdLineStrings(); 125 | int read(char** argv,int argc); 126 | void write( FILE* fp ) const; 127 | void print( int offset=0 ); 128 | void writeValue( char* str ); 129 | }; 130 | 131 | 132 | // This reads the arguments in argc, matches them against "names" and sets 133 | // the values of "r" appropriately. Parameters start with "--" 134 | bool cmdLineParse( int argc , char **argv , int num , cmdLineReadable** r , bool dumpError=true ); 135 | 136 | char* GetFileExtension(char* fileName); 137 | char* GetFileHeader(char* fileName); 138 | char* GetLocalFileName(char* fileName); 139 | 140 | #include "Util/CmdLineParser.inl" 141 | #endif // CMD_LINE_PARSER_INCLUDED 142 | -------------------------------------------------------------------------------- /Util/CmdLineParser.inl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | template 29 | cmdLineIntArray< Dim >::cmdLineIntArray( const char* name ) : cmdLineReadable(name) 30 | { 31 | for(int i=0;i 34 | cmdLineIntArray< Dim >::cmdLineIntArray(const char* name,const int v[Dim]) : cmdLineReadable(name) 35 | { 36 | for(int i=0;i 39 | int cmdLineIntArray< Dim >::read(char** argv,int argc) 40 | { 41 | if(argc>=Dim) 42 | { 43 | for(int i=0;i 50 | void cmdLineIntArray< Dim >::write( FILE* fp ) const 51 | { 52 | printf( "--%s" , name ); 53 | for( int i=0 ; i void cmdLineIntArray< Dim >::print( int offset ) 56 | { 57 | for( int i=0 ; i 64 | void cmdLineIntArray::writeValue(char* str) 65 | { 66 | char* temp=str; 67 | for( int i=0 ; i 78 | cmdLineFloatArray< Dim >::cmdLineFloatArray(const char* name) : cmdLineReadable(name) 79 | { 80 | for(int i=0;i 83 | cmdLineFloatArray::cmdLineFloatArray(const char* name,const float f[Dim]) : cmdLineReadable(name) 84 | { 85 | for( int i=0 ; i 88 | int cmdLineFloatArray< Dim >::read(char** argv,int argc) 89 | { 90 | if(argc>=Dim) 91 | { 92 | for(int i=0;i void cmdLineFloatArray< Dim >::write( FILE* fp ) const 99 | { 100 | printf( "--%s" , name ); 101 | for( int i=0 ; i void cmdLineFloatArray< Dim >::print( int offset ) 104 | { 105 | for( int i=0 ; i 112 | void cmdLineFloatArray::writeValue(char* str) 113 | { 114 | char* temp=str; 115 | for( int i=0 ; i 32 | class Color 33 | { 34 | Real c[Channels]; 35 | public: 36 | Color( void ); 37 | Color( Real clr ); 38 | Color( const Real* clr ); 39 | template< class Real2 > 40 | Color( const Color< Real2 , Channels >& clr ); 41 | 42 | // Real luminance( void ) const; 43 | 44 | Real& operator[] (int i); 45 | const Real& operator[] (int i) const; 46 | 47 | Color operator + ( const Color& clr ) const; 48 | Color operator - ( const Color& clr ) const; 49 | Color operator - ( void ) const; 50 | Color operator * ( const Real& s ) const; 51 | Color operator / ( const Real& s ) const; 52 | // An essential method for getting the conjugate gradient solver to work 53 | // Real operator * ( const Color& clr ) const; 54 | Color operator * ( const Color& clr ) const; 55 | 56 | Color& operator += ( const Color& clr ); 57 | Color& operator -= ( const Color& clr ); 58 | Color& operator *= ( const Real& s ); 59 | Color& operator /= ( const Real& s ); 60 | bool operator == ( const Color< Real , Channels >& clr ) const; 61 | bool operator != ( const Color< Real , Channels >& clr ) const; 62 | bool operator < ( const Color< Real , Channels >& clr ) const; 63 | bool operator <= ( const Color< Real , Channels >& clr ) const; 64 | bool operator > ( const Color< Real , Channels >& clr ) const; 65 | bool operator >= ( const Color< Real , Channels >& clr ) const; 66 | }; 67 | template< class Real , int Channels > 68 | inline Color< Real , Channels > pow( const Color< Real , Channels >& in , double e ) 69 | { 70 | Color< Real , Channels > out; 71 | for( int c=0 ; c 4 | #include "GridStream.h" 5 | class CompressedBufferedStreamingGrid : public StreamingGrid 6 | { 7 | bool read; 8 | void* data; 9 | int current,win; 10 | StreamingGrid* sg; 11 | public: 12 | BufferedStreamingGrid (StreamingGrid* sg); 13 | ~BufferedStreamingGrid (void); 14 | int rows (void) const; 15 | int rowSize (void) const; 16 | void* operator[] (int idx); 17 | void advance (void); 18 | void reset (bool read,int minWindowSize); 19 | }; 20 | 21 | #include "CompressedGridStream.inl" 22 | #endif // COMPRESSED_GRID_STREAM_INCLUDED -------------------------------------------------------------------------------- /Util/CompressedGridStream.inl: -------------------------------------------------------------------------------- 1 | 2 | ///////////////////////////////////// 3 | // CompressedBufferedStreamingGrid // 4 | ///////////////////////////////////// 5 | CompressedBufferedStreamingGrid::CompressedBufferedStreamingGrid(StreamingGrid* sg) 6 | { 7 | data=NULL; 8 | current=0; 9 | this->sg=sg; 10 | } 11 | CompressedBufferedStreamingGrid::~CompressedBufferedStreamingGrid(void) 12 | { 13 | if(data) free(data); 14 | data=NULL; 15 | sg=NULL; 16 | } 17 | int BufferedStreamingGrid::rows (void) const {return sg->rows();} 18 | int BufferedStreamingGrid::rowSize (void) const {return sg->rowSize();} 19 | void BufferedStreamingGrid::reset (bool read,int minWindowSize) 20 | { 21 | this->read=read; 22 | win=minWindowSizereset(read,1); 32 | if(read) 33 | { 34 | for(int w=0;wadvance(); 39 | } 40 | } 41 | current=0; 42 | } 43 | void BufferedStreamingGrid::advance(void) 44 | { 45 | if(read) 46 | { 47 | current++; 48 | if(current+win-1advance(); 51 | memcpy((void*)(long long(data)+((current+win-1)%win)*rowSize()),(*sg)[current+win-1],rowSize()); 52 | } 53 | } 54 | else 55 | { 56 | if(current-win+1>=0) 57 | { 58 | memcpy((*sg)[current-win+1],(void*)(long long(data)+((current-win+1)%win)*rowSize()),rowSize()); 59 | sg->advance(); 60 | } 61 | current++; 62 | } 63 | } 64 | void* BufferedStreamingGrid::operator[] (int idx) 65 | { 66 | #if ASSERT_MEMORY_ACCESS 67 | if(idx<0 || idx=rows() || idx>=current+win) 68 | fprintf(stderr,"BufferedStreamingGrid: Index out of bounds: %d\t[%d, %d]\t%d x %d\n",idx,current,current+win,rowSize(),rows()), exit(0); 69 | #endif // ASSERT_MEMORY_ACCESS 70 | return (void*)(long long(data)+(idx%win)*rowSize()); 71 | } 72 | -------------------------------------------------------------------------------- /Util/GridStream.inl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008, Michael Kazhdan 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | #include "Time.h" 29 | 30 | /////////////////////////// 31 | // MultiSocketBackedGrid // 32 | /////////////////////////// 33 | template< class Real , int Channels > 34 | MultiSocketBackedGrid< Real , Channels >::MultiSocketBackedGrid( Socket* socks , int* rowSizes , int sockCount , int rows ) 35 | { 36 | _read = true; 37 | _sockCount = sockCount; 38 | _rows = rows; 39 | _rowSize = 0; 40 | for( int i=0 ; i<_sockCount ; i++ ) _rowSize += rowSizes[i]; 41 | 42 | _rowSizes = ( int* )malloc( sizeof(int) * _sockCount ); 43 | _socks = ( Socket* )malloc( sizeof(Socket) * _sockCount ); 44 | _subData = AllocPointer< Pointer( Real ) >( _sockCount ); 45 | if( !_rowSizes || !_socks || !_subData ) fprintf( stderr , "Failed to allocate\n" ) , exit(0); 46 | for( int i=0 ; i<_sockCount ; i++ ) 47 | { 48 | _rowSizes[i] = rowSizes[i]; 49 | _socks[i] = socks[i]; 50 | _subData[i] = AllocPointer< Real >( Channels * rowSizes[i] ); 51 | if( !_subData[i] ) fprintf( stderr , "Failed to allocate\n" ) , exit(0); 52 | } 53 | 54 | _data = AllocPointer< Real >( _rowSize * Channels ); 55 | if( !_data ) fprintf( stderr , "Failed to allocate\n" ) , exit(0); 56 | } 57 | template< class Real , int Channels > 58 | MultiSocketBackedGrid< Real , Channels >::~MultiSocketBackedGrid(void) 59 | { 60 | for( int i=0 ; i<_sockCount ; i++ ) FreePointer( _subData[i] ); 61 | FreePointer( _data ); 62 | FreePointer( _subData ); 63 | free( _socks ); 64 | free( _rowSizes ); 65 | 66 | _rows = _rowSize = 0; 67 | _rowSizes = NULL; 68 | _socks = NULL; 69 | } 70 | template< class Real , int Channels > int MultiSocketBackedGrid< Real , Channels >::rows( void ) const { return _rows; } 71 | template< class Real , int Channels > int MultiSocketBackedGrid< Real , Channels >::rowSize( void ) const { return _rowSize * Channels * sizeof(Real); } 72 | template< class Real , int Channels > 73 | Pointer( byte ) MultiSocketBackedGrid< Real , Channels >::operator[]( int idx ) 74 | { 75 | if( _read && !_readComplete ) 76 | { 77 | int offset = 0; 78 | for( int i=0 ; i<_sockCount ; i++ ) 79 | { 80 | ReceiveOnSocket( _socks[i] , _subData[i] , _rowSizes[i]*Channels*sizeof(Real) , "MultiSocketBackedGrid::[]" ); 81 | memcpy( _data+offset*Channels , _subData[i] , _rowSizes[i]*Channels*sizeof(Real) ); 82 | offset += _rowSizes[i]; 83 | } 84 | _readComplete = true; 85 | } 86 | return ( Pointer( byte ) )_data; 87 | } 88 | template< class Real , int Channels > 89 | void MultiSocketBackedGrid< Real , Channels >::advance( void ) 90 | { 91 | if( !_read ) 92 | { 93 | int offset = 0; 94 | for( int i=0 ; i<_sockCount ; i++ ) 95 | { 96 | memcpy( _subData[i] , _data+offset*Channels , _rowSizes[i]*Channels*sizeof(Real) ); 97 | SendOnSocket( _socks[i] , ( ConstPointer( Real ) )_subData[i] , _rowSizes[i]*Channels*sizeof(Real) , "MultiSocketBackedGrid::advance" ); 98 | offset += _rowSizes[i]; 99 | } 100 | } 101 | else 102 | { 103 | if( !_readComplete ) 104 | { 105 | int offset = 0; 106 | for( int i=0 ; i<_sockCount ; i++ ) 107 | { 108 | memcpy( _subData[i] , _data+offset*Channels , _rowSizes[i]*Channels*sizeof(Real) ); 109 | ReceiveOnSocket( _socks[i] , _subData[i] , _rowSizes[i]*Channels*sizeof(Real) , "MultiSocketBackedGrid::advance" ); 110 | offset += _rowSizes[i]; 111 | } 112 | } 113 | _readComplete = false; 114 | } 115 | _current++; 116 | } 117 | template< class Real , int Channels > 118 | void MultiSocketBackedGrid< Real , Channels >::reset( bool read , int minWindowSize ) 119 | { 120 | _read = read; 121 | _readComplete = !_read; 122 | _current = 0; 123 | } 124 | 125 | -------------------------------------------------------------------------------- /Util/Half/eLut.h: -------------------------------------------------------------------------------- 1 | // 2 | // This is an automatically generated file. 3 | // Do not edit. 4 | // 5 | 6 | { 7 | 0, 0, 0, 0, 0, 0, 0, 0, 8 | 0, 0, 0, 0, 0, 0, 0, 0, 9 | 0, 0, 0, 0, 0, 0, 0, 0, 10 | 0, 0, 0, 0, 0, 0, 0, 0, 11 | 0, 0, 0, 0, 0, 0, 0, 0, 12 | 0, 0, 0, 0, 0, 0, 0, 0, 13 | 0, 0, 0, 0, 0, 0, 0, 0, 14 | 0, 0, 0, 0, 0, 0, 0, 0, 15 | 0, 0, 0, 0, 0, 0, 0, 0, 16 | 0, 0, 0, 0, 0, 0, 0, 0, 17 | 0, 0, 0, 0, 0, 0, 0, 0, 18 | 0, 0, 0, 0, 0, 0, 0, 0, 19 | 0, 0, 0, 0, 0, 0, 0, 0, 20 | 0, 0, 0, 0, 0, 0, 0, 0, 21 | 0, 1024, 2048, 3072, 4096, 5120, 6144, 7168, 22 | 8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360, 23 | 16384, 17408, 18432, 19456, 20480, 21504, 22528, 23552, 24 | 24576, 25600, 26624, 27648, 28672, 29696, 0, 0, 25 | 0, 0, 0, 0, 0, 0, 0, 0, 26 | 0, 0, 0, 0, 0, 0, 0, 0, 27 | 0, 0, 0, 0, 0, 0, 0, 0, 28 | 0, 0, 0, 0, 0, 0, 0, 0, 29 | 0, 0, 0, 0, 0, 0, 0, 0, 30 | 0, 0, 0, 0, 0, 0, 0, 0, 31 | 0, 0, 0, 0, 0, 0, 0, 0, 32 | 0, 0, 0, 0, 0, 0, 0, 0, 33 | 0, 0, 0, 0, 0, 0, 0, 0, 34 | 0, 0, 0, 0, 0, 0, 0, 0, 35 | 0, 0, 0, 0, 0, 0, 0, 0, 36 | 0, 0, 0, 0, 0, 0, 0, 0, 37 | 0, 0, 0, 0, 0, 0, 0, 0, 38 | 0, 0, 0, 0, 0, 0, 0, 0, 39 | 0, 0, 0, 0, 0, 0, 0, 0, 40 | 0, 0, 0, 0, 0, 0, 0, 0, 41 | 0, 0, 0, 0, 0, 0, 0, 0, 42 | 0, 0, 0, 0, 0, 0, 0, 0, 43 | 0, 0, 0, 0, 0, 0, 0, 0, 44 | 0, 0, 0, 0, 0, 0, 0, 0, 45 | 0, 0, 0, 0, 0, 0, 0, 0, 46 | 0, 0, 0, 0, 0, 0, 0, 0, 47 | 0, 0, 0, 0, 0, 0, 0, 0, 48 | 0, 0, 0, 0, 0, 0, 0, 0, 49 | 0, 0, 0, 0, 0, 0, 0, 0, 50 | 0, 0, 0, 0, 0, 0, 0, 0, 51 | 0, 0, 0, 0, 0, 0, 0, 0, 52 | 0, 0, 0, 0, 0, 0, 0, 0, 53 | 0, 33792, 34816, 35840, 36864, 37888, 38912, 39936, 54 | 40960, 41984, 43008, 44032, 45056, 46080, 47104, 48128, 55 | 49152, 50176, 51200, 52224, 53248, 54272, 55296, 56320, 56 | 57344, 58368, 59392, 60416, 61440, 62464, 0, 0, 57 | 0, 0, 0, 0, 0, 0, 0, 0, 58 | 0, 0, 0, 0, 0, 0, 0, 0, 59 | 0, 0, 0, 0, 0, 0, 0, 0, 60 | 0, 0, 0, 0, 0, 0, 0, 0, 61 | 0, 0, 0, 0, 0, 0, 0, 0, 62 | 0, 0, 0, 0, 0, 0, 0, 0, 63 | 0, 0, 0, 0, 0, 0, 0, 0, 64 | 0, 0, 0, 0, 0, 0, 0, 0, 65 | 0, 0, 0, 0, 0, 0, 0, 0, 66 | 0, 0, 0, 0, 0, 0, 0, 0, 67 | 0, 0, 0, 0, 0, 0, 0, 0, 68 | 0, 0, 0, 0, 0, 0, 0, 0, 69 | 0, 0, 0, 0, 0, 0, 0, 0, 70 | 0, 0, 0, 0, 0, 0, 0, 0, 71 | }; 72 | -------------------------------------------------------------------------------- /Util/Half/half.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/Util/Half/half.cpp -------------------------------------------------------------------------------- /Util/JPEG/jchuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jchuff.h 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains declarations for Huffman entropy encoding routines 9 | * that are shared between the sequential encoder (jchuff.c) and the 10 | * progressive encoder (jcphuff.c). No other modules need to see these. 11 | */ 12 | 13 | /* The legal range of a DCT coefficient is 14 | * -1024 .. +1023 for 8-bit data; 15 | * -16384 .. +16383 for 12-bit data. 16 | * Hence the magnitude should always fit in 10 or 14 bits respectively. 17 | */ 18 | 19 | #if BITS_IN_JSAMPLE == 8 20 | #define MAX_COEF_BITS 10 21 | #else 22 | #define MAX_COEF_BITS 14 23 | #endif 24 | 25 | /* Derived data constructed for each Huffman table */ 26 | 27 | typedef struct { 28 | unsigned int ehufco[256]; /* code for each symbol */ 29 | char ehufsi[256]; /* length of code for each symbol */ 30 | /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ 31 | } c_derived_tbl; 32 | 33 | /* Short forms of external names for systems with brain-damaged linkers. */ 34 | 35 | #ifdef NEED_SHORT_EXTERNAL_NAMES 36 | #define jpeg_make_c_derived_tbl jMkCDerived 37 | #define jpeg_gen_optimal_table jGenOptTbl 38 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 39 | 40 | /* Expand a Huffman table definition into the derived format */ 41 | EXTERN(void) jpeg_make_c_derived_tbl 42 | JPP((j_compress_ptr cinfo, boolean isDC, int tblno, 43 | c_derived_tbl ** pdtbl)); 44 | 45 | /* Generate an optimal table definition given the specified counts */ 46 | EXTERN(void) jpeg_gen_optimal_table 47 | JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); 48 | -------------------------------------------------------------------------------- /Util/JPEG/jcinit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * jcinit.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains initialization logic for the JPEG compressor. 9 | * This routine is in charge of selecting the modules to be executed and 10 | * making an initialization call to each one. 11 | * 12 | * Logically, this code belongs in jcmaster.c. It's split out because 13 | * linking this routine implies linking the entire compression library. 14 | * For a transcoding-only application, we want to be able to use jcmaster.c 15 | * without linking in the whole library. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | 22 | 23 | /* 24 | * Master selection of compression modules. 25 | * This is done once at the start of processing an image. We determine 26 | * which modules will be used and give them appropriate initialization calls. 27 | */ 28 | 29 | GLOBAL(void) 30 | jinit_compress_master (j_compress_ptr cinfo) 31 | { 32 | /* Initialize master control (includes parameter checking/processing) */ 33 | jinit_c_master_control(cinfo, FALSE /* full compression */); 34 | 35 | /* Preprocessing */ 36 | if (! cinfo->raw_data_in) { 37 | jinit_color_converter(cinfo); 38 | jinit_downsampler(cinfo); 39 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); 40 | } 41 | /* Forward DCT */ 42 | jinit_forward_dct(cinfo); 43 | /* Entropy encoding: either Huffman or arithmetic coding. */ 44 | if (cinfo->arith_code) { 45 | ERREXIT(cinfo, JERR_ARITH_NOTIMPL); 46 | } else { 47 | if (cinfo->progressive_mode) { 48 | #ifdef C_PROGRESSIVE_SUPPORTED 49 | jinit_phuff_encoder(cinfo); 50 | #else 51 | ERREXIT(cinfo, JERR_NOT_COMPILED); 52 | #endif 53 | } else 54 | jinit_huff_encoder(cinfo); 55 | } 56 | 57 | /* Need a full-image coefficient buffer in any multi-pass mode. */ 58 | jinit_c_coef_controller(cinfo, 59 | (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); 60 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); 61 | 62 | jinit_marker_writer(cinfo); 63 | 64 | /* We can now tell the memory manager to allocate virtual arrays. */ 65 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 66 | 67 | /* Write the datastream header (SOI) immediately. 68 | * Frame and scan headers are postponed till later. 69 | * This lets application insert special markers after the SOI. 70 | */ 71 | (*cinfo->marker->write_file_header) (cinfo); 72 | } 73 | -------------------------------------------------------------------------------- /Util/JPEG/jcomapi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * jcomapi.c 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains application interface routines that are used for both 9 | * compression and decompression. 10 | */ 11 | 12 | #define JPEG_INTERNALS 13 | #include "jinclude.h" 14 | #include "jpeglib.h" 15 | 16 | 17 | /* 18 | * Abort processing of a JPEG compression or decompression operation, 19 | * but don't destroy the object itself. 20 | * 21 | * For this, we merely clean up all the nonpermanent memory pools. 22 | * Note that temp files (virtual arrays) are not allowed to belong to 23 | * the permanent pool, so we will be able to close all temp files here. 24 | * Closing a data source or destination, if necessary, is the application's 25 | * responsibility. 26 | */ 27 | 28 | GLOBAL(void) 29 | jpeg_abort (j_common_ptr cinfo) 30 | { 31 | int pool; 32 | 33 | /* Do nothing if called on a not-initialized or destroyed JPEG object. */ 34 | if (cinfo->mem == NULL) 35 | return; 36 | 37 | /* Releasing pools in reverse order might help avoid fragmentation 38 | * with some (brain-damaged) malloc libraries. 39 | */ 40 | for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { 41 | (*cinfo->mem->free_pool) (cinfo, pool); 42 | } 43 | 44 | /* Reset overall state for possible reuse of object */ 45 | if (cinfo->is_decompressor) { 46 | cinfo->global_state = DSTATE_START; 47 | /* Try to keep application from accessing now-deleted marker list. 48 | * A bit kludgy to do it here, but this is the most central place. 49 | */ 50 | ((j_decompress_ptr) cinfo)->marker_list = NULL; 51 | } else { 52 | cinfo->global_state = CSTATE_START; 53 | } 54 | } 55 | 56 | 57 | /* 58 | * Destruction of a JPEG object. 59 | * 60 | * Everything gets deallocated except the master jpeg_compress_struct itself 61 | * and the error manager struct. Both of these are supplied by the application 62 | * and must be freed, if necessary, by the application. (Often they are on 63 | * the stack and so don't need to be freed anyway.) 64 | * Closing a data source or destination, if necessary, is the application's 65 | * responsibility. 66 | */ 67 | 68 | GLOBAL(void) 69 | jpeg_destroy (j_common_ptr cinfo) 70 | { 71 | /* We need only tell the memory manager to release everything. */ 72 | /* NB: mem pointer is NULL if memory mgr failed to initialize. */ 73 | if (cinfo->mem != NULL) 74 | (*cinfo->mem->self_destruct) (cinfo); 75 | cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ 76 | cinfo->global_state = 0; /* mark it destroyed */ 77 | } 78 | 79 | 80 | /* 81 | * Convenience routines for allocating quantization and Huffman tables. 82 | * (Would jutils.c be a more reasonable place to put these?) 83 | */ 84 | 85 | GLOBAL(JQUANT_TBL *) 86 | jpeg_alloc_quant_table (j_common_ptr cinfo) 87 | { 88 | JQUANT_TBL *tbl; 89 | 90 | tbl = (JQUANT_TBL *) 91 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); 92 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 93 | return tbl; 94 | } 95 | 96 | 97 | GLOBAL(JHUFF_TBL *) 98 | jpeg_alloc_huff_table (j_common_ptr cinfo) 99 | { 100 | JHUFF_TBL *tbl; 101 | 102 | tbl = (JHUFF_TBL *) 103 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); 104 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 105 | return tbl; 106 | } 107 | -------------------------------------------------------------------------------- /Util/JPEG/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h --- generated by ckconfig.c */ 2 | /* see jconfig.doc for explanations */ 3 | 4 | #define HAVE_PROTOTYPES 5 | #define HAVE_UNSIGNED_CHAR 6 | #define HAVE_UNSIGNED_SHORT 7 | /* #define void char */ 8 | /* #define const */ 9 | #undef CHAR_IS_UNSIGNED 10 | #define HAVE_STDDEF_H 11 | #define HAVE_STDLIB_H 12 | #undef NEED_BSD_STRINGS 13 | #undef NEED_SYS_TYPES_H 14 | #undef NEED_FAR_POINTERS 15 | #undef NEED_SHORT_EXTERNAL_NAMES 16 | #undef INCOMPLETE_TYPES_BROKEN 17 | 18 | #ifdef JPEG_INTERNALS 19 | 20 | #undef RIGHT_SHIFT_IS_UNSIGNED 21 | 22 | #endif /* JPEG_INTERNALS */ 23 | 24 | #ifdef JPEG_CJPEG_DJPEG 25 | 26 | #define BMP_SUPPORTED /* BMP image file format */ 27 | #define GIF_SUPPORTED /* GIF image file format */ 28 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 29 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 30 | #define TARGA_SUPPORTED /* Targa image file format */ 31 | 32 | #undef TWO_FILE_COMMANDLINE /* You may need this on non-Unix systems */ 33 | #undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ 34 | #undef DONT_USE_B_MODE 35 | /* #define PROGRESS_REPORT */ /* optional */ 36 | 37 | #endif /* JPEG_CJPEG_DJPEG */ 38 | -------------------------------------------------------------------------------- /Util/JPEG/jinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jinclude.h 3 | * 4 | * Copyright (C) 1991-1994, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file exists to provide a single place to fix any problems with 9 | * including the wrong system include files. (Common problems are taken 10 | * care of by the standard jconfig symbols, but on really weird systems 11 | * you may have to edit this file.) 12 | * 13 | * NOTE: this file is NOT intended to be included by applications using the 14 | * JPEG library. Most applications need only include jpeglib.h. 15 | */ 16 | 17 | 18 | /* Include auto-config file to find out which system include files we need. */ 19 | 20 | #include "jconfig.h" /* auto configuration options */ 21 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 22 | 23 | /* 24 | * We need the NULL macro and size_t typedef. 25 | * On an ANSI-conforming system it is sufficient to include . 26 | * Otherwise, we get them from or ; we may have to 27 | * pull in as well. 28 | * Note that the core JPEG library does not require ; 29 | * only the default error handler and data source/destination modules do. 30 | * But we must pull it in because of the references to FILE in jpeglib.h. 31 | * You can remove those references if you want to compile without . 32 | */ 33 | 34 | #ifdef HAVE_STDDEF_H 35 | #include 36 | #endif 37 | 38 | #ifdef HAVE_STDLIB_H 39 | #include 40 | #endif 41 | 42 | #ifdef NEED_SYS_TYPES_H 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | /* 49 | * We need memory copying and zeroing functions, plus strncpy(). 50 | * ANSI and System V implementations declare these in . 51 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 52 | * Some systems may declare memset and memcpy in . 53 | * 54 | * NOTE: we assume the size parameters to these functions are of type size_t. 55 | * Change the casts in these macros if not! 56 | */ 57 | 58 | #ifdef NEED_BSD_STRINGS 59 | 60 | #include 61 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 62 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 63 | 64 | #else /* not BSD, assume ANSI/SysV string lib */ 65 | 66 | #include 67 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 68 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 69 | 70 | #endif 71 | 72 | /* 73 | * In ANSI C, and indeed any rational implementation, size_t is also the 74 | * type returned by sizeof(). However, it seems there are some irrational 75 | * implementations out there, in which sizeof() returns an int even though 76 | * size_t is defined as long or unsigned long. To ensure consistent results 77 | * we always use this SIZEOF() macro in place of using sizeof() directly. 78 | */ 79 | 80 | #define SIZEOF(object) ((size_t) sizeof(object)) 81 | 82 | /* 83 | * The modules that use fread() and fwrite() always invoke them through 84 | * these macros. On some systems you may need to twiddle the argument casts. 85 | * CAUTION: argument order is different from underlying functions! 86 | */ 87 | 88 | #define JFREAD(file,buf,sizeofbuf) \ 89 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 90 | #define JFWRITE(file,buf,sizeofbuf) \ 91 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 92 | -------------------------------------------------------------------------------- /Util/JPEG/jmemnobs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * jmemnobs.c 3 | * 4 | * Copyright (C) 1992-1996, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file provides a really simple implementation of the system- 9 | * dependent portion of the JPEG memory manager. This implementation 10 | * assumes that no backing-store files are needed: all required space 11 | * can be obtained from malloc(). 12 | * This is very portable in the sense that it'll compile on almost anything, 13 | * but you'd better have lots of main memory (or virtual memory) if you want 14 | * to process big images. 15 | * Note that the max_memory_to_use option is ignored by this implementation. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | #include "jmemsys.h" /* import the system-dependent declarations */ 22 | 23 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ 24 | extern void * malloc JPP((size_t size)); 25 | extern void free JPP((void *ptr)); 26 | #endif 27 | 28 | 29 | /* 30 | * Memory allocation and freeing are controlled by the regular library 31 | * routines malloc() and free(). 32 | */ 33 | 34 | GLOBAL(void *) 35 | jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) 36 | { 37 | return (void *) malloc(sizeofobject); 38 | } 39 | 40 | GLOBAL(void) 41 | jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) 42 | { 43 | free(object); 44 | } 45 | 46 | 47 | /* 48 | * "Large" objects are treated the same as "small" ones. 49 | * NB: although we include FAR keywords in the routine declarations, 50 | * this file won't actually work in 80x86 small/medium model; at least, 51 | * you probably won't be able to process useful-size images in only 64KB. 52 | */ 53 | 54 | GLOBAL(void FAR *) 55 | jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) 56 | { 57 | return (void FAR *) malloc(sizeofobject); 58 | } 59 | 60 | GLOBAL(void) 61 | jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) 62 | { 63 | free(object); 64 | } 65 | 66 | 67 | /* 68 | * This routine computes the total memory space available for allocation. 69 | * Here we always say, "we got all you want bud!" 70 | */ 71 | 72 | GLOBAL(long) 73 | jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, 74 | long max_bytes_needed, long already_allocated) 75 | { 76 | return max_bytes_needed; 77 | } 78 | 79 | 80 | /* 81 | * Backing store (temporary file) management. 82 | * Since jpeg_mem_available always promised the moon, 83 | * this should never be called and we can just error out. 84 | */ 85 | 86 | GLOBAL(void) 87 | jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, 88 | long total_bytes_needed) 89 | { 90 | ERREXIT(cinfo, JERR_NO_BACKING_STORE); 91 | } 92 | 93 | 94 | /* 95 | * These routines take care of any system-dependent initialization and 96 | * cleanup required. Here, there isn't any. 97 | */ 98 | 99 | GLOBAL(long) 100 | jpeg_mem_init (j_common_ptr cinfo) 101 | { 102 | return 0; /* just set max_memory_to_use to 0 */ 103 | } 104 | 105 | GLOBAL(void) 106 | jpeg_mem_term (j_common_ptr cinfo) 107 | { 108 | /* no work */ 109 | } 110 | -------------------------------------------------------------------------------- /Util/JPEG/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-1998, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "6b 27-Mar-1998" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" 15 | -------------------------------------------------------------------------------- /Util/MemoryUsage.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | #ifndef MEMORY_USAGE_INCLUDED 30 | #define MEMORY_USAGE_INCLUDED 31 | 32 | #ifdef WIN32 33 | 34 | #include 35 | class MemoryInfo{ 36 | public: 37 | size_t TotalPhysicalMemory; 38 | size_t FreePhysicalMemory; 39 | size_t TotalSwapSpace; 40 | size_t FreeSwapSpace; 41 | size_t TotalVirtualAddressSpace; 42 | size_t FreeVirtualAddressSpace; 43 | size_t PageSize; 44 | 45 | void set(void){ 46 | MEMORYSTATUSEX Mem; 47 | SYSTEM_INFO Info; 48 | ZeroMemory( &Mem, sizeof(Mem)); 49 | ZeroMemory( &Info, sizeof(Info)); 50 | Mem.dwLength = sizeof(Mem); 51 | ::GlobalMemoryStatusEx( &Mem ); 52 | ::GetSystemInfo( &Info ); 53 | 54 | TotalPhysicalMemory = (size_t)Mem.ullTotalPhys; 55 | FreePhysicalMemory = (size_t)Mem.ullAvailPhys; 56 | TotalSwapSpace = (size_t)Mem.ullTotalPageFile; 57 | FreeSwapSpace = (size_t)Mem.ullAvailPageFile; 58 | TotalVirtualAddressSpace = (size_t)Mem.ullTotalVirtual; 59 | FreeVirtualAddressSpace = (size_t)Mem.ullAvailVirtual; 60 | PageSize = (size_t)Info.dwPageSize; 61 | } 62 | size_t usage(void) const {return TotalVirtualAddressSpace-FreeVirtualAddressSpace;} 63 | 64 | static size_t Usage(void){ 65 | MEMORY_BASIC_INFORMATION mbi; 66 | size_t dwMemUsed = 0; 67 | PVOID pvAddress = 0; 68 | 69 | 70 | memset(&mbi, 0, sizeof(MEMORY_BASIC_INFORMATION)); 71 | while(VirtualQuery(pvAddress, &mbi, sizeof(MEMORY_BASIC_INFORMATION)) == sizeof(MEMORY_BASIC_INFORMATION)){ 72 | if(mbi.State == MEM_COMMIT && mbi.Type == MEM_PRIVATE){dwMemUsed += mbi.RegionSize;} 73 | pvAddress = ((BYTE*)mbi.BaseAddress) + mbi.RegionSize; 74 | } 75 | return dwMemUsed; 76 | } 77 | }; 78 | 79 | #else 80 | 81 | #include 82 | #include 83 | 84 | class MemoryInfo 85 | { 86 | public: 87 | static size_t Usage(void) 88 | { 89 | FILE* f = fopen("/proc/self/stat","rb"); 90 | 91 | int d; 92 | long ld; 93 | unsigned long lu; 94 | unsigned long long llu; 95 | char* s; 96 | char c; 97 | 98 | int pid; 99 | unsigned long vm; 100 | 101 | int n = fscanf(f, "%d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %d %ld %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d %lu %lu" 102 | ,&pid ,&s ,&c ,&d ,&d ,&d ,&d ,&d ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&ld ,&ld ,&ld ,&ld ,&d ,&ld ,&llu ,&vm ,&ld ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&lu ,&d ,&d ,&lu ,&lu ); 103 | 104 | fclose(f); 105 | /* 106 | pid %d 107 | comm %s 108 | state %c 109 | ppid %d 110 | pgrp %d 111 | session %d 112 | tty_nr %d 113 | tpgid %d 114 | flags %lu 115 | minflt %lu 116 | cminflt %lu 117 | majflt %lu 118 | cmajflt %lu 119 | utime %lu 120 | stime %lu 121 | cutime %ld 122 | cstime %ld 123 | priority %ld 124 | nice %ld 125 | 0 %ld 126 | itrealvalue %ld 127 | starttime %lu 128 | vsize %lu 129 | rss %ld 130 | rlim %lu 131 | startcode %lu 132 | endcode %lu 133 | startstack %lu 134 | kstkesp %lu 135 | kstkeip %lu 136 | signal %lu 137 | blocked %lu 138 | sigignore %lu 139 | sigcatch %lu 140 | wchan %lu 141 | nswap %lu 142 | cnswap %lu 143 | exit_signal %d 144 | processor %d 145 | rt_priority %lu (since kernel 2.5.19) 146 | policy %lu (since kernel 2.5.19) 147 | */ 148 | return vm; 149 | } 150 | 151 | }; 152 | 153 | #endif 154 | 155 | #endif // MEMORY_USAGE_INCLUDE 156 | -------------------------------------------------------------------------------- /Util/MultiStreamIO.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, Michael Kazhdan 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | #ifndef MULTI_STREAM_IO 29 | #define MULTI_STREAM_IO 30 | #include 31 | #include "BaseMultiStreamIO.h" 32 | #include "GridStream.h" 33 | 34 | // [WARNING] Apparently bad things can happen if the bufferMultiplier is set to one. Possibly related to the fact that rows can overflow buffers? 35 | 36 | 37 | 38 | // When only the maximum size of the requested read/write is known in advance. 39 | class VariableIOClientStream : public IOClient 40 | { 41 | int _blockSize; // The actual size of a read/write operation 42 | Pointer( byte ) _data; 43 | int _bufferMultiplier; // The number of blocks to store in memory at any given time (must be at least 2) 44 | FILE* _fp; // Where to read/write data 45 | int _current; // The index of the buffer from which data can be requested 46 | int _frontAndBack; // For reading, [ _current , _frontAndBack ] is in the buffer. 47 | // For writing, [ _frontAndBack , _current ] is in the buffer 48 | bool _read; // Are we reading data? 49 | bool _endIO; // Have we performed all the requisite I/O? 50 | long long _pseudoHead; // Where are we believed to be in the file 51 | long long _head; // Where are we actually in the file 52 | public: 53 | VariableIOClientStream( void ); 54 | void Initialize( const char* fileName , int maxIOSize , int bufferMultiplier , bool read ); 55 | ~VariableIOClientStream( void ); 56 | int Service ( void ); 57 | size_t read ( Pointer( byte ) buffer , size_t sz ); 58 | size_t write( ConstPointer( byte ) buffer , size_t sz ); 59 | int close( void ); 60 | }; 61 | 62 | class FixedIOClientStream : public IOClient 63 | { 64 | public: 65 | int blockSize; 66 | Pointer( int ) off; 67 | Pointer( byte ) data; 68 | int r , rs , win , b; 69 | FileHandle hFile; 70 | bool read; 71 | int current,front,back; 72 | 73 | FixedIOClientStream ( void ); 74 | ~FixedIOClientStream( void ); 75 | void Init ( FileHandle hFile , int rowSize , int rows , int bufferMultiplier ); 76 | void Reset ( bool read , int minWindowSize ); 77 | void Unset ( void ); 78 | int Service ( void ); 79 | bool Advance ( void ); 80 | Pointer( byte ) operator[] ( int idx ); 81 | }; 82 | class MultiStreamIOClient : public StreamingGrid 83 | { 84 | FileHandle hFile; 85 | FixedIOClientStream stream; 86 | public: 87 | MultiStreamIOClient ( const char* fileName , int rs , int r , int bufferMultiplier , bool writeOnly=false ); 88 | MultiStreamIOClient ( int rs , int r , int bufferMultiplier , const char* prefix , bool deleteOnClose ); 89 | MultiStreamIOClient ( int rs , int r , int bufferMultiplier , const char* dir , const char* prefix , bool deleteOnClose); 90 | ~MultiStreamIOClient(void); 91 | void finalize (void); 92 | 93 | int rows ( void ) const; 94 | int rowSize ( void ) const; 95 | void advance ( void ); 96 | void reset ( bool read , int minWindowSize ); 97 | void unset ( void ); 98 | Pointer( byte ) operator[] ( int idx ); 99 | void SetServer ( MultiStreamIOServer* server ); 100 | bool Advance ( void ); 101 | int Service ( void ); 102 | }; 103 | 104 | #endif // MULTI_STREAM_IO -------------------------------------------------------------------------------- /Util/PFMStream.inl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, Michael Kazhdan 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | #ifndef PFM_STREAM_INCLUDED 29 | #define PFM_STREAM_INCLUDED 30 | #include 31 | #include 32 | #include 33 | #include "ChannelConverter.h" 34 | 35 | struct PFMReadInfo 36 | { 37 | FILE* fp; 38 | int width , height; 39 | Pointer( byte ) data; 40 | }; 41 | 42 | inline void PFMGetImageInfo( char* fn , int& width , int& height , int& channels , int& bytesPerChannel ) 43 | { 44 | PFMReadInfo info; 45 | info.fp = fopen( fn , "rb" ); 46 | if( !info.fp ) fprintf( stderr , "Failed to open: %s\n" , fn ) , exit(0); 47 | 48 | char buf[1024]; 49 | fgets( buf , 1024 , info.fp ); 50 | fgets( buf , 1024 , info.fp ); 51 | while (buf[0] == '#') fgets( buf , 1024 , info.fp ); 52 | sscanf(buf, "%d %d" , &info.width , &info.height); 53 | if( info.width<0 || info.height<0 ) 54 | { 55 | fprintf(stderr, "Invalid header or image not valid PFM.\n"); 56 | exit( 0 ); 57 | } 58 | width = info.width; 59 | height = info.height; 60 | channels = 3; 61 | bytesPerChannel = sizeof( float ); 62 | 63 | fclose( info.fp ); 64 | } 65 | template< int Channels , bool HDR > 66 | void* PFMInitWrite( char* fileName , int width , int height , int quality , MultiStreamIOServer* ioServer ) 67 | { 68 | fprintf( stderr , "[ERROR] PFMInitWrite: Function not supported\n" ) , exit( 0 ); 69 | } 70 | inline void PFMFinalizeWrite( void* v ) 71 | { 72 | fprintf( stderr , "[ERROR] PFMFinalizeWrite: Function not supported\n" ) , exit( 0 ); 73 | } 74 | template< int Channels , class ChannelType > 75 | void PFMWriteRow( Pointer( ChannelType ) pixels , void* v , int j ) 76 | { 77 | fprintf( stderr , "[ERROR] PFMWriteRow: Function not supported\n" ) , exit( 0 ); 78 | } 79 | 80 | inline void* PFMInitRead( char* fileName , int& width , int& height , MultiStreamIOServer* ioServer ) 81 | { 82 | PFMReadInfo *info=(PFMReadInfo*)malloc(sizeof(PFMReadInfo)); 83 | info->fp = fopen( fileName , "rb" ); 84 | if( !info->fp ) fprintf( stderr , "Failed to open: %s\n" , fileName ) , exit(0); 85 | 86 | char buf[1024]; 87 | fgets( buf , 1024 , info->fp ); 88 | fgets( buf , 1024 , info->fp ); 89 | while (buf[0] == '#') fgets( buf , 1024 , info->fp ); 90 | sscanf(buf, "%d %d", &info->width, &info->height); 91 | if( info->width<0 || info->height<0 ) 92 | { 93 | fprintf(stderr, "Invalid header or image not valid PFM.\n"); 94 | exit( 0 ); 95 | } 96 | fgets( buf, 1024 , info->fp ); 97 | while ( buf[0] == '#') fgets( buf , 1024 , info->fp ); 98 | 99 | 100 | width = info->width; 101 | height = info->height; 102 | info->data = AllocPointer< byte >( sizeof(float)*3*width ); 103 | 104 | return info; 105 | } 106 | template< int Channels , class ChannelType > 107 | void PFMReadRow( Pointer( ChannelType ) pixels , void* v , int j ) 108 | { 109 | PFMReadInfo* info = ( PFMReadInfo* )v; 110 | if( !fread( info->data , sizeof(float) , info->width * 3 , info->fp ) ) fprintf( stderr , "Failed to read PFM row of size %d\n" , info->width ) , exit( 0 ); 111 | ConvertRow< float , ChannelType >( ( ConstPointer( float ) )info->data , pixels , info->width , 3 , Channels ); 112 | } 113 | 114 | inline void PFMFinalizeRead( void* v ) 115 | { 116 | PFMReadInfo* info = (PFMReadInfo*)v; 117 | fclose( info->fp ); 118 | FreePointer( info->data ); 119 | free( info ); 120 | } 121 | #endif // PFM_STREAM_INCLUDED -------------------------------------------------------------------------------- /Util/PNG/pngasmrd.h: -------------------------------------------------------------------------------- 1 | /* pngasmrd.h - assembler version of utilities to read a PNG file 2 | * 3 | * libpng 1.2.5 - October 3, 2002 4 | * For conditions of distribution and use, see copyright notice in png.h 5 | * Copyright (c) 2002 Glenn Randers-Pehrson 6 | * 7 | */ 8 | 9 | /* This file is obsolete in libpng-1.0.9 and later; its contents now appear 10 | * at the end of pngconf.h. 11 | */ 12 | -------------------------------------------------------------------------------- /Util/PNG/pnggccrd.c: -------------------------------------------------------------------------------- 1 | /* pnggccrd.c was removed from libpng-1.2.20. */ 2 | 3 | /* This code snippet is for use by configure's compilation test. */ 4 | 5 | #if (!defined _MSC_VER) && \ 6 | defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ 7 | defined(PNG_MMX_CODE_SUPPORTED) 8 | 9 | int PNGAPI png_dummy_mmx_support(void); 10 | 11 | static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested 12 | 13 | int PNGAPI 14 | png_dummy_mmx_support(void) __attribute__((noinline)); 15 | 16 | int PNGAPI 17 | png_dummy_mmx_support(void) 18 | { 19 | int result; 20 | #if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck 21 | __asm__ __volatile__ ( 22 | #if defined(__x86_64__) 23 | "pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction 24 | "pushq %%rcx \n\t" // so does rcx... 25 | "pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux) 26 | "pushfq \n\t" // save Eflag to stack 27 | "popq %%rax \n\t" // get Eflag from stack into rax 28 | "movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx 29 | "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) 30 | "pushq %%rax \n\t" // save modified Eflag back to stack 31 | "popfq \n\t" // restore modified value to Eflag reg 32 | "pushfq \n\t" // save Eflag to stack 33 | "popq %%rax \n\t" // get Eflag from stack 34 | "pushq %%rcx \n\t" // save original Eflag to stack 35 | "popfq \n\t" // restore original Eflag 36 | #else 37 | "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction 38 | "pushl %%ecx \n\t" // so does ecx... 39 | "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) 40 | "pushfl \n\t" // save Eflag to stack 41 | "popl %%eax \n\t" // get Eflag from stack into eax 42 | "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx 43 | "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) 44 | "pushl %%eax \n\t" // save modified Eflag back to stack 45 | "popfl \n\t" // restore modified value to Eflag reg 46 | "pushfl \n\t" // save Eflag to stack 47 | "popl %%eax \n\t" // get Eflag from stack 48 | "pushl %%ecx \n\t" // save original Eflag to stack 49 | "popfl \n\t" // restore original Eflag 50 | #endif 51 | "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag 52 | "jz 0f \n\t" // if same, CPUID instr. is not supported 53 | 54 | "xorl %%eax, %%eax \n\t" // set eax to zero 55 | // ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) 56 | "cpuid \n\t" // get the CPU identification info 57 | "cmpl $1, %%eax \n\t" // make sure eax return non-zero value 58 | "jl 0f \n\t" // if eax is zero, MMX is not supported 59 | 60 | "xorl %%eax, %%eax \n\t" // set eax to zero and... 61 | "incl %%eax \n\t" // ...increment eax to 1. This pair is 62 | // faster than the instruction "mov eax, 1" 63 | "cpuid \n\t" // get the CPU identification info again 64 | "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) 65 | "cmpl $0, %%edx \n\t" // 0 = MMX not supported 66 | "jz 0f \n\t" // non-zero = yes, MMX IS supported 67 | 68 | "movl $1, %%eax \n\t" // set return value to 1 69 | "jmp 1f \n\t" // DONE: have MMX support 70 | 71 | "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions 72 | "movl $0, %%eax \n\t" // set return value to 0 73 | "1: \n\t" // .RETURN: target label for jump instructions 74 | #if defined(__x86_64__) 75 | "popq %%rdx \n\t" // restore rdx 76 | "popq %%rcx \n\t" // restore rcx 77 | "popq %%rbx \n\t" // restore rbx 78 | #else 79 | "popl %%edx \n\t" // restore edx 80 | "popl %%ecx \n\t" // restore ecx 81 | "popl %%ebx \n\t" // restore ebx 82 | #endif 83 | 84 | // "ret \n\t" // DONE: no MMX support 85 | // (fall through to standard C "ret") 86 | 87 | : "=a" (result) // output list 88 | 89 | : // any variables used on input (none) 90 | 91 | // no clobber list 92 | // , "%ebx", "%ecx", "%edx" // GRR: we handle these manually 93 | // , "memory" // if write to a variable gcc thought was in a reg 94 | // , "cc" // "condition codes" (flag bits) 95 | ); 96 | _mmx_supported = result; 97 | #else 98 | _mmx_supported = 0; 99 | #endif /* PNG_MMX_CODE_SUPPORTED */ 100 | 101 | return _mmx_supported; 102 | } 103 | #endif 104 | -------------------------------------------------------------------------------- /Util/PNG/pngvcrd.c: -------------------------------------------------------------------------------- 1 | /* pnggvrd.c was removed from libpng-1.2.20. */ 2 | -------------------------------------------------------------------------------- /Util/Socket.inl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008, Michael Kazhdan 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | template 30 | bool ReceiveOnSocket( Socket& s , Pointer( C ) data , size_t dataSize ) 31 | { 32 | unsigned long long rec=0; 33 | while( rec!=dataSize ) 34 | { 35 | int tmp = socket_receive( s , ( ( Pointer( char ) ) data) + rec , dataSize-rec ); 36 | if( tmp<=0 ) 37 | { 38 | IOServer::StderrLock lock; 39 | if( !tmp ) fprintfId( stderr , "Connection Closed...\n" ); 40 | else fprintfId( stderr , "socket_receive from client failed (%d): %s\n" , s , LastSocketError() ); 41 | return false; 42 | } 43 | rec+=tmp; 44 | } 45 | return true; 46 | } 47 | template 48 | bool SendOnSocket( Socket& s , ConstPointer( C ) data , size_t dataSize ) 49 | { 50 | if( socket_send( s , ( ConstPointer( char ) )data , dataSize )<0 ) 51 | { 52 | IOServer::StderrLock lock; 53 | fprintfId( stderr , "socket_send to client failed (%d): %s\n" , s , LastSocketError()); 54 | return false; 55 | } 56 | return true; 57 | } 58 | template 59 | void ReceiveOnSocket( Socket& s , Pointer( C ) data , size_t dataSize , const char* errorMessage , ... ) 60 | { 61 | unsigned long long rec=0; 62 | while( rec!=dataSize ) 63 | { 64 | int tmp = socket_receive( s , ( ( Pointer( char ) ) data) + rec , dataSize-rec ); 65 | if( tmp<=0 ) 66 | { 67 | IOServer::StderrLock lock; 68 | if(!tmp) fprintfId( stderr , "Connection Closed...\n" ); 69 | else fprintfId( stderr , "socket_receive from client failed (%d): %s\n" , s , LastSocketError() ); 70 | { 71 | fprintf( stderr , "\t" ); 72 | va_list args; 73 | va_start( args , errorMessage ); 74 | vfprintf( stderr , errorMessage , args ); 75 | va_end( args ); 76 | fprintf( stderr , "\n" ); 77 | } 78 | exit(0); 79 | } 80 | rec+=tmp; 81 | } 82 | } 83 | template 84 | void SendOnSocket( Socket& s , ConstPointer( C ) data , size_t dataSize , const char* errorMessage , ... ) 85 | { 86 | if( socket_send( s , ( ConstPointer( char ) )data , dataSize )<0 ) 87 | { 88 | IOServer::StderrLock lock; 89 | fprintfId( stderr , "socket_send to client failed (%d): %s\n" , s , LastSocketError()); 90 | { 91 | fprintf( stderr , "\t" ); 92 | va_list args; 93 | va_start( args , errorMessage ); 94 | vfprintf( stderr , errorMessage , args ); 95 | va_end( args ); 96 | fprintf( stderr , "\n" ); 97 | } 98 | exit(0); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Util/TIFF/Makefile.am: -------------------------------------------------------------------------------- 1 | # Tag Image File Format (TIFF) Software 2 | # 3 | # Copyright (C) 2004, Andrey Kiselev 4 | # 5 | # Permission to use, copy, modify, distribute, and sell this software and 6 | # its documentation for any purpose is hereby granted without fee, provided 7 | # that (i) the above copyright notices and this permission notice appear in 8 | # all copies of the software and related documentation, and (ii) the names of 9 | # Sam Leffler and Silicon Graphics may not be used in any advertising or 10 | # publicity relating to the software without the specific, prior written 11 | # permission of Sam Leffler and Silicon Graphics. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 14 | # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 15 | # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 16 | # 17 | # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 18 | # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 19 | # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 20 | # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 21 | # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 22 | # OF THIS SOFTWARE. 23 | 24 | # Process this file with automake to produce Makefile.in. 25 | 26 | LIBPORT = $(top_builddir)/port/libport.la 27 | LIBTIFF = $(top_builddir)/libtiff/libtiff.la 28 | 29 | EXTRA_DIST = Makefile.vc SConstruct tif_config.h.vc tiffconf.h.vc libtiff.def \ 30 | $(EXTRA_SRCS) 31 | 32 | HDRS = \ 33 | tiff.h \ 34 | tiffconf.h \ 35 | tiffio.h \ 36 | tiffvers.h 37 | 38 | if HAVE_CXX 39 | HDRS += tiffio.hxx 40 | endif 41 | 42 | EXTRA_HDRS = \ 43 | t4.h \ 44 | tif_dir.h \ 45 | tif_predict.h \ 46 | tiffiop.h \ 47 | uvcode.h 48 | 49 | SRCS = \ 50 | tif_aux.c \ 51 | tif_close.c \ 52 | tif_codec.c \ 53 | tif_color.c \ 54 | tif_compress.c \ 55 | tif_dir.c \ 56 | tif_dirinfo.c \ 57 | tif_dirread.c \ 58 | tif_dirwrite.c \ 59 | tif_dumpmode.c \ 60 | tif_error.c \ 61 | tif_extension.c \ 62 | tif_fax3.c \ 63 | tif_fax3sm.c \ 64 | tif_flush.c \ 65 | tif_getimage.c \ 66 | tif_jpeg.c \ 67 | tif_luv.c \ 68 | tif_lzw.c \ 69 | tif_next.c \ 70 | tif_ojpeg.c \ 71 | tif_open.c \ 72 | tif_packbits.c \ 73 | tif_pixarlog.c \ 74 | tif_predict.c \ 75 | tif_print.c \ 76 | tif_read.c \ 77 | tif_strip.c \ 78 | tif_swab.c \ 79 | tif_thunder.c \ 80 | tif_tile.c \ 81 | tif_unix.c \ 82 | tif_version.c \ 83 | tif_warning.c \ 84 | tif_write.c \ 85 | tif_zip.c 86 | 87 | SRCSXX = \ 88 | tif_stream.cxx 89 | 90 | EXTRA_SRCS = \ 91 | tif_acorn.c \ 92 | tif_apple.c \ 93 | tif_atari.c \ 94 | tif_msdos.c \ 95 | tif_next.c \ 96 | tif_win3.c \ 97 | tif_win32.c 98 | 99 | libtiffincludedir = $(includedir) 100 | libtiffinclude_HEADERS = $(HDRS) 101 | noinst_HEADERS = $(EXTRA_HDRS) 102 | 103 | lib_LTLIBRARIES = libtiff.la 104 | if HAVE_CXX 105 | lib_LTLIBRARIES += libtiffxx.la 106 | endif 107 | 108 | libtiff_la_SOURCES = $(SRCS) 109 | libtiff_la_LDFLAGS = \ 110 | -no-undefined \ 111 | -version-number $(LIBTIFF_VERSION_INFO) 112 | if HAVE_RPATH 113 | libtiff_la_LDFLAGS += $(LIBDIR) 114 | endif 115 | libtiff_la_LIBADD = $(LIBPORT) 116 | 117 | libtiffxx_la_SOURCES = $(SRCSXX) 118 | libtiffxx_la_LDFLAGS = \ 119 | -no-undefined \ 120 | -version-number $(LIBTIFF_VERSION_INFO) 121 | if HAVE_RPATH 122 | libtiffxx_la_LDFLAGS += $(LIBDIR) 123 | endif 124 | libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) 125 | libtiffxx_la_DEPENDENCIES = libtiff.la 126 | 127 | # 128 | # The finite state machine tables used by the G3/G4 decoders 129 | # are generated by the mkg3states program. On systems without 130 | # make these rules have to be manually carried out. 131 | # 132 | noinst_PROGRAMS = mkg3states 133 | mkg3states_SOURCES = mkg3states.c tif_fax3.h 134 | mkg3states_LDADD = $(LIBPORT) 135 | 136 | faxtable: mkg3states 137 | (rm -f tif_fax3sm.c && ./mkg3states -b -c const tif_fax3sm.c) 138 | 139 | -------------------------------------------------------------------------------- /Util/TIFF/Makefile.vc: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.vc,v 1.1 2014/11/20 04:29:28 uid42424 Exp $ 2 | # 3 | # Copyright (C) 2004, Andrey Kiselev 4 | # 5 | # Permission to use, copy, modify, distribute, and sell this software and 6 | # its documentation for any purpose is hereby granted without fee, provided 7 | # that (i) the above copyright notices and this permission notice appear in 8 | # all copies of the software and related documentation, and (ii) the names of 9 | # Sam Leffler and Silicon Graphics may not be used in any advertising or 10 | # publicity relating to the software without the specific, prior written 11 | # permission of Sam Leffler and Silicon Graphics. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 14 | # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 15 | # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 16 | # 17 | # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 18 | # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 19 | # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 20 | # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 21 | # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 22 | # OF THIS SOFTWARE. 23 | # 24 | # Makefile for MS Visual C and Watcom C compilers. 25 | # 26 | # To build: 27 | # C:\libtiff\libtiff> nmake /f makefile.vc all 28 | # 29 | 30 | !INCLUDE ..\nmake.opt 31 | 32 | INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE) 33 | 34 | !IFDEF USE_WIN_CRT_LIB 35 | OBJ_SYSDEP_MODULE = tif_unix.obj 36 | !ELSE 37 | OBJ_SYSDEP_MODULE = tif_win32.obj 38 | !ENDIF 39 | 40 | OBJ = \ 41 | tif_aux.obj \ 42 | tif_close.obj \ 43 | tif_codec.obj \ 44 | tif_color.obj \ 45 | tif_compress.obj \ 46 | tif_dir.obj \ 47 | tif_dirinfo.obj \ 48 | tif_dirread.obj \ 49 | tif_dirwrite.obj \ 50 | tif_dumpmode.obj \ 51 | tif_error.obj \ 52 | tif_extension.obj \ 53 | tif_fax3.obj \ 54 | tif_fax3sm.obj \ 55 | tif_getimage.obj \ 56 | tif_jpeg.obj \ 57 | tif_ojpeg.obj \ 58 | tif_flush.obj \ 59 | tif_luv.obj \ 60 | tif_lzw.obj \ 61 | tif_next.obj \ 62 | tif_open.obj \ 63 | tif_packbits.obj \ 64 | tif_pixarlog.obj \ 65 | tif_predict.obj \ 66 | tif_print.obj \ 67 | tif_read.obj \ 68 | tif_stream.obj \ 69 | tif_swab.obj \ 70 | tif_strip.obj \ 71 | tif_thunder.obj \ 72 | tif_tile.obj \ 73 | tif_version.obj \ 74 | tif_warning.obj \ 75 | tif_write.obj \ 76 | tif_zip.obj \ 77 | $(OBJ_SYSDEP_MODULE) 78 | 79 | all: libtiff.lib $(DLLNAME) 80 | 81 | tif_config.h: tif_config.h.vc 82 | copy tif_config.h.vc tif_config.h 83 | 84 | tiffconf.h: tiffconf.h.vc 85 | copy tiffconf.h.vc tiffconf.h 86 | 87 | libtiff.lib: tif_config.h tiffconf.h $(OBJ) 88 | $(AR) /out:libtiff.lib $(OBJ) $(LIBS) 89 | 90 | $(DLLNAME): tif_config.h tiffconf.h libtiff.def $(OBJ) 91 | $(LD) /debug /dll /def:libtiff.def /out:$(DLLNAME) \ 92 | /implib:libtiff_i.lib $(OBJ) $(LIBS) 93 | 94 | clean: 95 | -del *.obj 96 | -del *.lib 97 | -del *.dll 98 | -del *.exe 99 | -------------------------------------------------------------------------------- /Util/TIFF/SConstruct: -------------------------------------------------------------------------------- 1 | # $Id: SConstruct,v 1.1 2014/11/20 04:29:28 uid42424 Exp $ 2 | 3 | # Tag Image File Format (TIFF) Software 4 | # 5 | # Copyright (C) 2005, Andrey Kiselev 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 | # This file contains rules to build software with the SCons tool 27 | # (see the http://www.scons.org/ for details on SCons). 28 | 29 | # Import globally defined options 30 | Import([ 'env', 'idir_lib' ]) 31 | 32 | SRCS = [ \ 33 | 'tif_aux.c', \ 34 | 'tif_close.c', \ 35 | 'tif_codec.c', \ 36 | 'tif_color.c', \ 37 | 'tif_compress.c', \ 38 | 'tif_dir.c', \ 39 | 'tif_dirinfo.c', \ 40 | 'tif_dirread.c', \ 41 | 'tif_dirwrite.c', \ 42 | 'tif_dumpmode.c', \ 43 | 'tif_error.c', \ 44 | 'tif_extension.c', \ 45 | 'tif_fax3.c', \ 46 | 'tif_fax3sm.c', \ 47 | 'tif_flush.c', \ 48 | 'tif_getimage.c', \ 49 | 'tif_jpeg.c', \ 50 | 'tif_luv.c', \ 51 | 'tif_lzw.c', \ 52 | 'tif_next.c', \ 53 | 'tif_ojpeg.c', \ 54 | 'tif_open.c', \ 55 | 'tif_packbits.c', \ 56 | 'tif_pixarlog.c', \ 57 | 'tif_predict.c', \ 58 | 'tif_print.c', \ 59 | 'tif_read.c', \ 60 | 'tif_strip.c', \ 61 | 'tif_swab.c', \ 62 | 'tif_thunder.c', \ 63 | 'tif_tile.c', \ 64 | 'tif_unix.c', \ 65 | 'tif_version.c', \ 66 | 'tif_warning.c', \ 67 | 'tif_write.c', \ 68 | 'tif_zip.c' ] 69 | 70 | StaticLibrary('tiff', SRCS) 71 | SharedLibrary('tiff', SRCS) 72 | -------------------------------------------------------------------------------- /Util/TIFF/libtiff.def: -------------------------------------------------------------------------------- 1 | EXPORTS TIFFOpen 2 | TIFFOpenW 3 | TIFFGetVersion 4 | TIFFCleanup 5 | TIFFClose 6 | TIFFFlush 7 | TIFFFlushData 8 | TIFFGetField 9 | TIFFVGetField 10 | TIFFGetFieldDefaulted 11 | TIFFVGetFieldDefaulted 12 | TIFFGetTagListEntry 13 | TIFFGetTagListCount 14 | TIFFReadDirectory 15 | TIFFScanlineSize 16 | TIFFStripSize 17 | TIFFVStripSize 18 | TIFFRawStripSize 19 | TIFFTileRowSize 20 | TIFFTileSize 21 | TIFFVTileSize 22 | TIFFFileno 23 | TIFFSetFileno 24 | TIFFGetMode 25 | TIFFIsTiled 26 | TIFFIsByteSwapped 27 | TIFFIsBigEndian 28 | TIFFIsMSB2LSB 29 | TIFFIsUpSampled 30 | TIFFCIELabToRGBInit 31 | TIFFCIELabToXYZ 32 | TIFFXYZToRGB 33 | TIFFYCbCrToRGBInit 34 | TIFFYCbCrtoRGB 35 | TIFFCurrentRow 36 | TIFFCurrentDirectory 37 | TIFFCurrentStrip 38 | TIFFCurrentTile 39 | TIFFDataWidth 40 | TIFFReadBufferSetup 41 | TIFFWriteBufferSetup 42 | TIFFSetupStrips 43 | TIFFLastDirectory 44 | TIFFSetDirectory 45 | TIFFSetSubDirectory 46 | TIFFUnlinkDirectory 47 | TIFFSetField 48 | TIFFVSetField 49 | TIFFCheckpointDirectory 50 | TIFFWriteDirectory 51 | TIFFRewriteDirectory 52 | TIFFPrintDirectory 53 | TIFFReadScanline 54 | TIFFWriteScanline 55 | TIFFReadRGBAImage 56 | TIFFReadRGBAImageOriented 57 | TIFFFdOpen 58 | TIFFClientOpen 59 | TIFFFileName 60 | TIFFError 61 | TIFFErrorExt 62 | TIFFWarning 63 | TIFFWarningExt 64 | TIFFSetErrorHandler 65 | TIFFSetErrorHandlerExt 66 | TIFFSetWarningHandler 67 | TIFFSetWarningHandlerExt 68 | TIFFComputeTile 69 | TIFFCheckTile 70 | TIFFNumberOfTiles 71 | TIFFReadTile 72 | TIFFWriteTile 73 | TIFFComputeStrip 74 | TIFFNumberOfStrips 75 | TIFFRGBAImageBegin 76 | TIFFRGBAImageGet 77 | TIFFRGBAImageEnd 78 | TIFFReadEncodedStrip 79 | TIFFReadRawStrip 80 | TIFFReadEncodedTile 81 | TIFFReadRawTile 82 | TIFFReadRGBATile 83 | TIFFReadRGBAStrip 84 | TIFFWriteEncodedStrip 85 | TIFFWriteRawStrip 86 | TIFFWriteEncodedTile 87 | TIFFWriteRawTile 88 | TIFFSetWriteOffset 89 | TIFFSwabDouble 90 | TIFFSwabShort 91 | TIFFSwabLong 92 | TIFFSwabArrayOfShort 93 | TIFFSwabArrayOfLong 94 | TIFFSwabArrayOfDouble 95 | TIFFSwabArrayOfTriples 96 | TIFFReverseBits 97 | TIFFGetBitRevTable 98 | TIFFDefaultStripSize 99 | TIFFDefaultTileSize 100 | TIFFRasterScanlineSize 101 | _TIFFmalloc 102 | _TIFFrealloc 103 | _TIFFfree 104 | _TIFFmemset 105 | _TIFFmemcpy 106 | _TIFFmemcmp 107 | TIFFCreateDirectory 108 | TIFFSetTagExtender 109 | TIFFMergeFieldInfo 110 | TIFFFindFieldInfo 111 | TIFFFindFieldInfoByName 112 | TIFFFieldWithName 113 | TIFFFieldWithTag 114 | TIFFCurrentDirOffset 115 | TIFFWriteCheck 116 | TIFFRGBAImageOK 117 | TIFFNumberOfDirectories 118 | TIFFSetFileName 119 | TIFFSetClientdata 120 | TIFFSetMode 121 | TIFFClientdata 122 | TIFFGetReadProc 123 | TIFFGetWriteProc 124 | TIFFGetSeekProc 125 | TIFFGetCloseProc 126 | TIFFGetSizeProc 127 | TIFFGetMapFileProc 128 | TIFFGetUnmapFileProc 129 | TIFFIsCODECConfigured 130 | TIFFGetConfiguredCODECs 131 | TIFFFindCODEC 132 | TIFFRegisterCODEC 133 | TIFFUnRegisterCODEC 134 | TIFFFreeDirectory 135 | TIFFReadCustomDirectory 136 | TIFFReadEXIFDirectory 137 | TIFFAccessTagMethods 138 | TIFFGetClientInfo 139 | TIFFSetClientInfo 140 | TIFFReassignTagToIgnore 141 | -------------------------------------------------------------------------------- /Util/TIFF/tif_close.c: -------------------------------------------------------------------------------- 1 | /* $Id: tif_close.c,v 1.1 2014/11/20 04:29:29 uid42424 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 | /* 28 | * TIFF Library. 29 | */ 30 | #include "tiffiop.h" 31 | 32 | /************************************************************************/ 33 | /* TIFFCleanup() */ 34 | /************************************************************************/ 35 | 36 | /** 37 | * Auxiliary function to free the TIFF structure. Given structure will be 38 | * completetly freed, so you should save opened file handle and pointer 39 | * to the close procedure in external variables before calling 40 | * _TIFFCleanup(), if you will need these ones to close the file. 41 | * 42 | * @param tif A TIFF pointer. 43 | */ 44 | 45 | void 46 | TIFFCleanup(TIFF* tif) 47 | { 48 | if (tif->tif_mode != O_RDONLY) 49 | /* 50 | * Flush buffered data and directory (if dirty). 51 | */ 52 | TIFFFlush(tif); 53 | (*tif->tif_cleanup)(tif); 54 | TIFFFreeDirectory(tif); 55 | 56 | if (tif->tif_dirlist) 57 | _TIFFfree(tif->tif_dirlist); 58 | 59 | /* Clean up client info links */ 60 | while( tif->tif_clientinfo ) 61 | { 62 | TIFFClientInfoLink *link = tif->tif_clientinfo; 63 | 64 | tif->tif_clientinfo = link->next; 65 | _TIFFfree( link->name ); 66 | _TIFFfree( link ); 67 | } 68 | 69 | if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) 70 | _TIFFfree(tif->tif_rawdata); 71 | if (isMapped(tif)) 72 | TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); 73 | 74 | /* Clean up custom fields */ 75 | if (tif->tif_nfields > 0) 76 | { 77 | size_t i; 78 | 79 | for (i = 0; i < tif->tif_nfields; i++) 80 | { 81 | TIFFFieldInfo *fld = tif->tif_fieldinfo[i]; 82 | if (fld->field_bit == FIELD_CUSTOM && 83 | strncmp("Tag ", fld->field_name, 4) == 0) 84 | { 85 | _TIFFfree(fld->field_name); 86 | _TIFFfree(fld); 87 | } 88 | } 89 | 90 | _TIFFfree(tif->tif_fieldinfo); 91 | } 92 | 93 | _TIFFfree(tif); 94 | } 95 | 96 | /************************************************************************/ 97 | /* TIFFClose() */ 98 | /************************************************************************/ 99 | 100 | /** 101 | * Close a previously opened TIFF file. 102 | * 103 | * TIFFClose closes a file that was previously opened with TIFFOpen(). 104 | * Any buffered data are flushed to the file, including the contents of 105 | * the current directory (if modified); and all resources are reclaimed. 106 | * 107 | * @param tif A TIFF pointer. 108 | */ 109 | 110 | void 111 | TIFFClose(TIFF* tif) 112 | { 113 | TIFFCloseProc closeproc = tif->tif_closeproc; 114 | thandle_t fd = tif->tif_clientdata; 115 | 116 | TIFFCleanup(tif); 117 | (void) (*closeproc)(fd); 118 | } 119 | 120 | -------------------------------------------------------------------------------- /Util/TIFF/tif_codec.c: -------------------------------------------------------------------------------- 1 | /* $Id: tif_codec.c,v 1.1 2014/11/20 04:29:29 uid42424 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 | /* 28 | * TIFF Library 29 | * 30 | * Builtin Compression Scheme Configuration Support. 31 | */ 32 | #include "tiffiop.h" 33 | 34 | static int NotConfigured(TIFF*, int); 35 | 36 | #ifndef LZW_SUPPORT 37 | #define TIFFInitLZW NotConfigured 38 | #endif 39 | #ifndef PACKBITS_SUPPORT 40 | #define TIFFInitPackBits NotConfigured 41 | #endif 42 | #ifndef THUNDER_SUPPORT 43 | #define TIFFInitThunderScan NotConfigured 44 | #endif 45 | #ifndef NEXT_SUPPORT 46 | #define TIFFInitNeXT NotConfigured 47 | #endif 48 | #ifndef JPEG_SUPPORT 49 | #define TIFFInitJPEG NotConfigured 50 | #endif 51 | #ifndef OJPEG_SUPPORT 52 | #define TIFFInitOJPEG NotConfigured 53 | #endif 54 | #ifndef CCITT_SUPPORT 55 | #define TIFFInitCCITTRLE NotConfigured 56 | #define TIFFInitCCITTRLEW NotConfigured 57 | #define TIFFInitCCITTFax3 NotConfigured 58 | #define TIFFInitCCITTFax4 NotConfigured 59 | #endif 60 | #ifndef JBIG_SUPPORT 61 | #define TIFFInitJBIG NotConfigured 62 | #endif 63 | #ifndef ZIP_SUPPORT 64 | #define TIFFInitZIP NotConfigured 65 | #endif 66 | #ifndef PIXARLOG_SUPPORT 67 | #define TIFFInitPixarLog NotConfigured 68 | #endif 69 | #ifndef LOGLUV_SUPPORT 70 | #define TIFFInitSGILog NotConfigured 71 | #endif 72 | 73 | /* 74 | * Compression schemes statically built into the library. 75 | */ 76 | #ifdef VMS 77 | const TIFFCodec _TIFFBuiltinCODECS[] = { 78 | #else 79 | TIFFCodec _TIFFBuiltinCODECS[] = { 80 | #endif 81 | { "None", COMPRESSION_NONE, TIFFInitDumpMode }, 82 | { "LZW", COMPRESSION_LZW, TIFFInitLZW }, 83 | { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, 84 | { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, 85 | { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, 86 | { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, 87 | { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, 88 | { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, 89 | { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, 90 | { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, 91 | { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, 92 | { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, 93 | { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, 94 | { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, 95 | { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, 96 | { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, 97 | { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, 98 | { NULL, 0, NULL } 99 | }; 100 | 101 | static int 102 | _notConfigured(TIFF* tif) 103 | { 104 | const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); 105 | 106 | TIFFErrorExt(tif->tif_clientdata, tif->tif_name, 107 | "%s compression support is not configured", c->name); 108 | return (0); 109 | } 110 | 111 | static int 112 | NotConfigured(TIFF* tif, int scheme) 113 | { 114 | (void) scheme; 115 | 116 | tif->tif_decodestatus = FALSE; 117 | tif->tif_setupdecode = _notConfigured; 118 | tif->tif_encodestatus = FALSE; 119 | tif->tif_setupencode = _notConfigured; 120 | return (1); 121 | } 122 | 123 | /************************************************************************/ 124 | /* TIFFIsCODECConfigured() */ 125 | /************************************************************************/ 126 | 127 | /** 128 | * Check whether we have working codec for the specific coding scheme. 129 | * 130 | * @return returns 1 if the codec is configured and working. Otherwise 131 | * 0 will be returned. 132 | */ 133 | 134 | int 135 | TIFFIsCODECConfigured(uint16 scheme) 136 | { 137 | const TIFFCodec* codec = TIFFFindCODEC(scheme); 138 | 139 | if(codec == NULL) { 140 | return 0; 141 | } 142 | if(codec->init == NULL) { 143 | return 0; 144 | } 145 | if(codec->init != NotConfigured){ 146 | return 1; 147 | } 148 | return 0; 149 | } 150 | 151 | -------------------------------------------------------------------------------- /Util/TIFF/tif_config.h: -------------------------------------------------------------------------------- 1 | /* Define to 1 if you have the header file. */ 2 | #define HAVE_ASSERT_H 1 3 | 4 | /* Define to 1 if you have the header file. */ 5 | #define HAVE_FCNTL_H 1 6 | 7 | /* Define as 0 or 1 according to the floating point format suported by the 8 | machine */ 9 | #define HAVE_IEEEFP 1 10 | 11 | /* Define to 1 if you have the header file. */ 12 | #define HAVE_STRING_H 1 13 | 14 | /* Define to 1 if you have the header file. */ 15 | #define HAVE_SYS_TYPES_H 1 16 | 17 | /* Define to 1 if you have the header file. */ 18 | #define HAVE_IO_H 1 19 | 20 | /* Define to 1 if you have the header file. */ 21 | #define HAVE_SEARCH_H 1 22 | 23 | /* The size of a `int', as computed by sizeof. */ 24 | #define SIZEOF_INT 4 25 | 26 | /* The size of a `long', as computed by sizeof. */ 27 | #define SIZEOF_LONG 4 28 | 29 | /* Set the native cpu bit order */ 30 | #define HOST_FILLORDER FILLORDER_LSB2MSB 31 | 32 | /* Define to 1 if your processor stores words with the most significant byte 33 | first (like Motorola and SPARC, unlike Intel and VAX). */ 34 | /* #undef WORDS_BIGENDIAN */ 35 | 36 | /* Define to `__inline__' or `__inline' if that's what the C compiler 37 | calls it, or to nothing if 'inline' is not supported under any name. */ 38 | #ifndef __cplusplus 39 | # ifndef inline 40 | # define inline __inline 41 | # endif 42 | #endif 43 | 44 | #define lfind _lfind 45 | -------------------------------------------------------------------------------- /Util/TIFF/tif_dumpmode.c: -------------------------------------------------------------------------------- 1 | /* $Header: /cvs/Code.XPlatform/Util/TIFF/tif_dumpmode.c,v 1.1 2014/11/20 04:29:29 uid42424 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 | /* 28 | * TIFF Library. 29 | * 30 | * "Null" Compression Algorithm Support. 31 | */ 32 | #include "tiffiop.h" 33 | 34 | /* 35 | * Encode a hunk of pixels. 36 | */ 37 | static int 38 | DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) 39 | { 40 | (void) s; 41 | while (cc > 0) { 42 | tsize_t n; 43 | 44 | n = cc; 45 | if (tif->tif_rawcc + n > tif->tif_rawdatasize) 46 | n = tif->tif_rawdatasize - tif->tif_rawcc; 47 | 48 | assert( n > 0 ); 49 | 50 | /* 51 | * Avoid copy if client has setup raw 52 | * data buffer to avoid extra copy. 53 | */ 54 | if (tif->tif_rawcp != pp) 55 | _TIFFmemcpy(tif->tif_rawcp, pp, n); 56 | tif->tif_rawcp += n; 57 | tif->tif_rawcc += n; 58 | pp += n; 59 | cc -= n; 60 | if (tif->tif_rawcc >= tif->tif_rawdatasize && 61 | !TIFFFlushData1(tif)) 62 | return (-1); 63 | } 64 | return (1); 65 | } 66 | 67 | /* 68 | * Decode a hunk of pixels. 69 | */ 70 | static int 71 | DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) 72 | { 73 | (void) s; 74 | if (tif->tif_rawcc < cc) { 75 | TIFFErrorExt(tif->tif_clientdata, tif->tif_name, 76 | "DumpModeDecode: Not enough data for scanline %d", 77 | tif->tif_row); 78 | return (0); 79 | } 80 | /* 81 | * Avoid copy if client has setup raw 82 | * data buffer to avoid extra copy. 83 | */ 84 | if (tif->tif_rawcp != buf) 85 | _TIFFmemcpy(buf, tif->tif_rawcp, cc); 86 | tif->tif_rawcp += cc; 87 | tif->tif_rawcc -= cc; 88 | return (1); 89 | } 90 | 91 | /* 92 | * Seek forwards nrows in the current strip. 93 | */ 94 | static int 95 | DumpModeSeek(TIFF* tif, uint32 nrows) 96 | { 97 | tif->tif_rawcp += nrows * tif->tif_scanlinesize; 98 | tif->tif_rawcc -= nrows * tif->tif_scanlinesize; 99 | return (1); 100 | } 101 | 102 | /* 103 | * Initialize dump mode. 104 | */ 105 | int 106 | TIFFInitDumpMode(TIFF* tif, int scheme) 107 | { 108 | (void) scheme; 109 | tif->tif_decoderow = DumpModeDecode; 110 | tif->tif_decodestrip = DumpModeDecode; 111 | tif->tif_decodetile = DumpModeDecode; 112 | tif->tif_encoderow = DumpModeEncode; 113 | tif->tif_encodestrip = DumpModeEncode; 114 | tif->tif_encodetile = DumpModeEncode; 115 | tif->tif_seek = DumpModeSeek; 116 | return (1); 117 | } 118 | -------------------------------------------------------------------------------- /Util/TIFF/tif_error.c: -------------------------------------------------------------------------------- 1 | /* $Header: /cvs/Code.XPlatform/Util/TIFF/tif_error.c,v 1.1 2014/11/20 04:29:29 uid42424 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 | /* 28 | * TIFF Library. 29 | */ 30 | #include "tiffiop.h" 31 | 32 | TIFFErrorHandlerExt _TIFFerrorHandlerExt = NULL; 33 | 34 | TIFFErrorHandler 35 | TIFFSetErrorHandler(TIFFErrorHandler handler) 36 | { 37 | TIFFErrorHandler prev = _TIFFerrorHandler; 38 | _TIFFerrorHandler = handler; 39 | return (prev); 40 | } 41 | 42 | TIFFErrorHandlerExt 43 | TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler) 44 | { 45 | TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt; 46 | _TIFFerrorHandlerExt = handler; 47 | return (prev); 48 | } 49 | 50 | void 51 | TIFFError(const char* module, const char* fmt, ...) 52 | { 53 | va_list ap; 54 | va_start(ap, fmt); 55 | if (_TIFFerrorHandler) 56 | (*_TIFFerrorHandler)(module, fmt, ap); 57 | if (_TIFFerrorHandlerExt) 58 | (*_TIFFerrorHandlerExt)(0, module, fmt, ap); 59 | va_end(ap); 60 | } 61 | 62 | void 63 | TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...) 64 | { 65 | va_list ap; 66 | va_start(ap, fmt); 67 | if (_TIFFerrorHandler) 68 | (*_TIFFerrorHandler)(module, fmt, ap); 69 | if (_TIFFerrorHandlerExt) 70 | (*_TIFFerrorHandlerExt)(fd, module, fmt, ap); 71 | va_end(ap); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /Util/TIFF/tif_extension.c: -------------------------------------------------------------------------------- 1 | /* $Header: /cvs/Code.XPlatform/Util/TIFF/tif_extension.c,v 1.1 2014/11/20 04:29:29 uid42424 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 | /* 28 | * TIFF Library. 29 | * 30 | * Various routines support external extension of the tag set, and other 31 | * application extension capabilities. 32 | */ 33 | 34 | #include "tiffiop.h" 35 | 36 | int TIFFGetTagListCount( TIFF *tif ) 37 | 38 | { 39 | TIFFDirectory* td = &tif->tif_dir; 40 | 41 | return td->td_customValueCount; 42 | } 43 | 44 | ttag_t TIFFGetTagListEntry( TIFF *tif, int tag_index ) 45 | 46 | { 47 | TIFFDirectory* td = &tif->tif_dir; 48 | 49 | if( tag_index < 0 || tag_index >= td->td_customValueCount ) 50 | return (ttag_t) -1; 51 | else 52 | return td->td_customValues[tag_index].info->field_tag; 53 | } 54 | 55 | /* 56 | ** This provides read/write access to the TIFFTagMethods within the TIFF 57 | ** structure to application code without giving access to the private 58 | ** TIFF structure. 59 | */ 60 | TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif ) 61 | 62 | { 63 | return &(tif->tif_tagmethods); 64 | } 65 | 66 | void *TIFFGetClientInfo( TIFF *tif, const char *name ) 67 | 68 | { 69 | TIFFClientInfoLink *link = tif->tif_clientinfo; 70 | 71 | while( link != NULL && strcmp(link->name,name) != 0 ) 72 | link = link->next; 73 | 74 | if( link != NULL ) 75 | return link->data; 76 | else 77 | return NULL; 78 | } 79 | 80 | void TIFFSetClientInfo( TIFF *tif, void *data, const char *name ) 81 | 82 | { 83 | TIFFClientInfoLink *link = tif->tif_clientinfo; 84 | 85 | /* 86 | ** Do we have an existing link with this name? If so, just 87 | ** set it. 88 | */ 89 | while( link != NULL && strcmp(link->name,name) != 0 ) 90 | link = link->next; 91 | 92 | if( link != NULL ) 93 | { 94 | link->data = data; 95 | return; 96 | } 97 | 98 | /* 99 | ** Create a new link. 100 | */ 101 | 102 | link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink)); 103 | assert (link != NULL); 104 | link->next = tif->tif_clientinfo; 105 | link->name = (char *) _TIFFmalloc(strlen(name)+1); 106 | assert (link->name != NULL); 107 | strcpy(link->name, name); 108 | link->data = data; 109 | 110 | tif->tif_clientinfo = link; 111 | } 112 | -------------------------------------------------------------------------------- /Util/TIFF/tif_flush.c: -------------------------------------------------------------------------------- 1 | /* $Header: /cvs/Code.XPlatform/Util/TIFF/tif_flush.c,v 1.1 2014/11/20 04:29:29 uid42424 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 | /* 28 | * TIFF Library. 29 | */ 30 | #include "tiffiop.h" 31 | 32 | int 33 | TIFFFlush(TIFF* tif) 34 | { 35 | 36 | if (tif->tif_mode != O_RDONLY) { 37 | if (!TIFFFlushData(tif)) 38 | return (0); 39 | if ((tif->tif_flags & TIFF_DIRTYDIRECT) && 40 | !TIFFWriteDirectory(tif)) 41 | return (0); 42 | } 43 | return (1); 44 | } 45 | 46 | /* 47 | * Flush buffered data to the file. 48 | * 49 | * Frank Warmerdam'2000: I modified this to return 1 if TIFF_BEENWRITING 50 | * is not set, so that TIFFFlush() will proceed to write out the directory. 51 | * The documentation says returning 1 is an error indicator, but not having 52 | * been writing isn't exactly a an error. Hopefully this doesn't cause 53 | * problems for other people. 54 | */ 55 | int 56 | TIFFFlushData(TIFF* tif) 57 | { 58 | if ((tif->tif_flags & TIFF_BEENWRITING) == 0) 59 | return (0); 60 | if (tif->tif_flags & TIFF_POSTENCODE) { 61 | tif->tif_flags &= ~TIFF_POSTENCODE; 62 | if (!(*tif->tif_postencode)(tif)) 63 | return (0); 64 | } 65 | return (TIFFFlushData1(tif)); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /Util/TIFF/tif_next.c: -------------------------------------------------------------------------------- 1 | /* $Id: tif_next.c,v 1.1 2014/11/20 04:29:30 uid42424 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); 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, tidata_t buf, tsize_t occ, tsample_t s) 50 | { 51 | register unsigned char *bp, *op; 52 | register tsize_t cc; 53 | register int n; 54 | tidata_t row; 55 | tsize_t scanline; 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 = 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 | for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) { 70 | n = *bp++, cc--; 71 | switch (n) { 72 | case LITERALROW: 73 | /* 74 | * The entire scanline is given as literal values. 75 | */ 76 | if (cc < scanline) 77 | goto bad; 78 | _TIFFmemcpy(row, bp, scanline); 79 | bp += scanline; 80 | cc -= scanline; 81 | break; 82 | case LITERALSPAN: { 83 | int off; 84 | /* 85 | * The scanline has a literal span 86 | * that begins at some offset. 87 | */ 88 | off = (bp[0] * 256) + bp[1]; 89 | n = (bp[2] * 256) + bp[3]; 90 | if (cc < 4+n || off+n > scanline) 91 | goto bad; 92 | _TIFFmemcpy(row+off, bp+4, n); 93 | bp += 4+n; 94 | cc -= 4+n; 95 | break; 96 | } 97 | default: { 98 | register int npixels = 0, grey; 99 | unsigned long imagewidth = tif->tif_dir.td_imagewidth; 100 | 101 | /* 102 | * The scanline is composed of a sequence 103 | * of constant color ``runs''. We shift 104 | * into ``run mode'' and interpret bytes 105 | * as codes of the form 106 | * until we've filled the scanline. 107 | */ 108 | op = row; 109 | for (;;) { 110 | grey = (n>>6) & 0x3; 111 | n &= 0x3f; 112 | while (n-- > 0) 113 | SETPIXEL(op, grey); 114 | if (npixels >= (int) imagewidth) 115 | break; 116 | if (cc == 0) 117 | goto bad; 118 | n = *bp++, cc--; 119 | } 120 | break; 121 | } 122 | } 123 | } 124 | tif->tif_rawcp = (tidata_t) bp; 125 | tif->tif_rawcc = cc; 126 | return (1); 127 | bad: 128 | TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", 129 | (long) tif->tif_row); 130 | return (0); 131 | } 132 | 133 | int 134 | TIFFInitNeXT(TIFF* tif, int scheme) 135 | { 136 | (void) scheme; 137 | tif->tif_decoderow = NeXTDecode; 138 | tif->tif_decodestrip = NeXTDecode; 139 | tif->tif_decodetile = NeXTDecode; 140 | return (1); 141 | } 142 | #endif /* NEXT_SUPPORT */ 143 | 144 | /* vim: set ts=8 sts=8 sw=8 noet: */ 145 | -------------------------------------------------------------------------------- /Util/TIFF/tif_predict.h: -------------------------------------------------------------------------------- 1 | /* $Id: tif_predict.h,v 1.1 2014/11/20 04:29:30 uid42424 Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1995-1997 Sam Leffler 5 | * Copyright (c) 1995-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 | #ifndef _TIFFPREDICT_ 28 | #define _TIFFPREDICT_ 29 | /* 30 | * ``Library-private'' Support for the Predictor Tag 31 | */ 32 | 33 | /* 34 | * Codecs that want to support the Predictor tag must place 35 | * this structure first in their private state block so that 36 | * the predictor code can cast tif_data to find its state. 37 | */ 38 | typedef struct { 39 | int predictor; /* predictor tag value */ 40 | int stride; /* sample stride over data */ 41 | tsize_t rowsize; /* tile/strip row size */ 42 | 43 | TIFFPostMethod pfunc; /* horizontal differencer/accumulator */ 44 | TIFFCodeMethod coderow; /* parent codec encode/decode row */ 45 | TIFFCodeMethod codestrip; /* parent codec encode/decode strip */ 46 | TIFFCodeMethod codetile; /* parent codec encode/decode tile */ 47 | TIFFVGetMethod vgetparent; /* super-class method */ 48 | TIFFVSetMethod vsetparent; /* super-class method */ 49 | TIFFPrintMethod printdir; /* super-class method */ 50 | TIFFBoolMethod setupdecode; /* super-class method */ 51 | TIFFBoolMethod setupencode; /* super-class method */ 52 | } TIFFPredictorState; 53 | 54 | #if defined(__cplusplus) 55 | extern "C" { 56 | #endif 57 | extern int TIFFPredictorInit(TIFF*); 58 | extern int TIFFPredictorCleanup(TIFF*); 59 | #if defined(__cplusplus) 60 | } 61 | #endif 62 | #endif /* _TIFFPREDICT_ */ 63 | 64 | /* vim: set ts=8 sts=8 sw=8 noet: */ 65 | -------------------------------------------------------------------------------- /Util/TIFF/tif_thunder.c: -------------------------------------------------------------------------------- 1 | /* $Id: tif_thunder.c,v 1.1 2014/11/20 04:29:30 uid42424 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 THUNDER_SUPPORT 29 | /* 30 | * TIFF Library. 31 | * 32 | * ThunderScan 4-bit Compression Algorithm Support 33 | */ 34 | 35 | /* 36 | * ThunderScan uses an encoding scheme designed for 37 | * 4-bit pixel values. Data is encoded in bytes, with 38 | * each byte split into a 2-bit code word and a 6-bit 39 | * data value. The encoding gives raw data, runs of 40 | * pixels, or pixel values encoded as a delta from the 41 | * previous pixel value. For the latter, either 2-bit 42 | * or 3-bit delta values are used, with the deltas packed 43 | * into a single byte. 44 | */ 45 | #define THUNDER_DATA 0x3f /* mask for 6-bit data */ 46 | #define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ 47 | /* code values */ 48 | #define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ 49 | #define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ 50 | #define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ 51 | #define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ 52 | #define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ 53 | #define THUNDER_RAW 0xc0 /* raw data encoded */ 54 | 55 | static const int twobitdeltas[4] = { 0, 1, 0, -1 }; 56 | static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; 57 | 58 | #define SETPIXEL(op, v) { \ 59 | lastpixel = (v) & 0xf; \ 60 | if (npixels++ & 1) \ 61 | *op++ |= lastpixel; \ 62 | else \ 63 | op[0] = (tidataval_t) (lastpixel << 4); \ 64 | } 65 | 66 | static int 67 | ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) 68 | { 69 | register unsigned char *bp; 70 | register tsize_t cc; 71 | unsigned int lastpixel; 72 | tsize_t npixels; 73 | 74 | bp = (unsigned char *)tif->tif_rawcp; 75 | cc = tif->tif_rawcc; 76 | lastpixel = 0; 77 | npixels = 0; 78 | while (cc > 0 && npixels < maxpixels) { 79 | int n, delta; 80 | 81 | n = *bp++, cc--; 82 | switch (n & THUNDER_CODE) { 83 | case THUNDER_RUN: /* pixel run */ 84 | /* 85 | * Replicate the last pixel n times, 86 | * where n is the lower-order 6 bits. 87 | */ 88 | if (npixels & 1) { 89 | op[0] |= lastpixel; 90 | lastpixel = *op++; npixels++; n--; 91 | } else 92 | lastpixel |= lastpixel << 4; 93 | npixels += n; 94 | if (npixels < maxpixels) { 95 | for (; n > 0; n -= 2) 96 | *op++ = (tidataval_t) lastpixel; 97 | } 98 | if (n == -1) 99 | *--op &= 0xf0; 100 | lastpixel &= 0xf; 101 | break; 102 | case THUNDER_2BITDELTAS: /* 2-bit deltas */ 103 | if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) 104 | SETPIXEL(op, lastpixel + twobitdeltas[delta]); 105 | if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) 106 | SETPIXEL(op, lastpixel + twobitdeltas[delta]); 107 | if ((delta = (n & 3)) != DELTA2_SKIP) 108 | SETPIXEL(op, lastpixel + twobitdeltas[delta]); 109 | break; 110 | case THUNDER_3BITDELTAS: /* 3-bit deltas */ 111 | if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) 112 | SETPIXEL(op, lastpixel + threebitdeltas[delta]); 113 | if ((delta = (n & 7)) != DELTA3_SKIP) 114 | SETPIXEL(op, lastpixel + threebitdeltas[delta]); 115 | break; 116 | case THUNDER_RAW: /* raw data */ 117 | SETPIXEL(op, n); 118 | break; 119 | } 120 | } 121 | tif->tif_rawcp = (tidata_t) bp; 122 | tif->tif_rawcc = cc; 123 | if (npixels != maxpixels) { 124 | TIFFErrorExt(tif->tif_clientdata, tif->tif_name, 125 | "ThunderDecode: %s data at scanline %ld (%lu != %lu)", 126 | npixels < maxpixels ? "Not enough" : "Too much", 127 | (long) tif->tif_row, (long) npixels, (long) maxpixels); 128 | return (0); 129 | } 130 | return (1); 131 | } 132 | 133 | static int 134 | ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) 135 | { 136 | tidata_t row = buf; 137 | 138 | (void) s; 139 | while ((long)occ > 0) { 140 | if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) 141 | return (0); 142 | occ -= tif->tif_scanlinesize; 143 | row += tif->tif_scanlinesize; 144 | } 145 | return (1); 146 | } 147 | 148 | int 149 | TIFFInitThunderScan(TIFF* tif, int scheme) 150 | { 151 | (void) scheme; 152 | tif->tif_decoderow = ThunderDecodeRow; 153 | tif->tif_decodestrip = ThunderDecodeRow; 154 | return (1); 155 | } 156 | #endif /* THUNDER_SUPPORT */ 157 | 158 | /* vim: set ts=8 sts=8 sw=8 noet: */ 159 | -------------------------------------------------------------------------------- /Util/TIFF/tif_version.c: -------------------------------------------------------------------------------- 1 | /* $Header: /cvs/Code.XPlatform/Util/TIFF/tif_version.c,v 1.1 2014/11/20 04:29:30 uid42424 Exp $ */ 2 | /* 3 | * Copyright (c) 1992-1997 Sam Leffler 4 | * Copyright (c) 1992-1997 Silicon Graphics, Inc. 5 | * 6 | * Permission to use, copy, modify, distribute, and sell this software and 7 | * its documentation for any purpose is hereby granted without fee, provided 8 | * that (i) the above copyright notices and this permission notice appear in 9 | * all copies of the software and related documentation, and (ii) the names of 10 | * Sam Leffler and Silicon Graphics may not be used in any advertising or 11 | * publicity relating to the software without the specific, prior written 12 | * permission of Sam Leffler and Silicon Graphics. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 16 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 17 | * 18 | * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 19 | * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 20 | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21 | * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 22 | * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 23 | * OF THIS SOFTWARE. 24 | */ 25 | #include "tiffiop.h" 26 | 27 | static const char TIFFVersion[] = TIFFLIB_VERSION_STR; 28 | 29 | const char* 30 | TIFFGetVersion(void) 31 | { 32 | return (TIFFVersion); 33 | } 34 | -------------------------------------------------------------------------------- /Util/TIFF/tif_warning.c: -------------------------------------------------------------------------------- 1 | /* $Header: /cvs/Code.XPlatform/Util/TIFF/tif_warning.c,v 1.1 2014/11/20 04:29:30 uid42424 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 | /* 28 | * TIFF Library. 29 | */ 30 | #include "tiffiop.h" 31 | 32 | TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL; 33 | 34 | TIFFErrorHandler 35 | TIFFSetWarningHandler(TIFFErrorHandler handler) 36 | { 37 | TIFFErrorHandler prev = _TIFFwarningHandler; 38 | _TIFFwarningHandler = handler; 39 | return (prev); 40 | } 41 | 42 | TIFFErrorHandlerExt 43 | TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler) 44 | { 45 | TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt; 46 | _TIFFwarningHandlerExt = handler; 47 | return (prev); 48 | } 49 | 50 | void 51 | TIFFWarning(const char* module, const char* fmt, ...) 52 | { 53 | va_list ap; 54 | va_start(ap, fmt); 55 | if (_TIFFwarningHandler) 56 | (*_TIFFwarningHandler)(module, fmt, ap); 57 | if (_TIFFwarningHandlerExt) 58 | (*_TIFFwarningHandlerExt)(0, module, fmt, ap); 59 | va_end(ap); 60 | } 61 | 62 | void 63 | TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...) 64 | { 65 | va_list ap; 66 | va_start(ap, fmt); 67 | if (_TIFFwarningHandler) 68 | (*_TIFFwarningHandler)(module, fmt, ap); 69 | if (_TIFFwarningHandlerExt) 70 | (*_TIFFwarningHandlerExt)(fd, module, fmt, ap); 71 | va_end(ap); 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /Util/TIFF/tiffconf.h: -------------------------------------------------------------------------------- 1 | /* libtiff/tiffconf.h. Generated by configure. */ 2 | /* 3 | Configuration defines for installed libtiff. 4 | This file maintained for backward compatibility. Do not use definitions 5 | from this file in your programs. 6 | */ 7 | 8 | #ifndef _TIFFCONF_ 9 | #define _TIFFCONF_ 10 | 11 | /* Define to 1 if the system has the type `int16'. */ 12 | /* #undef HAVE_INT16 */ 13 | 14 | /* Define to 1 if the system has the type `int32'. */ 15 | /* #undef HAVE_INT32 */ 16 | 17 | /* Define to 1 if the system has the type `int8'. */ 18 | /* #undef HAVE_INT8 */ 19 | 20 | /* The size of a `int', as computed by sizeof. */ 21 | #define SIZEOF_INT 4 22 | 23 | /* The size of a `long', as computed by sizeof. */ 24 | #define SIZEOF_LONG 4 25 | 26 | /* Compatibility stuff. */ 27 | 28 | /* Define as 0 or 1 according to the floating point format suported by the 29 | machine */ 30 | #define HAVE_IEEEFP 1 31 | 32 | /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ 33 | #define HOST_FILLORDER FILLORDER_LSB2MSB 34 | 35 | /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian 36 | (Intel) */ 37 | #define HOST_BIGENDIAN 0 38 | 39 | /* Support CCITT Group 3 & 4 algorithms */ 40 | #define CCITT_SUPPORT 1 41 | 42 | /* Support JPEG compression (requires IJG JPEG library) */ 43 | //#define JPEG_SUPPORT 1 44 | #undef JPEG_SUPPORT 45 | 46 | /* Support LogLuv high dynamic range encoding */ 47 | #define LOGLUV_SUPPORT 1 48 | 49 | /* Support LZW algorithm */ 50 | #define LZW_SUPPORT 1 51 | 52 | /* Support NeXT 2-bit RLE algorithm */ 53 | #define NEXT_SUPPORT 1 54 | 55 | /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation 56 | fails with unpatched IJG JPEG library) */ 57 | /* #undef OJPEG_SUPPORT */ 58 | 59 | /* Support Macintosh PackBits algorithm */ 60 | #define PACKBITS_SUPPORT 1 61 | 62 | /* Support Pixar log-format algorithm (requires Zlib) */ 63 | #define PIXARLOG_SUPPORT 1 64 | 65 | /* Support ThunderScan 4-bit RLE algorithm */ 66 | #define THUNDER_SUPPORT 1 67 | 68 | /* Support Deflate compression */ 69 | #define ZIP_SUPPORT 1 70 | 71 | /* Support strip chopping (whether or not to convert single-strip uncompressed 72 | images to mutiple strips of ~8Kb to reduce memory usage) */ 73 | #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP 74 | 75 | /* Enable SubIFD tag (330) support */ 76 | #define SUBIFD_SUPPORT 1 77 | 78 | /* Treat extra sample as alpha (default enabled). The RGBA interface will 79 | treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many 80 | packages produce RGBA files but don't mark the alpha properly. */ 81 | #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 82 | 83 | /* Pick up YCbCr subsampling info from the JPEG data stream to support files 84 | lacking the tag (default enabled). */ 85 | #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 86 | 87 | /* Support MS MDI magic number files as TIFF */ 88 | #define MDI_SUPPORT 1 89 | 90 | /* 91 | * Feature support definitions. 92 | * XXX: These macros are obsoleted. Don't use them in your apps! 93 | * Macros stays here for backward compatibility and should be always defined. 94 | */ 95 | #define COLORIMETRY_SUPPORT 96 | #define YCBCR_SUPPORT 97 | #define CMYK_SUPPORT 98 | #define ICC_SUPPORT 99 | #define PHOTOSHOP_SUPPORT 100 | #define IPTC_SUPPORT 101 | 102 | #endif /* _TIFFCONF_ */ 103 | -------------------------------------------------------------------------------- /Util/TIFF/tiffconf.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | Configuration defines for installed libtiff. 3 | This file maintained for backward compatibility. Do not use definitions 4 | from this file in your programs. 5 | */ 6 | 7 | #ifndef _TIFFCONF_ 8 | #define _TIFFCONF_ 9 | 10 | /* Define to 1 if the system has the type `int16'. */ 11 | #undef HAVE_INT16 12 | 13 | /* Define to 1 if the system has the type `int32'. */ 14 | #undef HAVE_INT32 15 | 16 | /* Define to 1 if the system has the type `int8'. */ 17 | #undef HAVE_INT8 18 | 19 | /* The size of a `int', as computed by sizeof. */ 20 | #undef SIZEOF_INT 21 | 22 | /* The size of a `long', as computed by sizeof. */ 23 | #undef SIZEOF_LONG 24 | 25 | /* Compatibility stuff. */ 26 | 27 | /* Define as 0 or 1 according to the floating point format suported by the 28 | machine */ 29 | #undef HAVE_IEEEFP 30 | 31 | /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ 32 | #undef HOST_FILLORDER 33 | 34 | /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian 35 | (Intel) */ 36 | #undef HOST_BIGENDIAN 37 | 38 | /* Support CCITT Group 3 & 4 algorithms */ 39 | #undef CCITT_SUPPORT 40 | 41 | /* Support JPEG compression (requires IJG JPEG library) */ 42 | #undef JPEG_SUPPORT 43 | 44 | /* Support LogLuv high dynamic range encoding */ 45 | #undef LOGLUV_SUPPORT 46 | 47 | /* Support LZW algorithm */ 48 | #undef LZW_SUPPORT 49 | 50 | /* Support NeXT 2-bit RLE algorithm */ 51 | #undef NEXT_SUPPORT 52 | 53 | /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation 54 | fails with unpatched IJG JPEG library) */ 55 | #undef OJPEG_SUPPORT 56 | 57 | /* Support Macintosh PackBits algorithm */ 58 | #undef PACKBITS_SUPPORT 59 | 60 | /* Support Pixar log-format algorithm (requires Zlib) */ 61 | #undef PIXARLOG_SUPPORT 62 | 63 | /* Support ThunderScan 4-bit RLE algorithm */ 64 | #undef THUNDER_SUPPORT 65 | 66 | /* Support Deflate compression */ 67 | #undef ZIP_SUPPORT 68 | 69 | /* Support strip chopping (whether or not to convert single-strip uncompressed 70 | images to mutiple strips of ~8Kb to reduce memory usage) */ 71 | #undef STRIPCHOP_DEFAULT 72 | 73 | /* Enable SubIFD tag (330) support */ 74 | #undef SUBIFD_SUPPORT 75 | 76 | /* Treat extra sample as alpha (default enabled). The RGBA interface will 77 | treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many 78 | packages produce RGBA files but don't mark the alpha properly. */ 79 | #undef DEFAULT_EXTRASAMPLE_AS_ALPHA 80 | 81 | /* Pick up YCbCr subsampling info from the JPEG data stream to support files 82 | lacking the tag (default enabled). */ 83 | #undef CHECK_JPEG_YCBCR_SUBSAMPLING 84 | 85 | /* Support MS MDI magic number files as TIFF */ 86 | #undef MDI_SUPPORT 87 | 88 | /* 89 | * Feature support definitions. 90 | * XXX: These macros are obsoleted. Don't use them in your apps! 91 | * Macros stays here for backward compatibility and should be always defined. 92 | */ 93 | #define COLORIMETRY_SUPPORT 94 | #define YCBCR_SUPPORT 95 | #define CMYK_SUPPORT 96 | #define ICC_SUPPORT 97 | #define PHOTOSHOP_SUPPORT 98 | #define IPTC_SUPPORT 99 | 100 | #endif /* _TIFFCONF_ */ 101 | -------------------------------------------------------------------------------- /Util/TIFF/tiffconf.h.vc: -------------------------------------------------------------------------------- 1 | /* 2 | Configuration defines for installed libtiff. 3 | This file maintained for backward compatibility. Do not use definitions 4 | from this file in your programs. 5 | */ 6 | 7 | #ifndef _TIFFCONF_ 8 | #define _TIFFCONF_ 9 | 10 | /* Define to 1 if the system has the type `int16'. */ 11 | /* #undef HAVE_INT16 */ 12 | 13 | /* Define to 1 if the system has the type `int32'. */ 14 | /* #undef HAVE_INT32 */ 15 | 16 | /* Define to 1 if the system has the type `int8'. */ 17 | /* #undef HAVE_INT8 */ 18 | 19 | /* The size of a `int', as computed by sizeof. */ 20 | #define SIZEOF_INT 4 21 | 22 | /* The size of a `long', as computed by sizeof. */ 23 | #define SIZEOF_LONG 4 24 | 25 | /* Compatibility stuff. */ 26 | 27 | /* Define as 0 or 1 according to the floating point format suported by the 28 | machine */ 29 | #define HAVE_IEEEFP 1 30 | 31 | /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ 32 | #define HOST_FILLORDER FILLORDER_LSB2MSB 33 | 34 | /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian 35 | (Intel) */ 36 | #define HOST_BIGENDIAN 0 37 | 38 | /* Support CCITT Group 3 & 4 algorithms */ 39 | #define CCITT_SUPPORT 1 40 | 41 | /* Support JPEG compression (requires IJG JPEG library) */ 42 | /* #undef JPEG_SUPPORT */ 43 | 44 | /* Support LogLuv high dynamic range encoding */ 45 | #define LOGLUV_SUPPORT 1 46 | 47 | /* Support LZW algorithm */ 48 | #define LZW_SUPPORT 1 49 | 50 | /* Support NeXT 2-bit RLE algorithm */ 51 | #define NEXT_SUPPORT 1 52 | 53 | /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation 54 | fails with unpatched IJG JPEG library) */ 55 | /* #undef OJPEG_SUPPORT */ 56 | 57 | /* Support Macintosh PackBits algorithm */ 58 | #define PACKBITS_SUPPORT 1 59 | 60 | /* Support Pixar log-format algorithm (requires Zlib) */ 61 | /* #undef PIXARLOG_SUPPORT */ 62 | 63 | /* Support ThunderScan 4-bit RLE algorithm */ 64 | #define THUNDER_SUPPORT 1 65 | 66 | /* Support Deflate compression */ 67 | /* #undef ZIP_SUPPORT */ 68 | 69 | /* Support strip chopping (whether or not to convert single-strip uncompressed 70 | images to mutiple strips of ~8Kb to reduce memory usage) */ 71 | #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP 72 | 73 | /* Enable SubIFD tag (330) support */ 74 | #define SUBIFD_SUPPORT 1 75 | 76 | /* Treat extra sample as alpha (default enabled). The RGBA interface will 77 | treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many 78 | packages produce RGBA files but don't mark the alpha properly. */ 79 | #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 80 | 81 | /* Pick up YCbCr subsampling info from the JPEG data stream to support files 82 | lacking the tag (default enabled). */ 83 | #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 84 | 85 | /* 86 | * Feature support definitions. 87 | * XXX: These macros are obsoleted. Don't use them in your apps! 88 | * Macros stays here for backward compatibility and should be always defined. 89 | */ 90 | #define COLORIMETRY_SUPPORT 91 | #define YCBCR_SUPPORT 92 | #define CMYK_SUPPORT 93 | #define ICC_SUPPORT 94 | #define PHOTOSHOP_SUPPORT 95 | #define IPTC_SUPPORT 96 | 97 | #endif /* _TIFFCONF_ */ 98 | -------------------------------------------------------------------------------- /Util/TIFF/tiffio.hxx: -------------------------------------------------------------------------------- 1 | /* $Id: tiffio.hxx,v 1.1 2014/11/20 04:29:30 uid42424 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 | #ifndef _TIFFIO_HXX_ 28 | #define _TIFFIO_HXX_ 29 | 30 | /* 31 | * TIFF I/O library definitions which provide C++ streams API. 32 | */ 33 | 34 | #include 35 | #include "tiff.h" 36 | 37 | extern TIFF* TIFFStreamOpen(const char*, std::ostream *); 38 | extern TIFF* TIFFStreamOpen(const char*, std::istream *); 39 | 40 | #endif /* _TIFFIO_HXX_ */ 41 | 42 | /* vim: set ts=8 sts=8 sw=8 noet: */ 43 | -------------------------------------------------------------------------------- /Util/TIFF/tiffvers.h: -------------------------------------------------------------------------------- 1 | #define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.8.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." 2 | /* 3 | * This define can be used in code that requires 4 | * compilation-related definitions specific to a 5 | * version or versions of the library. Runtime 6 | * version checking should be done based on the 7 | * string returned by TIFFGetVersion. 8 | */ 9 | #define TIFFLIB_VERSION 20060323 10 | -------------------------------------------------------------------------------- /Util/Time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #ifndef WIN32 33 | #include 34 | #else 35 | #include 36 | #include 37 | #include 38 | #endif // WIN32 39 | 40 | double Time(void){ 41 | #ifdef WIN32 42 | static bool first=true; 43 | static __int64 lfreq; 44 | 45 | if (first) { 46 | first=false; 47 | LARGE_INTEGER l; 48 | QueryPerformanceFrequency(&l); 49 | lfreq=l.QuadPart; 50 | } 51 | 52 | LARGE_INTEGER l; 53 | QueryPerformanceCounter(&l); 54 | return double(l.QuadPart)/double(lfreq); 55 | #else // WIN32 56 | struct timeval t; 57 | gettimeofday(&t,NULL); 58 | return t.tv_sec+(double)t.tv_usec/1000000; 59 | #endif // WIN32 60 | } 61 | #ifdef WIN32 62 | void PrintError(DWORD err) 63 | { 64 | char error[1024]; 65 | int sz=FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,(LPTSTR)error, 1024, NULL); 66 | if(sz>0) 67 | { 68 | fprintf(stderr,"\t"); 69 | for(int i=0;i 2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hpp;hxx;hm;xsd 7 | 8 | 9 | {1b0f544b-dffb-40a9-bd51-fb8fbcf38055} 10 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 11 | 12 | 13 | {d6af4486-9fe9-4d70-bb21-6eb0406b4d66} 14 | inl;inc; 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | Header Files 59 | 60 | 61 | 62 | 63 | Inline Files 64 | 65 | 66 | Inline Files 67 | 68 | 69 | Inline Files 70 | 71 | 72 | Inline Files 73 | 74 | 75 | Inline Files 76 | 77 | 78 | Inline Files 79 | 80 | 81 | Inline Files 82 | 83 | 84 | Inline Files 85 | 86 | 87 | Inline Files 88 | 89 | 90 | Inline Files 91 | 92 | 93 | Inline Files 94 | 95 | 96 | Inline Files 97 | 98 | 99 | Inline Files 100 | 101 | 102 | Inline Files 103 | 104 | 105 | 106 | 107 | Source Files 108 | 109 | 110 | Source Files 111 | 112 | 113 | Source Files 114 | 115 | 116 | Source Files 117 | 118 | 119 | Source Files 120 | 121 | 122 | Source Files 123 | 124 | 125 | Source Files 126 | 127 | 128 | Source Files 129 | 130 | 131 | -------------------------------------------------------------------------------- /Util/Util.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Util/XPlatform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010, Michael Kazhdan 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list of 9 | conditions and the following disclaimer. Redistributions in binary form must reproduce 10 | the above copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the distribution. 12 | 13 | Neither the name of the Johns Hopkins University nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without specific 15 | prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 20 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 22 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 26 | DAMAGE. 27 | */ 28 | #include 29 | #include 30 | #include "XPlatform.h" 31 | 32 | int IOServer::_count = 0; 33 | CriticalSectionLock IOServer::_stdoutLock , IOServer::_stderrLock , IOServer::_systemLock; 34 | 35 | #if DEBUG_MUTEX 36 | IOServer::StdoutLock::StdoutLock ( void ){ EnterCriticalSection( &_stdoutLock , 100 , "StdoutLock::StdoutLock" ); } 37 | #else // !DEBUG_MUTEX 38 | IOServer::StdoutLock::StdoutLock ( void ){ EnterCriticalSection( &_stdoutLock ); } 39 | #endif // DEBUG_MUTEX 40 | IOServer::StdoutLock::~StdoutLock( void ){ LeaveCriticalSection( &_stdoutLock ); } 41 | #if DEBUG_MUTEX 42 | IOServer::StderrLock::StderrLock ( void ){ EnterCriticalSection( &_stderrLock , 100 , "StderrLock::StderrLock" ); } 43 | #else // !DEBUG_MUTEX 44 | IOServer::StderrLock::StderrLock ( void ){ EnterCriticalSection( &_stderrLock ); } 45 | #endif // DEBUG_MUTEX 46 | IOServer::StderrLock::~StderrLock( void ){ LeaveCriticalSection( &_stderrLock ); } 47 | #if DEBUG_MUTEX 48 | IOServer::SystemLock::SystemLock ( void ){ EnterCriticalSection( &_systemLock , 100 , "SystemLock::SystemLock" ); } 49 | #else // !DEBUG_MUTEX 50 | IOServer::SystemLock::SystemLock ( void ){ EnterCriticalSection( &_systemLock ); } 51 | #endif // DEBUG_MUTEX 52 | IOServer::SystemLock::~SystemLock( void ){ LeaveCriticalSection( &_systemLock ); } 53 | 54 | boost::asio::io_service IOServer::io_service; 55 | void IOServer::Load( void ) 56 | { 57 | if( !_count ) 58 | { 59 | InitializeCriticalSection( &_stdoutLock ); 60 | InitializeCriticalSection( &_stderrLock ); 61 | InitializeCriticalSection( &_systemLock ); 62 | } 63 | _count++; 64 | } 65 | void IOServer::UnLoad( void ) 66 | { 67 | _count--; 68 | if( !_count ) 69 | { 70 | DeleteCriticalSection( &_stdoutLock ); 71 | DeleteCriticalSection( &_stderrLock ); 72 | DeleteCriticalSection( &_systemLock ); 73 | } 74 | } 75 | 76 | void IOServer::fprintfID( FILE* fp , const char* format , ... ) 77 | { 78 | StdoutLock lock; 79 | va_list args; 80 | va_start( args , format ); 81 | char id[512] ; SetThisThreadID( id ); 82 | fprintf( fp , "%s] " , id ); 83 | vfprintf( fp , format , args ); 84 | va_end( args ); 85 | fflush( fp ); 86 | } 87 | 88 | void IOServer::printfID( const char* format , ... ) 89 | { 90 | StdoutLock lock; 91 | va_list args; 92 | va_start( args , format ); 93 | char id[512] ; SetThisThreadID( id ); 94 | printf( "%s] " , id ); 95 | vprintf( format , args ); 96 | va_end( args ); 97 | fflush( stdout ); 98 | } 99 | 100 | 101 | void PrintHostAddresses( FILE* fp ) 102 | { 103 | boost::asio::ip::tcp::resolver resolver( io_service ); 104 | boost::asio::ip::tcp::resolver::query query( boost::asio::ip::host_name() , std::string( "" ) , boost::asio::ip::resolver_query_base::numeric_service ); 105 | boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve( query ) , end; 106 | for( int count=0 ; iterator!=end ; ) 107 | { 108 | if( (*iterator).endpoint().address().is_v4() ) fprintf( fp , "%d] %s\n" , count++ , (*iterator).endpoint().address().to_string().c_str() ); 109 | // else fprintf( fp , "%d]* %s\n" , count++ , (*iterator).endpoint().address().to_string().c_str() ); 110 | iterator++; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Util/ZLIB/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id: adler32.c,v 1.1 2014/11/20 04:29:31 uid42424 Exp $ */ 7 | 8 | #include "zlib.h" 9 | 10 | #define BASE 65521L /* largest prime smaller than 65536 */ 11 | #define NMAX 5552 12 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 13 | 14 | #define DO1(buf,i) {s1 += buf[i]; s2 += s1;} 15 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 16 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 17 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 18 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 19 | 20 | /* ========================================================================= */ 21 | uLong ZEXPORT adler32(adler, buf, len) 22 | uLong adler; 23 | const Bytef *buf; 24 | uInt len; 25 | { 26 | unsigned long s1 = adler & 0xffff; 27 | unsigned long s2 = (adler >> 16) & 0xffff; 28 | int k; 29 | 30 | if (buf == Z_NULL) return 1L; 31 | 32 | while (len > 0) { 33 | k = len < NMAX ? len : NMAX; 34 | len -= k; 35 | while (k >= 16) { 36 | DO16(buf); 37 | buf += 16; 38 | k -= 16; 39 | } 40 | if (k != 0) do { 41 | s1 += *buf++; 42 | s2 += s1; 43 | } while (--k); 44 | s1 %= BASE; 45 | s2 %= BASE; 46 | } 47 | return (s2 << 16) | s1; 48 | } 49 | -------------------------------------------------------------------------------- /Util/ZLIB/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2002 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id: compress.c,v 1.1 2014/11/20 04:29:31 uid42424 Exp $ */ 7 | 8 | #include "zlib.h" 9 | 10 | /* =========================================================================== 11 | Compresses the source buffer into the destination buffer. The level 12 | parameter has the same meaning as in deflateInit. sourceLen is the byte 13 | length of the source buffer. Upon entry, destLen is the total size of the 14 | destination buffer, which must be at least 0.1% larger than sourceLen plus 15 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 16 | 17 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 18 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 19 | Z_STREAM_ERROR if the level parameter is invalid. 20 | */ 21 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 22 | Bytef *dest; 23 | uLongf *destLen; 24 | const Bytef *source; 25 | uLong sourceLen; 26 | int level; 27 | { 28 | z_stream stream; 29 | int err; 30 | 31 | stream.next_in = (Bytef*)source; 32 | stream.avail_in = (uInt)sourceLen; 33 | #ifdef MAXSEG_64K 34 | /* Check for source > 64K on 16-bit machine: */ 35 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 36 | #endif 37 | stream.next_out = dest; 38 | stream.avail_out = (uInt)*destLen; 39 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 40 | 41 | stream.zalloc = (alloc_func)0; 42 | stream.zfree = (free_func)0; 43 | stream.opaque = (voidpf)0; 44 | 45 | err = deflateInit(&stream, level); 46 | if (err != Z_OK) return err; 47 | 48 | err = deflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | deflateEnd(&stream); 51 | return err == Z_OK ? Z_BUF_ERROR : err; 52 | } 53 | *destLen = stream.total_out; 54 | 55 | err = deflateEnd(&stream); 56 | return err; 57 | } 58 | 59 | /* =========================================================================== 60 | */ 61 | int ZEXPORT compress (dest, destLen, source, sourceLen) 62 | Bytef *dest; 63 | uLongf *destLen; 64 | const Bytef *source; 65 | uLong sourceLen; 66 | { 67 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 68 | } 69 | -------------------------------------------------------------------------------- /Util/ZLIB/infblock.h: -------------------------------------------------------------------------------- 1 | /* infblock.h -- header to use infblock.c 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | struct inflate_blocks_state; 12 | typedef struct inflate_blocks_state FAR inflate_blocks_statef; 13 | 14 | extern inflate_blocks_statef * inflate_blocks_new OF(( 15 | z_streamp z, 16 | check_func c, /* check function */ 17 | uInt w)); /* window size */ 18 | 19 | extern int inflate_blocks OF(( 20 | inflate_blocks_statef *, 21 | z_streamp , 22 | int)); /* initial return code */ 23 | 24 | extern void inflate_blocks_reset OF(( 25 | inflate_blocks_statef *, 26 | z_streamp , 27 | uLongf *)); /* check value on output */ 28 | 29 | extern int inflate_blocks_free OF(( 30 | inflate_blocks_statef *, 31 | z_streamp)); 32 | 33 | extern void inflate_set_dictionary OF(( 34 | inflate_blocks_statef *s, 35 | const Bytef *d, /* dictionary */ 36 | uInt n)); /* dictionary length */ 37 | 38 | extern int inflate_blocks_sync_point OF(( 39 | inflate_blocks_statef *s)); 40 | -------------------------------------------------------------------------------- /Util/ZLIB/infcodes.h: -------------------------------------------------------------------------------- 1 | /* infcodes.h -- header to use infcodes.c 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | struct inflate_codes_state; 12 | typedef struct inflate_codes_state FAR inflate_codes_statef; 13 | 14 | extern inflate_codes_statef *inflate_codes_new OF(( 15 | uInt, uInt, 16 | inflate_huft *, inflate_huft *, 17 | z_streamp )); 18 | 19 | extern int inflate_codes OF(( 20 | inflate_blocks_statef *, 21 | z_streamp , 22 | int)); 23 | 24 | extern void inflate_codes_free OF(( 25 | inflate_codes_statef *, 26 | z_streamp )); 27 | 28 | -------------------------------------------------------------------------------- /Util/ZLIB/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | extern int inflate_fast OF(( 12 | uInt, 13 | uInt, 14 | inflate_huft *, 15 | inflate_huft *, 16 | inflate_blocks_statef *, 17 | z_streamp )); 18 | -------------------------------------------------------------------------------- /Util/ZLIB/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Huffman code lookup table entry--this entry is four bytes for machines 12 | that have 16-bit pointers (e.g. PC's in the small or medium model). */ 13 | 14 | typedef struct inflate_huft_s FAR inflate_huft; 15 | 16 | struct inflate_huft_s { 17 | union { 18 | struct { 19 | Byte Exop; /* number of extra bits or operation */ 20 | Byte Bits; /* number of bits in this code or subcode */ 21 | } what; 22 | uInt pad; /* pad structure to a power of 2 (4 bytes for */ 23 | } word; /* 16-bit, 8 bytes for 32-bit int's) */ 24 | uInt base; /* literal, length base, distance base, 25 | or table offset */ 26 | }; 27 | 28 | /* Maximum size of dynamic tree. The maximum found in a long but non- 29 | exhaustive search was 1004 huft structures (850 for length/literals 30 | and 154 for distances, the latter actually the result of an 31 | exhaustive search). The actual maximum is not known, but the 32 | value below is more than safe. */ 33 | #define MANY 1440 34 | 35 | extern int inflate_trees_bits OF(( 36 | uIntf *, /* 19 code lengths */ 37 | uIntf *, /* bits tree desired/actual depth */ 38 | inflate_huft * FAR *, /* bits tree result */ 39 | inflate_huft *, /* space for trees */ 40 | z_streamp)); /* for messages */ 41 | 42 | extern int inflate_trees_dynamic OF(( 43 | uInt, /* number of literal/length codes */ 44 | uInt, /* number of distance codes */ 45 | uIntf *, /* that many (total) code lengths */ 46 | uIntf *, /* literal desired/actual bit depth */ 47 | uIntf *, /* distance desired/actual bit depth */ 48 | inflate_huft * FAR *, /* literal/length tree result */ 49 | inflate_huft * FAR *, /* distance tree result */ 50 | inflate_huft *, /* space for trees */ 51 | z_streamp)); /* for messages */ 52 | 53 | extern int inflate_trees_fixed OF(( 54 | uIntf *, /* literal desired/actual bit depth */ 55 | uIntf *, /* distance desired/actual bit depth */ 56 | inflate_huft * FAR *, /* literal/length tree result */ 57 | inflate_huft * FAR *, /* distance tree result */ 58 | z_streamp)); /* for memory allocation */ 59 | -------------------------------------------------------------------------------- /Util/ZLIB/infutil.c: -------------------------------------------------------------------------------- 1 | /* inflate_util.c -- data and routines common to blocks and codes 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "zutil.h" 7 | #include "infblock.h" 8 | #include "inftrees.h" 9 | #include "infcodes.h" 10 | #include "infutil.h" 11 | 12 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ 13 | 14 | /* And'ing with mask[n] masks the lower n bits */ 15 | uInt inflate_mask[17] = { 16 | 0x0000, 17 | 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 18 | 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff 19 | }; 20 | 21 | 22 | /* copy as much as possible from the sliding window to the output area */ 23 | int inflate_flush(s, z, r) 24 | inflate_blocks_statef *s; 25 | z_streamp z; 26 | int r; 27 | { 28 | uInt n; 29 | Bytef *p; 30 | Bytef *q; 31 | 32 | /* local copies of source and destination pointers */ 33 | p = z->next_out; 34 | q = s->read; 35 | 36 | /* compute number of bytes to copy as far as end of window */ 37 | n = (uInt)((q <= s->write ? s->write : s->end) - q); 38 | if (n > z->avail_out) n = z->avail_out; 39 | if (n && r == Z_BUF_ERROR) r = Z_OK; 40 | 41 | /* update counters */ 42 | z->avail_out -= n; 43 | z->total_out += n; 44 | 45 | /* update check information */ 46 | if (s->checkfn != Z_NULL) 47 | z->adler = s->check = (*s->checkfn)(s->check, q, n); 48 | 49 | /* copy as far as end of window */ 50 | zmemcpy(p, q, n); 51 | p += n; 52 | q += n; 53 | 54 | /* see if more to copy at beginning of window */ 55 | if (q == s->end) 56 | { 57 | /* wrap pointers */ 58 | q = s->window; 59 | if (s->write == s->end) 60 | s->write = s->window; 61 | 62 | /* compute bytes to copy */ 63 | n = (uInt)(s->write - q); 64 | if (n > z->avail_out) n = z->avail_out; 65 | if (n && r == Z_BUF_ERROR) r = Z_OK; 66 | 67 | /* update counters */ 68 | z->avail_out -= n; 69 | z->total_out += n; 70 | 71 | /* update check information */ 72 | if (s->checkfn != Z_NULL) 73 | z->adler = s->check = (*s->checkfn)(s->check, q, n); 74 | 75 | /* copy */ 76 | zmemcpy(p, q, n); 77 | p += n; 78 | q += n; 79 | } 80 | 81 | /* update pointers */ 82 | z->next_out = p; 83 | s->read = q; 84 | 85 | /* done */ 86 | return r; 87 | } 88 | -------------------------------------------------------------------------------- /Util/ZLIB/infutil.h: -------------------------------------------------------------------------------- 1 | /* infutil.h -- types and macros common to blocks and codes 2 | * Copyright (C) 1995-2002 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | #ifndef _INFUTIL_H 12 | #define _INFUTIL_H 13 | 14 | typedef enum { 15 | TYPE, /* get type bits (3, including end bit) */ 16 | LENS, /* get lengths for stored */ 17 | STORED, /* processing stored block */ 18 | TABLE, /* get table lengths */ 19 | BTREE, /* get bit lengths tree for a dynamic block */ 20 | DTREE, /* get length, distance trees for a dynamic block */ 21 | CODES, /* processing fixed or dynamic block */ 22 | DRY, /* output remaining window bytes */ 23 | DONE, /* finished last block, done */ 24 | BAD} /* got a data error--stuck here */ 25 | inflate_block_mode; 26 | 27 | /* inflate blocks semi-private state */ 28 | struct inflate_blocks_state { 29 | 30 | /* mode */ 31 | inflate_block_mode mode; /* current inflate_block mode */ 32 | 33 | /* mode dependent information */ 34 | union { 35 | uInt left; /* if STORED, bytes left to copy */ 36 | struct { 37 | uInt table; /* table lengths (14 bits) */ 38 | uInt index; /* index into blens (or border) */ 39 | uIntf *blens; /* bit lengths of codes */ 40 | uInt bb; /* bit length tree depth */ 41 | inflate_huft *tb; /* bit length decoding tree */ 42 | } trees; /* if DTREE, decoding info for trees */ 43 | struct { 44 | inflate_codes_statef 45 | *codes; 46 | } decode; /* if CODES, current state */ 47 | } sub; /* submode */ 48 | uInt last; /* true if this block is the last block */ 49 | 50 | /* mode independent information */ 51 | uInt bitk; /* bits in bit buffer */ 52 | uLong bitb; /* bit buffer */ 53 | inflate_huft *hufts; /* single malloc for tree space */ 54 | Bytef *window; /* sliding window */ 55 | Bytef *end; /* one byte after sliding window */ 56 | Bytef *read; /* window read pointer */ 57 | Bytef *write; /* window write pointer */ 58 | check_func checkfn; /* check function */ 59 | uLong check; /* check on output */ 60 | 61 | }; 62 | 63 | 64 | /* defines for inflate input/output */ 65 | /* update pointers and return */ 66 | #define UPDBITS {s->bitb=b;s->bitk=k;} 67 | #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} 68 | #define UPDOUT {s->write=q;} 69 | #define UPDATE {UPDBITS UPDIN UPDOUT} 70 | #define LEAVE {UPDATE return inflate_flush(s,z,r);} 71 | /* get bytes and bits */ 72 | #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} 73 | #define NEEDBYTE {if(n)r=Z_OK;else LEAVE} 74 | #define NEXTBYTE (n--,*p++) 75 | #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} 77 | /* output bytes */ 78 | #define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) 79 | #define LOADOUT {q=s->write;m=(uInt)WAVAIL;} 80 | #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} 81 | #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} 82 | #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} 83 | #define OUTBYTE(a) {*q++=(Byte)(a);m--;} 84 | /* load local pointers */ 85 | #define LOAD {LOADIN LOADOUT} 86 | 87 | /* masks for lower bits (size given to avoid silly warnings with Visual C++) */ 88 | extern uInt inflate_mask[17]; 89 | 90 | /* copy as much as possible from the sliding window to the output area */ 91 | extern int inflate_flush OF(( 92 | inflate_blocks_statef *, 93 | z_streamp , 94 | int)); 95 | 96 | struct internal_state {int dummy;}; /* for buggy compilers */ 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /Util/ZLIB/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2002 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id: uncompr.c,v 1.1 2014/11/20 04:29:31 uid42424 Exp $ */ 7 | 8 | #include "zlib.h" 9 | 10 | /* =========================================================================== 11 | Decompresses the source buffer into the destination buffer. sourceLen is 12 | the byte length of the source buffer. Upon entry, destLen is the total 13 | size of the destination buffer, which must be large enough to hold the 14 | entire uncompressed data. (The size of the uncompressed data must have 15 | been saved previously by the compressor and transmitted to the decompressor 16 | by some mechanism outside the scope of this compression library.) 17 | Upon exit, destLen is the actual size of the compressed buffer. 18 | This function can be used to decompress a whole file at once if the 19 | input file is mmap'ed. 20 | 21 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 22 | enough memory, Z_BUF_ERROR if there was not enough room in the output 23 | buffer, or Z_DATA_ERROR if the input data was corrupted. 24 | */ 25 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 26 | Bytef *dest; 27 | uLongf *destLen; 28 | const Bytef *source; 29 | uLong sourceLen; 30 | { 31 | z_stream stream; 32 | int err; 33 | 34 | stream.next_in = (Bytef*)source; 35 | stream.avail_in = (uInt)sourceLen; 36 | /* Check for source > 64K on 16-bit machine: */ 37 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 38 | 39 | stream.next_out = dest; 40 | stream.avail_out = (uInt)*destLen; 41 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 42 | 43 | stream.zalloc = (alloc_func)0; 44 | stream.zfree = (free_func)0; 45 | 46 | err = inflateInit(&stream); 47 | if (err != Z_OK) return err; 48 | 49 | err = inflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | inflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = inflateEnd(&stream); 57 | return err; 58 | } 59 | -------------------------------------------------------------------------------- /ZLIB/Make_vms.com: -------------------------------------------------------------------------------- 1 | $! make libz under VMS 2 | $! written by Martin P.J. Zinser 3 | $! 4 | $! Look for the compiler used 5 | $! 6 | $ ccopt = "" 7 | $ if f$getsyi("HW_MODEL").ge.1024 8 | $ then 9 | $ ccopt = "/prefix=all"+ccopt 10 | $ comp = "__decc__=1" 11 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: 12 | $ else 13 | $ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" 14 | $ then 15 | $ comp = "__vaxc__=1" 16 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: 17 | $ else 18 | $ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: 19 | $ ccopt = "/decc/prefix=all"+ccopt 20 | $ comp = "__decc__=1" 21 | $ endif 22 | $ endif 23 | $! 24 | $! Build the thing plain or with mms 25 | $! 26 | $ write sys$output "Compiling Zlib sources ..." 27 | $ if f$search("SYS$SYSTEM:MMS.EXE").eqs."" 28 | $ then 29 | $ dele example.obj;*,minigzip.obj;* 30 | $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - 31 | adler32.c zlib.h zconf.h 32 | $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - 33 | compress.c zlib.h zconf.h 34 | $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - 35 | crc32.c zlib.h zconf.h 36 | $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - 37 | deflate.c deflate.h zutil.h zlib.h zconf.h 38 | $ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" - 39 | gzio.c zutil.h zlib.h zconf.h 40 | $ CALL MAKE infblock.OBJ "CC ''CCOPT' infblock" - 41 | infblock.c zutil.h zlib.h zconf.h infblock.h 42 | $ CALL MAKE infcodes.OBJ "CC ''CCOPT' infcodes" - 43 | infcodes.c zutil.h zlib.h zconf.h inftrees.h 44 | $ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - 45 | inffast.c zutil.h zlib.h zconf.h inffast.h 46 | $ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - 47 | inflate.c zutil.h zlib.h zconf.h infblock.h 48 | $ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - 49 | inftrees.c zutil.h zlib.h zconf.h inftrees.h 50 | $ CALL MAKE infutil.OBJ "CC ''CCOPT' infutil" - 51 | infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h 52 | $ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - 53 | trees.c deflate.h zutil.h zlib.h zconf.h 54 | $ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - 55 | uncompr.c zlib.h zconf.h 56 | $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - 57 | zutil.c zutil.h zlib.h zconf.h 58 | $ write sys$output "Building Zlib ..." 59 | $ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ 60 | $ write sys$output "Building example..." 61 | $ CALL MAKE example.OBJ "CC ''CCOPT' example" - 62 | example.c zlib.h zconf.h 63 | $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb 64 | $ write sys$output "Building minigzip..." 65 | $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - 66 | minigzip.c zlib.h zconf.h 67 | $ call make minigzip.exe - 68 | "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - 69 | minigzip.obj libz.olb 70 | $ else 71 | $ mms/macro=('comp') 72 | $ endif 73 | $ write sys$output "Zlib build completed" 74 | $ exit 75 | $! 76 | $! 77 | $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES 78 | $ V = 'F$Verify(0) 79 | $! P1 = What we are trying to make 80 | $! P2 = Command to make it 81 | $! P3 - P8 What it depends on 82 | $ 83 | $ If F$Search(P1) .Eqs. "" Then Goto Makeit 84 | $ Time = F$CvTime(F$File(P1,"RDT")) 85 | $arg=3 86 | $Loop: 87 | $ Argument = P'arg 88 | $ If Argument .Eqs. "" Then Goto Exit 89 | $ El=0 90 | $Loop2: 91 | $ File = F$Element(El," ",Argument) 92 | $ If File .Eqs. " " Then Goto Endl 93 | $ AFile = "" 94 | $Loop3: 95 | $ OFile = AFile 96 | $ AFile = F$Search(File) 97 | $ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl 98 | $ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit 99 | $ Goto Loop3 100 | $NextEL: 101 | $ El = El + 1 102 | $ Goto Loop2 103 | $EndL: 104 | $ arg=arg+1 105 | $ If arg .Le. 8 Then Goto Loop 106 | $ Goto Exit 107 | $ 108 | $Makeit: 109 | $ VV=F$VERIFY(0) 110 | $ write sys$output P2 111 | $ 'P2 112 | $ VV='F$Verify(VV) 113 | $Exit: 114 | $ If V Then Set Verify 115 | $ENDSUBROUTINE 116 | -------------------------------------------------------------------------------- /ZLIB/ZLIB.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | Source Files 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Source Files 52 | 53 | 54 | Source Files 55 | 56 | 57 | 58 | 59 | Header Files 60 | 61 | 62 | Header Files 63 | 64 | 65 | Header Files 66 | 67 | 68 | Header Files 69 | 70 | 71 | Header Files 72 | 73 | 74 | Header Files 75 | 76 | 77 | Header Files 78 | 79 | 80 | Header Files 81 | 82 | 83 | Header Files 84 | 85 | 86 | Header Files 87 | 88 | 89 | Header Files 90 | 91 | 92 | -------------------------------------------------------------------------------- /ZLIB/ZLIB.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /iGrid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | iGrid 4 | 5 | 6 |

The image-grid file format (iGrid)

7 | 8 |
9 | To support the input/output of large files, we have introduced an image-grid file format. A file with the .iGrid file extension will be assumed to consist of CxR images layed out in a regular grid. The individual images can be any file format, and the only restrictions are that all images in the same row must have the same height, and all images in the same column must have the same width. 10 |

11 | The syntax for the file is as follows. 12 |

13 | Columns: C
14 | Rows: R
15 | <image in column 1, row 1>
16 | <image in column 2, row 1>
17 | ...
18 | <image in column C-1, row 1>
19 | <image in column 1, row 2>
20 | ...
21 | <image in column C, row R>
22 |
23 |
24 | Back to Code 25 | 26 | 27 | -------------------------------------------------------------------------------- /system.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkazhdan/DMG/60dc4e1fe4d078ddaec694c388af57b7cdb748ff/system.jpg --------------------------------------------------------------------------------