Merge branch 'release2.4.3' into 2.4

This commit is contained in:
Andrey Kamaev 2012-10-17 02:12:20 +04:00
commit 69020da607
1231 changed files with 286533 additions and 22773 deletions

3
.gitignore vendored
View File

@ -3,3 +3,6 @@
refman.rst
OpenCV4Tegra/
*.user
.sw[a-z]
.*.swp
tags

Binary file not shown.

Binary file not shown.

123
3rdparty/ilmimf/README vendored
View File

@ -1,123 +0,0 @@
ABOUT THE OPENEXR LIBRARIES
----------------------------
Half is a class that encapsulates our 16-bit floating-point format.
IlmThread is a thread abstraction library for use with IlmImf. It
currently supports pthreads and Windows threads.
IlmImf is our "EXR" file format for storing 16-bit FP images.
Imath is a math library. IlmImf only uses a subset of it,
but we're releasing the full library because it's easier for us to
maintain, and we think it'll be useful to others.
Iex is an exception-handling library.
See the IlmImfExamples directory for some code that demonstrates how
to use the IlmImf library to read and write OpenEXR files. The doc
directory contains some high-level documentation and history about the
OpenEXR format.
If you have questions about using the OpenEXR libraries, you may want
to join our developer mailing list. See http://www.openexr.com for
details.
LICENSE
-------
The OpenEXR source code distribution is free software. See the file
named COPYING (included in this distribution) for details.
WHAT'S INCLUDED
---------------
Besides the core OpenEXR libraries, the release includes several
utilities for reading, writing, viewing, and manipulating OpenEXR
images. These include:
* exrdisplay, an image viewer.
* exrheader, a utility for dumping header information.
* exrstdattr, a utility for modifying OpenEXR standard attributes.
* exrmaketiled, for generating tiled and rip/mipmapped images.
* exrenvmap, for creating OpenEXR environment maps.
* exrmakepreview, for creating preview images for OpenEXR files.
exrdisplay requires FLTK 1.1 or greater and OpenGL. exrdisplay
supports fragment shaders if you have the Nvidia Cg SDK and a graphics
card capable of running fp30 profile fragment shaders. See
exrdisplay/README for details.
We have also released an OpenEXR display driver for Renderman, a file
I/O plugin for Shake, and a file I/O plugin for Adobe Photoshop (on
both Windows and MacOS). These are packaged separately. Go to
http://www.openexr.com to download them. NOTE: the most recent
versions of these applications now have native support for OpenEXR, so
you should only use our open-source versions of the plugins if you
have an older version of the application.
BUILDING OPENEXR
----------------
Building OpenEXR requires the zlib library. If you want to build the
'exrdisplay' image viewer, you'll also need FLTK 1.1, but this program
is not required to use OpenEXR's libraries in your application.
exrdisplay can also accelerate the display of OpenEXR images if you
have the NVIDIA Cg SDK.
Your OS distribution may already include these libraries, or supply
packages for them. That is the preferred way to obtain them for use
with OpenEXR. If not, you can obtain the source code for zlib and
FLTK from:
http://www.zlib.net
http://www.fltk.org
and you can download the NVIDIA Cg SDK from
http://developer.nvidia.com.
If you're building OpenEXR on a Windows platform, see README.win32 for
instructions on how to build OpenEXR. The remainder of this file
applies only to GNU/Linux or other UNIX-like systems.
After installing the required libraries, to build OpenEXR on
GNU/Linux or other UNIX-like systems, do this:
./configure
make
make install
unless you obtained OpenEXR directly from CVS, in which case you
should first read README.CVS.
If you have the Nvidia Cg SDK and you want to build support for
fragment shaders into exrdisplay, specify the path to the SDK using
the "--with-cg-prefix" flag. There are some additional compile-time
configuration options available; type `./configure --help` for more
information.
See README.OSX for details on building OpenEXR in MacOS X.
Do `make check` to run the OpenEXR confidence tests. They should all
pass; if you find a test that does not pass on your system, please let
us know.
Other UNIX variants haven't been tested, but should be easy to build.
Let us know if you're having problems porting OpenEXR to a particular
platform.
All include files needed to use the OpenEXR libraries are installed in the
OpenEXR subdirectory of the install prefix, e.g. /usr/local/include/OpenEXR.
USING OPENEXR IN YOUR APPLICATIONS
----------------------------------
On systems with support for pkg-config, use `pkg-config --cflags
OpenEXR` for the C++ flags required to compile against OpenEXR
headers; and `pkg-config --libs OpenEXR` for the linker flags required
to link against OpenEXR libraries.

Binary file not shown.

View File

@ -19,12 +19,12 @@ file(GLOB lib_ext_hdrs jasper/*.h)
add_library(${JASPER_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs} ${lib_ext_hdrs})
if(MSVC)
if(WIN32 AND NOT MINGW)
add_definitions(-DJAS_WIN_MSVC_BUILD)
endif()
endif(WIN32 AND NOT MINGW)
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes -Wmissing-declarations -Wunused -Wshadow -Wsign-compare
/wd4013 /wd4018 /wd4715 /wd4244 /wd4101 /wd4267)
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes -Wmissing-declarations -Wunused -Wshadow -Wsign-compare)
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005
if(UNIX)
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)

162
3rdparty/libjasper/changelog vendored Normal file
View File

@ -0,0 +1,162 @@
jasper (1.900.1-13) unstable; urgency=high
* Fix CVE-2011-4516 and CVE-2011-4517: Two buffer overflow issues possibly
exploitable via specially crafted input files (Closes: #652649)
Thanks to Red Hat and Michael Gilbert
-- Roland Stigge <stigge@antcom.de> Wed, 04 Jan 2012 19:14:40 +0100
jasper (1.900.1-12) unstable; urgency=low
* Added patch to fix filename buffer overflow, thanks to Jonas Smedegard
and Alex Cherepanov from ghostscript (Closes: #649833)
-- Roland Stigge <stigge@antcom.de> Sun, 27 Nov 2011 19:56:01 +0100
jasper (1.900.1-11) unstable; urgency=low
* Added Multiarch support, thanks to Colin Watson (Closes: #645118)
-- Roland Stigge <stigge@antcom.de> Wed, 02 Nov 2011 17:16:10 +0100
jasper (1.900.1-10) unstable; urgency=low
* Added debian/watch
* debian/patches/01-misc-fixes.patch:
- Separated out config.{guess,sub}
-- Roland Stigge <stigge@antcom.de> Mon, 15 Aug 2011 19:09:29 +0200
jasper (1.900.1-9) unstable; urgency=low
* Switch to dpkg-source 3.0 (quilt) format
* Using new dh 7 build system
-- Roland Stigge <stigge@antcom.de> Tue, 12 Jul 2011 20:21:21 +0200
jasper (1.900.1-8) unstable; urgency=low
* Removed unneeded .la file (Closes: #633162)
* debian/control:
- Standards-Version: 3.9.2
- use libjpeg8-dev instead of libjpeg62-dev
-- Roland Stigge <stigge@antcom.de> Mon, 11 Jul 2011 21:27:24 +0200
jasper (1.900.1-7) unstable; urgency=low
* Acknowledge NMU
* Added patch to fix Debian patch for CVE-2008-3521 (Closes: #506739)
* debian/control: Standards-Version: 3.8.4
-- Roland Stigge <stigge@antcom.de> Sun, 21 Feb 2010 16:09:45 +0100
jasper (1.900.1-6.1) unstable; urgency=low
* Non-maintainer upload.
* This is a fix for the GeoJP2 patch introduced in 1.900.1-5 which caused
GDAL faulting. Thanks Even Rouault. (Closes: #553429)
-- Francesco Paolo Lovergine <frankie@debian.org> Wed, 28 Oct 2009 09:39:28 +0100
jasper (1.900.1-6) unstable; urgency=low
* Reverted to jasper 1.900.1-6 because 1.900.1-5.1 messed up (see #528543)
but 1.900.1-5 wasn't available anymore. (Closes: #514296, #528543)
* Re-applied patch from #275619 as in 1.900.1-5
* debian/control: Standards-Version: 3.8.2
* Applied patch by Nico Golde (Closes: #501021)
- CVE-2008-3522[0]: Buffer overflow.
- CVE-2008-3521[1]: unsecure temporary files handling.
- CVE-2008-3520[2]: Multiple integer overflows.
-- Roland Stigge <stigge@antcom.de> Sat, 20 Jun 2009 15:21:16 +0200
jasper (1.900.1-5.1) unstable; urgency=low
* Non-maintainer upload.
* add patches/02_security.dpatch to fix various CVEs (Closes: #501021):
+ CVE-2008-3522[0]: Buffer overflow.
+ CVE-2008-3521[1]: unsecure temporary files handling.
+ CVE-2008-3520[2]: Multiple integer overflows.
-- Pierre Habouzit <madcoder@debian.org> Sun, 12 Oct 2008 21:40:59 +0200
jasper (1.900.1-5) unstable; urgency=low
* Added GeoJP2 patch by Sven Geggus <sven.geggus@iitb.fraunhofer.de>
(Closes: #275619)
* debian/control: Standards-Version: 3.8.0
-- Roland Stigge <stigge@antcom.de> Sun, 08 Jun 2008 13:14:24 +0200
jasper (1.900.1-4) unstable; urgency=low
* src/libjasper/jpc/jpc_dec.c: Extended assert() to accept 4 color
components (Closes: #469786)
* debian/rules: improve "make distclean", thanks to lintian
* debian/control:
- Standards-Version: 3.7.3
- ${Source-Version} -> ${binary:Version}
- Removed self-dependencies of libjasper-dev
-- Roland Stigge <stigge@antcom.de> Sun, 09 Mar 2008 11:53:44 +0100
jasper (1.900.1-3) unstable; urgency=low
* Fixed segfaults on broken images (Closes: #413041)
-- Roland Stigge <stigge@antcom.de> Tue, 10 Apr 2007 10:05:10 +0200
jasper (1.900.1-2) experimental; urgency=low
* Added jas_tmr.h to -dev package (Closes: #414705)
-- Roland Stigge <stigge@antcom.de> Tue, 13 Mar 2007 14:23:58 +0100
jasper (1.900.1-1) experimental; urgency=low
* New upstream release
* debian/control:
- Standards-Version: 3.7.2
- Build-Depends: freeglut3-dev instead of libglut3-dev (Closes: #394496)
* Renamed packages to libjasper1, libjasper-dev, libjasper-runtime according
to upstream shared library naming change
-- Roland Stigge <stigge@antcom.de> Fri, 26 Jan 2007 14:22:18 +0100
jasper (1.701.0-2) unstable; urgency=low
* Prevent compression of pdf documents in binary packages
* Added man pages for the executables (Closes: #250077)
* Again renamed binary packages to reflect Policy:
- libjasper-1.701-1
- libjasper-1.701-dev (Provides, Replaces and Conflicts: libjasper-dev)
- libjasper-runtime
-- Roland Stigge <stigge@antcom.de> Sun, 20 Jun 2004 13:54:10 +0200
jasper (1.701.0-1) unstable; urgency=low
* New maintainer (Closes: #217099)
* New upstream release (Closes: #217570)
- new DFSG-compliant license (Closes: #218999, #245075)
- includes newer libtool related files (Closes: #210383)
* debian/control:
- Standards-Version: 3.6.1
- Changed binary package names, fixed interdependencies (Closes: #211592)
libjasper-1.700-2 => libjasper1
libjasper-1.700-2-dev => libjasper-dev
libjasper-progs => libjasper-runtime
(new packages conflicting and replacing the old ones)
- Added libxi-dev, libxmu-dev, libxt-dev to Build-Depends
(Closes: #250481)
-- Roland Stigge <stigge@antcom.de> Sat, 19 Jun 2004 23:19:32 +0200
jasper (1.700.2-1) unstable; urgency=low
* Initial Release.
-- Christopher L Cheney <ccheney@debian.org> Fri, 22 Aug 2003 01:30:00 -0500

62
3rdparty/libjasper/copyright vendored Normal file
View File

@ -0,0 +1,62 @@
This package was debianized by Christopher L Cheney <ccheney@debian.org> on
Fri, 22 Aug 2003 01:33:34 -0500.
The current maintainer is Roland Stigge <stigge@antcom.de>
It was downloaded from http://www.ece.uvic.ca/~mdadams/jasper/
Upstream Author: Michael Adams <mdadams@ece.uvic.ca>
License:
JasPer License Version 2.0
Copyright (c) 1999-2000 Image Power, Inc.
Copyright (c) 1999-2000 The University of British Columbia
Copyright (c) 2001-2003 Michael David Adams
All rights reserved.
Permission is hereby granted, free of charge, to any person (the
"User") obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
1. The above copyright notices and this permission notice (which
includes the disclaimer below) shall be included in all copies or
substantial portions of the Software.
2. The name of a copyright holder shall not be used to endorse or
promote products derived from the Software without specific prior
written permission.
THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.

View File

@ -704,8 +704,7 @@ static int jas_cmpxformseq_resize(jas_cmpxformseq_t *pxformseq, int n)
{
jas_cmpxform_t **p;
assert(n >= pxformseq->numpxforms);
p = (!pxformseq->pxforms) ? jas_malloc(n * sizeof(jas_cmpxform_t *)) :
jas_realloc(pxformseq->pxforms, n * sizeof(jas_cmpxform_t *));
p = jas_realloc2(pxformseq->pxforms, n, sizeof(jas_cmpxform_t *));
if (!p) {
return -1;
}
@ -889,13 +888,13 @@ static int jas_cmshapmatlut_set(jas_cmshapmatlut_t *lut, jas_icccurv_t *curv)
jas_cmshapmatlut_cleanup(lut);
if (curv->numents == 0) {
lut->size = 2;
if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
goto error;
lut->data[0] = 0.0;
lut->data[1] = 1.0;
} else if (curv->numents == 1) {
lut->size = 256;
if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
goto error;
gamma = curv->ents[0] / 256.0;
for (i = 0; i < lut->size; ++i) {
@ -903,7 +902,7 @@ static int jas_cmshapmatlut_set(jas_cmshapmatlut_t *lut, jas_icccurv_t *curv)
}
} else {
lut->size = curv->numents;
if (!(lut->data = jas_malloc(lut->size * sizeof(jas_cmreal_t))))
if (!(lut->data = jas_alloc2(lut->size, sizeof(jas_cmreal_t))))
goto error;
for (i = 0; i < lut->size; ++i) {
lut->data[i] = curv->ents[i] / 65535.0;
@ -953,7 +952,7 @@ static int jas_cmshapmatlut_invert(jas_cmshapmatlut_t *invlut,
return -1;
}
}
if (!(invlut->data = jas_malloc(n * sizeof(jas_cmreal_t))))
if (!(invlut->data = jas_alloc2(n, sizeof(jas_cmreal_t))))
return -1;
invlut->size = n;
for (i = 0; i < invlut->size; ++i) {

View File

@ -373,7 +373,7 @@ int jas_iccprof_save(jas_iccprof_t *prof, jas_stream_t *out)
jas_icctagtab_t *tagtab;
tagtab = &prof->tagtab;
if (!(tagtab->ents = jas_malloc(prof->attrtab->numattrs *
if (!(tagtab->ents = jas_alloc2(prof->attrtab->numattrs,
sizeof(jas_icctagtabent_t))))
goto error;
tagtab->numents = prof->attrtab->numattrs;
@ -522,7 +522,7 @@ static int jas_iccprof_gettagtab(jas_stream_t *in, jas_icctagtab_t *tagtab)
}
if (jas_iccgetuint32(in, &tagtab->numents))
goto error;
if (!(tagtab->ents = jas_malloc(tagtab->numents *
if (!(tagtab->ents = jas_alloc2(tagtab->numents,
sizeof(jas_icctagtabent_t))))
goto error;
tagtabent = tagtab->ents;
@ -743,8 +743,7 @@ static int jas_iccattrtab_resize(jas_iccattrtab_t *tab, int maxents)
{
jas_iccattr_t *newattrs;
assert(maxents >= tab->numattrs);
newattrs = tab->attrs ? jas_realloc(tab->attrs, maxents *
sizeof(jas_iccattr_t)) : jas_malloc(maxents * sizeof(jas_iccattr_t));
newattrs = jas_realloc2(tab->attrs, maxents, sizeof(jas_iccattr_t));
if (!newattrs)
return -1;
tab->attrs = newattrs;
@ -999,7 +998,7 @@ static int jas_icccurv_input(jas_iccattrval_t *attrval, jas_stream_t *in,
if (jas_iccgetuint32(in, &curv->numents))
goto error;
if (!(curv->ents = jas_malloc(curv->numents * sizeof(jas_iccuint16_t))))
if (!(curv->ents = jas_alloc2(curv->numents, sizeof(jas_iccuint16_t))))
goto error;
for (i = 0; i < curv->numents; ++i) {
if (jas_iccgetuint16(in, &curv->ents[i]))
@ -1100,7 +1099,7 @@ static int jas_icctxtdesc_input(jas_iccattrval_t *attrval, jas_stream_t *in,
if (jas_iccgetuint32(in, &txtdesc->uclangcode) ||
jas_iccgetuint32(in, &txtdesc->uclen))
goto error;
if (!(txtdesc->ucdata = jas_malloc(txtdesc->uclen * 2)))
if (!(txtdesc->ucdata = jas_alloc2(txtdesc->uclen, 2)))
goto error;
if (jas_stream_read(in, txtdesc->ucdata, txtdesc->uclen * 2) !=
JAS_CAST(int, txtdesc->uclen * 2))
@ -1292,17 +1291,17 @@ static int jas_icclut8_input(jas_iccattrval_t *attrval, jas_stream_t *in,
jas_iccgetuint16(in, &lut8->numouttabents))
goto error;
clutsize = jas_iccpowi(lut8->clutlen, lut8->numinchans) * lut8->numoutchans;
if (!(lut8->clut = jas_malloc(clutsize * sizeof(jas_iccuint8_t))) ||
!(lut8->intabsbuf = jas_malloc(lut8->numinchans *
lut8->numintabents * sizeof(jas_iccuint8_t))) ||
!(lut8->intabs = jas_malloc(lut8->numinchans *
if (!(lut8->clut = jas_alloc2(clutsize, sizeof(jas_iccuint8_t))) ||
!(lut8->intabsbuf = jas_alloc3(lut8->numinchans,
lut8->numintabents, sizeof(jas_iccuint8_t))) ||
!(lut8->intabs = jas_alloc2(lut8->numinchans,
sizeof(jas_iccuint8_t *))))
goto error;
for (i = 0; i < lut8->numinchans; ++i)
lut8->intabs[i] = &lut8->intabsbuf[i * lut8->numintabents];
if (!(lut8->outtabsbuf = jas_malloc(lut8->numoutchans *
lut8->numouttabents * sizeof(jas_iccuint8_t))) ||
!(lut8->outtabs = jas_malloc(lut8->numoutchans *
if (!(lut8->outtabsbuf = jas_alloc3(lut8->numoutchans,
lut8->numouttabents, sizeof(jas_iccuint8_t))) ||
!(lut8->outtabs = jas_alloc2(lut8->numoutchans,
sizeof(jas_iccuint8_t *))))
goto error;
for (i = 0; i < lut8->numoutchans; ++i)
@ -1461,17 +1460,17 @@ static int jas_icclut16_input(jas_iccattrval_t *attrval, jas_stream_t *in,
jas_iccgetuint16(in, &lut16->numouttabents))
goto error;
clutsize = jas_iccpowi(lut16->clutlen, lut16->numinchans) * lut16->numoutchans;
if (!(lut16->clut = jas_malloc(clutsize * sizeof(jas_iccuint16_t))) ||
!(lut16->intabsbuf = jas_malloc(lut16->numinchans *
lut16->numintabents * sizeof(jas_iccuint16_t))) ||
!(lut16->intabs = jas_malloc(lut16->numinchans *
if (!(lut16->clut = jas_alloc2(clutsize, sizeof(jas_iccuint16_t))) ||
!(lut16->intabsbuf = jas_alloc3(lut16->numinchans,
lut16->numintabents, sizeof(jas_iccuint16_t))) ||
!(lut16->intabs = jas_alloc2(lut16->numinchans,
sizeof(jas_iccuint16_t *))))
goto error;
for (i = 0; i < lut16->numinchans; ++i)
lut16->intabs[i] = &lut16->intabsbuf[i * lut16->numintabents];
if (!(lut16->outtabsbuf = jas_malloc(lut16->numoutchans *
lut16->numouttabents * sizeof(jas_iccuint16_t))) ||
!(lut16->outtabs = jas_malloc(lut16->numoutchans *
if (!(lut16->outtabsbuf = jas_alloc3(lut16->numoutchans,
lut16->numouttabents, sizeof(jas_iccuint16_t))) ||
!(lut16->outtabs = jas_alloc2(lut16->numoutchans,
sizeof(jas_iccuint16_t *))))
goto error;
for (i = 0; i < lut16->numoutchans; ++i)

View File

@ -142,7 +142,7 @@ jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms,
image->inmem_ = true;
/* Allocate memory for the per-component information. */
if (!(image->cmpts_ = jas_malloc(image->maxcmpts_ *
if (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,
sizeof(jas_image_cmpt_t *)))) {
jas_image_destroy(image);
return 0;
@ -774,8 +774,7 @@ static int jas_image_growcmpts(jas_image_t *image, int maxcmpts)
jas_image_cmpt_t **newcmpts;
int cmptno;
newcmpts = (!image->cmpts_) ? jas_malloc(maxcmpts * sizeof(jas_image_cmpt_t *)) :
jas_realloc(image->cmpts_, maxcmpts * sizeof(jas_image_cmpt_t *));
newcmpts = jas_realloc2(image->cmpts_, maxcmpts, sizeof(jas_image_cmpt_t *));
if (!newcmpts) {
return -1;
}

View File

@ -76,6 +76,11 @@
/* We need the prototype for memset. */
#include <string.h>
#include <limits.h>
#include <errno.h>
#if !defined _WIN32 || defined __MINGW__ || defined __MINGW32__
#include <stdint.h>
#endif
#include "jasper/jas_malloc.h"
@ -113,18 +118,50 @@ void jas_free(void *ptr)
void *jas_realloc(void *ptr, size_t size)
{
return realloc(ptr, size);
return ptr ? realloc(ptr, size) : malloc(size);
}
void *jas_realloc2(void *ptr, size_t nmemb, size_t size)
{
if (!ptr)
return jas_alloc2(nmemb, size);
if (nmemb && SIZE_MAX / nmemb < size) {
errno = ENOMEM;
return NULL;
}
return jas_realloc(ptr, nmemb * size);
}
void *jas_alloc2(size_t nmemb, size_t size)
{
if (nmemb && SIZE_MAX / nmemb < size) {
errno = ENOMEM;
return NULL;
}
return jas_malloc(nmemb * size);
}
void *jas_alloc3(size_t a, size_t b, size_t c)
{
size_t n;
if (a && SIZE_MAX / a < b) {
errno = ENOMEM;
return NULL;
}
return jas_alloc2(a*b, c);
}
void *jas_calloc(size_t nmemb, size_t size)
{
void *ptr;
size_t n;
n = nmemb * size;
if (!(ptr = jas_malloc(n * sizeof(char)))) {
return 0;
}
memset(ptr, 0, n);
ptr = jas_alloc2(nmemb, size);
if (ptr)
memset(ptr, 0, nmemb*size);
return ptr;
}

View File

@ -114,7 +114,7 @@ jas_matrix_t *jas_matrix_create(int numrows, int numcols)
matrix->datasize_ = numrows * numcols;
if (matrix->maxrows_ > 0) {
if (!(matrix->rows_ = jas_malloc(matrix->maxrows_ *
if (!(matrix->rows_ = jas_alloc2(matrix->maxrows_,
sizeof(jas_seqent_t *)))) {
jas_matrix_destroy(matrix);
return 0;
@ -122,7 +122,7 @@ jas_matrix_t *jas_matrix_create(int numrows, int numcols)
}
if (matrix->datasize_ > 0) {
if (!(matrix->data_ = jas_malloc(matrix->datasize_ *
if (!(matrix->data_ = jas_alloc2(matrix->datasize_,
sizeof(jas_seqent_t)))) {
jas_matrix_destroy(matrix);
return 0;
@ -220,7 +220,7 @@ void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, int r0, int c0,
mat0->numrows_ = r1 - r0 + 1;
mat0->numcols_ = c1 - c0 + 1;
mat0->maxrows_ = mat0->numrows_;
mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *));
mat0->rows_ = jas_alloc2(mat0->maxrows_, sizeof(jas_seqent_t *));
for (i = 0; i < mat0->numrows_; ++i) {
mat0->rows_[i] = mat1->rows_[r0 + i] + c0;
}

View File

@ -212,7 +212,7 @@ jas_stream_t *jas_stream_memopen(char *buf, int bufsize)
if (buf) {
obj->buf_ = (unsigned char *) buf;
} else {
obj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));
obj->buf_ = jas_malloc(obj->bufsize_);
obj->myalloc_ = 1;
}
if (!obj->buf_) {
@ -361,9 +361,9 @@ jas_stream_t *jas_stream_tmpfile()
}
obj->fd = -1;
obj->flags = 0;
obj->pathname[0] = '\0';
stream->obj_ = obj;
#ifdef _WIN32
/* Choose a file name. */
tmpnam(obj->pathname);
@ -373,16 +373,22 @@ jas_stream_t *jas_stream_tmpfile()
jas_stream_destroy(stream);
return 0;
}
#else
/* Choose a file name. */
snprintf(obj->pathname, L_tmpnam, "%s/tmp.XXXXXXXXXX", P_tmpdir);
/* Open the underlying file. */
if ((obj->fd = mkstemp(obj->pathname)) < 0) {
jas_stream_destroy(stream);
return 0;
}
#endif
/* Unlink the file so that it will disappear if the program
terminates abnormally. */
/* Under UNIX, one can unlink an open file and continue to do I/O
on it. Not all operating systems support this functionality, however.
For example, under Microsoft Windows the unlink operation will fail,
since the file is open. */
if (unlink(obj->pathname)) {
/* We will try unlinking the file again after it is closed. */
obj->flags |= JAS_STREAM_FILEOBJ_DELONCLOSE;
jas_stream_destroy(stream);
return 0;
}
/* Use full buffering. */
@ -553,7 +559,7 @@ int jas_stream_printf(jas_stream_t *stream, const char *fmt, ...)
int ret;
va_start(ap, fmt);
ret = vsprintf(buf, fmt, ap);
ret = vsnprintf(buf, sizeof buf, fmt, ap);
jas_stream_puts(stream, buf);
va_end(ap);
return ret;
@ -992,7 +998,7 @@ static int mem_resize(jas_stream_memobj_t *m, int bufsize)
unsigned char *buf;
assert(m->buf_);
if (!(buf = jas_realloc(m->buf_, bufsize * sizeof(unsigned char)))) {
if (!(buf = jas_realloc(m->buf_, bufsize))) {
return -1;
}
m->buf_ = buf;

View File

@ -95,6 +95,9 @@ extern "C" {
#define jas_free MEMFREE
#define jas_realloc MEMREALLOC
#define jas_calloc MEMCALLOC
#define jas_alloc2(a, b) MEMALLOC((a)*(b))
#define jas_alloc3(a, b, c) MEMALLOC((a)*(b)*(c))
#define jas_realloc2(p, a, b) MEMREALLOC((p), (a)*(b))
#endif
/******************************************************************************\
@ -115,6 +118,12 @@ void *jas_realloc(void *ptr, size_t size);
/* Allocate a block of memory and initialize the contents to zero. */
void *jas_calloc(size_t nmemb, size_t size);
/* size-checked double allocation .*/
void *jas_alloc2(size_t, size_t);
void *jas_alloc3(size_t, size_t, size_t);
void *jas_realloc2(void *, size_t, size_t);
#endif
#ifdef __cplusplus

View File

@ -77,6 +77,7 @@
#include <jasper/jas_config.h>
#include <stdio.h>
#include <limits.h>
#if defined(HAVE_FCNTL_H)
#include <fcntl.h>
#endif
@ -251,7 +252,11 @@ typedef struct {
typedef struct {
int fd;
int flags;
char pathname[L_tmpnam + 1];
#if defined _WIN32 && !defined __MINGW__ && !defined __MINGW32__
char pathname[MAX_PATH + 1];
#else
char pathname[PATH_MAX + 1];
#endif
} jas_stream_fileobj_t;
#define JAS_STREAM_FILEOBJ_DELONCLOSE 0x01

View File

@ -5,6 +5,11 @@
* All rights reserved.
*/
/*
* Modified by Andrey Kiselev <dron@remotesensing.org> to handle UUID
* box properly.
*/
/* __START_OF_JASPER_LICENSE__
*
* JasPer License Version 2.0
@ -127,6 +132,9 @@ static void jp2_pclr_destroy(jp2_box_t *box);
static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in);
static int jp2_pclr_putdata(jp2_box_t *box, jas_stream_t *out);
static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out);
static void jp2_uuid_destroy(jp2_box_t *box);
static int jp2_uuid_getdata(jp2_box_t *box, jas_stream_t *in);
static int jp2_uuid_putdata(jp2_box_t *box, jas_stream_t *out);
/******************************************************************************\
* Local data.
@ -164,7 +172,7 @@ jp2_boxinfo_t jp2_boxinfos[] = {
{JP2_BOX_XML, "XML", 0,
{0, 0, 0, 0, 0}},
{JP2_BOX_UUID, "UUID", 0,
{0, 0, 0, 0, 0}},
{0, jp2_uuid_destroy, jp2_uuid_getdata, jp2_uuid_putdata, 0}},
{JP2_BOX_UINF, "UINF", JP2_BOX_SUPER,
{0, 0, 0, 0, 0}},
{JP2_BOX_ULST, "ULST", 0,
@ -372,7 +380,7 @@ static int jp2_bpcc_getdata(jp2_box_t *box, jas_stream_t *in)
jp2_bpcc_t *bpcc = &box->data.bpcc;
unsigned int i;
bpcc->numcmpts = box->datalen;
if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts * sizeof(uint_fast8_t)))) {
if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts, sizeof(uint_fast8_t)))) {
return -1;
}
for (i = 0; i < bpcc->numcmpts; ++i) {
@ -416,7 +424,7 @@ static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in)
break;
case JP2_COLR_ICC:
colr->iccplen = box->datalen - 3;
if (!(colr->iccp = jas_malloc(colr->iccplen * sizeof(uint_fast8_t)))) {
if (!(colr->iccp = jas_alloc2(colr->iccplen, sizeof(uint_fast8_t)))) {
return -1;
}
if (jas_stream_read(in, colr->iccp, colr->iccplen) != colr->iccplen) {
@ -453,7 +461,7 @@ static int jp2_cdef_getdata(jp2_box_t *box, jas_stream_t *in)
if (jp2_getuint16(in, &cdef->numchans)) {
return -1;
}
if (!(cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t)))) {
if (!(cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t)))) {
return -1;
}
for (channo = 0; channo < cdef->numchans; ++channo) {
@ -766,7 +774,7 @@ static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in)
unsigned int i;
cmap->numchans = (box->datalen) / 4;
if (!(cmap->ents = jas_malloc(cmap->numchans * sizeof(jp2_cmapent_t)))) {
if (!(cmap->ents = jas_alloc2(cmap->numchans, sizeof(jp2_cmapent_t)))) {
return -1;
}
for (i = 0; i < cmap->numchans; ++i) {
@ -828,10 +836,10 @@ static int jp2_pclr_getdata(jp2_box_t *box, jas_stream_t *in)
return -1;
}
lutsize = pclr->numlutents * pclr->numchans;
if (!(pclr->lutdata = jas_malloc(lutsize * sizeof(int_fast32_t)))) {
if (!(pclr->lutdata = jas_alloc2(lutsize, sizeof(int_fast32_t)))) {
return -1;
}
if (!(pclr->bpc = jas_malloc(pclr->numchans * sizeof(uint_fast8_t)))) {
if (!(pclr->bpc = jas_alloc2(pclr->numchans, sizeof(uint_fast8_t)))) {
return -1;
}
for (i = 0; i < pclr->numchans; ++i) {
@ -876,6 +884,56 @@ static void jp2_pclr_dumpdata(jp2_box_t *box, FILE *out)
}
}
static void jp2_uuid_destroy(jp2_box_t *box)
{
jp2_uuid_t *uuid = &box->data.uuid;
if (uuid->data)
{
jas_free(uuid->data);
uuid->data = NULL;
}
}
static int jp2_uuid_getdata(jp2_box_t *box, jas_stream_t *in)
{
jp2_uuid_t *uuid = &box->data.uuid;
int i;
for (i = 0; i < 16; i++)
{
if (jp2_getuint8(in, &uuid->uuid[i]))
return -1;
}
uuid->datalen = box->datalen - 16;
uuid->data = jas_malloc(uuid->datalen * sizeof(uint_fast8_t));
for (i = 0; i < uuid->datalen; i++)
{
if (jp2_getuint8(in, &uuid->data[i]))
return -1;
}
return 0;
}
static int jp2_uuid_putdata(jp2_box_t *box, jas_stream_t *out)
{
jp2_uuid_t *uuid = &box->data.uuid;
int i;
for (i = 0; i < 16; i++)
{
if (jp2_putuint8(out, uuid->uuid[i]))
return -1;
}
for (i = 0; i < uuid->datalen; i++)
{
if (jp2_putuint8(out, uuid->data[i]))
return -1;
}
return 0;
}
static int jp2_getint(jas_stream_t *in, int s, int n, int_fast32_t *val)
{
int c;

View File

@ -5,6 +5,11 @@
* All rights reserved.
*/
/*
* Modified by Andrey Kiselev <dron@remotesensing.org> to handle UUID
* box properly.
*/
/* __START_OF_JASPER_LICENSE__
*
* JasPer License Version 2.0
@ -229,6 +234,12 @@ typedef struct {
jp2_cmapent_t *ents;
} jp2_cmap_t;
typedef struct {
uint_fast32_t datalen;
uint_fast8_t uuid[16];
uint_fast8_t *data;
} jp2_uuid_t;
#define JP2_CMAP_DIRECT 0
#define JP2_CMAP_PALETTE 1
@ -257,6 +268,7 @@ typedef struct {
jp2_pclr_t pclr;
jp2_cdef_t cdef;
jp2_cmap_t cmap;
jp2_uuid_t uuid;
} data;
} jp2_box_t;

View File

@ -336,7 +336,7 @@ jas_image_t *jp2_decode(jas_stream_t *in, char *optstr)
}
/* Allocate space for the channel-number to component-number LUT. */
if (!(dec->chantocmptlut = jas_malloc(dec->numchans * sizeof(uint_fast16_t)))) {
if (!(dec->chantocmptlut = jas_alloc2(dec->numchans, sizeof(uint_fast16_t)))) {
jas_eprintf("error: no memory\n");
goto error;
}
@ -354,7 +354,7 @@ jas_image_t *jp2_decode(jas_stream_t *in, char *optstr)
if (cmapent->map == JP2_CMAP_DIRECT) {
dec->chantocmptlut[channo] = channo;
} else if (cmapent->map == JP2_CMAP_PALETTE) {
lutents = jas_malloc(pclrd->numlutents * sizeof(int_fast32_t));
lutents = jas_alloc2(pclrd->numlutents, sizeof(int_fast32_t));
for (i = 0; i < pclrd->numlutents; ++i) {
lutents[i] = pclrd->lutdata[cmapent->pcol + i * pclrd->numchans];
}

View File

@ -5,6 +5,11 @@
* All rights reserved.
*/
/*
* Modified by Andrey Kiselev <dron@remotesensing.org> to handle UUID
* box properly.
*/
/* __START_OF_JASPER_LICENSE__
*
* JasPer License Version 2.0
@ -86,7 +91,7 @@ static int clrspctojp2(jas_clrspc_t clrspc);
* Functions.
\******************************************************************************/
int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr)
int jp2_write_header(jas_image_t *image, jas_stream_t *out)
{
jp2_box_t *box;
jp2_ftyp_t *ftyp;
@ -97,8 +102,6 @@ int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr)
long len;
uint_fast16_t cmptno;
jp2_colr_t *colr;
char buf[4096];
uint_fast32_t overhead;
jp2_cdefchan_t *cdefchanent;
jp2_cdef_t *cdef;
int i;
@ -191,7 +194,7 @@ int sgnd;
}
bpcc = &box->data.bpcc;
bpcc->numcmpts = jas_image_numcmpts(image);
if (!(bpcc->bpcs = jas_malloc(bpcc->numcmpts *
if (!(bpcc->bpcs = jas_alloc2(bpcc->numcmpts,
sizeof(uint_fast8_t)))) {
goto error;
}
@ -285,7 +288,7 @@ int sgnd;
}
cdef = &box->data.cdef;
cdef->numchans = jas_image_numcmpts(image);
cdef->ents = jas_malloc(cdef->numchans * sizeof(jp2_cdefchan_t));
cdef->ents = jas_alloc2(cdef->numchans, sizeof(jp2_cdefchan_t));
for (i = 0; i < jas_image_numcmpts(image); ++i) {
cdefchanent = &cdef->ents[i];
cdefchanent->channo = i;
@ -326,6 +329,26 @@ int sgnd;
jas_stream_close(tmpstream);
tmpstream = 0;
return 0;
abort();
error:
if (box) {
jp2_box_destroy(box);
}
if (tmpstream) {
jas_stream_close(tmpstream);
}
return -1;
}
int jp2_write_codestream(jas_image_t *image, jas_stream_t *out, char *optstr)
{
jp2_box_t *box;
char buf[4096];
uint_fast32_t overhead;
/*
* Output the contiguous code stream box.
*/
@ -358,12 +381,34 @@ error:
if (box) {
jp2_box_destroy(box);
}
if (tmpstream) {
jas_stream_close(tmpstream);
}
return -1;
}
int jp2_encode(jas_image_t *image, jas_stream_t *out, char *optstr)
{
if (jp2_write_header(image, out) < 0)
return -1;
if (jp2_write_codestream(image, out, optstr) < 0)
return -1;
return 0;
}
int jp2_encode_uuid(jas_image_t *image, jas_stream_t *out,
char *optstr, jp2_box_t *uuid)
{
if (jp2_write_header(image, out) < 0)
return -1;
if (uuid) {
if (jp2_box_put(uuid, out))
return -1;
}
if (jp2_write_codestream(image, out, optstr) < 0)
return -1;
return 0;
}
static uint_fast32_t jp2_gettypeasoc(int colorspace, int ctype)
{
int type;

View File

@ -501,7 +501,7 @@ static int jpc_siz_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate,
!siz->tileheight || !siz->numcomps) {
return -1;
}
if (!(siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t)))) {
if (!(siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t)))) {
return -1;
}
for (i = 0; i < siz->numcomps; ++i) {
@ -743,6 +743,10 @@ static int jpc_cox_getcompparms(jpc_ms_t *ms, jpc_cstate_t *cstate,
return -1;
}
compparms->numrlvls = compparms->numdlvls + 1;
if (compparms->numrlvls > JPC_MAXRLVLS) {
jpc_cox_destroycompparms(compparms);
return -1;
}
if (prtflag) {
for (i = 0; i < compparms->numrlvls; ++i) {
if (jpc_getuint8(in, &tmp)) {
@ -981,7 +985,10 @@ static int jpc_qcx_getcompparms(jpc_qcxcp_t *compparms, jpc_cstate_t *cstate,
compparms->numstepsizes = (len - n) / 2;
break;
}
if (compparms->numstepsizes > 0) {
if (compparms->numstepsizes > 3 * JPC_MAXRLVLS + 1) {
jpc_qcx_destroycompparms(compparms);
return -1;
} else if (compparms->numstepsizes > 0) {
compparms->stepsizes = jas_malloc(compparms->numstepsizes *
sizeof(uint_fast16_t));
assert(compparms->stepsizes);
@ -1090,7 +1097,7 @@ static int jpc_ppm_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
ppm->len = ms->len - 1;
if (ppm->len > 0) {
if (!(ppm->data = jas_malloc(ppm->len * sizeof(unsigned char)))) {
if (!(ppm->data = jas_malloc(ppm->len))) {
goto error;
}
if (JAS_CAST(uint, jas_stream_read(in, ppm->data, ppm->len)) != ppm->len) {
@ -1159,7 +1166,7 @@ static int jpc_ppt_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
}
ppt->len = ms->len - 1;
if (ppt->len > 0) {
if (!(ppt->data = jas_malloc(ppt->len * sizeof(unsigned char)))) {
if (!(ppt->data = jas_malloc(ppt->len))) {
goto error;
}
if (jas_stream_read(in, (char *) ppt->data, ppt->len) != JAS_CAST(int, ppt->len)) {
@ -1222,7 +1229,7 @@ static int jpc_poc_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
uint_fast8_t tmp;
poc->numpchgs = (cstate->numcomps > 256) ? (ms->len / 9) :
(ms->len / 7);
if (!(poc->pchgs = jas_malloc(poc->numpchgs * sizeof(jpc_pocpchg_t)))) {
if (!(poc->pchgs = jas_alloc2(poc->numpchgs, sizeof(jpc_pocpchg_t)))) {
goto error;
}
for (pchgno = 0, pchg = poc->pchgs; pchgno < poc->numpchgs; ++pchgno,
@ -1327,7 +1334,7 @@ static int jpc_crg_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
jpc_crgcomp_t *comp;
uint_fast16_t compno;
crg->numcomps = cstate->numcomps;
if (!(crg->comps = jas_malloc(cstate->numcomps * sizeof(uint_fast16_t)))) {
if (!(crg->comps = jas_alloc2(cstate->numcomps, sizeof(jpc_crgcomp_t)))) {
return -1;
}
for (compno = 0, comp = crg->comps; compno < cstate->numcomps;
@ -1466,7 +1473,7 @@ static int jpc_unk_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in
cstate = 0;
if (ms->len > 0) {
if (!(unk->data = jas_malloc(ms->len * sizeof(unsigned char)))) {
if (!(unk->data = jas_malloc(ms->len))) {
return -1;
}
if (jas_stream_read(in, (char *) unk->data, ms->len) != JAS_CAST(int, ms->len)) {

View File

@ -449,7 +449,7 @@ static int jpc_dec_process_sot(jpc_dec_t *dec, jpc_ms_t *ms)
if (dec->state == JPC_MH) {
compinfos = jas_malloc(dec->numcomps * sizeof(jas_image_cmptparm_t));
compinfos = jas_alloc2(dec->numcomps, sizeof(jas_image_cmptparm_t));
assert(compinfos);
for (cmptno = 0, cmpt = dec->cmpts, compinfo = compinfos;
cmptno < dec->numcomps; ++cmptno, ++cmpt, ++compinfo) {
@ -692,7 +692,7 @@ static int jpc_dec_tileinit(jpc_dec_t *dec, jpc_dec_tile_t *tile)
tile->realmode = 1;
}
tcomp->numrlvls = ccp->numrlvls;
if (!(tcomp->rlvls = jas_malloc(tcomp->numrlvls *
if (!(tcomp->rlvls = jas_alloc2(tcomp->numrlvls,
sizeof(jpc_dec_rlvl_t)))) {
return -1;
}
@ -764,7 +764,7 @@ rlvl->bands = 0;
rlvl->cbgheightexpn);
rlvl->numbands = (!rlvlno) ? 1 : 3;
if (!(rlvl->bands = jas_malloc(rlvl->numbands *
if (!(rlvl->bands = jas_alloc2(rlvl->numbands,
sizeof(jpc_dec_band_t)))) {
return -1;
}
@ -797,7 +797,7 @@ rlvl->bands = 0;
assert(rlvl->numprcs);
if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_dec_prc_t)))) {
if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_dec_prc_t)))) {
return -1;
}
@ -834,7 +834,7 @@ rlvl->bands = 0;
if (!(prc->numimsbstagtree = jpc_tagtree_create(prc->numhcblks, prc->numvcblks))) {
return -1;
}
if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_dec_cblk_t)))) {
if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_dec_cblk_t)))) {
return -1;
}
@ -1069,12 +1069,12 @@ static int jpc_dec_tiledecode(jpc_dec_t *dec, jpc_dec_tile_t *tile)
/* Apply an inverse intercomponent transform if necessary. */
switch (tile->cp->mctid) {
case JPC_MCT_RCT:
assert(dec->numcomps == 3);
assert(dec->numcomps == 3 || dec->numcomps == 4);
jpc_irct(tile->tcomps[0].data, tile->tcomps[1].data,
tile->tcomps[2].data);
break;
case JPC_MCT_ICT:
assert(dec->numcomps == 3);
assert(dec->numcomps == 3 || dec->numcomps == 4);
jpc_iict(tile->tcomps[0].data, tile->tcomps[1].data,
tile->tcomps[2].data);
break;
@ -1181,7 +1181,7 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
return -1;
}
if (!(dec->cmpts = jas_malloc(dec->numcomps * sizeof(jpc_dec_cmpt_t)))) {
if (!(dec->cmpts = jas_alloc2(dec->numcomps, sizeof(jpc_dec_cmpt_t)))) {
return -1;
}
@ -1204,7 +1204,7 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
dec->numhtiles = JPC_CEILDIV(dec->xend - dec->tilexoff, dec->tilewidth);
dec->numvtiles = JPC_CEILDIV(dec->yend - dec->tileyoff, dec->tileheight);
dec->numtiles = dec->numhtiles * dec->numvtiles;
if (!(dec->tiles = jas_malloc(dec->numtiles * sizeof(jpc_dec_tile_t)))) {
if (!(dec->tiles = jas_alloc2(dec->numtiles, sizeof(jpc_dec_tile_t)))) {
return -1;
}
@ -1228,7 +1228,7 @@ static int jpc_dec_process_siz(jpc_dec_t *dec, jpc_ms_t *ms)
tile->pkthdrstreampos = 0;
tile->pptstab = 0;
tile->cp = 0;
if (!(tile->tcomps = jas_malloc(dec->numcomps *
if (!(tile->tcomps = jas_alloc2(dec->numcomps,
sizeof(jpc_dec_tcomp_t)))) {
return -1;
}
@ -1489,7 +1489,7 @@ static jpc_dec_cp_t *jpc_dec_cp_create(uint_fast16_t numcomps)
cp->numlyrs = 0;
cp->mctid = 0;
cp->csty = 0;
if (!(cp->ccps = jas_malloc(cp->numcomps * sizeof(jpc_dec_ccp_t)))) {
if (!(cp->ccps = jas_alloc2(cp->numcomps, sizeof(jpc_dec_ccp_t)))) {
return 0;
}
if (!(cp->pchglist = jpc_pchglist_create())) {
@ -2048,7 +2048,7 @@ jpc_streamlist_t *jpc_streamlist_create()
}
streamlist->numstreams = 0;
streamlist->maxstreams = 100;
if (!(streamlist->streams = jas_malloc(streamlist->maxstreams *
if (!(streamlist->streams = jas_alloc2(streamlist->maxstreams,
sizeof(jas_stream_t *)))) {
jas_free(streamlist);
return 0;
@ -2068,8 +2068,8 @@ int jpc_streamlist_insert(jpc_streamlist_t *streamlist, int streamno,
/* Grow the array of streams if necessary. */
if (streamlist->numstreams >= streamlist->maxstreams) {
newmaxstreams = streamlist->maxstreams + 1024;
if (!(newstreams = jas_realloc(streamlist->streams,
(newmaxstreams + 1024) * sizeof(jas_stream_t *)))) {
if (!(newstreams = jas_realloc2(streamlist->streams,
(newmaxstreams + 1024), sizeof(jas_stream_t *)))) {
return -1;
}
for (i = streamlist->numstreams; i < streamlist->maxstreams; ++i) {
@ -2155,8 +2155,7 @@ int jpc_ppxstab_grow(jpc_ppxstab_t *tab, int maxents)
{
jpc_ppxstabent_t **newents;
if (tab->maxents < maxents) {
newents = (tab->ents) ? jas_realloc(tab->ents, maxents *
sizeof(jpc_ppxstabent_t *)) : jas_malloc(maxents * sizeof(jpc_ppxstabent_t *));
newents = jas_realloc2(tab->ents, maxents, sizeof(jpc_ppxstabent_t *));
if (!newents) {
return -1;
}

View File

@ -403,7 +403,7 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image)
vsteplcm *= jas_image_cmptvstep(image, cmptno);
}
if (!(cp->ccps = jas_malloc(cp->numcmpts * sizeof(jpc_enc_ccp_t)))) {
if (!(cp->ccps = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_ccp_t)))) {
goto error;
}
for (cmptno = 0, ccp = cp->ccps; cmptno < JAS_CAST(int, cp->numcmpts); ++cmptno,
@ -656,7 +656,7 @@ static jpc_enc_cp_t *cp_create(char *optstr, jas_image_t *image)
if (ilyrrates && numilyrrates > 0) {
tcp->numlyrs = numilyrrates + 1;
if (!(tcp->ilyrrates = jas_malloc((tcp->numlyrs - 1) *
if (!(tcp->ilyrrates = jas_alloc2((tcp->numlyrs - 1),
sizeof(jpc_fix_t)))) {
goto error;
}
@ -940,7 +940,7 @@ startoff = jas_stream_getrwcount(enc->out);
siz->tilewidth = cp->tilewidth;
siz->tileheight = cp->tileheight;
siz->numcomps = cp->numcmpts;
siz->comps = jas_malloc(siz->numcomps * sizeof(jpc_sizcomp_t));
siz->comps = jas_alloc2(siz->numcomps, sizeof(jpc_sizcomp_t));
assert(siz->comps);
for (i = 0; i < JAS_CAST(int, cp->numcmpts); ++i) {
siz->comps[i].prec = cp->ccps[i].prec;
@ -977,7 +977,7 @@ startoff = jas_stream_getrwcount(enc->out);
return -1;
}
crg = &enc->mrk->parms.crg;
crg->comps = jas_malloc(crg->numcomps * sizeof(jpc_crgcomp_t));
crg->comps = jas_alloc2(crg->numcomps, sizeof(jpc_crgcomp_t));
if (jpc_putms(enc->out, enc->cstate, enc->mrk)) {
jas_eprintf("cannot write CRG marker\n");
return -1;
@ -1955,7 +1955,7 @@ jpc_enc_tile_t *jpc_enc_tile_create(jpc_enc_cp_t *cp, jas_image_t *image, int ti
tile->mctid = cp->tcp.mctid;
tile->numlyrs = cp->tcp.numlyrs;
if (!(tile->lyrsizes = jas_malloc(tile->numlyrs *
if (!(tile->lyrsizes = jas_alloc2(tile->numlyrs,
sizeof(uint_fast32_t)))) {
goto error;
}
@ -1964,7 +1964,7 @@ jpc_enc_tile_t *jpc_enc_tile_create(jpc_enc_cp_t *cp, jas_image_t *image, int ti
}
/* Allocate an array for the per-tile-component information. */
if (!(tile->tcmpts = jas_malloc(cp->numcmpts * sizeof(jpc_enc_tcmpt_t)))) {
if (!(tile->tcmpts = jas_alloc2(cp->numcmpts, sizeof(jpc_enc_tcmpt_t)))) {
goto error;
}
/* Initialize a few members critical for error recovery. */
@ -2110,7 +2110,7 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp,
jas_seq2d_ystart(tcmpt->data), jas_seq2d_xend(tcmpt->data),
jas_seq2d_yend(tcmpt->data), bandinfos);
if (!(tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)))) {
if (!(tcmpt->rlvls = jas_alloc2(tcmpt->numrlvls, sizeof(jpc_enc_rlvl_t)))) {
goto error;
}
for (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls;
@ -2213,7 +2213,7 @@ static jpc_enc_rlvl_t *rlvl_create(jpc_enc_rlvl_t *rlvl, jpc_enc_cp_t *cp,
rlvl->numvprcs = JPC_FLOORDIVPOW2(brprcbry - tlprctly, rlvl->prcheightexpn);
rlvl->numprcs = rlvl->numhprcs * rlvl->numvprcs;
if (!(rlvl->bands = jas_malloc(rlvl->numbands * sizeof(jpc_enc_band_t)))) {
if (!(rlvl->bands = jas_alloc2(rlvl->numbands, sizeof(jpc_enc_band_t)))) {
goto error;
}
for (bandno = 0, band = rlvl->bands; bandno < rlvl->numbands;
@ -2290,7 +2290,7 @@ if (bandinfo->xstart != bandinfo->xend && bandinfo->ystart != bandinfo->yend) {
band->synweight = bandinfo->synenergywt;
if (band->data) {
if (!(band->prcs = jas_malloc(rlvl->numprcs * sizeof(jpc_enc_prc_t)))) {
if (!(band->prcs = jas_alloc2(rlvl->numprcs, sizeof(jpc_enc_prc_t)))) {
goto error;
}
for (prcno = 0, prc = band->prcs; prcno < rlvl->numprcs; ++prcno,
@ -2422,7 +2422,7 @@ if (!rlvlno) {
goto error;
}
if (!(prc->cblks = jas_malloc(prc->numcblks * sizeof(jpc_enc_cblk_t)))) {
if (!(prc->cblks = jas_alloc2(prc->numcblks, sizeof(jpc_enc_cblk_t)))) {
goto error;
}
for (cblkno = 0, cblk = prc->cblks; cblkno < prc->numcblks;

View File

@ -118,7 +118,7 @@ jpc_mqdec_t *jpc_mqdec_create(int maxctxs, jas_stream_t *in)
mqdec->in = in;
mqdec->maxctxs = maxctxs;
/* Allocate memory for the per-context state information. */
if (!(mqdec->ctxs = jas_malloc(mqdec->maxctxs * sizeof(jpc_mqstate_t *)))) {
if (!(mqdec->ctxs = jas_alloc2(mqdec->maxctxs, sizeof(jpc_mqstate_t *)))) {
goto error;
}
/* Set the current context to the first context. */

View File

@ -197,7 +197,7 @@ jpc_mqenc_t *jpc_mqenc_create(int maxctxs, jas_stream_t *out)
mqenc->maxctxs = maxctxs;
/* Allocate memory for the per-context state information. */
if (!(mqenc->ctxs = jas_malloc(mqenc->maxctxs * sizeof(jpc_mqstate_t *)))) {
if (!(mqenc->ctxs = jas_alloc2(mqenc->maxctxs, sizeof(jpc_mqstate_t *)))) {
goto error;
}

View File

@ -94,14 +94,14 @@
#define QMFB_SPLITBUFSIZE 4096
#define QMFB_JOINBUFSIZE 4096
int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int jpc_ft_analyze(int *a, int xstart, int ystart, int width, int height,
int stride);
int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
int stride);
int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int jpc_ns_analyze(int *a, int xstart, int ystart, int width, int height,
int stride);
int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
int jpc_ns_synthesize(int *a, int xstart, int ystart, int width,
int height, int stride);
void jpc_ft_fwdlift_row(jpc_fix_t *a, int numcols, int parity);
@ -321,7 +321,7 @@ void jpc_qmfb_split_row(jpc_fix_t *a, int numcols, int parity)
#if !defined(HAVE_VLA)
/* Get a buffer. */
if (bufsize > QMFB_SPLITBUFSIZE) {
if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide in this case. */
abort();
}
@ -389,7 +389,7 @@ void jpc_qmfb_split_col(jpc_fix_t *a, int numrows, int stride,
#if !defined(HAVE_VLA)
/* Get a buffer. */
if (bufsize > QMFB_SPLITBUFSIZE) {
if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide in this case. */
abort();
}
@ -460,7 +460,7 @@ void jpc_qmfb_split_colgrp(jpc_fix_t *a, int numrows, int stride,
#if !defined(HAVE_VLA)
/* Get a buffer. */
if (bufsize > QMFB_SPLITBUFSIZE) {
if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide in this case. */
abort();
}
@ -549,7 +549,7 @@ void jpc_qmfb_split_colres(jpc_fix_t *a, int numrows, int numcols,
#if !defined(HAVE_VLA)
/* Get a buffer. */
if (bufsize > QMFB_SPLITBUFSIZE) {
if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide in this case. */
abort();
}
@ -633,7 +633,7 @@ void jpc_qmfb_join_row(jpc_fix_t *a, int numcols, int parity)
#if !defined(HAVE_VLA)
/* Allocate memory for the join buffer from the heap. */
if (bufsize > QMFB_JOINBUFSIZE) {
if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide. */
abort();
}
@ -698,7 +698,7 @@ void jpc_qmfb_join_col(jpc_fix_t *a, int numrows, int stride,
#if !defined(HAVE_VLA)
/* Allocate memory for the join buffer from the heap. */
if (bufsize > QMFB_JOINBUFSIZE) {
if (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide. */
abort();
}
@ -766,7 +766,7 @@ void jpc_qmfb_join_colgrp(jpc_fix_t *a, int numrows, int stride,
#if !defined(HAVE_VLA)
/* Allocate memory for the join buffer from the heap. */
if (bufsize > QMFB_JOINBUFSIZE) {
if (!(buf = jas_malloc(bufsize * JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc2(bufsize, JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide. */
abort();
}
@ -852,7 +852,7 @@ void jpc_qmfb_join_colres(jpc_fix_t *a, int numrows, int numcols,
#if !defined(HAVE_VLA)
/* Allocate memory for the join buffer from the heap. */
if (bufsize > QMFB_JOINBUFSIZE) {
if (!(buf = jas_malloc(bufsize * numcols * sizeof(jpc_fix_t)))) {
if (!(buf = jas_alloc3(bufsize, numcols, sizeof(jpc_fix_t)))) {
/* We have no choice but to commit suicide. */
abort();
}
@ -1556,7 +1556,7 @@ void jpc_ft_invlift_colres(jpc_fix_t *a, int numrows, int numcols, int stride,
}
int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int jpc_ft_analyze(int *a, int xstart, int ystart, int width, int height,
int stride)
{
int numrows = height;
@ -1568,7 +1568,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int maxcols;
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);
jpc_ft_fwdlift_colgrp(startptr, numrows, stride, rowparity);
@ -1581,7 +1581,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
rowparity);
}
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) {
jpc_qmfb_split_row(startptr, numcols, colparity);
jpc_ft_fwdlift_row(startptr, numcols, colparity);
@ -1604,7 +1604,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
jpc_fix_t *startptr;
int i;
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) {
jpc_ft_invlift_row(startptr, numcols, colparity);
jpc_qmfb_join_row(startptr, numcols, colparity);
@ -1612,7 +1612,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
}
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_ft_invlift_colgrp(startptr, numrows, stride, rowparity);
jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity);
@ -3068,7 +3068,7 @@ void jpc_ns_invlift_col(jpc_fix_t *a, int numrows, int stride,
}
int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int jpc_ns_analyze(int *a, int xstart, int ystart, int width, int height,
int stride)
{
@ -3081,7 +3081,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
int maxcols;
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);
jpc_ns_fwdlift_colgrp(startptr, numrows, stride, rowparity);
@ -3094,7 +3094,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
rowparity);
}
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) {
jpc_qmfb_split_row(startptr, numcols, colparity);
jpc_ns_fwdlift_row(startptr, numcols, colparity);
@ -3105,7 +3105,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
}
int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
int jpc_ns_synthesize(int *a, int xstart, int ystart, int width,
int height, int stride)
{
@ -3117,7 +3117,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
jpc_fix_t *startptr;
int i;
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < numrows; ++i) {
jpc_ns_invlift_row(startptr, numcols, colparity);
jpc_qmfb_join_row(startptr, numcols, colparity);
@ -3125,7 +3125,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
}
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
startptr = &a[0];
startptr = (jpc_fix_t*)&a[0];
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
jpc_ns_invlift_colgrp(startptr, numrows, stride, rowparity);
jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity);

View File

@ -219,7 +219,7 @@ int jpc_enc_enccblk(jpc_enc_t *enc, jas_stream_t *out, jpc_enc_tcmpt_t *tcmpt, j
cblk->numpasses = (cblk->numbps > 0) ? (3 * cblk->numbps - 2) : 0;
if (cblk->numpasses > 0) {
cblk->passes = jas_malloc(cblk->numpasses * sizeof(jpc_enc_pass_t));
cblk->passes = jas_alloc2(cblk->numpasses, sizeof(jpc_enc_pass_t));
assert(cblk->passes);
} else {
cblk->passes = 0;

View File

@ -573,7 +573,7 @@ int jpc_pchglist_insert(jpc_pchglist_t *pchglist, int pchgno, jpc_pchg_t *pchg)
}
if (pchglist->numpchgs >= pchglist->maxpchgs) {
newmaxpchgs = pchglist->maxpchgs + 128;
if (!(newpchgs = jas_realloc(pchglist->pchgs, newmaxpchgs * sizeof(jpc_pchg_t *)))) {
if (!(newpchgs = jas_realloc2(pchglist->pchgs, newmaxpchgs, sizeof(jpc_pchg_t *)))) {
return -1;
}
pchglist->maxpchgs = newmaxpchgs;

View File

@ -478,7 +478,7 @@ jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *dec, jpc_dec_tile_t *tile)
return 0;
}
pi->numcomps = dec->numcomps;
if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
if (!(pi->picomps = jas_alloc2(pi->numcomps, sizeof(jpc_picomp_t)))) {
jpc_pi_destroy(pi);
return 0;
}
@ -490,7 +490,7 @@ jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *dec, jpc_dec_tile_t *tile)
for (compno = 0, tcomp = tile->tcomps, picomp = pi->picomps;
compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
picomp->numrlvls = tcomp->numrlvls;
if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
if (!(picomp->pirlvls = jas_alloc2(picomp->numrlvls,
sizeof(jpc_pirlvl_t)))) {
jpc_pi_destroy(pi);
return 0;
@ -503,7 +503,7 @@ jpc_pi_t *jpc_dec_pi_create(jpc_dec_t *dec, jpc_dec_tile_t *tile)
rlvlno < picomp->numrlvls; ++rlvlno, ++pirlvl, ++rlvl) {
/* XXX sizeof(long) should be sizeof different type */
pirlvl->numprcs = rlvl->numprcs;
if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
if (!(pirlvl->prclyrnos = jas_alloc2(pirlvl->numprcs,
sizeof(long)))) {
jpc_pi_destroy(pi);
return 0;

View File

@ -565,7 +565,7 @@ jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t *cp, jpc_enc_tile_t *tile)
}
pi->pktno = -1;
pi->numcomps = cp->numcmpts;
if (!(pi->picomps = jas_malloc(pi->numcomps * sizeof(jpc_picomp_t)))) {
if (!(pi->picomps = jas_alloc2(pi->numcomps, sizeof(jpc_picomp_t)))) {
jpc_pi_destroy(pi);
return 0;
}
@ -577,7 +577,7 @@ jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t *cp, jpc_enc_tile_t *tile)
for (compno = 0, tcomp = tile->tcmpts, picomp = pi->picomps;
compno < pi->numcomps; ++compno, ++tcomp, ++picomp) {
picomp->numrlvls = tcomp->numrlvls;
if (!(picomp->pirlvls = jas_malloc(picomp->numrlvls *
if (!(picomp->pirlvls = jas_alloc2(picomp->numrlvls,
sizeof(jpc_pirlvl_t)))) {
jpc_pi_destroy(pi);
return 0;
@ -591,7 +591,7 @@ jpc_pi_t *jpc_enc_pi_create(jpc_enc_cp_t *cp, jpc_enc_tile_t *tile)
/* XXX sizeof(long) should be sizeof different type */
pirlvl->numprcs = rlvl->numprcs;
if (rlvl->numprcs) {
if (!(pirlvl->prclyrnos = jas_malloc(pirlvl->numprcs *
if (!(pirlvl->prclyrnos = jas_alloc2(pirlvl->numprcs,
sizeof(long)))) {
jpc_pi_destroy(pi);
return 0;

View File

@ -125,7 +125,7 @@ jpc_tagtree_t *jpc_tagtree_create(int numleafsh, int numleafsv)
++numlvls;
} while (n > 1);
if (!(tree->nodes_ = jas_malloc(tree->numnodes_ * sizeof(jpc_tagtreenode_t)))) {
if (!(tree->nodes_ = jas_alloc2(tree->numnodes_, sizeof(jpc_tagtreenode_t)))) {
return 0;
}

View File

@ -109,7 +109,7 @@ int jpc_atoaf(char *s, int *numvalues, double **values)
}
if (n) {
if (!(vs = jas_malloc(n * sizeof(double)))) {
if (!(vs = jas_alloc2(n, sizeof(double)))) {
return -1;
}

View File

@ -9,7 +9,7 @@
/*#undef const*/
#undef CHAR_IS_UNSIGNED
#if !defined WIN32 && !defined _WIN32
#if defined __MINGW__ || defined __MINGW32__ || (!defined WIN32 && !defined _WIN32)
#define HAVE_STDDEF_H
#define HAVE_STDLIB_H
#endif

3906
3rdparty/libpng/CHANGES vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,18 +2,35 @@
# CMake file for libpng. See root CMakeLists.txt
#
# ----------------------------------------------------------------------------
project(${PNG_LIBRARY})
if(NEON)
project(${PNG_LIBRARY} ASM)
else()
project(${PNG_LIBRARY})
endif()
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIR})
file(GLOB lib_srcs *.c)
file(GLOB lib_hdrs *.h)
if(NEON)
list(APPEND lib_srcs arm/filter_neon.S)
add_definitions(-DPNG_ARM_NEON)
endif()
# ----------------------------------------------------------------------------------
# Define the library target:
# ----------------------------------------------------------------------------------
add_definitions(-DPNG_CONFIGURE_LIBPNG)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC)
add_library(${PNG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
target_link_libraries(${PNG_LIBRARY} ${ZLIB_LIBRARY})
if(UNIX)
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)

111
3rdparty/libpng/LICENSE vendored Normal file
View File

@ -0,0 +1,111 @@
This copy of the libpng notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.5.12, July 11, 2012, are
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
Simon-Pierre Cadieux
Eric S. Raymond
Gilles Vollant
and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
John Bowler
Kevin Bracey
Sam Bushell
Magnus Holmgren
Greg Roelofs
Tom Tanner
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
Andreas Dilger
Dave Martindale
Guy Eric Schalnat
Paul Schmidt
Tim Wegner
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
printf("%s",png_get_copyright(NULL));
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
July 11, 2012

View File

@ -1,4 +1,4 @@
README for libpng version 1.5.9 - February 18, 2012 (shared library 15.0)
README for libpng version 1.5.12 - July 11, 2012 (shared library 15.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.

225
3rdparty/libpng/arm/filter_neon.S vendored Normal file
View File

@ -0,0 +1,225 @@
/* filter_neon.S - NEON optimised filter functions
*
* Copyright (c) 2011 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
#ifdef __ELF__
# define ELF
#else
# define ELF @
#endif
.arch armv7-a
.fpu neon
.macro func name, export=0
.macro endfunc
ELF .size \name, . - \name
.endfunc
.purgem endfunc
.endm
.text
.if \export
.global \name
.endif
ELF .type \name, STT_FUNC
.func \name
\name:
.endm
func png_read_filter_row_sub4_neon, export=1
ldr r3, [r0, #4] @ rowbytes
vmov.i8 d3, #0
1:
vld4.32 {d4[],d5[],d6[],d7[]}, [r1]
vadd.u8 d0, d3, d4
vadd.u8 d1, d0, d5
vadd.u8 d2, d1, d6
vadd.u8 d3, d2, d7
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1]!
subs r3, r3, #16
bgt 1b
bx lr
endfunc
func png_read_filter_row_sub3_neon, export=1
ldr r3, [r0, #4] @ rowbytes
vmov.i8 d3, #0
mov r0, r1
mov r2, #3
mov r12, #12
vld1.8 {q11}, [r0], r12
1:
vext.8 d5, d22, d23, #3
vadd.u8 d0, d3, d22
vext.8 d6, d22, d23, #6
vadd.u8 d1, d0, d5
vext.8 d7, d23, d23, #1
vld1.8 {q11}, [r0], r12
vst1.32 {d0[0]}, [r1], r2
vadd.u8 d2, d1, d6
vst1.32 {d1[0]}, [r1], r2
vadd.u8 d3, d2, d7
vst1.32 {d2[0]}, [r1], r2
vst1.32 {d3[0]}, [r1], r2
subs r3, r3, #12
bgt 1b
bx lr
endfunc
func png_read_filter_row_up_neon, export=1
ldr r3, [r0, #4] @ rowbytes
1:
vld1.8 {q0}, [r1]
vld1.8 {q1}, [r2]!
vadd.u8 q0, q0, q1
vst1.8 {q0}, [r1]!
subs r3, r3, #16
bgt 1b
bx lr
endfunc
func png_read_filter_row_avg4_neon, export=1
ldr r12, [r0, #4] @ rowbytes
vmov.i8 d3, #0
1:
vld4.32 {d4[],d5[],d6[],d7[]}, [r1]
vld4.32 {d16[],d17[],d18[],d19[]},[r2]!
vhadd.u8 d0, d3, d16
vadd.u8 d0, d0, d4
vhadd.u8 d1, d0, d17
vadd.u8 d1, d1, d5
vhadd.u8 d2, d1, d18
vadd.u8 d2, d2, d6
vhadd.u8 d3, d2, d19
vadd.u8 d3, d3, d7
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1]!
subs r12, r12, #16
bgt 1b
bx lr
endfunc
func png_read_filter_row_avg3_neon, export=1
push {r4,lr}
ldr r12, [r0, #4] @ rowbytes
vmov.i8 d3, #0
mov r0, r1
mov r4, #3
mov lr, #12
vld1.8 {q11}, [r0], lr
1:
vld1.8 {q10}, [r2], lr
vext.8 d5, d22, d23, #3
vhadd.u8 d0, d3, d20
vext.8 d17, d20, d21, #3
vadd.u8 d0, d0, d22
vext.8 d6, d22, d23, #6
vhadd.u8 d1, d0, d17
vext.8 d18, d20, d21, #6
vadd.u8 d1, d1, d5
vext.8 d7, d23, d23, #1
vld1.8 {q11}, [r0], lr
vst1.32 {d0[0]}, [r1], r4
vhadd.u8 d2, d1, d18
vst1.32 {d1[0]}, [r1], r4
vext.8 d19, d21, d21, #1
vadd.u8 d2, d2, d6
vhadd.u8 d3, d2, d19
vst1.32 {d2[0]}, [r1], r4
vadd.u8 d3, d3, d7
vst1.32 {d3[0]}, [r1], r4
subs r12, r12, #12
bgt 1b
pop {r4,pc}
endfunc
.macro paeth rx, ra, rb, rc
vaddl.u8 q12, \ra, \rb @ a + b
vaddl.u8 q15, \rc, \rc @ 2*c
vabdl.u8 q13, \rb, \rc @ pa
vabdl.u8 q14, \ra, \rc @ pb
vabd.u16 q15, q12, q15 @ pc
vcle.u16 q12, q13, q14 @ pa <= pb
vcle.u16 q13, q13, q15 @ pa <= pc
vcle.u16 q14, q14, q15 @ pb <= pc
vand q12, q12, q13 @ pa <= pb && pa <= pc
vmovn.u16 d28, q14
vmovn.u16 \rx, q12
vbsl d28, \rb, \rc
vbsl \rx, \ra, d28
.endm
func png_read_filter_row_paeth4_neon, export=1
ldr r12, [r0, #4] @ rowbytes
vmov.i8 d3, #0
vmov.i8 d20, #0
1:
vld4.32 {d4[],d5[],d6[],d7[]}, [r1]
vld4.32 {d16[],d17[],d18[],d19[]},[r2]!
paeth d0, d3, d16, d20
vadd.u8 d0, d0, d4
paeth d1, d0, d17, d16
vadd.u8 d1, d1, d5
paeth d2, d1, d18, d17
vadd.u8 d2, d2, d6
paeth d3, d2, d19, d18
vmov d20, d19
vadd.u8 d3, d3, d7
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1]!
subs r12, r12, #16
bgt 1b
bx lr
endfunc
func png_read_filter_row_paeth3_neon, export=1
push {r4,lr}
ldr r12, [r0, #4] @ rowbytes
vmov.i8 d3, #0
vmov.i8 d4, #0
mov r0, r1
mov r4, #3
mov lr, #12
vld1.8 {q11}, [r0], lr
1:
vld1.8 {q10}, [r2], lr
paeth d0, d3, d20, d4
vext.8 d5, d22, d23, #3
vadd.u8 d0, d0, d22
vext.8 d17, d20, d21, #3
paeth d1, d0, d17, d20
vst1.32 {d0[0]}, [r1], r4
vext.8 d6, d22, d23, #6
vadd.u8 d1, d1, d5
vext.8 d18, d20, d21, #6
paeth d2, d1, d18, d17
vext.8 d7, d23, d23, #1
vld1.8 {q11}, [r0], lr
vst1.32 {d1[0]}, [r1], r4
vadd.u8 d2, d2, d6
vext.8 d19, d21, d21, #1
paeth d3, d2, d19, d18
vst1.32 {d2[0]}, [r1], r4
vmov d4, d19
vadd.u8 d3, d3, d7
vst1.32 {d3[0]}, [r1], r4
subs r12, r12, #12
bgt 1b
pop {r4,pc}
endfunc

40
3rdparty/libpng/png.c vendored
View File

@ -1,8 +1,8 @@
/* png.c - location for general purpose libpng functions
*
* Last changed in libpng 1.5.7 [December 15, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.11 [June 14, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_5_9 Your_png_h_is_not_version_1_5_9;
typedef png_libpng_version_1_5_12 Your_png_h_is_not_version_1_5_12;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@ -655,14 +655,14 @@ png_get_copyright(png_const_structp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.5.9 - February 18, 2012" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2011 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"libpng version 1.5.12 - July 11, 2012" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.5.9 - February 18, 2012\
Copyright (c) 1998-2011 Glenn Randers-Pehrson\
return "libpng version 1.5.12 - July 11, 2012\
Copyright (c) 1998-2012 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
# endif
@ -969,8 +969,8 @@ int png_XYZ_from_xy(png_XYZ *XYZ, png_xy xy)
* and it is certain that it becomes unstable where the end points are close
* together.
*
* So this code uses the perhaps slighly less optimal but more understandable
* and totally obvious approach of calculating color-scale.
* So this code uses the perhaps slightly less optimal but more
* understandable and totally obvious approach of calculating color-scale.
*
* This algorithm depends on the precision in white-scale and that is
* (1/white-y), so we can immediately see that as white-y approaches 0 the
@ -1467,7 +1467,7 @@ static double
png_pow10(int power)
{
int recip = 0;
double d = 1;
double d = 1.0;
/* Handle negative exponent with a reciprocal at the end because
* 10 is exact whereas .1 is inexact in base 2
@ -1481,7 +1481,7 @@ png_pow10(int power)
if (power > 0)
{
/* Decompose power bitwise. */
double mult = 10;
double mult = 10.0;
do
{
if (power & 1) d *= mult;
@ -1600,7 +1600,8 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
{
double d;
fp *= 10;
fp *= 10.0;
/* Use modf here, not floor and subtract, so that
* the separation is done in one step. At the end
* of the loop don't break the number into parts so
@ -1613,7 +1614,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
{
d = floor(fp + .5);
if (d > 9)
if (d > 9.0)
{
/* Rounding up to 10, handle that here. */
if (czero > 0)
@ -1621,9 +1622,10 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
--czero, d = 1;
if (cdigits == 0) --clead;
}
else
{
while (cdigits > 0 && d > 9)
while (cdigits > 0 && d > 9.0)
{
int ch = *--ascii;
@ -1648,7 +1650,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
* exponent but take into account the leading
* decimal point.
*/
if (d > 9) /* cdigits == 0 */
if (d > 9.0) /* cdigits == 0 */
{
if (exp_b10 == (-1))
{
@ -1669,18 +1671,19 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
++exp_b10;
/* In all cases we output a '1' */
d = 1;
d = 1.0;
}
}
}
fp = 0; /* Guarantees termination below. */
}
if (d == 0)
if (d == 0.0)
{
++czero;
if (cdigits == 0) ++clead;
}
else
{
/* Included embedded zeros in the digit count. */
@ -1708,6 +1711,7 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
above */
--exp_b10;
}
*ascii++ = (char)(48 + (int)d), ++cdigits;
}
}
@ -2040,7 +2044,7 @@ png_muldiv_warn(png_structp png_ptr, png_fixed_point a, png_int_32 times,
}
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gammma */
#ifdef PNG_READ_GAMMA_SUPPORTED /* more fixed point functions for gamma */
/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */
png_fixed_point
png_reciprocal(png_fixed_point a)

41
3rdparty/libpng/png.h vendored
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.5.9 - February 18, 2012
* libpng version 1.5.12 - July 11, 2012
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.5.9 - February 18, 2012: Glenn
* libpng versions 0.97, January 1998, through 1.5.12 - July 11, 2012: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -172,6 +172,12 @@
* 1.5.9beta01-02 15 10509 15.so.15.9[.0]
* 1.5.9rc01 15 10509 15.so.15.9[.0]
* 1.5.9 15 10509 15.so.15.9[.0]
* 1.5.10beta01-05 15 10510 15.so.15.10[.0]
* 1.5.10 15 10510 15.so.15.10[.0]
* 1.5.11beta01 15 10511 15.so.15.11[.0]
* 1.5.11rc01-05 15 10511 15.so.15.11[.0]
* 1.5.11 15 10511 15.so.15.11[.0]
* 1.5.12 15 10512 15.so.15.12[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@ -181,7 +187,7 @@
* to the source version x.y.z (leading zeros in y and z). Beta versions
* were given the previous public release number plus a letter, until
* version 1.0.6j; from then on they were given the upcoming public
* release number plus "betaNN" or "rcN".
* release number plus "betaNN" or "rcNN".
*
* Binary incompatibility exists only when applications make direct access
* to the info_ptr or png_ptr members through png.h, and the compiled
@ -203,7 +209,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.5.9, February 18, 2012, are
* libpng versions 1.2.6, August 15, 2004, through 1.5.12, July 11, 2012, are
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@ -315,13 +321,13 @@
* Y2K compliance in libpng:
* =========================
*
* February 18, 2012
* July 11, 2012
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
* upward through 1.5.9 are Y2K compliant. It is my belief that
* upward through 1.5.12 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@ -332,7 +338,8 @@
* "png_uint_16 year" in png_time_struct.
*
* The string is
* "png_char time_buffer" in png_struct
* "char time_buffer[29]" in png_struct. This will be no
* longer used in libpng-1.6.0 and will be removed from libpng-1.7.0.
*
* There are seven time-related functions:
* png.c: png_convert_to_rfc_1123() in png.c
@ -379,9 +386,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.5.9"
#define PNG_LIBPNG_VER_STRING "1.5.12"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.5.9 - February 18, 2012\n"
" libpng version 1.5.12 - July 11, 2012\n"
#define PNG_LIBPNG_VER_SONUM 15
#define PNG_LIBPNG_VER_DLLNUM 15
@ -389,7 +396,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 5
#define PNG_LIBPNG_VER_RELEASE 9
#define PNG_LIBPNG_VER_RELEASE 12
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@ -412,7 +419,7 @@
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros.
@ -420,7 +427,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
#define PNG_LIBPNG_VER 10509 /* 1.5.9 */
#define PNG_LIBPNG_VER 10512 /* 1.5.12 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@ -542,7 +549,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_5_9;
typedef char* png_libpng_version_1_5_12;
/* Three color definitions. The order of the red, green, and blue, (and the
* exact size) is not important, although the size of the fields need to
@ -2637,6 +2644,12 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
: (png_int_32)png_get_uint_32(buf)))
#endif
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
PNG_EXPORT(234, void, png_set_check_for_invalid_index, (png_structp png_ptr,
int allowed));
#endif
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
*/
@ -2646,7 +2659,7 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
* scripts/symbols.def as well.
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(233);
PNG_EXPORT_LAST_ORDINAL(234);
#endif
#ifdef __cplusplus

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.5.9 - February 18, 2012
* libpng version 1.5.12 - July 11, 2012
*
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -25,7 +25,7 @@
#ifndef PNG_BUILDING_SYMBOL_TABLE
/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C
* definition file for machine specific limits, this may impact the
* correctness of the definitons below (see uses of INT_MAX).
* correctness of the definitions below (see uses of INT_MAX).
*/
# ifndef PNG_NO_LIMITS_H
# include <limits.h>
@ -51,8 +51,8 @@
/* This controls optimization of the reading of 16 and 32 bit values
* from PNG files. It can be set on a per-app-file basis - it
* just changes whether a macro is used to the function is called.
* The library builder sets the default, if read functions are not
* just changes whether a macro is used when the function is called.
* The library builder sets the default; if read functions are not
* built into the library the macro implementation is forced on.
*/
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED

View File

@ -2,7 +2,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.5.8 [February 1, 2011]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*

View File

@ -3,9 +3,9 @@
/* pnglibconf.h - library build configuration */
/* Libpng 1.5.9 - February 18, 2012 */
/* Libpng 1.5.12 - July 11, 2012 */
/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */
@ -31,10 +31,6 @@
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_sCAL_PRECISION 5
#define PNG_USER_CHUNK_CACHE_MAX 0
#define PNG_USER_CHUNK_MALLOC_MAX 0
#define PNG_USER_HEIGHT_MAX 1000000
#define PNG_USER_WIDTH_MAX 1000000
#define PNG_WEIGHT_SHIFT 8
#define PNG_ZBUF_SIZE 8192
/* end of settings */
@ -45,6 +41,7 @@
#define PNG_bKGD_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_CHECK_cHRM_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
@ -74,6 +71,7 @@
#define PNG_READ_BACKGROUND_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
@ -145,6 +143,7 @@
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED

View File

@ -1,8 +1,8 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.5.9 [February 18, 2012]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.11 [June 14, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -128,30 +128,6 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr)
break;
}
#ifdef PNG_READ_tEXt_SUPPORTED
case PNG_READ_tEXt_MODE:
{
png_push_read_tEXt(png_ptr, info_ptr);
break;
}
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
case PNG_READ_zTXt_MODE:
{
png_push_read_zTXt(png_ptr, info_ptr);
break;
}
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
case PNG_READ_iTXt_MODE:
{
png_push_read_iTXt(png_ptr, info_ptr);
break;
}
#endif
case PNG_SKIP_MODE:
{
png_push_crc_finish(png_ptr);
@ -176,7 +152,7 @@ void /* PRIVATE */
png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
{
png_size_t num_checked = png_ptr->sig_bytes,
num_to_check = 8 - num_checked;
num_to_check = 8 - num_checked;
if (png_ptr->buffer_size < num_to_check)
{
@ -196,6 +172,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr)
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
}
else
{
if (png_ptr->sig_bytes >= 8)
@ -305,8 +282,8 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_error(png_ptr, "Missing PLTE before IDAT");
}
}
#endif
else if (chunk_name == png_PLTE)
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
@ -543,7 +520,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
return;
}
png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
@ -556,7 +533,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
return;
}
png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
@ -569,10 +546,11 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
return;
}
png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
else
{
if (png_ptr->push_length + 4 > png_ptr->buffer_size)
@ -580,7 +558,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
png_push_save_buffer(png_ptr);
return;
}
png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
}
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
@ -620,6 +598,7 @@ png_push_crc_finish(png_structp png_ptr)
png_ptr->save_buffer_size -= save_size;
png_ptr->save_buffer_ptr += save_size;
}
if (png_ptr->skip_length && png_ptr->current_buffer_size)
{
png_size_t save_size = png_ptr->current_buffer_size;
@ -641,6 +620,7 @@ png_push_crc_finish(png_structp png_ptr)
png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += save_size;
}
if (!png_ptr->skip_length)
{
if (png_ptr->buffer_size < 4)
@ -663,6 +643,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
return;
ptr = buffer;
if (png_ptr->save_buffer_size)
{
png_size_t save_size;
@ -680,6 +661,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
png_ptr->save_buffer_size -= save_size;
png_ptr->save_buffer_ptr += save_size;
}
if (length && png_ptr->current_buffer_size)
{
png_size_t save_size;
@ -709,6 +691,7 @@ png_push_save_buffer(png_structp png_ptr)
png_bytep dp;
istop = png_ptr->save_buffer_size;
for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer;
i < istop; i++, sp++, dp++)
{
@ -716,6 +699,7 @@ png_push_save_buffer(png_structp png_ptr)
}
}
}
if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
png_ptr->save_buffer_max)
{
@ -742,6 +726,7 @@ png_push_save_buffer(png_structp png_ptr)
png_free(png_ptr, old_buffer);
png_ptr->save_buffer_max = new_max;
}
if (png_ptr->current_buffer_size)
{
png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size,
@ -749,6 +734,7 @@ png_push_save_buffer(png_structp png_ptr)
png_ptr->save_buffer_size += png_ptr->current_buffer_size;
png_ptr->current_buffer_size = 0;
}
png_ptr->save_buffer_ptr = png_ptr->save_buffer;
png_ptr->buffer_size = 0;
}
@ -850,6 +836,7 @@ png_push_read_IDAT(png_structp png_ptr)
png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += save_size;
}
if (!png_ptr->idat_size)
{
if (png_ptr->buffer_size < 4)
@ -1263,521 +1250,6 @@ png_read_push_finish_row(png_structp png_ptr)
#endif /* PNG_READ_INTERLACING_SUPPORTED */
}
#ifdef PNG_READ_tEXt_SUPPORTED
void /* PRIVATE */
png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
length)
{
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
png_error(png_ptr, "Out of place tEXt");
/* NOT REACHED */
}
#ifdef PNG_MAX_MALLOC_64K
png_ptr->skip_length = 0; /* This may not be necessary */
if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
{
png_warning(png_ptr, "tEXt chunk too large to fit in memory");
png_ptr->skip_length = length - (png_uint_32)65535L;
length = (png_uint_32)65535L;
}
#endif
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_tEXt_MODE;
}
void /* PRIVATE */
png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr->buffer_size && png_ptr->current_text_left)
{
png_size_t text_size;
if (png_ptr->buffer_size < png_ptr->current_text_left)
text_size = png_ptr->buffer_size;
else
text_size = png_ptr->current_text_left;
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
png_ptr->current_text_left -= text_size;
png_ptr->current_text_ptr += text_size;
}
if (!(png_ptr->current_text_left))
{
png_textp text_ptr;
png_charp text;
png_charp key;
int ret;
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_crc_finish(png_ptr);
#ifdef PNG_MAX_MALLOC_64K
if (png_ptr->skip_length)
return;
#endif
key = png_ptr->current_text;
for (text = key; *text; text++)
/* Empty loop */ ;
if (text < key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr, png_sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr->key = key;
text_ptr->itxt_length = 0;
text_ptr->lang = NULL;
text_ptr->lang_key = NULL;
text_ptr->text = text;
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key);
png_free(png_ptr, text_ptr);
png_ptr->current_text = NULL;
if (ret)
png_warning(png_ptr, "Insufficient memory to store text chunk");
}
}
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
void /* PRIVATE */
png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
length)
{
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
png_error(png_ptr, "Out of place zTXt");
/* NOT REACHED */
}
#ifdef PNG_MAX_MALLOC_64K
/* We can't handle zTXt chunks > 64K, since we don't have enough space
* to be able to store the uncompressed data. Actually, the threshold
* is probably around 32K, but it isn't as definite as 64K is.
*/
if (length > (png_uint_32)65535L)
{
png_warning(png_ptr, "zTXt chunk too large to fit in memory");
png_push_crc_skip(png_ptr, length);
return;
}
#endif
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_zTXt_MODE;
}
void /* PRIVATE */
png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr->buffer_size && png_ptr->current_text_left)
{
png_size_t text_size;
if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left)
text_size = png_ptr->buffer_size;
else
text_size = png_ptr->current_text_left;
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
png_ptr->current_text_left -= text_size;
png_ptr->current_text_ptr += text_size;
}
if (!(png_ptr->current_text_left))
{
png_textp text_ptr;
png_charp text;
png_charp key;
int ret;
png_size_t text_size, key_size;
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_crc_finish(png_ptr);
key = png_ptr->current_text;
for (text = key; *text; text++)
/* Empty loop */ ;
/* zTXt can't have zero text */
if (text >= key + png_ptr->current_text_size)
{
png_ptr->current_text = NULL;
png_free(png_ptr, key);
return;
}
text++;
if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */
{
png_ptr->current_text = NULL;
png_free(png_ptr, key);
return;
}
text++;
png_ptr->zstream.next_in = (png_bytep)text;
png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size -
(text - key));
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
key_size = text - key;
text_size = 0;
text = NULL;
ret = Z_STREAM_END;
while (png_ptr->zstream.avail_in)
{
ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END)
{
inflateReset(&png_ptr->zstream);
png_ptr->zstream.avail_in = 0;
png_ptr->current_text = NULL;
png_free(png_ptr, key);
png_free(png_ptr, text);
return;
}
if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END)
{
if (text == NULL)
{
text = (png_charp)png_malloc(png_ptr,
(png_ptr->zbuf_size
- png_ptr->zstream.avail_out + key_size + 1));
png_memcpy(text + key_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
png_memcpy(text, key, key_size);
text_size = key_size + png_ptr->zbuf_size -
png_ptr->zstream.avail_out;
*(text + text_size) = '\0';
}
else
{
png_charp tmp;
tmp = text;
text = (png_charp)png_malloc(png_ptr, text_size +
(png_ptr->zbuf_size
- png_ptr->zstream.avail_out + 1));
png_memcpy(text, tmp, text_size);
png_free(png_ptr, tmp);
png_memcpy(text + text_size, png_ptr->zbuf,
png_ptr->zbuf_size - png_ptr->zstream.avail_out);
text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
*(text + text_size) = '\0';
}
if (ret != Z_STREAM_END)
{
png_ptr->zstream.next_out = png_ptr->zbuf;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
}
}
else
{
break;
}
if (ret == Z_STREAM_END)
break;
}
inflateReset(&png_ptr->zstream);
png_ptr->zstream.avail_in = 0;
if (ret != Z_STREAM_END)
{
png_ptr->current_text = NULL;
png_free(png_ptr, key);
png_free(png_ptr, text);
return;
}
png_ptr->current_text = NULL;
png_free(png_ptr, key);
key = text;
text += key_size;
text_ptr = (png_textp)png_malloc(png_ptr,
png_sizeof(png_text));
text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt;
text_ptr->key = key;
text_ptr->itxt_length = 0;
text_ptr->lang = NULL;
text_ptr->lang_key = NULL;
text_ptr->text = text;
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_free(png_ptr, key);
png_free(png_ptr, text_ptr);
if (ret)
png_warning(png_ptr, "Insufficient memory to store text chunk");
}
}
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
void /* PRIVATE */
png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32
length)
{
if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND))
{
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
png_error(png_ptr, "Out of place iTXt");
/* NOT REACHED */
}
#ifdef PNG_MAX_MALLOC_64K
png_ptr->skip_length = 0; /* This may not be necessary */
if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */
{
png_warning(png_ptr, "iTXt chunk too large to fit in memory");
png_ptr->skip_length = length - (png_uint_32)65535L;
length = (png_uint_32)65535L;
}
#endif
png_ptr->current_text = (png_charp)png_malloc(png_ptr, length + 1);
png_ptr->current_text[length] = '\0';
png_ptr->current_text_ptr = png_ptr->current_text;
png_ptr->current_text_size = (png_size_t)length;
png_ptr->current_text_left = (png_size_t)length;
png_ptr->process_mode = PNG_READ_iTXt_MODE;
}
void /* PRIVATE */
png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr->buffer_size && png_ptr->current_text_left)
{
png_size_t text_size;
if (png_ptr->buffer_size < png_ptr->current_text_left)
text_size = png_ptr->buffer_size;
else
text_size = png_ptr->current_text_left;
png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size);
png_ptr->current_text_left -= text_size;
png_ptr->current_text_ptr += text_size;
}
if (!(png_ptr->current_text_left))
{
png_textp text_ptr;
png_charp key;
int comp_flag;
png_charp lang;
png_charp lang_key;
png_charp text;
int ret;
if (png_ptr->buffer_size < 4)
{
png_push_save_buffer(png_ptr);
return;
}
png_push_crc_finish(png_ptr);
#ifdef PNG_MAX_MALLOC_64K
if (png_ptr->skip_length)
return;
#endif
key = png_ptr->current_text;
for (lang = key; *lang; lang++)
/* Empty loop */ ;
if (lang < key + png_ptr->current_text_size - 3)
lang++;
comp_flag = *lang++;
lang++; /* Skip comp_type, always zero */
for (lang_key = lang; *lang_key; lang_key++)
/* Empty loop */ ;
lang_key++; /* Skip NUL separator */
text=lang_key;
if (lang_key < key + png_ptr->current_text_size - 1)
{
for (; *text; text++)
/* Empty loop */ ;
}
if (text < key + png_ptr->current_text_size)
text++;
text_ptr = (png_textp)png_malloc(png_ptr,
png_sizeof(png_text));
text_ptr->compression = comp_flag + 2;
text_ptr->key = key;
text_ptr->lang = lang;
text_ptr->lang_key = lang_key;
text_ptr->text = text;
text_ptr->text_length = 0;
text_ptr->itxt_length = png_strlen(text);
ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
png_ptr->current_text = NULL;
png_free(png_ptr, text_ptr);
if (ret)
png_warning(png_ptr, "Insufficient memory to store iTXt chunk");
}
}
#endif
/* This function is called when we haven't found a handler for this
* chunk. If there isn't a problem with the chunk itself (ie a bad chunk
* name or a critical chunk), the chunk is (currently) silently ignored.
*/
void /* PRIVATE */
png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32
length)
{
png_uint_32 skip = 0;
png_uint_32 chunk_name = png_ptr->chunk_name;
if (PNG_CHUNK_CRITICAL(chunk_name))
{
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
&& png_ptr->read_user_chunk_fn == NULL
#endif
)
#endif
png_chunk_error(png_ptr, "unknown critical chunk");
PNG_UNUSED(info_ptr) /* To quiet some compiler warnings */
}
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
/* TODO: the code below is apparently just using the
* png_struct::unknown_chunk member as a temporarily variable, it should be
* possible to eliminate both it and the temporary buffer.
*/
if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
{
#ifdef PNG_MAX_MALLOC_64K
if (length > 65535)
{
png_warning(png_ptr, "unknown chunk too large to fit in memory");
skip = length - 65535;
length = 65535;
}
#endif
/* This is just a record for the user; libpng doesn't use the character
* form of the name.
*/
PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
png_ptr->unknown_chunk.size = length;
if (length == 0)
png_ptr->unknown_chunk.data = NULL;
else
{
png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr,
png_ptr->unknown_chunk.size);
png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data,
png_ptr->unknown_chunk.size);
}
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
if (png_ptr->read_user_chunk_fn != NULL)
{
/* Callback to user unknown chunk handler */
int ret;
ret = (*(png_ptr->read_user_chunk_fn))
(png_ptr, &png_ptr->unknown_chunk);
if (ret < 0)
png_chunk_error(png_ptr, "error in user chunk");
if (ret == 0)
{
if (PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
if (png_chunk_unknown_handling(png_ptr, chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS)
png_chunk_error(png_ptr, "unknown critical chunk");
png_set_unknown_chunks(png_ptr, info_ptr,
&png_ptr->unknown_chunk, 1);
}
}
else
#endif
png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
png_free(png_ptr, png_ptr->unknown_chunk.data);
png_ptr->unknown_chunk.data = NULL;
}
else
#endif
skip=length;
png_push_crc_skip(png_ptr, skip);
}
void /* PRIVATE */
png_push_have_info(png_structp png_ptr, png_infop info_ptr)
{

View File

@ -2,11 +2,11 @@
/* pngpriv.h - private declarations for use inside libpng
*
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.5.7 [December 15, 2011]
* Last changed in libpng 1.5.10 [March 29, 2012]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -133,6 +133,46 @@
# define PNG_DLL_EXPORT
#endif
/* SECURITY and SAFETY:
*
* By default libpng is built without any internal limits on image size,
* individual heap (png_malloc) allocations or the total amount of memory used.
* If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used
* (unless individually overridden). These limits are believed to be fairly
* safe, but builders of secure systems should verify the values against the
* real system capabilities.
*/
#ifdef PNG_SAFE_LIMITS_SUPPORTED
/* 'safe' limits */
# ifndef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 1000000
# endif
# ifndef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 1000000
# endif
# ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 128
# endif
# ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 8000000
# endif
#else
/* values for no limits */
# ifndef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 0x7fffffff
# endif
# ifndef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 0x7fffffff
# endif
# ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 0
# endif
# ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 0
# endif
#endif
/* This is used for 16 bit gamma tables - only the top level pointers are const,
* this could be changed:
*/
@ -426,6 +466,7 @@ typedef PNG_CONST png_uint_16p FAR * png_const_uint_16pp;
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
#define PNG_HAVE_iCCP 0x4000
/* Flags for the transformations the PNG library does on the image data */
#define PNG_BGR 0x0001
@ -1218,10 +1259,8 @@ PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
png_uint_32 length));
#endif
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
png_infop info_ptr, png_uint_32 length));
#endif
PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
png_uint_32 chunk_name));
@ -1355,6 +1394,13 @@ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr,
int color_type, int interlace_type, int compression_type,
int filter_type));
/* Added at libpng version 1.5.10 */
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
PNG_EXTERN void png_do_check_palette_indexes PNGARG((png_structp png_ptr,
png_row_infop row_info));
#endif
/* Free all memory used by the read (old method - NOT DLL EXPORTED) */
PNG_EXTERN void png_read_destroy PNGARG((png_structp png_ptr,
png_infop info_ptr, png_infop end_info_ptr));

View File

@ -1,8 +1,8 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.5.7 [December 15, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.10 [March 8, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -67,15 +67,11 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_ptr->user_width_max = PNG_USER_WIDTH_MAX;
png_ptr->user_height_max = PNG_USER_HEIGHT_MAX;
# ifdef PNG_USER_CHUNK_CACHE_MAX
/* Added at libpng-1.2.43 and 1.4.0 */
png_ptr->user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
# endif
# ifdef PNG_SET_USER_CHUNK_MALLOC_MAX
/* Added at libpng-1.2.43 and 1.4.1 */
png_ptr->user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
# endif
#endif
#ifdef PNG_SETJMP_SUPPORTED
@ -805,6 +801,13 @@ png_read_end(png_structp png_ptr, png_infop info_ptr)
png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Report invalid palette index; added at libng-1.5.10 */
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
png_ptr->num_palette_max > png_ptr->num_palette)
png_benign_error(png_ptr, "Read palette index exceeding num_palette");
#endif
do
{
png_uint_32 length = png_read_chunk_header(png_ptr);
@ -1070,12 +1073,6 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr,
png_free(png_ptr, png_ptr->save_buffer);
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
#ifdef PNG_TEXT_SUPPORTED
png_free(png_ptr, png_ptr->current_text);
#endif /* PNG_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
/* Save the important info out of the png_struct, in case it is
* being used again.
*/

View File

@ -1,8 +1,8 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.5.7 [December 15, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.11 [June 14, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -1770,8 +1770,8 @@ png_init_read_transformations(png_structp png_ptr)
int num_palette = png_ptr->num_palette;
int i;
/*NOTE: there are other transformations that should probably be in here
* too.
/* NOTE: there are other transformations that should probably be in
* here too.
*/
for (i = 0; i < num_palette; i++)
{
@ -1830,12 +1830,15 @@ png_init_read_transformations(png_structp png_ptr)
#ifdef PNG_READ_SHIFT_SUPPORTED
if ((png_ptr->transformations & PNG_SHIFT) &&
!(png_ptr->transformations & PNG_EXPAND) &&
(png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
{
int i;
int istop = png_ptr->num_palette;
int shift = 8 - png_ptr->sig_bit.red;
png_ptr->transformations &= ~PNG_SHIFT;
/* significant bits can be in the range 1 to 7 for a meaninful result, if
* the number of significant bits is 0 then no shift is done (this is an
* error condition which is silently ignored.)
@ -2274,7 +2277,7 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
/*NOTE: moved here in 1.5.4 (from much later in this list.) */
/* NOTE: moved here in 1.5.4 (from much later in this list.) */
if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1);
@ -2296,6 +2299,13 @@ png_do_read_transformations(png_structp png_ptr, png_row_infop row_info)
png_do_unpack(row_info, png_ptr->row_buf + 1);
#endif
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Added at libpng-1.5.10 */
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
png_ptr->num_palette_max >= 0)
png_do_check_palette_indexes(png_ptr, row_info);
#endif
#ifdef PNG_READ_BGR_SUPPORTED
if (png_ptr->transformations & PNG_BGR)
png_do_bgr(row_info, png_ptr->row_buf + 1);
@ -3293,7 +3303,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
if (red != green || red != blue)
{
rgb_error |= 1;
/*NOTE: this is the historical approach which simply
/* NOTE: this is the historical approach which simply
* truncates the results.
*/
*(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.5.9 [February 18, 2012]
* Last changed in libpng 1.5.10 [March 8, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -434,14 +434,12 @@ png_decompress_chunk(png_structp png_ptr, int comp_type,
*/
if (prefix_size >= (~(png_size_t)0) - 1 ||
expanded_size >= (~(png_size_t)0) - 1 - prefix_size
#ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
#ifdef PNG_USER_LIMITS_SUPPORTED
|| (png_ptr->user_chunk_malloc_max &&
(prefix_size + expanded_size >= png_ptr->user_chunk_malloc_max - 1))
#else
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|| ((PNG_USER_CHUNK_MALLOC_MAX > 0) &&
prefix_size + expanded_size >= PNG_USER_CHUNK_MALLOC_MAX - 1)
# endif
#endif
)
png_warning(png_ptr, "Exceeded size limit while expanding chunk");
@ -1259,13 +1257,16 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
/* Should be an error, but we can cope with it */
png_warning(png_ptr, "Out of place iCCP chunk");
if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))
if ((png_ptr->mode & PNG_HAVE_iCCP) || (info_ptr != NULL &&
(info_ptr->valid & (PNG_INFO_iCCP|PNG_INFO_sRGB))))
{
png_warning(png_ptr, "Duplicate iCCP chunk");
png_crc_finish(png_ptr, length);
return;
}
png_ptr->mode |= PNG_HAVE_iCCP;
#ifdef PNG_MAX_MALLOC_64K
if (length > (png_uint_32)65535L)
{
@ -1795,16 +1796,16 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
return;
}
num = length / 2 ;
if (num != (unsigned int)png_ptr->num_palette || num >
(unsigned int)PNG_MAX_PALETTE_LENGTH)
if (length > 2*PNG_MAX_PALETTE_LENGTH ||
length != (unsigned int) (2*png_ptr->num_palette))
{
png_warning(png_ptr, "Incorrect hIST chunk length");
png_crc_finish(png_ptr, length);
return;
}
num = length / 2 ;
for (i = 0; i < num; i++)
{
png_byte buf[2];
@ -3661,7 +3662,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
#ifdef PNG_ARM_NEON
#ifdef __linux__
#if defined __linux__ && !defined __ANDROID__
#include <stdio.h>
#include <elf.h>
#include <asm/hwcap.h>
@ -3694,7 +3695,7 @@ static int png_have_hwcap(unsigned cap)
static void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{
#ifdef __linux__
#if defined __linux__ && !defined __ANDROID__
if (!png_have_hwcap(HWCAP_NEON))
return;
#endif

View File

@ -1,8 +1,8 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.5.7 [December 15, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.11 [June 14, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -149,7 +149,7 @@ png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
* possible for 1/gamma to overflow the limit of 21474 and this means the
* gamma value must be at least 5/100000 and hence at most 20000.0. For
* safety the limits here are a little narrower. The values are 0.00016 to
* 6250.0, which are truly ridiculous gammma values (and will produce
* 6250.0, which are truly ridiculous gamma values (and will produce
* displays that are all black or all white.)
*/
if (file_gamma < 16 || file_gamma > 625000000)
@ -692,24 +692,28 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
*/
if (info_ptr->num_text + num_text > info_ptr->max_text)
{
int old_max_text = info_ptr->max_text;
int old_num_text = info_ptr->num_text;
if (info_ptr->text != NULL)
{
png_textp old_text;
int old_max;
old_max = info_ptr->max_text;
info_ptr->max_text = info_ptr->num_text + num_text + 8;
old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
{
png_free(png_ptr, old_text);
/* Restore to previous condition */
info_ptr->max_text = old_max_text;
info_ptr->text = old_text;
return(1);
}
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
png_sizeof(png_text)));
png_free(png_ptr, old_text);
}
@ -721,7 +725,12 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr,
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
if (info_ptr->text == NULL)
{
/* Restore to previous condition */
info_ptr->num_text = old_num_text;
info_ptr->max_text = old_max_text;
return(1);
}
info_ptr->free_me |= PNG_FREE_TEXT;
}
@ -1281,4 +1290,22 @@ png_set_benign_errors(png_structp png_ptr, int allowed)
png_ptr->flags &= ~PNG_FLAG_BENIGN_ERRORS_WARN;
}
#endif /* PNG_BENIGN_ERRORS_SUPPORTED */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Whether to report invalid palette index; added at libng-1.5.10
* allowed - one of 0: disable; 1: enable
*/
void PNGAPI
png_set_check_for_invalid_index(png_structp png_ptr, int allowed)
{
png_debug(1, "in png_set_check_for_invalid_index");
if (allowed)
png_ptr->num_palette_max = 0;
else
png_ptr->num_palette_max = -1;
}
#endif
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

View File

@ -1,7 +1,7 @@
/* pngstruct.h - header file for PNG reference library
*
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -121,6 +121,12 @@ struct png_struct_def
png_uint_32 crc; /* current chunk CRC value */
png_colorp palette; /* palette from the input file */
png_uint_16 num_palette; /* number of color entries in palette */
/* Added at libpng-1.5.10 */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
int num_palette_max; /* maximum palette index found in IDAT */
#endif
png_uint_16 num_trans; /* number of transparency values */
png_byte compression; /* file compression type (always 0) */
png_byte filter; /* file filter type (always 0) */
@ -211,13 +217,6 @@ struct png_struct_def
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
# ifdef PNG_TEXT_SUPPORTED
png_size_t current_text_size; /* current size of text input data */
png_size_t current_text_left; /* how much text left to read in input */
png_charp current_text; /* current text chunk buffer */
png_charp current_text_ptr; /* current location in current_text */
# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
@ -249,6 +248,7 @@ struct png_struct_def
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
/* This is going to be unused in libpng16 and removed from libpng17 */
char time_buffer[29]; /* String to hold RFC 1123 time text */
#endif

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -1,8 +1,8 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.5.4 [July 7, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.11 [June 14, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -619,6 +619,109 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
}
#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
/* Added at libpng-1.5.10 */
void /* PRIVATE */
png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
{
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
{
/* Calculations moved outside switch in an attempt to stop different
* compiler warnings. 'padding' is in *bits* within the last byte, it is
* an 'int' because pixel_depth becomes an 'int' in the expression below,
* and this calculation is used because it avoids warnings that other
* forms produced on either GCC or MSVC.
*/
int padding = (-row_info->pixel_depth * row_info->width) & 7;
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
switch (row_info->bit_depth)
{
case 1:
{
/* in this case, all bytes must be 0 so we don't need
* to unpack the pixels except for the rightmost one.
*/
for (; rp > png_ptr->row_buf; rp--)
{
if (*rp >> padding != 0)
png_ptr->num_palette_max = 1;
padding = 0;
}
break;
}
case 2:
{
for (; rp > png_ptr->row_buf; rp--)
{
int i = ((*rp >> padding) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 2) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 4) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 6) & 0x03);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
padding = 0;
}
break;
}
case 4:
{
for (; rp > png_ptr->row_buf; rp--)
{
int i = ((*rp >> padding) & 0x0f);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
i = (((*rp >> padding) >> 4) & 0x0f);
if (i > png_ptr->num_palette_max)
png_ptr->num_palette_max = i;
padding = 0;
}
break;
}
case 8:
{
for (; rp > png_ptr->row_buf; rp--)
{
if (*rp > png_ptr->num_palette_max)
png_ptr->num_palette_max = (int) *rp;
}
break;
}
default:
break;
}
}
}
#endif /* PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED */
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED

View File

@ -1,8 +1,8 @@
/* pngwrite.c - general routines to write a PNG file
*
* Last changed in libpng 1.5.7 [December 15, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.11 [June 14, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -305,6 +305,11 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
if (!(png_ptr->mode & PNG_HAVE_IDAT))
png_error(png_ptr, "No IDATs written into file");
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
if (png_ptr->num_palette_max > png_ptr->num_palette)
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
#endif
/* See if user wants us to write information chunks */
if (info_ptr != NULL)
{
@ -798,6 +803,14 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
}
#endif
/* Added at libpng-1.5.10 */
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Check for out-of-range palette index */
if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&
png_ptr->num_palette_max >= 0)
png_do_check_palette_indexes(png_ptr, &row_info);
#endif
/* Find a filter if necessary, filter the row and write it out. */
png_write_find_filter(png_ptr, &row_info);

View File

@ -1,8 +1,8 @@
/* pngwutil.c - utilities to write a PNG file
*
* Last changed in libpng 1.5.6 [November 3, 2011]
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
* Last changed in libpng 1.5.10 [March 8, 2012]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@ -569,14 +569,15 @@ png_text_compress(png_structp png_ptr,
/* Ship the compressed text out via chunk writes */
static void /* PRIVATE */
png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
png_write_compressed_data_out(png_structp png_ptr, compression_state *comp,
png_size_t data_len)
{
int i;
/* Handle the no-compression case */
if (comp->input)
{
png_write_chunk_data(png_ptr, comp->input, comp->input_len);
png_write_chunk_data(png_ptr, comp->input, data_len);
return;
}
@ -585,7 +586,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
/* The zbuf_size test is because the code below doesn't work if zbuf_size is
* '1'; simply skip it to avoid memory overwrite.
*/
if (comp->input_len >= 2 && comp->input_len < 16384 && png_ptr->zbuf_size > 1)
if (data_len >= 2 && comp->input_len < 16384 && png_ptr->zbuf_size > 1)
{
unsigned int z_cmf; /* zlib compression method and flags */
@ -1164,8 +1165,7 @@ png_write_iCCP(png_structp png_ptr, png_const_charp name, int compression_type,
if (profile_len)
{
comp.input_len = profile_len;
png_write_compressed_data_out(png_ptr, &comp);
png_write_compressed_data_out(png_ptr, &comp, profile_len);
}
png_write_chunk_end(png_ptr);
@ -1735,8 +1735,7 @@ png_write_zTXt(png_structp png_ptr, png_const_charp key, png_const_charp text,
png_write_chunk_data(png_ptr, &buf, (png_size_t)1);
/* Write the compressed data */
comp.input_len = text_len;
png_write_compressed_data_out(png_ptr, &comp);
png_write_compressed_data_out(png_ptr, &comp, text_len);
/* Close the chunk */
png_write_chunk_end(png_ptr);
@ -1827,7 +1826,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_const_charp key,
png_write_chunk_data(png_ptr, (lang_key ? (png_const_bytep)lang_key : cbuf),
(png_size_t)(lang_key_len + 1));
png_write_compressed_data_out(png_ptr, &comp);
png_write_compressed_data_out(png_ptr, &comp, text_len);
png_write_chunk_end(png_ptr);

View File

@ -89,7 +89,11 @@ endif(WIN32)
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare
-Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter /wd4100 /wd4244 /wd4706 /wd4127 /wd4701 /wd4018 /wd4267 /wd4306 /wd4305 /wd4312 /wd4311)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4100 /wd4127 /wd4311 /wd4701 /wd4706) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267 /wd4305 /wd4306) # vs2008 Win64
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4703) # vs2012
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")

21
3rdparty/libtiff/COPYRIGHT vendored Normal file
View File

@ -0,0 +1,21 @@
Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 Silicon Graphics, Inc.
Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee, provided
that (i) the above copyright notices and this permission notice appear in
all copies of the software and related documentation, and (ii) the names of
Sam Leffler and Silicon Graphics may not be used in any advertising or
publicity relating to the software without the specific, prior written
permission of Sam Leffler and Silicon Graphics.
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.

5753
3rdparty/libtiff/ChangeLog vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -325,8 +325,8 @@ _TIFFUInt64ToFloat(uint64 ui64)
if (i.part.high >= 0) {
return (float)i.value;
} else {
double df;
df = (double)i.value;
long double df;
df = (long double)i.value;
df += 18446744073709551616.0; /* adding 2**64 */
return (float)df;
}
@ -341,8 +341,8 @@ _TIFFUInt64ToDouble(uint64 ui64)
if (i.part.high >= 0) {
return (double)i.value;
} else {
double df;
df = (double)i.value;
long double df;
df = (long double)i.value;
df += 18446744073709551616.0; /* adding 2**64 */
return (double)df;
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_dir.c,v 1.108 2012-02-01 01:51:00 fwarmerdam Exp $ */
/* $Id: tif_dir.c,v 1.113 2012-06-14 20:32:53 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -122,6 +122,10 @@ setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v)
#undef EXTRASAMPLE_COREL_UNASSALPHA
}
/*
* Confirm we have "samplesperpixel" ink names separated by \0. Returns
* zero if the ink names are not as expected.
*/
static uint32
checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
{
@ -132,9 +136,9 @@ checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
const char* ep = s+slen;
const char* cp = s;
for (; i > 0; i--) {
for (; *cp != '\0'; cp++)
if (cp >= ep)
goto bad;
for (; cp < ep && *cp != '\0'; cp++) {}
if (cp >= ep)
goto bad;
cp++; /* skip \0 */
}
return ((uint32)(cp-s));
@ -157,8 +161,20 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
int status = 1;
uint32 v32, i, v;
char* s;
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
uint32 standard_tag = tag;
switch (tag) {
/*
* We want to force the custom code to be used for custom
* fields even if the tag happens to match a well known
* one - important for reinterpreted handling of standard
* tag values in custom directories (ie. EXIF)
*/
if (fip->field_bit == FIELD_CUSTOM) {
standard_tag = 0;
}
switch (standard_tag) {
case TIFFTAG_SUBFILETYPE:
td->td_subfiletype = (uint32) va_arg(ap, uint32);
break;
@ -423,7 +439,6 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
default: {
TIFFTagValue *tv;
int tv_size, iCustom;
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
/*
* This can happen if multiple images are open with different
@ -550,102 +565,99 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
goto end;
}
if ((fip->field_passcount
|| fip->field_writecount == TIFF_VARIABLE
|| fip->field_writecount == TIFF_VARIABLE2
|| fip->field_writecount == TIFF_SPP
|| tv->count > 1)
&& fip->field_tag != TIFFTAG_PAGENUMBER
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
&& fip->field_tag != TIFFTAG_DOTRANGE) {
if (fip->field_tag == TIFFTAG_DOTRANGE
&& strcmp(fip->field_name,"DotRange") == 0) {
/* TODO: This is an evil exception and should not have been
handled this way ... likely best if we move it into
the directory structure with an explicit field in
libtiff 4.1 and assign it a FIELD_ value */
uint16 v[2];
v[0] = (uint16)va_arg(ap, int);
v[1] = (uint16)va_arg(ap, int);
_TIFFmemcpy(tv->value, &v, 4);
}
else if (fip->field_passcount
|| fip->field_writecount == TIFF_VARIABLE
|| fip->field_writecount == TIFF_VARIABLE2
|| fip->field_writecount == TIFF_SPP
|| tv->count > 1) {
_TIFFmemcpy(tv->value, va_arg(ap, void *),
tv->count * tv_size);
} else {
/*
* XXX: The following loop required to handle
* TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS,
* TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags.
* These tags are actually arrays and should be passed as
* array pointers to TIFFSetField() function, but actually
* passed as a list of separate values. This behaviour
* must be changed in the future!
*/
int i;
char *val = (char *)tv->value;
assert( tv->count == 1 );
for (i = 0; i < tv->count; i++, val += tv_size) {
switch (fip->field_type) {
case TIFF_BYTE:
case TIFF_UNDEFINED:
{
uint8 v = (uint8)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SBYTE:
{
int8 v = (int8)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SHORT:
{
uint16 v = (uint16)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SSHORT:
{
int16 v = (int16)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_LONG:
case TIFF_IFD:
{
uint32 v = va_arg(ap, uint32);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SLONG:
{
int32 v = va_arg(ap, int32);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_LONG8:
case TIFF_IFD8:
{
uint64 v = va_arg(ap, uint64);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SLONG8:
{
int64 v = va_arg(ap, int64);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
case TIFF_FLOAT:
{
float v = (float)va_arg(ap, double);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_DOUBLE:
{
double v = va_arg(ap, double);
_TIFFmemcpy(val, &v, tv_size);
}
break;
default:
_TIFFmemset(val, 0, tv_size);
status = 0;
break;
switch (fip->field_type) {
case TIFF_BYTE:
case TIFF_UNDEFINED:
{
uint8 v = (uint8)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SBYTE:
{
int8 v = (int8)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SHORT:
{
uint16 v = (uint16)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SSHORT:
{
int16 v = (int16)va_arg(ap, int);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_LONG:
case TIFF_IFD:
{
uint32 v = va_arg(ap, uint32);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SLONG:
{
int32 v = va_arg(ap, int32);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_LONG8:
case TIFF_IFD8:
{
uint64 v = va_arg(ap, uint64);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_SLONG8:
{
int64 v = va_arg(ap, int64);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
case TIFF_FLOAT:
{
float v = (float)va_arg(ap, double);
_TIFFmemcpy(val, &v, tv_size);
}
break;
case TIFF_DOUBLE:
{
double v = va_arg(ap, double);
_TIFFmemcpy(val, &v, tv_size);
}
break;
default:
_TIFFmemset(val, 0, tv_size);
status = 0;
break;
}
}
}
@ -795,8 +807,20 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
{
TIFFDirectory* td = &tif->tif_dir;
int ret_val = 1;
uint32 standard_tag = tag;
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
/*
* We want to force the custom code to be used for custom
* fields even if the tag happens to match a well known
* one - important for reinterpreted handling of standard
* tag values in custom directories (ie. EXIF)
*/
if (fip->field_bit == FIELD_CUSTOM) {
standard_tag = 0;
}
switch (tag) {
switch (standard_tag) {
case TIFFTAG_SUBFILETYPE:
*va_arg(ap, uint32*) = td->td_subfiletype;
break;
@ -971,8 +995,6 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
break;
default:
{
const TIFFField* fip =
TIFFFindField(tif, tag, TIFF_ANY);
int i;
/*
@ -1013,84 +1035,85 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
*va_arg(ap, uint16*) = (uint16)tv->count;
*va_arg(ap, void **) = tv->value;
ret_val = 1;
} else if (fip->field_tag == TIFFTAG_DOTRANGE
&& strcmp(fip->field_name,"DotRange") == 0) {
/* TODO: This is an evil exception and should not have been
handled this way ... likely best if we move it into
the directory structure with an explicit field in
libtiff 4.1 and assign it a FIELD_ value */
*va_arg(ap, uint16*) = ((uint16 *)tv->value)[0];
*va_arg(ap, uint16*) = ((uint16 *)tv->value)[1];
ret_val = 1;
} else {
if ((fip->field_type == TIFF_ASCII
if (fip->field_type == TIFF_ASCII
|| fip->field_readcount == TIFF_VARIABLE
|| fip->field_readcount == TIFF_VARIABLE2
|| fip->field_readcount == TIFF_SPP
|| tv->count > 1)
&& fip->field_tag != TIFFTAG_PAGENUMBER
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
&& fip->field_tag != TIFFTAG_DOTRANGE) {
|| tv->count > 1) {
*va_arg(ap, void **) = tv->value;
ret_val = 1;
} else {
int j;
char *val = (char *)tv->value;
for (j = 0; j < tv->count;
j++, val += _TIFFDataSize(tv->info->field_type)) {
switch (fip->field_type) {
case TIFF_BYTE:
case TIFF_UNDEFINED:
*va_arg(ap, uint8*) =
*(uint8 *)val;
ret_val = 1;
break;
case TIFF_SBYTE:
*va_arg(ap, int8*) =
*(int8 *)val;
ret_val = 1;
break;
case TIFF_SHORT:
*va_arg(ap, uint16*) =
*(uint16 *)val;
ret_val = 1;
break;
case TIFF_SSHORT:
*va_arg(ap, int16*) =
*(int16 *)val;
ret_val = 1;
break;
case TIFF_LONG:
case TIFF_IFD:
*va_arg(ap, uint32*) =
*(uint32 *)val;
ret_val = 1;
break;
case TIFF_SLONG:
*va_arg(ap, int32*) =
*(int32 *)val;
ret_val = 1;
break;
case TIFF_LONG8:
case TIFF_IFD8:
*va_arg(ap, uint64*) =
*(uint64 *)val;
ret_val = 1;
break;
case TIFF_SLONG8:
*va_arg(ap, int64*) =
*(int64 *)val;
ret_val = 1;
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
case TIFF_FLOAT:
*va_arg(ap, float*) =
*(float *)val;
ret_val = 1;
break;
case TIFF_DOUBLE:
*va_arg(ap, double*) =
*(double *)val;
ret_val = 1;
break;
default:
ret_val = 0;
break;
}
assert( tv->count == 1 );
switch (fip->field_type) {
case TIFF_BYTE:
case TIFF_UNDEFINED:
*va_arg(ap, uint8*) =
*(uint8 *)val;
ret_val = 1;
break;
case TIFF_SBYTE:
*va_arg(ap, int8*) =
*(int8 *)val;
ret_val = 1;
break;
case TIFF_SHORT:
*va_arg(ap, uint16*) =
*(uint16 *)val;
ret_val = 1;
break;
case TIFF_SSHORT:
*va_arg(ap, int16*) =
*(int16 *)val;
ret_val = 1;
break;
case TIFF_LONG:
case TIFF_IFD:
*va_arg(ap, uint32*) =
*(uint32 *)val;
ret_val = 1;
break;
case TIFF_SLONG:
*va_arg(ap, int32*) =
*(int32 *)val;
ret_val = 1;
break;
case TIFF_LONG8:
case TIFF_IFD8:
*va_arg(ap, uint64*) =
*(uint64 *)val;
ret_val = 1;
break;
case TIFF_SLONG8:
*va_arg(ap, int64*) =
*(int64 *)val;
ret_val = 1;
break;
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
case TIFF_FLOAT:
*va_arg(ap, float*) =
*(float *)val;
ret_val = 1;
break;
case TIFF_DOUBLE:
*va_arg(ap, double*) =
*(double *)val;
ret_val = 1;
break;
default:
ret_val = 0;
break;
}
}
}
@ -1214,6 +1237,35 @@ TIFFCreateDirectory(TIFF* tif)
return 0;
}
int
TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
{
TIFFDefaultDirectory(tif);
/*
* Reset the field definitions to match the application provided list.
* Hopefully TIFFDefaultDirectory() won't have done anything irreversable
* based on it's assumption this is an image directory.
*/
_TIFFSetupFields(tif, infoarray);
tif->tif_diroff = 0;
tif->tif_nextdiroff = 0;
tif->tif_curoff = 0;
tif->tif_row = (uint32) -1;
tif->tif_curstrip = (uint32) -1;
return 0;
}
int
TIFFCreateEXIFDirectory(TIFF* tif)
{
const TIFFFieldArray* exifFieldArray;
exifFieldArray = _TIFFGetExifFields();
return TIFFCreateCustomDirectory(tif, exifFieldArray);
}
/*
* Setup a default directory structure.
*/

View File

@ -1,4 +1,4 @@
/* $Id: tif_fax3.c,v 1.72 2010-06-09 17:17:13 bfriesen Exp $ */
/* $Id: tif_fax3.c,v 1.73 2012-06-13 00:27:20 fwarmerdam Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
@ -526,6 +526,7 @@ Fax3SetupState(TIFF* tif)
"for Group 3/4 run arrays");
if (dsp->runs == NULL)
return (0);
memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2));
dsp->curruns = dsp->runs;
if (needsRefLine)
dsp->refruns = dsp->runs + nruns;

View File

@ -1,4 +1,4 @@
/* $Id: tif_getimage.c,v 1.78 2011-02-23 21:46:09 fwarmerdam Exp $ */
/* $Id: tif_getimage.c,v 1.82 2012-06-06 00:17:49 fwarmerdam Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -692,6 +692,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
unsigned char* p2;
unsigned char* pa;
tmsize_t tilesize;
tmsize_t bufsize;
int32 fromskew, toskew;
int alpha = img->alpha;
uint32 nrow;
@ -699,12 +700,17 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
int colorchannels;
tilesize = TIFFTileSize(tif);
buf = (unsigned char*) _TIFFmalloc((alpha?4:3)*tilesize);
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize);
if (bufsize == 0) {
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate");
return (0);
}
buf = (unsigned char*) _TIFFmalloc(bufsize);
if (buf == 0) {
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "No space for tile buffer");
return (0);
}
_TIFFmemset(buf, 0, (alpha?4:3)*tilesize);
_TIFFmemset(buf, 0, bufsize);
p0 = buf;
p1 = p0 + tilesize;
p2 = p1 + tilesize;
@ -917,17 +923,23 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
uint32 rowsperstrip, offset_row;
uint32 imagewidth = img->width;
tmsize_t stripsize;
tmsize_t bufsize;
int32 fromskew, toskew;
int alpha = img->alpha;
int ret = 1, flip, colorchannels;
stripsize = TIFFStripSize(tif);
p0 = buf = (unsigned char *)_TIFFmalloc((alpha?4:3)*stripsize);
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize);
if (bufsize == 0) {
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate");
return (0);
}
p0 = buf = (unsigned char *)_TIFFmalloc(bufsize);
if (buf == 0) {
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer");
return (0);
}
_TIFFmemset(buf, 0, (alpha?4:3)*stripsize);
_TIFFmemset(buf, 0, bufsize);
p1 = p0 + stripsize;
p2 = p1 + stripsize;
pa = (alpha?(p2+stripsize):NULL);
@ -1196,6 +1208,26 @@ DECLAREContigPutFunc(putgreytile)
}
}
/*
* 8-bit greyscale with associated alpha => colormap/RGBA
*/
DECLAREContigPutFunc(putagreytile)
{
int samplesperpixel = img->samplesperpixel;
uint32** BWmap = img->BWmap;
(void) y;
while (h-- > 0) {
for (x = w; x-- > 0;)
{
*cp++ = BWmap[*pp][0] & (*(pp+1) << 24 | ~A1);
pp += samplesperpixel;
}
cp += toskew;
pp += fromskew;
}
}
/*
* 16-bit greyscale => colormap/RGB
*/
@ -1494,6 +1526,26 @@ DECLARESepPutFunc(putRGBAAseparate8bittile)
}
}
/*
* 8-bit unpacked CMYK samples => RGBA
*/
DECLARESepPutFunc(putCMYKseparate8bittile)
{
(void) img; (void) y;
while (h-- > 0) {
uint32 rv, gv, bv, kv;
for (x = w; x-- > 0;) {
kv = 255 - *a++;
rv = (kv*(255-*r++))/255;
gv = (kv*(255-*g++))/255;
bv = (kv*(255-*b++))/255;
*cp++ = PACK4(rv,gv,bv,255);
}
SKEW4(r, g, b, a, fromskew);
cp += toskew;
}
}
/*
* 8-bit unpacked samples => RGBA w/ unassociated alpha
*/
@ -2461,7 +2513,10 @@ PickContigCase(TIFFRGBAImage* img)
img->put.contig = put16bitbwtile;
break;
case 8:
img->put.contig = putgreytile;
if (img->alpha && img->samplesperpixel == 2)
img->put.contig = putagreytile;
else
img->put.contig = putgreytile;
break;
case 4:
img->put.contig = put4bitbwtile;
@ -2540,58 +2595,65 @@ PickSeparateCase(TIFFRGBAImage* img)
img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate;
img->put.separate = NULL;
switch (img->photometric) {
case PHOTOMETRIC_MINISWHITE:
case PHOTOMETRIC_MINISBLACK:
/* greyscale images processed pretty much as RGB by gtTileSeparate */
case PHOTOMETRIC_RGB:
switch (img->bitspersample) {
case 8:
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
img->put.separate = putRGBAAseparate8bittile;
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
{
if (BuildMapUaToAa(img))
img->put.separate = putRGBUAseparate8bittile;
}
else
img->put.separate = putRGBseparate8bittile;
break;
case 16:
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
{
if (BuildMapBitdepth16To8(img))
img->put.separate = putRGBAAseparate16bittile;
}
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
{
if (BuildMapBitdepth16To8(img) &&
BuildMapUaToAa(img))
img->put.separate = putRGBUAseparate16bittile;
}
else
{
if (BuildMapBitdepth16To8(img))
img->put.separate = putRGBseparate16bittile;
}
break;
case PHOTOMETRIC_MINISWHITE:
case PHOTOMETRIC_MINISBLACK:
/* greyscale images processed pretty much as RGB by gtTileSeparate */
case PHOTOMETRIC_RGB:
switch (img->bitspersample) {
case 8:
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
img->put.separate = putRGBAAseparate8bittile;
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
{
if (BuildMapUaToAa(img))
img->put.separate = putRGBUAseparate8bittile;
}
else
img->put.separate = putRGBseparate8bittile;
break;
case 16:
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
{
if (BuildMapBitdepth16To8(img))
img->put.separate = putRGBAAseparate16bittile;
}
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
{
if (BuildMapBitdepth16To8(img) &&
BuildMapUaToAa(img))
img->put.separate = putRGBUAseparate16bittile;
}
else
{
if (BuildMapBitdepth16To8(img))
img->put.separate = putRGBseparate16bittile;
}
break;
case PHOTOMETRIC_YCBCR:
if ((img->bitspersample==8) && (img->samplesperpixel==3))
}
break;
case PHOTOMETRIC_SEPARATED:
if (img->bitspersample == 8 && img->samplesperpixel == 4)
{
img->alpha = 1; // Not alpha, but seems like the only way to get 4th band
img->put.separate = putCMYKseparate8bittile;
}
break;
case PHOTOMETRIC_YCBCR:
if ((img->bitspersample==8) && (img->samplesperpixel==3))
{
if (initYCbCrConversion(img)!=0)
{
if (initYCbCrConversion(img)!=0)
{
uint16 hs, vs;
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
switch ((hs<<4)|vs) {
case 0x11:
img->put.separate = putseparate8bitYCbCr11tile;
break;
/* TODO: add other cases here */
}
uint16 hs, vs;
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
switch ((hs<<4)|vs) {
case 0x11:
img->put.separate = putseparate8bitYCbCr11tile;
break;
/* TODO: add other cases here */
}
}
break;
}
break;
}
return ((img->get!=NULL) && (img->put.separate!=NULL));
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_jpeg.c,v 1.105 2012-02-01 01:51:00 fwarmerdam Exp $ */
/* $Id: tif_jpeg.c,v 1.108 2012-06-05 03:24:30 fwarmerdam Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
@ -1095,50 +1095,13 @@ JPEGPreDecode(TIFF* tif, uint16 s)
/* Component 0 should have expected sampling factors */
if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) {
TIFFWarningExt(tif->tif_clientdata, module,
"Improper JPEG sampling factors %d,%d\n"
"Apparently should be %d,%d.",
sp->cinfo.d.comp_info[0].h_samp_factor,
sp->cinfo.d.comp_info[0].v_samp_factor,
sp->h_sampling, sp->v_sampling);
/*
* There are potential security issues here
* for decoders that have already allocated
* buffers based on the expected sampling
* factors. Lets check the sampling factors
* dont exceed what we were expecting.
*/
if (sp->cinfo.d.comp_info[0].h_samp_factor
> sp->h_sampling
|| sp->cinfo.d.comp_info[0].v_samp_factor
> sp->v_sampling) {
TIFFErrorExt(tif->tif_clientdata,
module,
"Cannot honour JPEG sampling factors"
" that exceed those specified.");
return (0);
}
/*
* XXX: Files written by the Intergraph software
* has different sampling factors stored in the
* TIFF tags and in the JPEG structures. We will
* try to deduce Intergraph files by the presense
* of the tag 33918.
*/
if (!TIFFFindField(tif, 33918, TIFF_ANY)) {
TIFFWarningExt(tif->tif_clientdata, module,
"Decompressor will try reading with "
"sampling %d,%d.",
sp->cinfo.d.comp_info[0].h_samp_factor,
sp->cinfo.d.comp_info[0].v_samp_factor);
sp->h_sampling = (uint16)
sp->cinfo.d.comp_info[0].h_samp_factor;
sp->v_sampling = (uint16)
sp->cinfo.d.comp_info[0].v_samp_factor;
}
TIFFErrorExt(tif->tif_clientdata, module,
"Improper JPEG sampling factors %d,%d\n"
"Apparently should be %d,%d.",
sp->cinfo.d.comp_info[0].h_samp_factor,
sp->cinfo.d.comp_info[0].v_samp_factor,
sp->h_sampling, sp->v_sampling);
return (0);
}
/* Rest should have sampling factors 1,1 */
for (ci = 1; ci < sp->cinfo.d.num_components; ci++) {
@ -1160,11 +1123,11 @@ JPEGPreDecode(TIFF* tif, uint16 s)
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
sp->photometric == PHOTOMETRIC_YCBCR &&
sp->jpegcolormode == JPEGCOLORMODE_RGB) {
/* Convert YCbCr to RGB */
/* Convert YCbCr to RGB */
sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
sp->cinfo.d.out_color_space = JCS_RGB;
} else {
/* Suppress colorspace handling */
/* Suppress colorspace handling */
sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
sp->cinfo.d.out_color_space = JCS_UNKNOWN;
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
@ -1349,8 +1312,8 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
#if defined(JPEG_LIB_MK1_OR_12BIT)
unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) *
sp->cinfo.d.output_width *
sp->cinfo.d.num_components);
sp->cinfo.d.output_width *
sp->cinfo.d.num_components);
if(tmpbuf==NULL) {
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
"Out of memory");
@ -1362,10 +1325,10 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
jpeg_component_info *compptr;
int ci, clumpoffset;
if( cc < sp->bytesperline * sp->v_sampling ) {
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
"application buffer not large enough for all data.");
return 0;
if( cc < sp->bytesperline ) {
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
"application buffer not large enough for all data.");
return 0;
}
/* Reload downsampled-data buffer if needed */
@ -1381,20 +1344,25 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
*/
clumpoffset = 0; /* first sample in clump */
for (ci = 0, compptr = sp->cinfo.d.comp_info;
ci < sp->cinfo.d.num_components;
ci++, compptr++) {
ci < sp->cinfo.d.num_components;
ci++, compptr++) {
int hsamp = compptr->h_samp_factor;
int vsamp = compptr->v_samp_factor;
int ypos;
for (ypos = 0; ypos < vsamp; ypos++) {
JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos];
JDIMENSION nclump;
#if defined(JPEG_LIB_MK1_OR_12BIT)
JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset;
#else
JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset;
if (cc < clumpoffset + samples_per_clump*(clumps_per_line-1) + hsamp) {
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
"application buffer not large enough for all data, possible subsampling issue");
return 0;
}
#endif
JDIMENSION nclump;
if (hsamp == 1) {
/* fast path for at least Cb and Cr */
@ -1405,7 +1373,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
} else {
int xpos;
/* general case */
/* general case */
for (nclump = clumps_per_line; nclump-- > 0; ) {
for (xpos = 0; xpos < hsamp; xpos++)
outptr[xpos] = *inptr++;
@ -1428,9 +1396,9 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
}
}
else
{ /* 12-bit */
{ /* 12-bit */
int value_pairs = (sp->cinfo.d.output_width
* sp->cinfo.d.num_components) / 2;
* sp->cinfo.d.num_components) / 2;
int iPair;
for( iPair = 0; iPair < value_pairs; iPair++ )
{
@ -1438,7 +1406,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
JSAMPLE *in_ptr = (JSAMPLE *) (tmpbuf + iPair * 2);
out_ptr[0] = (in_ptr[0] & 0xff0) >> 4;
out_ptr[1] = ((in_ptr[0] & 0xf) << 4)
| ((in_ptr[1] & 0xf00) >> 8);
| ((in_ptr[1] & 0xf00) >> 8);
out_ptr[2] = ((in_ptr[1] & 0xff) >> 0);
}
}
@ -1447,12 +1415,9 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
sp->scancount ++;
tif->tif_row += sp->v_sampling;
/*
buf += clumps_per_line*samples_per_clump;
cc -= clumps_per_line*samples_per_clump;
*/
buf += sp->bytesperline * sp->v_sampling;
cc -= sp->bytesperline * sp->v_sampling;
buf += sp->bytesperline;
cc -= sp->bytesperline;
nrows -= sp->v_sampling;
} while (nrows > 0);
@ -1465,7 +1430,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
/* Close down the decompressor if done. */
return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
|| TIFFjpeg_finish_decompress(sp);
|| TIFFjpeg_finish_decompress(sp);
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_ojpeg.c,v 1.54 2011-05-31 17:05:07 bfriesen Exp $ */
/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam Exp $ */
/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
specification is now totally obsolete and deprecated for new applications and
@ -1146,7 +1146,9 @@ OJPEGWriteHeaderInfo(TIFF* tif)
OJPEGState* sp=(OJPEGState*)tif->tif_data;
uint8** m;
uint32 n;
assert(sp->libjpeg_session_active==0);
/* if a previous attempt failed, don't try again */
if (sp->libjpeg_session_active != 0)
return 0;
sp->out_state=ososSoi;
sp->restart_index=0;
jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr));
@ -1954,6 +1956,11 @@ OJPEGReadBufferFill(OJPEGState* sp)
case osibsJpegInterchangeFormat:
sp->in_buffer_source=osibsStrile;
case osibsStrile:
if (!_TIFFFillStriles( sp->tif )
|| sp->tif->tif_dir.td_stripoffset == NULL
|| sp->tif->tif_dir.td_stripbytecount == NULL)
return 0;
if (sp->in_buffer_next_strile==sp->in_buffer_strile_count)
sp->in_buffer_source=osibsEof;
else

View File

@ -1,4 +1,4 @@
/* $Id: tif_pixarlog.c,v 1.35 2011-01-06 16:00:23 fwarmerdam Exp $ */
/* $Id: tif_pixarlog.c,v 1.37 2012-05-24 23:21:45 fwarmerdam Exp $ */
/*
* Copyright (c) 1996-1997 Sam Leffler
@ -120,9 +120,9 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op,
if (n >= stride) {
mask = CODE_MASK;
if (stride == 3) {
t0 = ToLinearF[cr = wp[0]];
t1 = ToLinearF[cg = wp[1]];
t2 = ToLinearF[cb = wp[2]];
t0 = ToLinearF[cr = (wp[0] & mask)];
t1 = ToLinearF[cg = (wp[1] & mask)];
t2 = ToLinearF[cb = (wp[2] & mask)];
op[0] = t0;
op[1] = t1;
op[2] = t2;
@ -139,10 +139,10 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op,
op[2] = t2;
}
} else if (stride == 4) {
t0 = ToLinearF[cr = wp[0]];
t1 = ToLinearF[cg = wp[1]];
t2 = ToLinearF[cb = wp[2]];
t3 = ToLinearF[ca = wp[3]];
t0 = ToLinearF[cr = (wp[0] & mask)];
t1 = ToLinearF[cg = (wp[1] & mask)];
t2 = ToLinearF[cb = (wp[2] & mask)];
t3 = ToLinearF[ca = (wp[3] & mask)];
op[0] = t0;
op[1] = t1;
op[2] = t2;
@ -186,9 +186,9 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op,
if (n >= stride) {
mask = CODE_MASK;
if (stride == 3) {
t0 = ToLinearF[cr = wp[0]] * SCALE12;
t1 = ToLinearF[cg = wp[1]] * SCALE12;
t2 = ToLinearF[cb = wp[2]] * SCALE12;
t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
op[0] = CLAMP12(t0);
op[1] = CLAMP12(t1);
op[2] = CLAMP12(t2);
@ -205,10 +205,10 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op,
op[2] = CLAMP12(t2);
}
} else if (stride == 4) {
t0 = ToLinearF[cr = wp[0]] * SCALE12;
t1 = ToLinearF[cg = wp[1]] * SCALE12;
t2 = ToLinearF[cb = wp[2]] * SCALE12;
t3 = ToLinearF[ca = wp[3]] * SCALE12;
t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12;
op[0] = CLAMP12(t0);
op[1] = CLAMP12(t1);
op[2] = CLAMP12(t2);
@ -250,9 +250,9 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op,
if (n >= stride) {
mask = CODE_MASK;
if (stride == 3) {
op[0] = ToLinear16[cr = wp[0]];
op[1] = ToLinear16[cg = wp[1]];
op[2] = ToLinear16[cb = wp[2]];
op[0] = ToLinear16[cr = (wp[0] & mask)];
op[1] = ToLinear16[cg = (wp[1] & mask)];
op[2] = ToLinear16[cb = (wp[2] & mask)];
n -= 3;
while (n > 0) {
wp += 3;
@ -263,10 +263,10 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op,
op[2] = ToLinear16[(cb += wp[2]) & mask];
}
} else if (stride == 4) {
op[0] = ToLinear16[cr = wp[0]];
op[1] = ToLinear16[cg = wp[1]];
op[2] = ToLinear16[cb = wp[2]];
op[3] = ToLinear16[ca = wp[3]];
op[0] = ToLinear16[cr = (wp[0] & mask)];
op[1] = ToLinear16[cg = (wp[1] & mask)];
op[2] = ToLinear16[cb = (wp[2] & mask)];
op[3] = ToLinear16[ca = (wp[3] & mask)];
n -= 4;
while (n > 0) {
wp += 4;
@ -345,9 +345,9 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op,
if (n >= stride) {
mask = CODE_MASK;
if (stride == 3) {
op[0] = ToLinear8[cr = wp[0]];
op[1] = ToLinear8[cg = wp[1]];
op[2] = ToLinear8[cb = wp[2]];
op[0] = ToLinear8[cr = (wp[0] & mask)];
op[1] = ToLinear8[cg = (wp[1] & mask)];
op[2] = ToLinear8[cb = (wp[2] & mask)];
n -= 3;
while (n > 0) {
n -= 3;
@ -358,10 +358,10 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op,
op[2] = ToLinear8[(cb += wp[2]) & mask];
}
} else if (stride == 4) {
op[0] = ToLinear8[cr = wp[0]];
op[1] = ToLinear8[cg = wp[1]];
op[2] = ToLinear8[cb = wp[2]];
op[3] = ToLinear8[ca = wp[3]];
op[0] = ToLinear8[cr = (wp[0] & mask)];
op[1] = ToLinear8[cg = (wp[1] & mask)];
op[2] = ToLinear8[cb = (wp[2] & mask)];
op[3] = ToLinear8[ca = (wp[3] & mask)];
n -= 4;
while (n > 0) {
n -= 4;
@ -396,9 +396,9 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op,
mask = CODE_MASK;
if (stride == 3) {
op[0] = 0;
t1 = ToLinear8[cb = wp[2]];
t2 = ToLinear8[cg = wp[1]];
t3 = ToLinear8[cr = wp[0]];
t1 = ToLinear8[cb = (wp[2] & mask)];
t2 = ToLinear8[cg = (wp[1] & mask)];
t3 = ToLinear8[cr = (wp[0] & mask)];
op[1] = t1;
op[2] = t2;
op[3] = t3;
@ -416,10 +416,10 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op,
op[3] = t3;
}
} else if (stride == 4) {
t0 = ToLinear8[ca = wp[3]];
t1 = ToLinear8[cb = wp[2]];
t2 = ToLinear8[cg = wp[1]];
t3 = ToLinear8[cr = wp[0]];
t0 = ToLinear8[ca = (wp[3] & mask)];
t1 = ToLinear8[cb = (wp[2] & mask)];
t2 = ToLinear8[cg = (wp[1] & mask)];
t3 = ToLinear8[cr = (wp[0] & mask)];
op[0] = t0;
op[1] = t1;
op[2] = t2;
@ -673,7 +673,7 @@ PixarLogSetupDecode(TIFF* tif)
td->td_rowsperstrip), sizeof(uint16));
if (tbuf_size == 0)
return (0); /* TODO: this is an error return without error report through TIFFErrorExt */
sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16));
if (sp->tbuf == NULL)
return (0);
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)

View File

@ -1,4 +1,4 @@
/* $Id: tif_print.c,v 1.54 2011-04-02 20:54:09 bfriesen Exp $ */
/* $Id: tif_print.c,v 1.59 2012-06-13 01:08:51 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -34,6 +34,9 @@
#include <ctype.h>
static void
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars);
static const char *photoNames[] = {
"min-is-white", /* PHOTOMETRIC_MINISWHITE */
"min-is-black", /* PHOTOMETRIC_MINISBLACK */
@ -135,34 +138,51 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip,
}
static int
_TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag,
_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag,
uint32 value_count, void *raw_data)
{
(void) tif;
/* do not try to pretty print auto-defined fields */
if (strncmp(fip->field_name,"Tag ", 4) == 0) {
return 0;
}
switch (tag)
{
case TIFFTAG_INKSET:
fprintf(fd, " Ink Set: ");
switch (*((uint16*)raw_data)) {
if (value_count == 2 && fip->field_type == TIFF_SHORT) {
fprintf(fd, " Ink Set: ");
switch (*((uint16*)raw_data)) {
case INKSET_CMYK:
fprintf(fd, "CMYK\n");
break;
default:
fprintf(fd, "%u (0x%x)\n",
*((uint16*)raw_data),
*((uint16*)raw_data));
*((uint16*)raw_data),
*((uint16*)raw_data));
break;
}
return 1;
}
return 1;
return 0;
case TIFFTAG_DOTRANGE:
fprintf(fd, " Dot Range: %u-%u\n",
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
return 1;
if (value_count == 2 && fip->field_type == TIFF_SHORT) {
fprintf(fd, " Dot Range: %u-%u\n",
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
return 1;
}
return 0;
case TIFFTAG_WHITEPOINT:
fprintf(fd, " White Point: %g-%g\n",
((float *)raw_data)[0], ((float *)raw_data)[1]);
return 1;
if (value_count == 2 && fip->field_type == TIFF_RATIONAL) {
fprintf(fd, " White Point: %g-%g\n",
((float *)raw_data)[0], ((float *)raw_data)[1]);
return 1;
}
return 0;
case TIFFTAG_XMLPACKET:
{
uint32 i;
@ -182,19 +202,25 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag,
" RichTIFFIPTC Data: <present>, %lu bytes\n",
(unsigned long) value_count * 4);
return 1;
case TIFFTAG_PHOTOSHOP:
fprintf(fd, " Photoshop Data: <present>, %lu bytes\n",
(unsigned long) value_count);
return 1;
case TIFFTAG_ICCPROFILE:
fprintf(fd, " ICC Profile: <present>, %lu bytes\n",
(unsigned long) value_count);
return 1;
case TIFFTAG_STONITS:
fprintf(fd,
" Sample to Nits conversion factor: %.4e\n",
*((double*)raw_data));
return 1;
if (value_count == 1 && fip->field_type == TIFF_DOUBLE) {
fprintf(fd,
" Sample to Nits conversion factor: %.4e\n",
*((double*)raw_data));
return 1;
}
return 0;
}
return 0;
@ -364,9 +390,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, " Ink Names: ");
i = td->td_samplesperpixel;
sep = "";
for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) {
for (cp = td->td_inknames;
i > 0 && cp < td->td_inknames + td->td_inknameslen;
cp = strchr(cp,'\0')+1, i--) {
int max_chars =
td->td_inknameslen - (cp - td->td_inknames);
fputs(sep, fd);
_TIFFprintAscii(fd, cp);
_TIFFprintAsciiBounded(fd, cp, max_chars);
sep = ", ";
}
fputs("\n", fd);
@ -449,14 +479,16 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE))
fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue);
if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) {
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
fprintf(fd, " SMin Sample Value:");
for (i = 0; i < td->td_samplesperpixel; ++i)
for (i = 0; i < count; ++i)
fprintf(fd, " %g", td->td_sminsamplevalue[i]);
fprintf(fd, "\n");
}
if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) {
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
fprintf(fd, " SMax Sample Value:");
for (i = 0; i < td->td_samplesperpixel; ++i)
for (i = 0; i < count; ++i)
fprintf(fd, " %g", td->td_smaxsamplevalue[i]);
fprintf(fd, "\n");
}
@ -548,8 +580,19 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
continue;
if(fip->field_passcount) {
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
if (fip->field_readcount == TIFF_VARIABLE2 ) {
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
continue;
} else if (fip->field_readcount == TIFF_VARIABLE2 ) {
uint16 small_value_count;
if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
continue;
value_count = small_value_count;
} else {
assert (fip->field_readcount == TIFF_VARIABLE
|| fip->field_readcount == TIFF_VARIABLE2);
continue;
}
} else {
if (fip->field_readcount == TIFF_VARIABLE
|| fip->field_readcount == TIFF_VARIABLE2)
@ -558,21 +601,23 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
value_count = td->td_samplesperpixel;
else
value_count = fip->field_readcount;
if ((fip->field_type == TIFF_ASCII
|| fip->field_readcount == TIFF_VARIABLE
|| fip->field_readcount == TIFF_VARIABLE2
|| fip->field_readcount == TIFF_SPP
|| value_count > 1)
&& fip->field_tag != TIFFTAG_PAGENUMBER
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
&& fip->field_tag != TIFFTAG_DOTRANGE) {
if (fip->field_tag == TIFFTAG_DOTRANGE
&& strcmp(fip->field_name,"DotRange") == 0) {
/* TODO: This is an evil exception and should not have been
handled this way ... likely best if we move it into
the directory structure with an explicit field in
libtiff 4.1 and assign it a FIELD_ value */
static uint16 dotrange[2];
raw_data = dotrange;
TIFFGetField(tif, tag, dotrange+0, dotrange+1);
} else if (fip->field_type == TIFF_ASCII
|| fip->field_readcount == TIFF_VARIABLE
|| fip->field_readcount == TIFF_VARIABLE2
|| fip->field_readcount == TIFF_SPP
|| value_count > 1) {
if(TIFFGetField(tif, tag, &raw_data) != 1)
continue;
} else if (fip->field_tag != TIFFTAG_PAGENUMBER
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
&& fip->field_tag != TIFFTAG_DOTRANGE) {
} else {
raw_data = _TIFFmalloc(
_TIFFDataSize(fip->field_type)
* value_count);
@ -581,26 +626,6 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
_TIFFfree(raw_data);
continue;
}
} else {
/*
* XXX: Should be fixed and removed,
* see the notes related to
* TIFFTAG_PAGENUMBER,
* TIFFTAG_HALFTONEHINTS,
* TIFFTAG_YCBCRSUBSAMPLING and
* TIFFTAG_DOTRANGE tags in tif_dir.c.
*/
char *tmp;
raw_data = _TIFFmalloc(
_TIFFDataSize(fip->field_type)
* value_count);
tmp = raw_data;
mem_alloc = 1;
if(TIFFGetField(tif, tag, tmp,
tmp + _TIFFDataSize(fip->field_type)) != 1) {
_TIFFfree(raw_data);
continue;
}
}
}
@ -610,7 +635,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
* _TIFFPrettyPrintField() fall down and print it as
* any other tag.
*/
if (!_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data))
if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data))
_TIFFPrintField(fd, fip, value_count, raw_data);
if(mem_alloc)
@ -648,7 +673,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
void
_TIFFprintAscii(FILE* fd, const char* cp)
{
for (; *cp != '\0'; cp++) {
_TIFFprintAsciiBounded( fd, cp, strlen(cp));
}
static void
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars)
{
for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) {
const char* tp;
if (isprint((int)*cp)) {

View File

@ -1,4 +1,4 @@
/* $Id: tif_read.c,v 1.38 2011-12-09 03:29:10 fwarmerdam Exp $ */
/* $Id: tif_read.c,v 1.40 2012-06-01 00:55:09 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -93,6 +93,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
if( unused_data > 0 )
{
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data );
}
@ -120,6 +121,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
- tif->tif_rawdataoff - tif->tif_rawdataloaded;
}
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
cc = TIFFReadFile(tif, tif->tif_rawdata + unused_data, to_read);
if (cc != to_read) {
@ -145,8 +147,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
tif->tif_rawcp = tif->tif_rawdata;
if (!isFillOrder(tif, td->td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
(tif->tif_flags & TIFF_NOBITREV) == 0) {
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
TIFFReverseBits(tif->tif_rawdata + unused_data, to_read );
}
/*
** When starting a strip from the beginning we need to
@ -522,8 +526,11 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
* buffer (if they try to, the application will get a
* fault since the file is mapped read-only).
*/
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = NULL;
tif->tif_rawdatasize = 0;
}
tif->tif_flags &= ~TIFF_MYBUFFER;
/*
* We must check for overflow, potentially causing
@ -565,6 +572,14 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
tif->tif_rawdata = tif->tif_base + (tmsize_t)td->td_stripoffset[strip];
tif->tif_rawdataoff = 0;
tif->tif_rawdataloaded = (tmsize_t) bytecount;
/*
* When we have tif_rawdata reference directly into the memory mapped file
* we need to be pretty careful about how we use the rawdata. It is not
* a general purpose working buffer as it normally otherwise is. So we
* keep track of this fact to avoid using it improperly.
*/
tif->tif_flags |= TIFF_BUFFERMMAP;
} else {
/*
* Expand raw data buffer, if needed, to hold data
@ -589,6 +604,11 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
return (0);
}
if (tif->tif_flags&TIFF_BUFFERMMAP) {
tif->tif_curstrip = NOSTRIP;
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
return (0);
}
if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata,
bytecountm, module) != bytecountm)
return (0);
@ -809,8 +829,11 @@ TIFFFillTile(TIFF* tif, uint32 tile)
* buffer (if they try to, the application will get a
* fault since the file is mapped read-only).
*/
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = NULL;
tif->tif_rawdatasize = 0;
}
tif->tif_flags &= ~TIFF_MYBUFFER;
/*
* We must check for overflow, potentially causing
@ -831,6 +854,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
tif->tif_base + (tmsize_t)td->td_stripoffset[tile];
tif->tif_rawdataoff = 0;
tif->tif_rawdataloaded = (tmsize_t) bytecount;
tif->tif_flags |= TIFF_BUFFERMMAP;
} else {
/*
* Expand raw data buffer, if needed, to hold data
@ -855,6 +879,12 @@ TIFFFillTile(TIFF* tif, uint32 tile)
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
return (0);
}
if (tif->tif_flags&TIFF_BUFFERMMAP) {
tif->tif_curtile = NOTILE;
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
return (0);
}
if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata,
bytecountm, module) != bytecountm)
return (0);
@ -886,10 +916,13 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
static const char module[] = "TIFFReadBufferSetup";
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
tif->tif_flags &= ~TIFF_BUFFERMMAP;
if (tif->tif_rawdata) {
if (tif->tif_flags & TIFF_MYBUFFER)
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = NULL;
tif->tif_rawdatasize = 0;
}
if (bp) {
tif->tif_rawdatasize = size;

View File

@ -28,6 +28,7 @@
* TIFF Library UNIX-specific Routines.
*/
#include "tiffiop.h"
#include "tiffio.hxx"
#include <iostream>
#ifndef __VMS

View File

@ -1,4 +1,4 @@
/* $Id: tif_strip.c,v 1.34 2011-04-02 20:54:09 bfriesen Exp $ */
/* $Id: tif_strip.c,v 1.35 2012-06-06 05:33:55 fwarmerdam Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -107,11 +107,13 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows)
}
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
ycbcrsubsampling+1);
if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
{
TIFFErrorExt(tif->tif_clientdata,module,
"Invalid YCbCr subsampling");
"Invalid YCbCr subsampling (%dx%d)",
ycbcrsubsampling[0],
ycbcrsubsampling[1] );
return 0;
}
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;

View File

@ -1,4 +1,4 @@
/* $Id: tif_tile.c,v 1.22 2010-07-01 15:33:28 dron Exp $ */
/* $Id: tif_tile.c,v 1.23 2012-06-06 05:33:55 fwarmerdam Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -203,12 +203,13 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows)
uint64 samplingrow_size;
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
ycbcrsubsampling+1);
assert((ycbcrsubsampling[0]==1)||(ycbcrsubsampling[0]==2)||(ycbcrsubsampling[0]==4));
assert((ycbcrsubsampling[1]==1)||(ycbcrsubsampling[1]==2)||(ycbcrsubsampling[1]==4));
if (ycbcrsubsampling[0]*ycbcrsubsampling[1]==0)
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
{
TIFFErrorExt(tif->tif_clientdata,module,
"Invalid YCbCr subsampling");
"Invalid YCbCr subsampling (%dx%d)",
ycbcrsubsampling[0],
ycbcrsubsampling[1] );
return 0;
}
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;

View File

@ -1,4 +1,4 @@
/* $Id: tif_unix.c,v 1.22 2010-03-10 18:56:49 bfriesen Exp $ */
/* $Id: tif_unix.c,v 1.23 2012-06-01 21:40:59 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -186,7 +186,11 @@ TIFFOpen(const char* name, const char* mode)
fd = open(name, m, 0666);
if (fd < 0) {
TIFFErrorExt(0, module, "%s: Cannot open", name);
if (errno > 0 && strerror(errno) != NULL ) {
TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) );
} else {
TIFFErrorExt(0, module, "%s: Cannot open", name);
}
return ((TIFF *)0);
}

View File

@ -1,4 +1,4 @@
/* $Id: tiffio.h,v 1.89 2012-02-18 16:20:26 bfriesen Exp $ */
/* $Id: tiffio.h,v 1.90 2012-06-06 04:58:00 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -392,6 +392,8 @@ extern int TIFFSetupStrips(TIFF *);
extern int TIFFWriteCheck(TIFF*, int, const char *);
extern void TIFFFreeDirectory(TIFF*);
extern int TIFFCreateDirectory(TIFF*);
extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
extern int TIFFCreateEXIFDirectory(TIFF*);
extern int TIFFLastDirectory(TIFF*);
extern int TIFFSetDirectory(TIFF*, uint16);
extern int TIFFSetSubDirectory(TIFF*, uint64);
@ -400,6 +402,7 @@ extern int TIFFSetField(TIFF*, uint32, ...);
extern int TIFFVSetField(TIFF*, uint32, va_list);
extern int TIFFUnsetField(TIFF*, uint32);
extern int TIFFWriteDirectory(TIFF *);
extern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
extern int TIFFCheckpointDirectory(TIFF *);
extern int TIFFRewriteDirectory(TIFF *);

View File

@ -1,4 +1,4 @@
/* $Id: tiffiop.h,v 1.82 2011-02-18 20:53:05 fwarmerdam Exp $ */
/* $Id: tiffiop.h,v 1.84 2012-05-30 01:50:17 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -121,6 +121,7 @@ struct tiff {
#define TIFF_BUF4WRITE 0x100000 /* rawcc bytes are for writing */
#define TIFF_DIRTYSTRIP 0x200000 /* stripoffsets/stripbytecount dirty*/
#define TIFF_PERSAMPLE 0x400000 /* get/set per sample tags as arrays */
#define TIFF_BUFFERMMAP 0x800000 /* read buffer (tif_rawdata) points into mmap() memory */
uint64 tif_diroff; /* file offset of current directory */
uint64 tif_nextdiroff; /* file offset of following directory */
uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */
@ -250,7 +251,7 @@ struct tiff {
#define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y))
/* Safe multiply which returns zero if there is an integer overflow */
#define TIFFSafeMultiply(t,v,m) ((((t)m != (t)0) && (((t)((v*m)/m)) == (t)v)) ? (t)(v*m) : (t)0)
#define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0)
#define TIFFmax(A,B) ((A)>(B)?(A):(B))
#define TIFFmin(A,B) ((A)<(B)?(A):(B))

View File

@ -1,4 +1,4 @@
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/*
* This define can be used in code that requires
* compilation-related definitions specific to a
@ -6,4 +6,4 @@
* version checking should be done based on the
* string returned by TIFFGetVersion.
*/
#define TIFFLIB_VERSION 20120218
#define TIFFLIB_VERSION 20120615

21
3rdparty/openexr/AUTHORS.ilmbase vendored Normal file
View File

@ -0,0 +1,21 @@
Developers:
-----------
Florian Kainz <kainz@ilm.com>
Rod Bogart <rgb@ilm.com>
Drew Hess <dhess@ilm.com>
Bill Anderson <wja@ilm.com>
Wojciech Jarosz <wjarosz@ucsd.edu>
Contributors:
-------------
Rito Trevino
Josh Pines
Christian Rouet
Win32 build system:
-------------------
Nick Porcino <NPorcino@lucasarts.com>
Kimball Thurston

41
3rdparty/openexr/AUTHORS.openexr vendored Normal file
View File

@ -0,0 +1,41 @@
Developers:
-----------
Florian Kainz <kainz@ilm.com>
Rod Bogart <rgb@ilm.com>
Drew Hess <dhess@ilm.com>
Paul Schneider <paultschneider@mac.com>
Bill Anderson <wja@ilm.com>
Wojciech Jarosz <wjarosz@ucsd.edu>
Andrew Kunz <akunz@ilm.com>
Contributors:
-------------
Simon Green <SGreen@nvidia.com>
Rito Trevino <etrevino@ilm.com>
Josh Pines
Christian Rouet
Rodrigo Damazio <rdamazio@lsi.usp.br>
Greg Ward <gward@lmi.net>
Joseph Goldstone <joseph@lp.com>
Loren Carpenter, Pixar Animation Studios
Win32 build system:
-------------------
Nick Porcino <NPorcino@lucasarts.com>
Kimball Thurston
Win32 port contributors:
------------------------
Dustin Graves <dgraves@computer.org>
Jukka Liimatta <jukka.liimatta@twilight3d.com>
Baumann Konstantin <Konstantin.Baumann@hpi.uni-potsdam.de>
Daniel Koch <daniel@eyeonline.com>
E. Scott Larsen <larsene@cs.unc.edu>
stephan mantler <step@acm.org>
Andreas Kahler <AKahler@nxn-software.com>
Frank Jargstorff <fjargstorff@nvidia.com>
Lutz Latta

69
3rdparty/openexr/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,69 @@
# ----------------------------------------------------------------------------
# CMake file for openexr
#
# ----------------------------------------------------------------------------
project(openexr CXX)
if(UNIX)
set(HAVE_PTHREAD 1)
include(CheckIncludeFile)
check_include_file(semaphore.h HAVE_POSIX_SEMAPHORES)
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/IlmBaseConfig.h.cmakein"
"${CMAKE_CURRENT_BINARY_DIR}/IlmBaseConfig.h" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/OpenEXRConfig.h.cmakein"
"${CMAKE_CURRENT_BINARY_DIR}/OpenEXRConfig.h" @ONLY)
set(OPENEXR_INCLUDE_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/Half"
"${CMAKE_CURRENT_SOURCE_DIR}/Iex"
"${CMAKE_CURRENT_SOURCE_DIR}/IlmThread"
"${CMAKE_CURRENT_SOURCE_DIR}/Imath"
"${CMAKE_CURRENT_SOURCE_DIR}/IlmImf")
ocv_include_directories("${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIR} ${OPENEXR_INCLUDE_PATHS})
file(GLOB lib_srcs Half/half.cpp Iex/*.cpp IlmThread/*.cpp Imath/*.cpp IlmImf/*.cpp)
file(GLOB lib_hdrs Half/*.h Iex/Iex*.h IlmThread/IlmThread*.h Imath/Imath*.h IlmImf/*.h)
list(APPEND lib_hdrs "${CMAKE_CURRENT_BINARY_DIR}/IlmBaseConfig.h" "${CMAKE_CURRENT_BINARY_DIR}/OpenEXRConfig.h")
if(WIN32)
ocv_list_filterout(lib_srcs Posix.*cpp)
else()
ocv_list_filterout(lib_srcs Win32.cpp)
endif()
source_group("Include" FILES ${lib_hdrs} )
source_group("Src" FILES ${lib_srcs})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267) # vs2008 Win64
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
add_library(IlmImf STATIC ${lib_hdrs} ${lib_srcs})
target_link_libraries(IlmImf ${ZLIB_LIBRARIES})
set_target_properties(IlmImf
PROPERTIES
OUTPUT_NAME "IlmImf"
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(IlmImf PROPERTIES FOLDER "3rdparty")
endif()
if(NOT BUILD_SHARED_LIBS)
install(TARGETS IlmImf ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
endif()
set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)
set(OPENEXR_VERSION "1.7.1" PARENT_SCOPE)

109
3rdparty/openexr/ChangeLog.ilmbase vendored Normal file
View File

@ -0,0 +1,109 @@
Version 1.0.3
* Added support for enabling/disabling large stack optimisations, used in
halfFunction.h.
(Piotr Stanczyk)
* Added ImathNoise.(h/cpp) files. Initializes Perlin noise to match the
Renderman implmenetation.
(Pixar Contribution)
* Fixed a number of missing includes to comply with stricter
enforcement by gnu compilers.
(Piotr Stanczyk)
* Depracated compiler flag: -Wno-long-double since it is no longer
supported under OS X.
(Piotr Stanczyk)
* A minor API change to Imath::Frustum has been made: the functions
'near' and 'far' have been renamed to 'nearPlane' and 'farPlane' due
to conflicts with certain windows headers. The former alternate
accessor names for these values on windows ('hither' and 'yon')
remain, though should be considered deprecated.
(David Lenihan)
* Added SVD, eigenvalue solver, and procrustes fit calculations
to ImathMatrixAlgo.
(Chris Twigg, Ji Hun Yu)
* Added Imath::FrustumTest for frustum visibility testing.
(Eric Johnston)
* Fixed a stack corruption in the matrix minorOf functions.
(Nick Rasmussen)
* Visual studio 2008 project files have been added to the vc/vc9
directory, and several minor visual studio compile fixes have
been applied.
(Nick Rasmussen)
* Updated the so verison to 7.
(Piotr Stanczyk)
* Depracated the MacCode_Warrior and Shake submodules.
(Piotr Stanczyk)
Version 1.0.2
* Added support for targetting builds on 64bit Windows and minimising
number of compiler warnings on Windows. Thanks to Ger Hobbelt for his
contributions to CreateDLL.
(Ji Hun Yu)
* Removed a spurious restrict qualifier in the matrix manipulation code
that was causing the 64-bit MS compiler to generate code in release
mode that caused incorrect results.
(Ji Hun Yu)
* Added patches for improving universal binaries on OS X. Thanks to
Paul Schneider for the contribution
(Piotr Stanczyk)
* Imath::Box optimization: remove loops from methods by partially
specializing the class, for boxes of two and three dimensions.
(Piotr Stanczyk)
* Added explicit copy constructors to Imath::Matrix33<T> and
ImathMatrix44<T> to make conversions between float and double
matrices more convenient.
(Florian Kainz)
* Added slerpShortestArc() and euclideanInnerProduct() functions
to Imath::Quat<T>.
(Nick Porcino)
* Added 4D vector class template Imath::Vec4<T>.
(Nick Porcino)
* Copy constructors and assignment operators for Matrix33<T>
and Matrix44<T> are up to 25% faster. Added matrix constructors
that do not initialize the matrix (this is faster in cases where
the initial value of the matrix is immediately overwritten anyway).
(Nick Porcino)
* Rewrote function closestPointOnBox(point,box). Shortened
the code, improved numerical accuracy, fixed a bug where
closestPointOnBox(box.center(),box) would return the center
of the +Z side of the box, even if the +/-X or +/-Y sides
were closer.
(Florian Kainz)
* Rewrote function findEntryAndExitPoints() in ImathBoxAlgo.h.
Results are now consistent with those from intersect(), also
in ImathBoxAlgo.h.
(Florian Kainz)
* Made Vec2<T>::length() and Vec3<T>::length() more accurate for
vectors whose length is less than sqrt(limits<T>::smallest());
(Florian Kainz)
* Made Quat<T>::angle() more accurate for small angles.
(Don Hatch)
Version 1.0.1:
* Removed Windows .suo files from distribution.
(Eric Wimmer)
Version 1.0.0:
* Bumped DSO version number to 6.0
(Florian Kainz)
* Rounding during float-to-half conversion now implements
"round to nearest even" mode: if the original float value
is exactly in the middle between the two closest half values
then rounding chooses the half value whose least significant
bit is zero.
(Florian Kainz)
* Installation Tuning:
- Corrected version number on dso's (libtool) - now 5.0
- Separated ILMBASE_LDFLAGS and ILMBASE_LIBS so that test programs
in configure scripts of packages dependent on IlmBase can link
with static libraries properly
- eliminated some warning messages during install
(Andrew Kunz)
Version 0.9.0:
* Initial release of this code as a separate library.
Previously the libraries contained were part of
version 1.4.0 of OpenEXR
* New build scripts for Linux/Unix
(Andrew Kunz)
* New Windows project files and build scripts
(Kimball Thurston)

666
3rdparty/openexr/ChangeLog.openexr vendored Normal file
View File

@ -0,0 +1,666 @@
Version 1.7.1:
* Updated the .so verison to 7.
(Piotr Stanczyk)
Version 1.7.0:
* Added support for targetting builds on 64bit Windows and minimising
number of compiler warnings on Windows. Thanks to Ger Hobbelt for his
contributions to CreateDLL.
(Ji Hun Yu)
* Added new atttribute types:
M33dAttribute 3x3 double-precision matrix
M44dAttribute 4x4 double-precision matrix
V2d 2D double-precision vector
V3d 3D double-precision vector
(Florian Kainz)
* Bug fix: crash when reading a damaged image file (found
by Apple). An exception thrown inside the PIZ Huffman
decoder bypasses initialization of an array of pointers.
The uninitialized pointers are later passed to operator
delete.
(Florian Kainz)
* Bug fix: crash when reading a damaged image file (found by
Apple). Computing the size of input certain buffers may
overflow and wrap around to a small number, later causing
writes beyond the end of the buffer.
(Florian Kainz)
* In the "Technical Introduction" document, added
Premultiplied vs. Un-Premulitiplied Color section:
states explicitly that pixels with zero alpha and non-zero
RGB are allowed, points out that preserving such a pixel can
be a problem in application programs with un-premultiplied
internal image representations.
(Florian Kainz)
* exrenvmap improvements:
- New command line flags set the type of the input image to
latitude-longitude map or cube-face map, overriding the
envmap attribute in the input file header.
- Cube-face maps can now be assembled from or split into six
square sub-images.
- Converting a cube-face map into a new cube-face map with
the same face size copies the image instead of resampling
it. This avoids blurring when a cube-face map is assembled
from or split into sub-images.
(Florian Kainz)
* Updated standard chromaticities in ImfAcesFile.cpp to match
final ACES (Academy Color Encoding Specification) document.
(Florian Kainz)
* Added worldToCamera and worldToNDC matrices to
ImfStandardAttributes.h (Florian Kainz)
* Increased the maximum length of attribute and channel names
from 31 to 255 characters. For files that do contain names
longer than 31 characters, a new LONG_NAMES_FLAG in the fil
version number is set. This flag causes older versions of
the IlmImf library (1.6.1 and earlier) to reject files with
long names. Without the flag, older library versions would
mis-interpret files with long names as broken.
(Florian Kainz)
* Reading luminance/chroma-encoded files via the RGBA
interface is faster: buffer padding avoids cache thrashing
for certain image sizes, redundant calls to saturation()
have been eliminated.
(Mike Wall)
* Added "hemispherical blur" option to exrenvmap.
(Florian Kainz)
* Added experimental version of I/O classes for ACES file
format (restricted OpenEXR format with special primaries
and white point); added exr2aces file converter.
(Florian Kainz)
* Added new constructors to classes Imf::RgbaInputFile and
Imf::TiledRgbaInputFile. The new constructors have a
layerName parameter, which allows the caller to specify
which layer of a multi-layer or multi-view image will
be read.
(Florian Kainz)
* A number of member functions in classes Imf::Header,
Imf::ChannelList and Imf::FrameBuffer have parameters
of type "const char *". Added equivalent functions that
take "const std::string &" parameters.
(Florian Kainz)
* Added library support for Weta Digital multi-view images:
StringVector attribute type, multiView standard attribute
of type StringVector, utility functions related to grouping
channels into separate views.
(Peter Hillman, Florian Kainz)
Version 1.6.1:
* Removed Windows .suo files from distribution.
(Eric Wimmer)
* Bug fix: crashes, memory leaks and file descriptor leaks
when reading damaged image files (some reported by Apple,
others found by running IlmImfFuzzTest).
(Florian Kainz)
* Added new IlmImfFuzzTest program to test how resilient the
IlmImf library is with respect broken input files: the program
first damages OpenEXR files by partially overwriting them with
random data; then it tries to read the damaged files. If all
goes well, the program doesn't crash.
(Florian Kainz)
Version 1.6.0:
* Bumped DSO version number to 6.0
(Florian Kainz)
* Added new standard attributes related to color rendering with
CTL (Color Transformation Language): renderingTransform,
lookModTransform and adoptedNeutral.
(Florian Kainz)
* Bug fix: for pixels with luminance near HALF_MIN, conversion
from RGB to luminance/chroma produces NaNs and infinities
(Florian Kainz)
* Bug fix: excessive desaturation of small details with certain
colors after repeatedly loading and saving luminance/chroma
encoded images with B44 compression.
(Florian Kainz)
* Added B44A compression, a minor variation of B44: in most cases,
the compression ratio is 2.28:1, the same as with B44, but in
uniform image areas where all pixels have the same value, the
compression ratio increases to 10.66:1. Uniform areas occur, for
example, in an image's alpha channel, which typically contains
large patches that are solid black or white, or in computer-
generated images with a black background.
(Florian Kainz)
* Added flag to configure.ac to enable or disable use of large
auto arrays in the IlmImf library. Default is "enable" for
Linux, "disable" for everything else.
(Darby Johnston, Florian Kainz)
* corrected version number on dso's (libtool) - now 5.0
* Separated ILMBASE_LDFLAGS and ILMBASE_LIBS so that test programs
can link with static libraries properly
* eliminated some warning messages during install
(Andrew Kunz)
Version 1.5.0:
* reorganized packaging of OpenEXR libraries to facilitate
integration with CTL. Now this library depends on the library
IlmBase. Some functionality has been moved into OpenEXR_Viewers,
which depends on two other libraries, CTL and OpenEXR_CTL.
Note: previously there were separate releases of
OpenEXR-related plugins for Renderman, Shake and Photoshop.
OpenEXR is supported natively by Rendermand and Photoshop, so
these plugins will not be supported for this or future
versions of OpenEXR.
(Andrew Kunz)
* New build scripts for Linux/Unix
(Andrew Kunz)
* New Windows project files and build scripts
(Kimball Thurston)
* float-to-half conversion now preserves the sign of float zeroes
and of floats that are so small that they become half zeroes.
(Florian Kainz)
* Bug fix: Imath::Frustum<T>::planes() returns incorrect planes
if the frustum is orthogonal.
(Philip Hubbard)
* added new framesPerSecond optional standard attribute
(Florian Kainz)
* Imath cleanup:
- Rewrote function Imath::Quat<T>::setRotation() to make it
numerically more accurate, added confidence tests
- Rewrote function Imath::Quat<T>::slerp() using Don Hatch's
method, which is numerically more accurate, added confidence
tests.
- Rewrote functions Imath::closestPoints(), Imath::intersect(),
added confidence tests.
- Removed broken function Imath::nearestPointOnTriangle().
- Rewrote Imath::drand48(), Imath::lrand48(), etc. to make
them functionally identical with the Unix/Linux versions
of drand48(), lrand48() and friends.
- Replaced redundant definitions of Int64 in Imath and IlmImf
with a single definition in ImathInt64.h.
(Florian Kainz)
* exrdisplay: if the file's and the display's RGB chromaticities
differ, the pixels RGB values are transformed from the file's
to the display's RGB space.
(Florian Kainz)
* Added new lossy B44 compression method. HALF channels are
compressed with a fixed ratio of 2.28:1. UINT and FLOAT
channels are stored verbatim, without compression.
(Florian Kainz)
Version 1.4.0a:
* Fixed the ReleaseDLL targets for Visual Studio 2003.
(Barnaby Robson)
Version 1.4.0:
* Production release.
* Bug Fix: calling setFrameBuffer() for every scan line
while reading a tiled file through the scan line API
returns bad pixel data. (Paul Schneider, Florian Kainz)
Version 1.3.1:
* Fixed the ReleaseDLL targets for Visual Studio 2005.
(Nick Porcino, Drew Hess)
* Fixes/enhancements for createDLL.
(Nick Porcino)
Version 1.3.0:
* Removed openexr.spec file, it's out of date and broken to
boot.
(Drew Hess)
* Support for Visual Studio 2005.
(Drew Hess, Nick Porcino)
* When compiling against OpenEXR headers on Windows, you
no longer need to define any HAVE_* or PLATFORM_*
macros in your projects. If you are using any OpenEXR
DLLs, however, you must define OPENEXR_DLL in your
project's preprocessor directives.
(Drew Hess)
* Many fixes to the Windows VC7 build system.
(Drew Hess, Nick Porcino)
* Support for building universal binaries on OS X 10.4.
(Drew Hess, Paul Schneider)
* Minor configure.ac fix to accomodate OS X's automake.
(Drew Hess)
* Removed CPU-specific optimizations from configure.ac,
autoconf's guess at the CPU type isn't very useful,
anyway. Closes #13429.
(Drew Hess)
* Fixed quoting for tests in configure.ac. Closes #13428.
(Drew Hess)
* Use host specification instead of target in configure.ac.
Closes #13427.
(Drew Hess)
* Fix use of AC_ARG_ENABLE in configure.ac. Closes
#13426.
(Drew Hess)
* Removed workaround for OS X istream::read bug.
(Drew Hess)
* Added pthread support to OpenEXR pkg-config file.
(Drew Hess)
* Added -no-undefined to LDFLAGS and required libs to LIBADD
for library projects with other library dependencies, per
Rex Dieter's patch.
(Drew Hess)
* HAVE_* macros are now defined in the OpenEXRConfig.h header
file instead of via compiler flags. There are a handful of
public headers which rely on the value of these macros,
and projects including these headers have previously needed
to define the same macros and values as used by OpenEXR's
'configure', which is bad form. Now 'configure' writes these
values to the OpenEXRConfig.h header file, which is included
by any OpenEXR source files that need these macros. This
method of specifying HAVE_* macros guarantees that projects
will get the proper settings without needing to add compile-
time flags to accomodate OpenEXR. Note that this isn't
implemented properly for Windows yet.
(Drew Hess)
* Platform cleanups:
- No more support for IRIX or OSF1.
- No more explicit support for SunOS, because we have no way to
verify that it's working. I suspect that newish versions of
SunOS will just work out of the box, but let me know if not.
- No more PLATFORM_* macros (vestiges of the ILM internal build
system). PLATFORM_DARWIN_PPC is replaced by HAVE_DARWIN.
PLATFORM_REDHAT_IA32 (which was only used in IlmImfTest) is
replaced by HAVE_LINUX_PROCFS.
- OS X 10.4, which is the minimum version we're going to support
with this version, appears to have support for nrand48 and friends,
so no need to use the Imath-supplied version of them anymore.
(Drew Hess)
* No more PLATFORM_WINDOWS or PLATFORM_WIN32, replace with
proper standard Windows macros. (Drew Hess)
* Remove support for gcc 2.95, no longer supported. (Drew Hess)
* Eliminate HAVE_IOS_BASE macro, OpenEXR now requires support for
ios_base. (Drew Hess)
* Eliminate HAVE_STL_LIMITS macro, OpenEXR now requires the ISO C++
<limits> header. (Drew Hess)
* Use double quote-style include dirctives for OpenEXR
includes. (Drew Hess)
* Added a document that gives an overview of the on-disk
layout of OpenEXR files (Florian Kainz)
* Added sections on layers and on memory-mapped file input
to the documentation. (Florian Kainz)
* Bug fix: reading an incomplete file causes a deadlock while
waiting on a semaphore. (Florian Kainz)
* Updated documentation (ReadingAndWritingImageFiles.sxw) and
sample code (IlmImfExamples):
Added a section about multi-threading, updated section on
thread-safety, changed documentation and sample code to use
readTiles()/writeTiles() instead of readTile()/writeTile()
where possible, mentioned that environment maps contain
redundant pixels, updated section on testing if a file is
an OpenEXR file.
(Florian Kainz)
* Multi-threading bug fixes (exceptions could be thrown
multiple times, some operations were not thread safe),
updated some comments, added comments, more multithreaded
testing.
(Florian Kainz)
* Added multi-threading support: multiple threads
cooperate to read or write a single OpenEXR file.
(Wojciech Jarosz)
* Added operator== and operator!= to Imath::Frustum.
(Andre Mazzone)
* Bug fix: Reading a PIZ-compressed file with an invalid
Huffman code table caused crashes by indexing off the
end of an array.
(Florian Kainz)
Version 1.2.2:
* Updated README to remove option for building with Visual C++ 6.0.
(Drew Hess)
* Some older versions of gcc don't support a full iomanip
implemenation; check for this during configuration.
(Drew Hess)
* Install PDF versions of documentation, remove old/out-of-date
HTML documentation. (Florian Kainz)
* Removed vc/vc6 directory; Visual C++ 6.0 is no longer
supported. (Drew Hess)
* Updated README.win32 with details of new build system.
(Florian Kainz, Drew Hess)
* New build system for Windows / Visual C++ 7 builds both
static libraries and DLLs.
(Nick Porcino)
* Removed Imath::TMatrix<T> and related classes, which are not
used anywhere in OpenEXR.
(Florian Kainz)
* Added minimal support for "image layers" to class Imf::ChannelList
(Florian Kainz)
* Added new isComplete() method to InputFile, TiledInputFile
etc., that checks if a file is complete or if any pixels
are missing (for example, because writing the file was
aborted prematurely).
(Florian Kainz)
* Exposed staticInitialize() function in ImfHeader.h in order
to allow thread-safe library initialization in multithreaded
programs.
(Florian Kainz)
* Added a new "time code" attribute
(Florian Kainz)
* exrmaketiled: when a MIPMAP_LEVELS or RIPMAP_LEVELS image
is produced, low-pass filtering takes samples outside the
image's data window. This requires extrapolating the image.
The user can now specify how the image is extrapolated
horizontally and vertically (image is surrounded by black /
outermost row of pixels repeats / entire image repeats /
entire image repeats, every other copy is a mirror image).
exrdisplay: added option to swap the top and botton half,
and the left and right half of an image, so that the image's
four corners end up in the center. This is useful for checking
the seams of wrap-around texture map images.
IlmImf library: Added new "wrapmodes" standard attribute
to indicate the extrapolation mode for MIPMAP_LEVELS and
RIPMAP_LEVELS images.
(Florian Kainz)
* Added a new "key code" attribute to identify motion picture
film frames.
(Florian Kainz)
* Removed #include <Iex.h> from ImfAttribute.h, ImfHeader.h
and ImfXdr.h so that including header files such as
ImfInputFile.h no longer defines ASSERT and THROW macros,
which may conflict with similar macros defined by
application programs.
(Florian Kainz)
* Converted HTML documentation to OpenOffice format to
make maintaining the documents easier:
api.html -> ReadingAndWritingImageFiles.sxw
details.html -> TechnicalIntroduction.sxw
(Florian Kainz)
Version 1.2.1:
* exrenvmap and exrmaketiled use slightly less memory
(Florian Kainz)
* Added functions to IlmImf for quickly testing if a file
is an OpenEXR file, and whether the file is scan-line
based or tiled. (Florian Kainz)
* Added preview image examples to IlmImfExamples. Added
description of preview images and environment maps to
docs/api.html (Florian Kainz)
* Bug fix: PXR24 compression did not work properly for channels
with ySampling != 1.
(Florian Kainz)
* Made template <class T> become template <class S, class T> for
the transform(ObjectS, ObjectT) methods. This was done to allow
for differing templated objects to be passed in e.g. say a
Box<Vec3<S>> and a Matrix44<T>, where S=float and T=double.
(Jeff Yost, Arkell Rasiah)
* New method Matrix44::setTheMatrix(). Used for assigning a
M44f to a M44d. (Jeff Yost, Arkell Rasiah)
* Added convenience Color typedefs for half versions of Color3
and Color4. Note the Makefile.am for both Imath and ImathTest
have been updated with -I and/or -L pathing to Half.
(Max Chen, Arkell Rasiah)
* Methods equalWithAbsError() and equalWithRelError() are now
declared as const. (Colette Mullenhoff, Arkell Rasiah)
* Fixes for gcc34. Mainly typename/template/using/this syntax
correctness changes. (Nick Ramussen, Arkell Rasiah)
* Added Custom low-level file I/O examples to IlmImfExamples
and to the docs/api.html document. (Florian Kainz)
* Eliminated most warnings messages when OpenEXR is compiled
with Visual C++. The OpenEXR code uses lots of (intentional
and unintended) implicit type conversions. By default, Visual
C++ warns about almost all of them. Most implicit conversions
have been removed from the .h files, so that including them
should not generate warnings even at warning level 3. Most
.cpp files are now compiled with warning level 1.
(Florian Kainz)
Version 1.2.0:
* Production-ready release.
* Disable long double warnings on OS X. (Drew Hess)
* Add new source files to VC7 IlmImfDll target. (Drew Hess)
* Iex: change the way that APPEND_EXC and REPLACE_EXC modify
their what() string to work around an issue with Visual C++
7.1. (Florian Kainz, Nick Porcino)
* Bumped OpenEXR version to 1.2 and .so versions to 2.0.0 in
preparation for the release. (Drew Hess)
* Imath: fixed ImathTMatrix.h to work with gcc 3.4. (Drew Hess)
* Another quoting fix in openexr.m4. (Drew Hess)
* Quoting fix in acinclude.m4 for automake 1.8. (Brad Hards)
* Imath: put inline at beginning of declaration in ImathMatrix.h
to fix a warning. (Ken McGaugh)
* Imath: made Vec equalWith*Error () methods const.
* Cleaned up compile-time Win32 support. (Florian Kainz)
* Bug fix: Reading a particular broken PIZ-compressed file
caused crashes by indexing off the end of an array.
(Florian Kainz)
Version 1.1.1:
* Half: operator= and variants now return by reference rather
than by value. This brings half into conformance with
built-in types. (Drew Hess)
* Half: remove copy constructor, let compiler supply its
own. This improves performance up to 25% on some
expressions using half. (Drew Hess)
* configure: don't try to be fancy with CXXFLAGS, just use
what the user supplies or let configure choose a sensible
default if CXXFLAGS is not defined.
* IlmImf: fixed a bug in reading scanline files on big-endian
architectures. (Drew Hess)
* exrmaketiled: Added an option to select compression type.
(Florian Kainz)
* exrenvmap: Added an option to select compression type.
(Florian Kainz)
* exrdisplay: Added some new command-line options. (Florian Kainz)
* IlmImf: Added Pixar's new "slightly lossy" image compression
method. The new method, named PXR24, preserves HALF and
UINT data without loss, but FLOAT pixels are converted to
a 24-bit representation. PXR24 appears to compress
FLOAT depth buffers very well without losing much accuracy.
(Loren Carpenter, Florian Kainz)
* Changed top-level LICENSE file to allow for other copyright
holders for individual files.
* IlmImf: TILED FILE FORMAT CHANGE. TiledOutputFile was
incorrectly interleaving channels and scanlines before
passing pixel data to a compressor. The lossless compressors
still work, but lossy compressors do not. Fix the bug by
interleaving channels and scanlines in tiled files in the
same way as ScanLineOutputFile does. Programs compiled with
the new version of IlmImf cannot read tiled images produced
with version 1.1.0. (Florian Kainz)
* IlmImf: ImfXdr.h fix for 64-bit architectures. (Florian Kainz)
* IlmImf: OpenEXR now supports YCA (luminance/chroma/alpha)
images with subsampled chroma channels. When an image
is written with the RGBA convenience interface, selecting
WRITE_YCA instead of WRITE_RGBA causes the library to
convert the pixels to YCA format. If WRITE_Y is selected,
only luminance is stored in the file (for black and white
images). When an image file is read with the RGBA convenience
interface, YCA data are automatically converted back to RGBA.
(Florian Kainz)
* IlmImf: speed up reading tiled files as scan lines.
(Florian Kainz)
* Half: Fixed subtle bug in Half where signaling float NaNs
were being converted to inf in half. (Florian Kainz)
* gcc 3.3 compiler warning cleanups. (various)
* Imath: ImathEuler.h fixes for gcc 3.4. (Garrick Meeker)
Version 1.1.0:
* Added new targets to Visual C++ .NET 2003 project
for exrmaketiled, exrenvmap, exrmakepreview, and exrstdattr.
(Drew Hess)
* A few assorted Win32 fixes for Imath. (Drew Hess)
* GNU autoconf builds now produce versioned libraries.
This release is 1:0:0. (Drew Hess)
* Fixes for Visual C++ .NET 2003. (Paul Schneider)
* Updated Visual C++ zlib project file to zlib 1.2.1.
(Drew Hess)
* exrdisplay: Fixed fragment shader version. (Drew Hess)
* *Test: Fixed some compiler issues. (Drew Hess)
* Imath: Handle "restrict" keyword properly. (Drew Hess)
* IlmImfExamples: Updated to latest versions of example
source code, includes tiling and multi-res images.
(Florian Kainz)
* exrmakepreview: A new utility to create preview images.
(Florian Kainz)
* exrenvmap: A new utility to create OpenEXR environment
maps. (Florian Kainz)
* exrstdattr: A new utility to modify standard
attributes. (Florian Kainz)
* Updated exrheader to print level rounding mode and
preview image size. (Florian Kainz)
* Updated exrmaketiled to use level rounding mode.
(Florian Kainz)
* IlmImf: Changed the orientation of lat-long envmaps to
match typical panoramic camera setups. (Florian Kainz)
* IlmImf: Fixed a bug where partially-completed files with
DECREASING_Y could not be read. (Florian Kainz)
* IlmImf: Added support for selectable rounding mode (up/down)
when generating multiresolution files. (Florian Kainz)
* exrdisplay: Support for tiled images, mip/ripmaps, preview
images, and display windows. (Florian Kainz, Drew Hess)
* exrmaketiled: A new utility which generates tiled
versions of OpenEXR images. (Florian Kainz)
* IlmImf: Changed Imf::VERSION to Imf::EXR_VERSION to
work around problems with autoconf VERSION macro
conflict. (Drew Hess)
* exrheader: Support for tiles, mipmaps, environment
maps. (Florian Kainz)
* IlmImf: Environment map support. (Florian Kainz)
* IlmImf: Abstracted stream I/O support. (Florian Kainz)
* IlmImf: Support for tiled and mip/ripmapped files;
requires new file format. (Wojciech Jarosz, Florian Kainz)
* Imath: TMatrix*, generic 2D matricies and algorithms.
(Francesco Callari)
* Imath: major quaternions cleanup. (Cary Phillips)
* Imath: added GLBegin, GLPushAttrib, GLPushMatrix objects
for automatic cleanup on exceptions. (Cary Phillips)
* Imath: removed implicit scalar->vector promotions and vector
comparisons. (Nick Rasmussen)
Version 1.0.7:
* Fixed a typo in one of the IlmImfTest tests. (Paul Schneider)
* Fixed a bug in exrdisplay that causes the image to display
as all black if there's a NaN or infinity in an OpenEXR
image. (Florian Kainz)
* Updated exrheader per recent changes to IlmImf library.
(Florian Kainz)
* Changed an errant float to a T in ImathFrame.h nextFrame().
(Cary Phillips)
* Support for new "optional standard" attributes
(chromaticities, luminance, comments, etc.).
(Florian Kainz, Greg Ward, Joseph Goldstone)
* Fixed a buffer overrun in ImfOpaqueAttribute. (Paul Schneider)
* Added new function, isImfMagic (). (Florian Kainz)
Version 1.0.6:
* Added README.win32 to disted files.
* Fixed OpenEXR.pc.in pkg-config file, OpenEXR now works
with pkg-config.
* Random fixes to readme files for new release.
* Fixed openexr.m4, now looks in /usr by default.
* Added Visual Studio .NET 2003 "solution."
* Fixes for Visual Studio .NET 2003 w/ Microsoft C++ compiler.
(Various)
* Random Imath fixes and enhancements. Note that
extractSHRT now takes an additional optional
argument, see ImathMatrixAlgo.h for details. (Various)
* Added Wojciech Jarosz to AUTHORS file.
* Added test cases for uncompressed case, preview images,
frame buffer type conversion. (Wojciech Jarosz,
Florian Kainz)
* Fix a bug in IlmImf where uncompressed data doesn't get
read/written correctly. (Wojciech Jarosz)
* Added support for preview images and preview image
attributes (thumbnail images) in IlmImf. (Florian Kainz)
* Added support for automatic frame buffer type conversion
in IlmImf. (Florian Kainz)
* Cleaned up some compile-time checks.
* Added HalfTest unit tests.
* [exrdisplay] Download half framebuffer to texture memory
instead of converting to float first. Requires latest
Nvidia drivers.
Version 1.0.5:
* Fixed IlmImf.dll to use static runtime libs (Andreas).
* Added exrheader project to Visual Studio 6.0 workspace.
* Added some example code showing how to use the IlmImf library.
(Florian)
* Use DLL runtime libs for Win32 libraries rather than static
runtime libs.
* Add an exrdisplay_fragshader project to the Visual Studio 6.0
workspace to enable fragment shaders in Win32.
* Add an IlmImfDll project to the Visual Studio 6.0 workspace.
* In Win32, export the ImfCRgbaFile C interface via a DLL so
that Visual C++ 6.0 users can link against an Intel-compiled
IlmImf. (Andreas Kahler)
* Use auto_ptr in ImfAutoArray on Win32, it doesn't like large
automatic stacks.
* Performance improvements in PIZ decoding, between
20 and 60% speedup on Athlon and Pentium 4 systems.
(Florian)
* Updated the README with various information, made
some cosmetic changes for readability.
* Added fragment shader support to exrdisplay.
* Bumped the version to 1.0.5 in prep for release.
* Updated README and README.OSX to talk about CodeWarrior
project files.
* Incorporated Rodrigo Damazio's patch for an openexr.m4
macro file and an openexr.spec file for building RPMs.
* Small change in ImfAttribute.h to make IlmImf compile with gcc 2.95.
* Updated ImfDoubleAttribute.h for Codewarrior on MacOS.
* Added exrheader utility.
* Update to AUTHORS file.
* Added a README.win32 file.
* Added project files for Visual Studio 6.0.
* Initial Win32 port. Requires Visual Studio 6.0 and Intel C++
compiler version 7.0.
* Added new intersectT method in ImathSphere.h
* Fixed some bugs in ImathQuat.h
* Proper use of fltk-config to get platform-specific FLTK
compile- and link-time flags.
* exrdisplay uses Imath::Math<T>::pow instead of powf now.
powf is not availble on all platforms.
* Roll OS X "hack" into the source until Apple fixes their
istream implementation.
Version 1.0.4:
* OpenEXR is now covered by a modified BSD license. See LICENSE
for the new terms.
Version 1.0.3:
* OpenEXR is now in sf.net CVS.
* Imf::Xdr namespace cleanups.
* Some IlmImfTest cleanups for OS X.
* Use .cpp extension in exrdisplay sources.
* Iex cleanups.
* Make IlmImf compile with Metrowerks Codewarrior.
* Change large automatic stacks in ImfHuf.C to auto_ptrs allocated
off the heap. MacOS X default stack size isn't large enough.
* std::ios fix for MacOS X in ImfInputFile.C.
* Added new FP predecessor/successor functions to Imath, added
tests to ImathTest
* Fixed a bug in Imath::extractSHRT for 3x3 matricies when
exactly one of the original scaling factors is negative, updated
ImathTest to check this case.
* Install include files when 'make install' is run.
* exrdisplay requires fltk 1.1+ now in an effort to support
a MacOS X display program (fltk 1.1 runs on OS X), though this
is untested.
* renamed configure.in to configure.ac
* Removed some tests from IexTest that are no longer used.
* Removed ImfHalfXdr.h, it's not used anymore.
* Revamped the autoconf system, added some compile-time
optimizations, a pkgconfig target, and some maintainer-specific
stuff.
Version 1.0.2:
* More OS X fixes in Imath, IlmImf and IlmImfTest.
* Imath updates.
* Fixed a rotation bug in Imath
Version 1.0.1:
* Used autoconf 2.53 and automake 1.6 to generate build environment.
* Makefile.am cleanups.
* OS X fixes.
* removed images directory (now distributed separately).
Version 1.0:
* first official release.
* added some high-level documentation, removed the old OpenEXR.html
documentation.
* fixed a few nagging build problems.
* bumped IMV_VERSION_NUMBER to 2
Version 0.9:
* added exrdisplay viewer application.
* cleanup _data in Imf::InputFile and Imf::OutputFile constructors.
* removed old ILM copyright notices.
Version 0.8:
* Initial release.

114
3rdparty/openexr/Half/eLut.cpp vendored Normal file
View File

@ -0,0 +1,114 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <iomanip>
using namespace std;
//-----------------------------------------------------
// Compute a lookup table for float-to-half conversion.
//
// When indexed with the combined sign and exponent of
// a float, the table either returns the combined sign
// and exponent of the corresponding half, or zero if
// the corresponding half may not be normalized (zero,
// denormalized, overflow).
//-----------------------------------------------------
void
initELut (unsigned short eLut[])
{
for (int i = 0; i < 0x100; i++)
{
int e = (i & 0x0ff) - (127 - 15);
if (e <= 0 || e >= 30)
{
//
// Special case
//
eLut[i] = 0;
eLut[i | 0x100] = 0;
}
else
{
//
// Common case - normalized half, no exponent overflow possible
//
eLut[i] = (e << 10);
eLut[i | 0x100] = ((e << 10) | 0x8000);
}
}
}
//------------------------------------------------------------
// Main - prints the sign-and-exponent conversion lookup table
//------------------------------------------------------------
int
main ()
{
const int tableSize = 1 << 9;
unsigned short eLut[tableSize];
initELut (eLut);
cout << "//\n"
"// This is an automatically generated file.\n"
"// Do not edit.\n"
"//\n\n";
cout << "{\n ";
for (int i = 0; i < tableSize; i++)
{
cout << setw (5) << eLut[i] << ", ";
if (i % 8 == 7)
{
cout << "\n";
if (i < tableSize - 1)
cout << " ";
}
}
cout << "};\n";
return 0;
}

71
3rdparty/openexr/Half/eLut.h vendored Normal file
View File

@ -0,0 +1,71 @@
//
// This is an automatically generated file.
// Do not edit.
//
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 1024, 2048, 3072, 4096, 5120, 6144, 7168,
8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360,
16384, 17408, 18432, 19456, 20480, 21504, 22528, 23552,
24576, 25600, 26624, 27648, 28672, 29696, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 33792, 34816, 35840, 36864, 37888, 38912, 39936,
40960, 41984, 43008, 44032, 45056, 46080, 47104, 48128,
49152, 50176, 51200, 52224, 53248, 54272, 55296, 56320,
57344, 58368, 59392, 60416, 61440, 62464, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};

311
3rdparty/openexr/Half/half.cpp vendored Normal file
View File

@ -0,0 +1,311 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
// Primary authors:
// Florian Kainz <kainz@ilm.com>
// Rod Bogart <rgb@ilm.com>
//---------------------------------------------------------------------------
//
// class half --
// implementation of non-inline members
//
//---------------------------------------------------------------------------
#include <assert.h>
#include "half.h"
using namespace std;
//-------------------------------------------------------------
// Lookup tables for half-to-float and float-to-half conversion
//-------------------------------------------------------------
HALF_EXPORT_CONST half::uif half::_toFloat[1 << 16] =
#include "toFloat.h"
HALF_EXPORT_CONST unsigned short half::_eLut[1 << 9] =
#include "eLut.h"
//-----------------------------------------------
// Overflow handler for float-to-half conversion;
// generates a hardware floating-point overflow,
// which may be trapped by the operating system.
//-----------------------------------------------
float
half::overflow ()
{
volatile float f = 1e10;
for (int i = 0; i < 10; i++)
f *= f; // this will overflow before
// the for­loop terminates
return f;
}
//-----------------------------------------------------
// Float-to-half conversion -- general case, including
// zeroes, denormalized numbers and exponent overflows.
//-----------------------------------------------------
short
half::convert (int i)
{
//
// Our floating point number, f, is represented by the bit
// pattern in integer i. Disassemble that bit pattern into
// the sign, s, the exponent, e, and the significand, m.
// Shift s into the position where it will go in in the
// resulting half number.
// Adjust e, accounting for the different exponent bias
// of float and half (127 versus 15).
//
register int s = (i >> 16) & 0x00008000;
register int e = ((i >> 23) & 0x000000ff) - (127 - 15);
register int m = i & 0x007fffff;
//
// Now reassemble s, e and m into a half:
//
if (e <= 0)
{
if (e < -10)
{
//
// E is less than -10. The absolute value of f is
// less than HALF_MIN (f may be a small normalized
// float, a denormalized float or a zero).
//
// We convert f to a half zero with the same sign as f.
//
return s;
}
//
// E is between -10 and 0. F is a normalized float
// whose magnitude is less than HALF_NRM_MIN.
//
// We convert f to a denormalized half.
//
//
// Add an explicit leading 1 to the significand.
//
m = m | 0x00800000;
//
// Round to m to the nearest (10+e)-bit value (with e between
// -10 and 0); in case of a tie, round to the nearest even value.
//
// Rounding may cause the significand to overflow and make
// our number normalized. Because of the way a half's bits
// are laid out, we don't have to treat this case separately;
// the code below will handle it correctly.
//
int t = 14 - e;
int a = (1 << (t - 1)) - 1;
int b = (m >> t) & 1;
m = (m + a + b) >> t;
//
// Assemble the half from s, e (zero) and m.
//
return s | m;
}
else if (e == 0xff - (127 - 15))
{
if (m == 0)
{
//
// F is an infinity; convert f to a half
// infinity with the same sign as f.
//
return s | 0x7c00;
}
else
{
//
// F is a NAN; we produce a half NAN that preserves
// the sign bit and the 10 leftmost bits of the
// significand of f, with one exception: If the 10
// leftmost bits are all zero, the NAN would turn
// into an infinity, so we have to set at least one
// bit in the significand.
//
m >>= 13;
return s | 0x7c00 | m | (m == 0);
}
}
else
{
//
// E is greater than zero. F is a normalized float.
// We try to convert f to a normalized half.
//
//
// Round to m to the nearest 10-bit value. In case of
// a tie, round to the nearest even value.
//
m = m + 0x00000fff + ((m >> 13) & 1);
if (m & 0x00800000)
{
m = 0; // overflow in significand,
e += 1; // adjust exponent
}
//
// Handle exponent overflow
//
if (e > 30)
{
overflow (); // Cause a hardware floating point overflow;
return s | 0x7c00; // if this returns, the half becomes an
} // infinity with the same sign as f.
//
// Assemble the half from s, e and m.
//
return s | (e << 10) | (m >> 13);
}
}
//---------------------
// Stream I/O operators
//---------------------
ostream &
operator << (ostream &os, half h)
{
os << float (h);
return os;
}
istream &
operator >> (istream &is, half &h)
{
float f;
is >> f;
h = half (f);
return is;
}
//---------------------------------------
// Functions to print the bit-layout of
// floats and halfs, mostly for debugging
//---------------------------------------
void
printBits (ostream &os, half h)
{
unsigned short b = h.bits();
for (int i = 15; i >= 0; i--)
{
os << (((b >> i) & 1)? '1': '0');
if (i == 15 || i == 10)
os << ' ';
}
}
void
printBits (ostream &os, float f)
{
half::uif x;
x.f = f;
for (int i = 31; i >= 0; i--)
{
os << (((x.i >> i) & 1)? '1': '0');
if (i == 31 || i == 23)
os << ' ';
}
}
void
printBits (char c[19], half h)
{
unsigned short b = h.bits();
for (int i = 15, j = 0; i >= 0; i--, j++)
{
c[j] = (((b >> i) & 1)? '1': '0');
if (i == 15 || i == 10)
c[++j] = ' ';
}
c[18] = 0;
}
void
printBits (char c[35], float f)
{
half::uif x;
x.f = f;
for (int i = 31, j = 0; i >= 0; i--, j++)
{
c[j] = (((x.i >> i) & 1)? '1': '0');
if (i == 31 || i == 23)
c[++j] = ' ';
}
c[34] = 0;
}

766
3rdparty/openexr/Half/half.h vendored Normal file
View File

@ -0,0 +1,766 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
// Primary authors:
// Florian Kainz <kainz@ilm.com>
// Rod Bogart <rgb@ilm.com>
//---------------------------------------------------------------------------
//
// half -- a 16-bit floating point number class:
//
// Type half can represent positive and negative numbers whose
// magnitude is between roughly 6.1e-5 and 6.5e+4 with a relative
// error of 9.8e-4; numbers smaller than 6.1e-5 can be represented
// with an absolute error of 6.0e-8. All integers from -2048 to
// +2048 can be represented exactly.
//
// Type half behaves (almost) like the built-in C++ floating point
// types. In arithmetic expressions, half, float and double can be
// mixed freely. Here are a few examples:
//
// half a (3.5);
// float b (a + sqrt (a));
// a += b;
// b += a;
// b = a + 7;
//
// Conversions from half to float are lossless; all half numbers
// are exactly representable as floats.
//
// Conversions from float to half may not preserve a float's value
// exactly. If a float is not representable as a half, then the
// float value is rounded to the nearest representable half. If a
// float value is exactly in the middle between the two closest
// representable half values, then the float value is rounded to
// the closest half whose least significant bit is zero.
//
// Overflows during float-to-half conversions cause arithmetic
// exceptions. An overflow occurs when the float value to be
// converted is too large to be represented as a half, or if the
// float value is an infinity or a NAN.
//
// The implementation of type half makes the following assumptions
// about the implementation of the built-in C++ types:
//
// float is an IEEE 754 single-precision number
// sizeof (float) == 4
// sizeof (unsigned int) == sizeof (float)
// alignof (unsigned int) == alignof (float)
// sizeof (unsigned short) == 2
//
//---------------------------------------------------------------------------
#ifndef _HALF_H_
#define _HALF_H_
#include <iostream>
#if defined(OPENEXR_DLL)
#if defined(HALF_EXPORTS)
#define HALF_EXPORT __declspec(dllexport)
#else
#define HALF_EXPORT __declspec(dllimport)
#endif
#define HALF_EXPORT_CONST
#else
#define HALF_EXPORT
#define HALF_EXPORT_CONST const
#endif
class HALF_EXPORT half
{
public:
//-------------
// Constructors
//-------------
half (); // no initialization
half (float f);
//--------------------
// Conversion to float
//--------------------
operator float () const;
//------------
// Unary minus
//------------
half operator - () const;
//-----------
// Assignment
//-----------
half & operator = (half h);
half & operator = (float f);
half & operator += (half h);
half & operator += (float f);
half & operator -= (half h);
half & operator -= (float f);
half & operator *= (half h);
half & operator *= (float f);
half & operator /= (half h);
half & operator /= (float f);
//---------------------------------------------------------
// Round to n-bit precision (n should be between 0 and 10).
// After rounding, the significand's 10-n least significant
// bits will be zero.
//---------------------------------------------------------
half round (unsigned int n) const;
//--------------------------------------------------------------------
// Classification:
//
// h.isFinite() returns true if h is a normalized number,
// a denormalized number or zero
//
// h.isNormalized() returns true if h is a normalized number
//
// h.isDenormalized() returns true if h is a denormalized number
//
// h.isZero() returns true if h is zero
//
// h.isNan() returns true if h is a NAN
//
// h.isInfinity() returns true if h is a positive
// or a negative infinity
//
// h.isNegative() returns true if the sign bit of h
// is set (negative)
//--------------------------------------------------------------------
bool isFinite () const;
bool isNormalized () const;
bool isDenormalized () const;
bool isZero () const;
bool isNan () const;
bool isInfinity () const;
bool isNegative () const;
//--------------------------------------------
// Special values
//
// posInf() returns +infinity
//
// negInf() returns -infinity
//
// qNan() returns a NAN with the bit
// pattern 0111111111111111
//
// sNan() returns a NAN with the bit
// pattern 0111110111111111
//--------------------------------------------
static half posInf ();
static half negInf ();
static half qNan ();
static half sNan ();
//--------------------------------------
// Access to the internal representation
//--------------------------------------
unsigned short bits () const;
void setBits (unsigned short bits);
public:
union uif
{
unsigned int i;
float f;
};
private:
static short convert (int i);
static float overflow ();
unsigned short _h;
static HALF_EXPORT_CONST uif _toFloat[1 << 16];
static HALF_EXPORT_CONST unsigned short _eLut[1 << 9];
};
//-----------
// Stream I/O
//-----------
HALF_EXPORT std::ostream & operator << (std::ostream &os, half h);
HALF_EXPORT std::istream & operator >> (std::istream &is, half &h);
//----------
// Debugging
//----------
HALF_EXPORT void printBits (std::ostream &os, half h);
HALF_EXPORT void printBits (std::ostream &os, float f);
HALF_EXPORT void printBits (char c[19], half h);
HALF_EXPORT void printBits (char c[35], float f);
//-------------------------------------------------------------------------
// Limits
//
// Visual C++ will complain if HALF_MIN, HALF_NRM_MIN etc. are not float
// constants, but at least one other compiler (gcc 2.96) produces incorrect
// results if they are.
//-------------------------------------------------------------------------
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
#define HALF_MIN 5.96046448e-08f // Smallest positive half
#define HALF_NRM_MIN 6.10351562e-05f // Smallest positive normalized half
#define HALF_MAX 65504.0f // Largest positive half
#define HALF_EPSILON 0.00097656f // Smallest positive e for which
// half (1.0 + e) != half (1.0)
#else
#define HALF_MIN 5.96046448e-08 // Smallest positive half
#define HALF_NRM_MIN 6.10351562e-05 // Smallest positive normalized half
#define HALF_MAX 65504.0 // Largest positive half
#define HALF_EPSILON 0.00097656 // Smallest positive e for which
// half (1.0 + e) != half (1.0)
#endif
#define HALF_MANT_DIG 11 // Number of digits in mantissa
// (significand + hidden leading 1)
#define HALF_DIG 2 // Number of base 10 digits that
// can be represented without change
#define HALF_RADIX 2 // Base of the exponent
#define HALF_MIN_EXP -13 // Minimum negative integer such that
// HALF_RADIX raised to the power of
// one less than that integer is a
// normalized half
#define HALF_MAX_EXP 16 // Maximum positive integer such that
// HALF_RADIX raised to the power of
// one less than that integer is a
// normalized half
#define HALF_MIN_10_EXP -4 // Minimum positive integer such
// that 10 raised to that power is
// a normalized half
#define HALF_MAX_10_EXP 4 // Maximum positive integer such
// that 10 raised to that power is
// a normalized half
//---------------------------------------------------------------------------
//
// Implementation --
//
// Representation of a float:
//
// We assume that a float, f, is an IEEE 754 single-precision
// floating point number, whose bits are arranged as follows:
//
// 31 (msb)
// |
// | 30 23
// | | |
// | | | 22 0 (lsb)
// | | | | |
// X XXXXXXXX XXXXXXXXXXXXXXXXXXXXXXX
//
// s e m
//
// S is the sign-bit, e is the exponent and m is the significand.
//
// If e is between 1 and 254, f is a normalized number:
//
// s e-127
// f = (-1) * 2 * 1.m
//
// If e is 0, and m is not zero, f is a denormalized number:
//
// s -126
// f = (-1) * 2 * 0.m
//
// If e and m are both zero, f is zero:
//
// f = 0.0
//
// If e is 255, f is an "infinity" or "not a number" (NAN),
// depending on whether m is zero or not.
//
// Examples:
//
// 0 00000000 00000000000000000000000 = 0.0
// 0 01111110 00000000000000000000000 = 0.5
// 0 01111111 00000000000000000000000 = 1.0
// 0 10000000 00000000000000000000000 = 2.0
// 0 10000000 10000000000000000000000 = 3.0
// 1 10000101 11110000010000000000000 = -124.0625
// 0 11111111 00000000000000000000000 = +infinity
// 1 11111111 00000000000000000000000 = -infinity
// 0 11111111 10000000000000000000000 = NAN
// 1 11111111 11111111111111111111111 = NAN
//
// Representation of a half:
//
// Here is the bit-layout for a half number, h:
//
// 15 (msb)
// |
// | 14 10
// | | |
// | | | 9 0 (lsb)
// | | | | |
// X XXXXX XXXXXXXXXX
//
// s e m
//
// S is the sign-bit, e is the exponent and m is the significand.
//
// If e is between 1 and 30, h is a normalized number:
//
// s e-15
// h = (-1) * 2 * 1.m
//
// If e is 0, and m is not zero, h is a denormalized number:
//
// S -14
// h = (-1) * 2 * 0.m
//
// If e and m are both zero, h is zero:
//
// h = 0.0
//
// If e is 31, h is an "infinity" or "not a number" (NAN),
// depending on whether m is zero or not.
//
// Examples:
//
// 0 00000 0000000000 = 0.0
// 0 01110 0000000000 = 0.5
// 0 01111 0000000000 = 1.0
// 0 10000 0000000000 = 2.0
// 0 10000 1000000000 = 3.0
// 1 10101 1111000001 = -124.0625
// 0 11111 0000000000 = +infinity
// 1 11111 0000000000 = -infinity
// 0 11111 1000000000 = NAN
// 1 11111 1111111111 = NAN
//
// Conversion:
//
// Converting from a float to a half requires some non-trivial bit
// manipulations. In some cases, this makes conversion relatively
// slow, but the most common case is accelerated via table lookups.
//
// Converting back from a half to a float is easier because we don't
// have to do any rounding. In addition, there are only 65536
// different half numbers; we can convert each of those numbers once
// and store the results in a table. Later, all conversions can be
// done using only simple table lookups.
//
//---------------------------------------------------------------------------
//--------------------
// Simple constructors
//--------------------
inline
half::half ()
{
// no initialization
}
//----------------------------
// Half-from-float constructor
//----------------------------
inline
half::half (float f)
{
uif x;
x.f = f;
if (f == 0)
{
//
// Common special case - zero.
// Preserve the zero's sign bit.
//
_h = (x.i >> 16);
}
else
{
//
// We extract the combined sign and exponent, e, from our
// floating-point number, f. Then we convert e to the sign
// and exponent of the half number via a table lookup.
//
// For the most common case, where a normalized half is produced,
// the table lookup returns a non-zero value; in this case, all
// we have to do is round f's significand to 10 bits and combine
// the result with e.
//
// For all other cases (overflow, zeroes, denormalized numbers
// resulting from underflow, infinities and NANs), the table
// lookup returns zero, and we call a longer, non-inline function
// to do the float-to-half conversion.
//
register int e = (x.i >> 23) & 0x000001ff;
e = _eLut[e];
if (e)
{
//
// Simple case - round the significand, m, to 10
// bits and combine it with the sign and exponent.
//
register int m = x.i & 0x007fffff;
_h = e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13);
}
else
{
//
// Difficult case - call a function.
//
_h = convert (x.i);
}
}
}
//------------------------------------------
// Half-to-float conversion via table lookup
//------------------------------------------
inline
half::operator float () const
{
return _toFloat[_h].f;
}
//-------------------------
// Round to n-bit precision
//-------------------------
inline half
half::round (unsigned int n) const
{
//
// Parameter check.
//
if (n >= 10)
return *this;
//
// Disassemble h into the sign, s,
// and the combined exponent and significand, e.
//
unsigned short s = _h & 0x8000;
unsigned short e = _h & 0x7fff;
//
// Round the exponent and significand to the nearest value
// where ones occur only in the (10-n) most significant bits.
// Note that the exponent adjusts automatically if rounding
// up causes the significand to overflow.
//
e >>= 9 - n;
e += e & 1;
e <<= 9 - n;
//
// Check for exponent overflow.
//
if (e >= 0x7c00)
{
//
// Overflow occurred -- truncate instead of rounding.
//
e = _h;
e >>= 10 - n;
e <<= 10 - n;
}
//
// Put the original sign bit back.
//
half h;
h._h = s | e;
return h;
}
//-----------------------
// Other inline functions
//-----------------------
inline half
half::operator - () const
{
half h;
h._h = _h ^ 0x8000;
return h;
}
inline half &
half::operator = (half h)
{
_h = h._h;
return *this;
}
inline half &
half::operator = (float f)
{
*this = half (f);
return *this;
}
inline half &
half::operator += (half h)
{
*this = half (float (*this) + float (h));
return *this;
}
inline half &
half::operator += (float f)
{
*this = half (float (*this) + f);
return *this;
}
inline half &
half::operator -= (half h)
{
*this = half (float (*this) - float (h));
return *this;
}
inline half &
half::operator -= (float f)
{
*this = half (float (*this) - f);
return *this;
}
inline half &
half::operator *= (half h)
{
*this = half (float (*this) * float (h));
return *this;
}
inline half &
half::operator *= (float f)
{
*this = half (float (*this) * f);
return *this;
}
inline half &
half::operator /= (half h)
{
*this = half (float (*this) / float (h));
return *this;
}
inline half &
half::operator /= (float f)
{
*this = half (float (*this) / f);
return *this;
}
inline bool
half::isFinite () const
{
unsigned short e = (_h >> 10) & 0x001f;
return e < 31;
}
inline bool
half::isNormalized () const
{
unsigned short e = (_h >> 10) & 0x001f;
return e > 0 && e < 31;
}
inline bool
half::isDenormalized () const
{
unsigned short e = (_h >> 10) & 0x001f;
unsigned short m = _h & 0x3ff;
return e == 0 && m != 0;
}
inline bool
half::isZero () const
{
return (_h & 0x7fff) == 0;
}
inline bool
half::isNan () const
{
unsigned short e = (_h >> 10) & 0x001f;
unsigned short m = _h & 0x3ff;
return e == 31 && m != 0;
}
inline bool
half::isInfinity () const
{
unsigned short e = (_h >> 10) & 0x001f;
unsigned short m = _h & 0x3ff;
return e == 31 && m == 0;
}
inline bool
half::isNegative () const
{
return (_h & 0x8000) != 0;
}
inline half
half::posInf ()
{
half h;
h._h = 0x7c00;
return h;
}
inline half
half::negInf ()
{
half h;
h._h = 0xfc00;
return h;
}
inline half
half::qNan ()
{
half h;
h._h = 0x7fff;
return h;
}
inline half
half::sNan ()
{
half h;
h._h = 0x7dff;
return h;
}
inline unsigned short
half::bits () const
{
return _h;
}
inline void
half::setBits (unsigned short bits)
{
_h = bits;
}
#endif

178
3rdparty/openexr/Half/halfFunction.h vendored Normal file
View File

@ -0,0 +1,178 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
// Primary authors:
// Florian Kainz <kainz@ilm.com>
// Rod Bogart <rgb@ilm.com>
//---------------------------------------------------------------------------
//
// halfFunction<T> -- a class for fast evaluation
// of half --> T functions
//
// The constructor for a halfFunction object,
//
// halfFunction (function,
// domainMin, domainMax,
// defaultValue,
// posInfValue, negInfValue,
// nanValue);
//
// evaluates the function for all finite half values in the interval
// [domainMin, domainMax], and stores the results in a lookup table.
// For finite half values that are not in [domainMin, domainMax], the
// constructor stores defaultValue in the table. For positive infinity,
// negative infinity and NANs, posInfValue, negInfValue and nanValue
// are stored in the table.
//
// The tabulated function can then be evaluated quickly for arbitrary
// half values by calling the the halfFunction object's operator()
// method.
//
// Example:
//
// #include <math.h>
// #include <halfFunction.h>
//
// halfFunction<half> hsin (sin);
//
// halfFunction<half> hsqrt (sqrt, // function
// 0, HALF_MAX, // domain
// half::qNan(), // sqrt(x) for x < 0
// half::posInf(), // sqrt(+inf)
// half::qNan(), // sqrt(-inf)
// half::qNan()); // sqrt(nan)
//
// half x = hsin (1);
// half y = hsqrt (3.5);
//
//---------------------------------------------------------------------------
#ifndef _HALF_FUNCTION_H_
#define _HALF_FUNCTION_H_
#include "half.h"
#include <IlmBaseConfig.h>
#ifndef ILMBASE_HAVE_LARGE_STACK
#include <string.h> // need this for memset
#else
#endif
#include <float.h>
template <class T>
class halfFunction
{
public:
//------------
// Constructor
//------------
template <class Function>
halfFunction (Function f,
half domainMin = -HALF_MAX,
half domainMax = HALF_MAX,
T defaultValue = 0,
T posInfValue = 0,
T negInfValue = 0,
T nanValue = 0);
#ifndef ILMBASE_HAVE_LARGE_STACK
~halfFunction () { delete [] _lut; }
#endif
//-----------
// Evaluation
//-----------
T operator () (half x) const;
private:
#ifdef ILMBASE_HAVE_LARGE_STACK
T _lut[1 << 16];
#else
T * _lut;
#endif
};
//---------------
// Implementation
//---------------
template <class T>
template <class Function>
halfFunction<T>::halfFunction (Function f,
half domainMin,
half domainMax,
T defaultValue,
T posInfValue,
T negInfValue,
T nanValue)
{
#ifndef ILMBASE_HAVE_LARGE_STACK
_lut = new T[1<<16];
memset (_lut, 0 , (1<<16) * sizeof(T));
#endif
for (int i = 0; i < (1 << 16); i++)
{
half x;
x.setBits (i);
if (x.isNan())
_lut[i] = nanValue;
else if (x.isInfinity())
_lut[i] = x.isNegative()? negInfValue: posInfValue;
else if (x < domainMin || x > domainMax)
_lut[i] = defaultValue;
else
_lut[i] = f (x);
}
}
template <class T>
inline T
halfFunction<T>::operator () (half x) const
{
return _lut[x.bits()];
}
#endif

102
3rdparty/openexr/Half/halfLimits.h vendored Normal file
View File

@ -0,0 +1,102 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
// Primary authors:
// Florian Kainz <kainz@ilm.com>
// Rod Bogart <rgb@ilm.com>
#ifndef INCLUDED_HALF_LIMITS_H
#define INCLUDED_HALF_LIMITS_H
//------------------------------------------------------------------------
//
// C++ standard library-style numeric_limits for class half
//
//------------------------------------------------------------------------
#include <limits>
#include "half.h"
namespace std {
template <>
class numeric_limits <half>
{
public:
static const bool is_specialized = true;
static half min () throw () {return HALF_NRM_MIN;}
static half max () throw () {return HALF_MAX;}
static const int digits = HALF_MANT_DIG;
static const int digits10 = HALF_DIG;
static const bool is_signed = true;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = HALF_RADIX;
static half epsilon () throw () {return HALF_EPSILON;}
static half round_error () throw () {return HALF_EPSILON / 2;}
static const int min_exponent = HALF_MIN_EXP;
static const int min_exponent10 = HALF_MIN_10_EXP;
static const int max_exponent = HALF_MAX_EXP;
static const int max_exponent10 = HALF_MAX_10_EXP;
static const bool has_infinity = true;
static const bool has_quiet_NaN = true;
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_present;
static const bool has_denorm_loss = false;
static half infinity () throw () {return half::posInf();}
static half quiet_NaN () throw () {return half::qNan();}
static half signaling_NaN () throw () {return half::sNan();}
static half denorm_min () throw () {return HALF_MIN;}
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = true;
static const bool tinyness_before = false;
static const float_round_style round_style = round_to_nearest;
};
} // namespace std
#endif

164
3rdparty/openexr/Half/toFloat.cpp vendored Normal file
View File

@ -0,0 +1,164 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------------
//
// toFloat
//
// A program to generate the lookup table for half-to-float
// conversion needed by class half.
// The program loops over all 65536 possible half numbers,
// converts each of them to a float, and prints the result.
//
//---------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
//---------------------------------------------------
// Interpret an unsigned short bit pattern as a half,
// and convert that half to the corresponding float's
// bit pattern.
//---------------------------------------------------
unsigned int
halfToFloat (unsigned short y)
{
int s = (y >> 15) & 0x00000001;
int e = (y >> 10) & 0x0000001f;
int m = y & 0x000003ff;
if (e == 0)
{
if (m == 0)
{
//
// Plus or minus zero
//
return s << 31;
}
else
{
//
// Denormalized number -- renormalize it
//
while (!(m & 0x00000400))
{
m <<= 1;
e -= 1;
}
e += 1;
m &= ~0x00000400;
}
}
else if (e == 31)
{
if (m == 0)
{
//
// Positive or negative infinity
//
return (s << 31) | 0x7f800000;
}
else
{
//
// Nan -- preserve sign and significand bits
//
return (s << 31) | 0x7f800000 | (m << 13);
}
}
//
// Normalized number
//
e = e + (127 - 15);
m = m << 13;
//
// Assemble s, e and m.
//
return (s << 31) | (e << 23) | m;
}
//---------------------------------------------
// Main - prints the half-to-float lookup table
//---------------------------------------------
int
main ()
{
cout.precision (9);
cout.setf (ios_base::hex, ios_base::basefield);
cout << "//\n"
"// This is an automatically generated file.\n"
"// Do not edit.\n"
"//\n\n";
cout << "{\n ";
const int iMax = (1 << 16);
for (int i = 0; i < iMax; i++)
{
cout << "{0x" << setfill ('0') << setw (8) << halfToFloat (i) << "}, ";
if (i % 4 == 3)
{
cout << "\n";
if (i < iMax - 1)
cout << " ";
}
}
cout << "};\n";
return 0;
}

16391
3rdparty/openexr/Half/toFloat.h vendored Normal file

File diff suppressed because it is too large Load Diff

60
3rdparty/openexr/Iex/Iex.h vendored Normal file
View File

@ -0,0 +1,60 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEX_H
#define INCLUDED_IEX_H
//--------------------------------
//
// Exception handling
//
//--------------------------------
#include "IexMacros.h"
#include "IexBaseExc.h"
#include "IexMathExc.h"
#include "IexThrowErrnoExc.h"
// Note that we do not include file IexErrnoExc.h here. That file
// defines over 150 classes and significantly slows down compilation.
// If you throw ErrnoExc exceptions using the throwErrnoExc() function,
// you don't need IexErrnoExc.h. You have to include IexErrnoExc.h
// only if you want to catch specific subclasses of ErrnoExc.
#endif

129
3rdparty/openexr/Iex/IexBaseExc.cpp vendored Normal file
View File

@ -0,0 +1,129 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------
//
// Constructors and destructors for our exception base class.
//
//---------------------------------------------------------------------
#include "IexBaseExc.h"
namespace Iex {
namespace {
StackTracer currentStackTracer = 0;
} // namespace
void
setStackTracer (StackTracer stackTracer)
{
currentStackTracer = stackTracer;
}
StackTracer
stackTracer ()
{
return currentStackTracer;
}
BaseExc::BaseExc (const char* s) throw () :
std::string (s? s: ""),
_stackTrace (currentStackTracer? currentStackTracer(): "")
{
// empty
}
BaseExc::BaseExc (const std::string &s) throw () :
std::string (s),
_stackTrace (currentStackTracer? currentStackTracer(): "")
{
// empty
}
BaseExc::BaseExc (std::stringstream &s) throw () :
std::string (s.str()),
_stackTrace (currentStackTracer? currentStackTracer(): "")
{
// empty
}
BaseExc::BaseExc (const BaseExc &be) throw () :
std::string (be),
_stackTrace (be._stackTrace)
{
// empty
}
BaseExc::~BaseExc () throw ()
{
// empty
}
const char *
BaseExc::what () const throw ()
{
return c_str();
}
BaseExc &
BaseExc::assign (std::stringstream &s)
{
std::string::assign (s.str());
return *this;
}
BaseExc &
BaseExc::append (std::stringstream &s)
{
std::string::append (s.str());
return *this;
}
} // namespace Iex

266
3rdparty/openexr/Iex/IexBaseExc.h vendored Normal file
View File

@ -0,0 +1,266 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXBASEEXC_H
#define INCLUDED_IEXBASEEXC_H
//----------------------------------------------------------
//
// A general exception base class, and a few
// useful exceptions derived from the base class.
//
//----------------------------------------------------------
#include <string>
#include <exception>
#include <sstream>
namespace Iex {
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
// Tell MS VC++ to suppress exception specification warnings
#pragma warning(disable:4290)
#endif
//-------------------------------
// Our most basic exception class
//-------------------------------
class BaseExc: public std::string, public std::exception
{
public:
//----------------------------
// Constructors and destructor
//----------------------------
BaseExc (const char *s = 0) throw(); // std::string (s)
BaseExc (const std::string &s) throw(); // std::string (s)
BaseExc (std::stringstream &s) throw(); // std::string (s.str())
BaseExc (const BaseExc &be) throw();
virtual ~BaseExc () throw ();
//--------------------------------------------
// what() method -- e.what() returns e.c_str()
//--------------------------------------------
virtual const char * what () const throw ();
//--------------------------------------------------
// Convenient methods to change the exception's text
//--------------------------------------------------
BaseExc & assign (std::stringstream &s); // assign (s.str())
BaseExc & operator = (std::stringstream &s);
BaseExc & append (std::stringstream &s); // append (s.str())
BaseExc & operator += (std::stringstream &s);
//--------------------------------------------------
// These methods from the base class get obscured by
// the definitions above.
//--------------------------------------------------
BaseExc & assign (const char *s);
BaseExc & operator = (const char *s);
BaseExc & append (const char *s);
BaseExc & operator += (const char *s);
//--------------------------------------------------
// Stack trace for the point at which the exception
// was thrown. The stack trace will be an empty
// string unless a working stack-tracing routine
// has been installed (see below, setStackTracer()).
//--------------------------------------------------
const std::string & stackTrace () const;
private:
std::string _stackTrace;
};
//-----------------------------------------------------
// A macro to save typing when declararing an exception
// class derived directly or indirectly from BaseExc:
//-----------------------------------------------------
#define DEFINE_EXC(name, base) \
class name: public base \
{ \
public: \
name (const char* text=0) throw(): base (text) {} \
name (const std::string &text) throw(): base (text) {} \
name (std::stringstream &text) throw(): base (text) {} \
};
//--------------------------------------------------------
// Some exceptions which should be useful in most programs
//--------------------------------------------------------
DEFINE_EXC (ArgExc, BaseExc) // Invalid arguments to a function call
DEFINE_EXC (LogicExc, BaseExc) // General error in a program's logic,
// for example, a function was called
// in a context where the call does
// not make sense.
DEFINE_EXC (InputExc, BaseExc) // Invalid input data, e.g. from a file
DEFINE_EXC (IoExc, BaseExc) // Input or output operation failed
DEFINE_EXC (MathExc, BaseExc) // Arithmetic exception; more specific
// exceptions derived from this class
// are defined in ExcMath.h
DEFINE_EXC (ErrnoExc, BaseExc) // Base class for exceptions corresponding
// to errno values (see errno.h); more
// specific exceptions derived from this
// class are defined in ExcErrno.h
DEFINE_EXC (NoImplExc, BaseExc) // Missing method exception e.g. from a
// call to a method that is only partially
// or not at all implemented. A reminder
// to lazy software people to get back
// to work.
DEFINE_EXC (NullExc, BaseExc) // A pointer is inappropriately null.
DEFINE_EXC (TypeExc, BaseExc) // An object is an inappropriate type,
// i.e. a dynamnic_cast failed.
//----------------------------------------------------------------------
// Stack-tracing support:
//
// setStackTracer(st)
//
// installs a stack-tracing routine, st, which will be called from
// class BaseExc's constructor every time an exception derived from
// BaseExc is thrown. The stack-tracing routine should return a
// string that contains a printable representation of the program's
// current call stack. This string will be stored in the BaseExc
// object; the string is accesible via the BaseExc::stackTrace()
// method.
//
// setStackTracer(0)
//
// removes the current stack tracing routine. When an exception
// derived from BaseExc is thrown, the stack trace string stored
// in the BaseExc object will be empty.
//
// stackTracer()
//
// returns a pointer to the current stack-tracing routine, or 0
// if there is no current stack stack-tracing routine.
//
//----------------------------------------------------------------------
typedef std::string (* StackTracer) ();
void setStackTracer (StackTracer stackTracer);
StackTracer stackTracer ();
//-----------------
// Inline functions
//-----------------
inline BaseExc &
BaseExc::operator = (std::stringstream &s)
{
return assign (s);
}
inline BaseExc &
BaseExc::operator += (std::stringstream &s)
{
return append (s);
}
inline BaseExc &
BaseExc::assign (const char *s)
{
std::string::assign(s);
return *this;
}
inline BaseExc &
BaseExc::operator = (const char *s)
{
return assign(s);
}
inline BaseExc &
BaseExc::append (const char *s)
{
std::string::append(s);
return *this;
}
inline BaseExc &
BaseExc::operator += (const char *s)
{
return append(s);
}
inline const std::string &
BaseExc::stackTrace () const
{
return _stackTrace;
}
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
#pragma warning(default:4290)
#endif
} // namespace Iex
#endif

210
3rdparty/openexr/Iex/IexErrnoExc.h vendored Normal file
View File

@ -0,0 +1,210 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXERRNOEXC_H
#define INCLUDED_IEXERRNOEXC_H
//----------------------------------------------------------------
//
// Exceptions which correspond to "errno" error codes.
//
//----------------------------------------------------------------
#include "IexBaseExc.h"
namespace Iex {
DEFINE_EXC (EpermExc, ErrnoExc)
DEFINE_EXC (EnoentExc, ErrnoExc)
DEFINE_EXC (EsrchExc, ErrnoExc)
DEFINE_EXC (EintrExc, ErrnoExc)
DEFINE_EXC (EioExc, ErrnoExc)
DEFINE_EXC (EnxioExc, ErrnoExc)
DEFINE_EXC (E2bigExc, ErrnoExc)
DEFINE_EXC (EnoexecExc, ErrnoExc)
DEFINE_EXC (EbadfExc, ErrnoExc)
DEFINE_EXC (EchildExc, ErrnoExc)
DEFINE_EXC (EagainExc, ErrnoExc)
DEFINE_EXC (EnomemExc, ErrnoExc)
DEFINE_EXC (EaccesExc, ErrnoExc)
DEFINE_EXC (EfaultExc, ErrnoExc)
DEFINE_EXC (EnotblkExc, ErrnoExc)
DEFINE_EXC (EbusyExc, ErrnoExc)
DEFINE_EXC (EexistExc, ErrnoExc)
DEFINE_EXC (ExdevExc, ErrnoExc)
DEFINE_EXC (EnodevExc, ErrnoExc)
DEFINE_EXC (EnotdirExc, ErrnoExc)
DEFINE_EXC (EisdirExc, ErrnoExc)
DEFINE_EXC (EinvalExc, ErrnoExc)
DEFINE_EXC (EnfileExc, ErrnoExc)
DEFINE_EXC (EmfileExc, ErrnoExc)
DEFINE_EXC (EnottyExc, ErrnoExc)
DEFINE_EXC (EtxtbsyExc, ErrnoExc)
DEFINE_EXC (EfbigExc, ErrnoExc)
DEFINE_EXC (EnospcExc, ErrnoExc)
DEFINE_EXC (EspipeExc, ErrnoExc)
DEFINE_EXC (ErofsExc, ErrnoExc)
DEFINE_EXC (EmlinkExc, ErrnoExc)
DEFINE_EXC (EpipeExc, ErrnoExc)
DEFINE_EXC (EdomExc, ErrnoExc)
DEFINE_EXC (ErangeExc, ErrnoExc)
DEFINE_EXC (EnomsgExc, ErrnoExc)
DEFINE_EXC (EidrmExc, ErrnoExc)
DEFINE_EXC (EchrngExc, ErrnoExc)
DEFINE_EXC (El2nsyncExc, ErrnoExc)
DEFINE_EXC (El3hltExc, ErrnoExc)
DEFINE_EXC (El3rstExc, ErrnoExc)
DEFINE_EXC (ElnrngExc, ErrnoExc)
DEFINE_EXC (EunatchExc, ErrnoExc)
DEFINE_EXC (EnocsiExc, ErrnoExc)
DEFINE_EXC (El2hltExc, ErrnoExc)
DEFINE_EXC (EdeadlkExc, ErrnoExc)
DEFINE_EXC (EnolckExc, ErrnoExc)
DEFINE_EXC (EbadeExc, ErrnoExc)
DEFINE_EXC (EbadrExc, ErrnoExc)
DEFINE_EXC (ExfullExc, ErrnoExc)
DEFINE_EXC (EnoanoExc, ErrnoExc)
DEFINE_EXC (EbadrqcExc, ErrnoExc)
DEFINE_EXC (EbadsltExc, ErrnoExc)
DEFINE_EXC (EdeadlockExc, ErrnoExc)
DEFINE_EXC (EbfontExc, ErrnoExc)
DEFINE_EXC (EnostrExc, ErrnoExc)
DEFINE_EXC (EnodataExc, ErrnoExc)
DEFINE_EXC (EtimeExc, ErrnoExc)
DEFINE_EXC (EnosrExc, ErrnoExc)
DEFINE_EXC (EnonetExc, ErrnoExc)
DEFINE_EXC (EnopkgExc, ErrnoExc)
DEFINE_EXC (EremoteExc, ErrnoExc)
DEFINE_EXC (EnolinkExc, ErrnoExc)
DEFINE_EXC (EadvExc, ErrnoExc)
DEFINE_EXC (EsrmntExc, ErrnoExc)
DEFINE_EXC (EcommExc, ErrnoExc)
DEFINE_EXC (EprotoExc, ErrnoExc)
DEFINE_EXC (EmultihopExc, ErrnoExc)
DEFINE_EXC (EbadmsgExc, ErrnoExc)
DEFINE_EXC (EnametoolongExc, ErrnoExc)
DEFINE_EXC (EoverflowExc, ErrnoExc)
DEFINE_EXC (EnotuniqExc, ErrnoExc)
DEFINE_EXC (EbadfdExc, ErrnoExc)
DEFINE_EXC (EremchgExc, ErrnoExc)
DEFINE_EXC (ElibaccExc, ErrnoExc)
DEFINE_EXC (ElibbadExc, ErrnoExc)
DEFINE_EXC (ElibscnExc, ErrnoExc)
DEFINE_EXC (ElibmaxExc, ErrnoExc)
DEFINE_EXC (ElibexecExc, ErrnoExc)
DEFINE_EXC (EilseqExc, ErrnoExc)
DEFINE_EXC (EnosysExc, ErrnoExc)
DEFINE_EXC (EloopExc, ErrnoExc)
DEFINE_EXC (ErestartExc, ErrnoExc)
DEFINE_EXC (EstrpipeExc, ErrnoExc)
DEFINE_EXC (EnotemptyExc, ErrnoExc)
DEFINE_EXC (EusersExc, ErrnoExc)
DEFINE_EXC (EnotsockExc, ErrnoExc)
DEFINE_EXC (EdestaddrreqExc, ErrnoExc)
DEFINE_EXC (EmsgsizeExc, ErrnoExc)
DEFINE_EXC (EprototypeExc, ErrnoExc)
DEFINE_EXC (EnoprotooptExc, ErrnoExc)
DEFINE_EXC (EprotonosupportExc, ErrnoExc)
DEFINE_EXC (EsocktnosupportExc, ErrnoExc)
DEFINE_EXC (EopnotsuppExc, ErrnoExc)
DEFINE_EXC (EpfnosupportExc, ErrnoExc)
DEFINE_EXC (EafnosupportExc, ErrnoExc)
DEFINE_EXC (EaddrinuseExc, ErrnoExc)
DEFINE_EXC (EaddrnotavailExc, ErrnoExc)
DEFINE_EXC (EnetdownExc, ErrnoExc)
DEFINE_EXC (EnetunreachExc, ErrnoExc)
DEFINE_EXC (EnetresetExc, ErrnoExc)
DEFINE_EXC (EconnabortedExc, ErrnoExc)
DEFINE_EXC (EconnresetExc, ErrnoExc)
DEFINE_EXC (EnobufsExc, ErrnoExc)
DEFINE_EXC (EisconnExc, ErrnoExc)
DEFINE_EXC (EnotconnExc, ErrnoExc)
DEFINE_EXC (EshutdownExc, ErrnoExc)
DEFINE_EXC (EtoomanyrefsExc, ErrnoExc)
DEFINE_EXC (EtimedoutExc, ErrnoExc)
DEFINE_EXC (EconnrefusedExc, ErrnoExc)
DEFINE_EXC (EhostdownExc, ErrnoExc)
DEFINE_EXC (EhostunreachExc, ErrnoExc)
DEFINE_EXC (EalreadyExc, ErrnoExc)
DEFINE_EXC (EinprogressExc, ErrnoExc)
DEFINE_EXC (EstaleExc, ErrnoExc)
DEFINE_EXC (EioresidExc, ErrnoExc)
DEFINE_EXC (EucleanExc, ErrnoExc)
DEFINE_EXC (EnotnamExc, ErrnoExc)
DEFINE_EXC (EnavailExc, ErrnoExc)
DEFINE_EXC (EisnamExc, ErrnoExc)
DEFINE_EXC (EremoteioExc, ErrnoExc)
DEFINE_EXC (EinitExc, ErrnoExc)
DEFINE_EXC (EremdevExc, ErrnoExc)
DEFINE_EXC (EcanceledExc, ErrnoExc)
DEFINE_EXC (EnolimfileExc, ErrnoExc)
DEFINE_EXC (EproclimExc, ErrnoExc)
DEFINE_EXC (EdisjointExc, ErrnoExc)
DEFINE_EXC (EnologinExc, ErrnoExc)
DEFINE_EXC (EloginlimExc, ErrnoExc)
DEFINE_EXC (EgrouploopExc, ErrnoExc)
DEFINE_EXC (EnoattachExc, ErrnoExc)
DEFINE_EXC (EnotsupExc, ErrnoExc)
DEFINE_EXC (EnoattrExc, ErrnoExc)
DEFINE_EXC (EdircorruptedExc, ErrnoExc)
DEFINE_EXC (EdquotExc, ErrnoExc)
DEFINE_EXC (EnfsremoteExc, ErrnoExc)
DEFINE_EXC (EcontrollerExc, ErrnoExc)
DEFINE_EXC (EnotcontrollerExc, ErrnoExc)
DEFINE_EXC (EenqueuedExc, ErrnoExc)
DEFINE_EXC (EnotenqueuedExc, ErrnoExc)
DEFINE_EXC (EjoinedExc, ErrnoExc)
DEFINE_EXC (EnotjoinedExc, ErrnoExc)
DEFINE_EXC (EnoprocExc, ErrnoExc)
DEFINE_EXC (EmustrunExc, ErrnoExc)
DEFINE_EXC (EnotstoppedExc, ErrnoExc)
DEFINE_EXC (EclockcpuExc, ErrnoExc)
DEFINE_EXC (EinvalstateExc, ErrnoExc)
DEFINE_EXC (EnoexistExc, ErrnoExc)
DEFINE_EXC (EendofminorExc, ErrnoExc)
DEFINE_EXC (EbufsizeExc, ErrnoExc)
DEFINE_EXC (EemptyExc, ErrnoExc)
DEFINE_EXC (EnointrgroupExc, ErrnoExc)
DEFINE_EXC (EinvalmodeExc, ErrnoExc)
DEFINE_EXC (EcantextentExc, ErrnoExc)
DEFINE_EXC (EinvaltimeExc, ErrnoExc)
DEFINE_EXC (EdestroyedExc, ErrnoExc)
} // namespace Iex
#endif

148
3rdparty/openexr/Iex/IexMacros.h vendored Normal file
View File

@ -0,0 +1,148 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXMACROS_H
#define INCLUDED_IEXMACROS_H
//--------------------------------------------------------------------
//
// Macros which make throwing exceptions more convenient
//
//--------------------------------------------------------------------
#include <sstream>
//----------------------------------------------------------------------------
// A macro to throw exceptions whose text is assembled using stringstreams.
//
// Example:
//
// THROW (InputExc, "Syntax error in line " << line ", " << file << ".");
//
//----------------------------------------------------------------------------
#define THROW(type, text) \
do \
{ \
std::stringstream s; \
s << text; \
throw type (s); \
} \
while (0)
//----------------------------------------------------------------------------
// Macros to add to or to replace the text of an exception.
// The new text is assembled using stringstreams.
//
// Examples:
//
// Append to end of an exception's text:
//
// catch (BaseExc &e)
// {
// APPEND_EXC (e, " Directory " << name << " does not exist.");
// throw;
// }
//
// Replace an exception's text:
//
// catch (BaseExc &e)
// {
// REPLACE_EXC (e, "Directory " << name << " does not exist. " << e);
// throw;
// }
//----------------------------------------------------------------------------
#define APPEND_EXC(exc, text) \
do \
{ \
std::stringstream s; \
s << text; \
exc.append (s); \
} \
while (0)
#define REPLACE_EXC(exc, text) \
do \
{ \
std::stringstream s; \
s << text; \
exc.assign (s); \
} \
while (0)
//-------------------------------------------------------------
// A macro to throw ErrnoExc exceptions whose text is assembled
// using stringstreams:
//
// Example:
//
// THROW_ERRNO ("Cannot open file " << name << " (%T).");
//
//-------------------------------------------------------------
#define THROW_ERRNO(text) \
do \
{ \
std::stringstream s; \
s << text; \
::Iex::throwErrnoExc (s.str()); \
} \
while (0)
//-------------------------------------------------------------
// A macro to throw exceptions if an assertion is false.
//
// Example:
//
// ASSERT (ptr != NULL, NullExc, "Null pointer" );
//
//-------------------------------------------------------------
#define ASSERT(assertion, type, text) \
do \
{ \
if ((assertion) == false) \
THROW (type, text); \
} \
while (0)
#endif

58
3rdparty/openexr/Iex/IexMathExc.h vendored Normal file
View File

@ -0,0 +1,58 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXMATHEXC_H
#define INCLUDED_IEXMATHEXC_H
#include "IexBaseExc.h"
namespace Iex {
//---------------------------------------------------------
// Exception classess which correspond to specific floating
// point exceptions.
//---------------------------------------------------------
DEFINE_EXC (OverflowExc, MathExc) // Overflow
DEFINE_EXC (UnderflowExc, MathExc) // Underflow
DEFINE_EXC (DivzeroExc, MathExc) // Division by zero
DEFINE_EXC (InexactExc, MathExc) // Inexact result
DEFINE_EXC (InvalidFpOpExc, MathExc) // Invalid operation
} // namespace Iex
#endif

View File

@ -0,0 +1,859 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------
//
// Exceptions that correspond to "errno" error codes,
// and a function to make throwing those exceptions easy.
//
//----------------------------------------------------------------
#include "IexThrowErrnoExc.h"
#include "IexErrnoExc.h"
#include <string.h>
#include <errno.h>
namespace Iex {
void throwErrnoExc (const std::string &text, int errnum)
{
const char *entext = strerror (errnum);
std::string tmp (text);
std::string::size_type pos;
while (std::string::npos != (pos = tmp.find ("%T")))
tmp.replace (pos, 2, entext, strlen (entext));
switch (errnum)
{
#if defined (EPERM)
case EPERM:
throw EpermExc (tmp);
#endif
#if defined (ENOENT)
case ENOENT:
throw EnoentExc (tmp);
#endif
#if defined (ESRCH)
case ESRCH:
throw EsrchExc (tmp);
#endif
#if defined (EINTR)
case EINTR:
throw EintrExc (tmp);
#endif
#if defined (EIO)
case EIO:
throw EioExc (tmp);
#endif
#if defined (ENXIO)
case ENXIO:
throw EnxioExc (tmp);
#endif
#if defined (E2BIG)
case E2BIG:
throw E2bigExc (tmp);
#endif
#if defined (ENOEXEC)
case ENOEXEC:
throw EnoexecExc (tmp);
#endif
#if defined (EBADF)
case EBADF:
throw EbadfExc (tmp);
#endif
#if defined (ECHILD)
case ECHILD:
throw EchildExc (tmp);
#endif
#if defined (EAGAIN)
case EAGAIN:
throw EagainExc (tmp);
#endif
#if defined (ENOMEM)
case ENOMEM:
throw EnomemExc (tmp);
#endif
#if defined (EACCES)
case EACCES:
throw EaccesExc (tmp);
#endif
#if defined (EFAULT)
case EFAULT:
throw EfaultExc (tmp);
#endif
#if defined (ENOTBLK)
case ENOTBLK:
throw EnotblkExc (tmp);
#endif
#if defined (EBUSY)
case EBUSY:
throw EbusyExc (tmp);
#endif
#if defined (EEXIST)
case EEXIST:
throw EexistExc (tmp);
#endif
#if defined (EXDEV)
case EXDEV:
throw ExdevExc (tmp);
#endif
#if defined (ENODEV)
case ENODEV:
throw EnodevExc (tmp);
#endif
#if defined (ENOTDIR)
case ENOTDIR:
throw EnotdirExc (tmp);
#endif
#if defined (EISDIR)
case EISDIR:
throw EisdirExc (tmp);
#endif
#if defined (EINVAL)
case EINVAL:
throw EinvalExc (tmp);
#endif
#if defined (ENFILE)
case ENFILE:
throw EnfileExc (tmp);
#endif
#if defined (EMFILE)
case EMFILE:
throw EmfileExc (tmp);
#endif
#if defined (ENOTTY)
case ENOTTY:
throw EnottyExc (tmp);
#endif
#if defined (ETXTBSY)
case ETXTBSY:
throw EtxtbsyExc (tmp);
#endif
#if defined (EFBIG)
case EFBIG:
throw EfbigExc (tmp);
#endif
#if defined (ENOSPC)
case ENOSPC:
throw EnospcExc (tmp);
#endif
#if defined (ESPIPE)
case ESPIPE:
throw EspipeExc (tmp);
#endif
#if defined (EROFS)
case EROFS:
throw ErofsExc (tmp);
#endif
#if defined (EMLINK)
case EMLINK:
throw EmlinkExc (tmp);
#endif
#if defined (EPIPE)
case EPIPE:
throw EpipeExc (tmp);
#endif
#if defined (EDOM)
case EDOM:
throw EdomExc (tmp);
#endif
#if defined (ERANGE)
case ERANGE:
throw ErangeExc (tmp);
#endif
#if defined (ENOMSG)
case ENOMSG:
throw EnomsgExc (tmp);
#endif
#if defined (EIDRM)
case EIDRM:
throw EidrmExc (tmp);
#endif
#if defined (ECHRNG)
case ECHRNG:
throw EchrngExc (tmp);
#endif
#if defined (EL2NSYNC)
case EL2NSYNC:
throw El2nsyncExc (tmp);
#endif
#if defined (EL3HLT)
case EL3HLT:
throw El3hltExc (tmp);
#endif
#if defined (EL3RST)
case EL3RST:
throw El3rstExc (tmp);
#endif
#if defined (ELNRNG)
case ELNRNG:
throw ElnrngExc (tmp);
#endif
#if defined (EUNATCH)
case EUNATCH:
throw EunatchExc (tmp);
#endif
#if defined (ENOSCI)
case ENOCSI:
throw EnocsiExc (tmp);
#endif
#if defined (EL2HLT)
case EL2HLT:
throw El2hltExc (tmp);
#endif
#if defined (EDEADLK)
case EDEADLK:
throw EdeadlkExc (tmp);
#endif
#if defined (ENOLCK)
case ENOLCK:
throw EnolckExc (tmp);
#endif
#if defined (EBADE)
case EBADE:
throw EbadeExc (tmp);
#endif
#if defined (EBADR)
case EBADR:
throw EbadrExc (tmp);
#endif
#if defined (EXFULL)
case EXFULL:
throw ExfullExc (tmp);
#endif
#if defined (ENOANO)
case ENOANO:
throw EnoanoExc (tmp);
#endif
#if defined (EBADRQC)
case EBADRQC:
throw EbadrqcExc (tmp);
#endif
#if defined (EBADSLT)
case EBADSLT:
throw EbadsltExc (tmp);
#endif
#if defined (EDEADLOCK) && defined (EDEADLK)
#if EDEADLOCK != EDEADLK
case EDEADLOCK:
throw EdeadlockExc (tmp);
#endif
#elif defined (EDEADLOCK)
case EDEADLOCK:
throw EdeadlockExc (tmp);
#endif
#if defined (EBFONT)
case EBFONT:
throw EbfontExc (tmp);
#endif
#if defined (ENOSTR)
case ENOSTR:
throw EnostrExc (tmp);
#endif
#if defined (ENODATA)
case ENODATA:
throw EnodataExc (tmp);
#endif
#if defined (ETIME)
case ETIME:
throw EtimeExc (tmp);
#endif
#if defined (ENOSR)
case ENOSR:
throw EnosrExc (tmp);
#endif
#if defined (ENONET)
case ENONET:
throw EnonetExc (tmp);
#endif
#if defined (ENOPKG)
case ENOPKG:
throw EnopkgExc (tmp);
#endif
#if defined (EREMOTE)
case EREMOTE:
throw EremoteExc (tmp);
#endif
#if defined (ENOLINK)
case ENOLINK:
throw EnolinkExc (tmp);
#endif
#if defined (EADV)
case EADV:
throw EadvExc (tmp);
#endif
#if defined (ESRMNT)
case ESRMNT:
throw EsrmntExc (tmp);
#endif
#if defined (ECOMM)
case ECOMM:
throw EcommExc (tmp);
#endif
#if defined (EPROTO)
case EPROTO:
throw EprotoExc (tmp);
#endif
#if defined (EMULTIHOP)
case EMULTIHOP:
throw EmultihopExc (tmp);
#endif
#if defined (EBADMSG)
case EBADMSG:
throw EbadmsgExc (tmp);
#endif
#if defined (ENAMETOOLONG)
case ENAMETOOLONG:
throw EnametoolongExc (tmp);
#endif
#if defined (EOVERFLOW)
case EOVERFLOW:
throw EoverflowExc (tmp);
#endif
#if defined (ENOTUNIQ)
case ENOTUNIQ:
throw EnotuniqExc (tmp);
#endif
#if defined (EBADFD)
case EBADFD:
throw EbadfdExc (tmp);
#endif
#if defined (EREMCHG)
case EREMCHG:
throw EremchgExc (tmp);
#endif
#if defined (ELIBACC)
case ELIBACC:
throw ElibaccExc (tmp);
#endif
#if defined (ELIBBAD)
case ELIBBAD:
throw ElibbadExc (tmp);
#endif
#if defined (ELIBSCN)
case ELIBSCN:
throw ElibscnExc (tmp);
#endif
#if defined (ELIBMAX)
case ELIBMAX:
throw ElibmaxExc (tmp);
#endif
#if defined (ELIBEXEC)
case ELIBEXEC:
throw ElibexecExc (tmp);
#endif
#if defined (EILSEQ)
case EILSEQ:
throw EilseqExc (tmp);
#endif
#if defined (ENOSYS)
case ENOSYS:
throw EnosysExc (tmp);
#endif
#if defined (ELOOP)
case ELOOP:
throw EloopExc (tmp);
#endif
#if defined (ERESTART)
case ERESTART:
throw ErestartExc (tmp);
#endif
#if defined (ESTRPIPE)
case ESTRPIPE:
throw EstrpipeExc (tmp);
#endif
#if defined (ENOTEMPTY)
case ENOTEMPTY:
throw EnotemptyExc (tmp);
#endif
#if defined (EUSERS)
case EUSERS:
throw EusersExc (tmp);
#endif
#if defined (ENOTSOCK)
case ENOTSOCK:
throw EnotsockExc (tmp);
#endif
#if defined (EDESTADDRREQ)
case EDESTADDRREQ:
throw EdestaddrreqExc (tmp);
#endif
#if defined (EMSGSIZE)
case EMSGSIZE:
throw EmsgsizeExc (tmp);
#endif
#if defined (EPROTOTYPE)
case EPROTOTYPE:
throw EprototypeExc (tmp);
#endif
#if defined (ENOPROTOOPT)
case ENOPROTOOPT:
throw EnoprotooptExc (tmp);
#endif
#if defined (EPROTONOSUPPORT)
case EPROTONOSUPPORT:
throw EprotonosupportExc (tmp);
#endif
#if defined (ESOCKTNOSUPPORT)
case ESOCKTNOSUPPORT:
throw EsocktnosupportExc (tmp);
#endif
#if defined (EOPNOTSUPP)
case EOPNOTSUPP:
throw EopnotsuppExc (tmp);
#endif
#if defined (EPFNOSUPPORT)
case EPFNOSUPPORT:
throw EpfnosupportExc (tmp);
#endif
#if defined (EAFNOSUPPORT)
case EAFNOSUPPORT:
throw EafnosupportExc (tmp);
#endif
#if defined (EADDRINUSE)
case EADDRINUSE:
throw EaddrinuseExc (tmp);
#endif
#if defined (EADDRNOTAVAIL)
case EADDRNOTAVAIL:
throw EaddrnotavailExc (tmp);
#endif
#if defined (ENETDOWN)
case ENETDOWN:
throw EnetdownExc (tmp);
#endif
#if defined (ENETUNREACH)
case ENETUNREACH:
throw EnetunreachExc (tmp);
#endif
#if defined (ENETRESET)
case ENETRESET:
throw EnetresetExc (tmp);
#endif
#if defined (ECONNABORTED)
case ECONNABORTED:
throw EconnabortedExc (tmp);
#endif
#if defined (ECONNRESET)
case ECONNRESET:
throw EconnresetExc (tmp);
#endif
#if defined (ENOBUFS)
case ENOBUFS:
throw EnobufsExc (tmp);
#endif
#if defined (EISCONN)
case EISCONN:
throw EisconnExc (tmp);
#endif
#if defined (ENOTCONN)
case ENOTCONN:
throw EnotconnExc (tmp);
#endif
#if defined (ESHUTDOWN)
case ESHUTDOWN:
throw EshutdownExc (tmp);
#endif
#if defined (ETOOMANYREFS)
case ETOOMANYREFS:
throw EtoomanyrefsExc (tmp);
#endif
#if defined (ETIMEDOUT)
case ETIMEDOUT:
throw EtimedoutExc (tmp);
#endif
#if defined (ECONNREFUSED)
case ECONNREFUSED:
throw EconnrefusedExc (tmp);
#endif
#if defined (EHOSTDOWN)
case EHOSTDOWN:
throw EhostdownExc (tmp);
#endif
#if defined (EHOSTUNREACH)
case EHOSTUNREACH:
throw EhostunreachExc (tmp);
#endif
#if defined (EALREADY)
case EALREADY:
throw EalreadyExc (tmp);
#endif
#if defined (EINPROGRESS)
case EINPROGRESS:
throw EinprogressExc (tmp);
#endif
#if defined (ESTALE)
case ESTALE:
throw EstaleExc (tmp);
#endif
#if defined (EIORESID)
case EIORESID:
throw EioresidExc (tmp);
#endif
#if defined (EUCLEAN)
case EUCLEAN:
throw EucleanExc (tmp);
#endif
#if defined (ENOTNAM)
case ENOTNAM:
throw EnotnamExc (tmp);
#endif
#if defined (ENAVAIL)
case ENAVAIL:
throw EnavailExc (tmp);
#endif
#if defined (EISNAM)
case EISNAM:
throw EisnamExc (tmp);
#endif
#if defined (EREMOTEIO)
case EREMOTEIO:
throw EremoteioExc (tmp);
#endif
#if defined (EINIT)
case EINIT:
throw EinitExc (tmp);
#endif
#if defined (EREMDEV)
case EREMDEV:
throw EremdevExc (tmp);
#endif
#if defined (ECANCELED)
case ECANCELED:
throw EcanceledExc (tmp);
#endif
#if defined (ENOLIMFILE)
case ENOLIMFILE:
throw EnolimfileExc (tmp);
#endif
#if defined (EPROCLIM)
case EPROCLIM:
throw EproclimExc (tmp);
#endif
#if defined (EDISJOINT)
case EDISJOINT:
throw EdisjointExc (tmp);
#endif
#if defined (ENOLOGIN)
case ENOLOGIN:
throw EnologinExc (tmp);
#endif
#if defined (ELOGINLIM)
case ELOGINLIM:
throw EloginlimExc (tmp);
#endif
#if defined (EGROUPLOOP)
case EGROUPLOOP:
throw EgrouploopExc (tmp);
#endif
#if defined (ENOATTACH)
case ENOATTACH:
throw EnoattachExc (tmp);
#endif
#if defined (ENOTSUP) && defined (EOPNOTSUPP)
#if ENOTSUP != EOPNOTSUPP
case ENOTSUP:
throw EnotsupExc (tmp);
#endif
#elif defined (ENOTSUP)
case ENOTSUP:
throw EnotsupExc (tmp);
#endif
#if defined (ENOATTR)
case ENOATTR:
throw EnoattrExc (tmp);
#endif
#if defined (EDIRCORRUPTED)
case EDIRCORRUPTED:
throw EdircorruptedExc (tmp);
#endif
#if defined (EDQUOT)
case EDQUOT:
throw EdquotExc (tmp);
#endif
#if defined (ENFSREMOTE)
case ENFSREMOTE:
throw EnfsremoteExc (tmp);
#endif
#if defined (ECONTROLLER)
case ECONTROLLER:
throw EcontrollerExc (tmp);
#endif
#if defined (ENOTCONTROLLER)
case ENOTCONTROLLER:
throw EnotcontrollerExc (tmp);
#endif
#if defined (EENQUEUED)
case EENQUEUED:
throw EenqueuedExc (tmp);
#endif
#if defined (ENOTENQUEUED)
case ENOTENQUEUED:
throw EnotenqueuedExc (tmp);
#endif
#if defined (EJOINED)
case EJOINED:
throw EjoinedExc (tmp);
#endif
#if defined (ENOTJOINED)
case ENOTJOINED:
throw EnotjoinedExc (tmp);
#endif
#if defined (ENOPROC)
case ENOPROC:
throw EnoprocExc (tmp);
#endif
#if defined (EMUSTRUN)
case EMUSTRUN:
throw EmustrunExc (tmp);
#endif
#if defined (ENOTSTOPPED)
case ENOTSTOPPED:
throw EnotstoppedExc (tmp);
#endif
#if defined (ECLOCKCPU)
case ECLOCKCPU:
throw EclockcpuExc (tmp);
#endif
#if defined (EINVALSTATE)
case EINVALSTATE:
throw EinvalstateExc (tmp);
#endif
#if defined (ENOEXIST)
case ENOEXIST:
throw EnoexistExc (tmp);
#endif
#if defined (EENDOFMINOR)
case EENDOFMINOR:
throw EendofminorExc (tmp);
#endif
#if defined (EBUFSIZE)
case EBUFSIZE:
throw EbufsizeExc (tmp);
#endif
#if defined (EEMPTY)
case EEMPTY:
throw EemptyExc (tmp);
#endif
#if defined (ENOINTRGROUP)
case ENOINTRGROUP:
throw EnointrgroupExc (tmp);
#endif
#if defined (EINVALMODE)
case EINVALMODE:
throw EinvalmodeExc (tmp);
#endif
#if defined (ECANTEXTENT)
case ECANTEXTENT:
throw EcantextentExc (tmp);
#endif
#if defined (EINVALTIME)
case EINVALTIME:
throw EinvaltimeExc (tmp);
#endif
#if defined (EDESTROYED)
case EDESTROYED:
throw EdestroyedExc (tmp);
#endif
}
throw ErrnoExc (tmp);
}
void throwErrnoExc (const std::string &text)
{
throwErrnoExc (text, errno);
}
} // namespace Iex

96
3rdparty/openexr/Iex/IexThrowErrnoExc.h vendored Normal file
View File

@ -0,0 +1,96 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IEXTHROWERRNOEXC_H
#define INCLUDED_IEXTHROWERRNOEXC_H
//----------------------------------------------------------
//
// A function which throws ExcErrno exceptions
//
//----------------------------------------------------------
#include "IexBaseExc.h"
namespace Iex {
//--------------------------------------------------------------------------
//
// Function throwErrnoExc() throws an exception which corresponds to
// error code errnum. The exception text is initialized with a copy
// of the string passed to throwErrnoExc(), where all occurrences of
// "%T" have been replaced with the output of strerror(oserror()).
//
// Example:
//
// If opening file /tmp/output failed with an ENOENT error code,
// calling
//
// throwErrnoExc ();
//
// or
//
// throwErrnoExc ("%T.");
//
// will throw an EnoentExc whose text reads
//
// No such file or directory.
//
// More detailed messages can be assembled using stringstreams:
//
// std::stringstream s;
// s << "Cannot open file " << name << " (%T).";
// throwErrnoExc (s);
//
// The resulting exception contains the following text:
//
// Cannot open file /tmp/output (No such file or directory).
//
// Alternatively, you may want to use the THROW_ERRNO macro defined
// in IexMacros.h:
//
// THROW_ERRNO ("Cannot open file " << name << " (%T).")
//
//--------------------------------------------------------------------------
void throwErrnoExc (const std::string &txt, int errnum);
void throwErrnoExc (const std::string &txt = "%T." /*, int errnum = oserror() */);
} // namespace Iex
#endif

View File

@ -0,0 +1,30 @@
//
// Define and set to 1 if the target system has POSIX thread support
// and you want IlmBase to use it for multithreaded file I/O.
//
#cmakedefine01 HAVE_PTHREAD
//
// Define and set to 1 if the target system supports POSIX semaphores
// and you want OpenEXR to use them; otherwise, OpenEXR will use its
// own semaphore implementation.
//
#cmakedefine01 HAVE_POSIX_SEMAPHORES
#undef HAVE_UCONTEXT_H
//
// Define and set to 1 if the target system has support for large
// stack sizes.
//
#undef ILMBASE_HAVE_LARGE_STACK
//
// Version string for runtime access
//
#define ILMBASE_VERSION_STRING "1.0.3"
#define ILMBASE_PACKAGE_STRING "IlmBase 1.0.3"

631
3rdparty/openexr/IlmImf/ImfAcesFile.cpp vendored Normal file
View File

@ -0,0 +1,631 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// ACES image file I/O.
//
//-----------------------------------------------------------------------------
#include <ImfAcesFile.h>
#include <ImfRgbaFile.h>
#include <ImfStandardAttributes.h>
#include <Iex.h>
using namespace std;
using namespace Imath;
using namespace Iex;
namespace Imf {
const Chromaticities &
acesChromaticities ()
{
static const Chromaticities acesChr
(V2f (0.73470, 0.26530), // red
V2f (0.00000, 1.00000), // green
V2f (0.00010, -0.07700), // blue
V2f (0.32168, 0.33767)); // white
return acesChr;
}
class AcesOutputFile::Data
{
public:
Data();
~Data();
RgbaOutputFile * rgbaFile;
};
AcesOutputFile::Data::Data ():
rgbaFile (0)
{
// empty
}
AcesOutputFile::Data::~Data ()
{
delete rgbaFile;
}
namespace {
void
checkCompression (Compression compression)
{
//
// Not all compression methods are allowed in ACES files.
//
switch (compression)
{
case NO_COMPRESSION:
case PIZ_COMPRESSION:
case B44A_COMPRESSION:
break;
default:
throw ArgExc ("Invalid compression type for ACES file.");
}
}
} // namespace
AcesOutputFile::AcesOutputFile
(const std::string &name,
const Header &header,
RgbaChannels rgbaChannels,
int numThreads)
:
_data (new Data)
{
checkCompression (header.compression());
Header newHeader = header;
addChromaticities (newHeader, acesChromaticities());
addAdoptedNeutral (newHeader, acesChromaticities().white);
_data->rgbaFile = new RgbaOutputFile (name.c_str(),
newHeader,
rgbaChannels,
numThreads);
_data->rgbaFile->setYCRounding (7, 6);
}
AcesOutputFile::AcesOutputFile
(OStream &os,
const Header &header,
RgbaChannels rgbaChannels,
int numThreads)
:
_data (new Data)
{
checkCompression (header.compression());
Header newHeader = header;
addChromaticities (newHeader, acesChromaticities());
addAdoptedNeutral (newHeader, acesChromaticities().white);
_data->rgbaFile = new RgbaOutputFile (os,
header,
rgbaChannels,
numThreads);
_data->rgbaFile->setYCRounding (7, 6);
}
AcesOutputFile::AcesOutputFile
(const std::string &name,
const Imath::Box2i &displayWindow,
const Imath::Box2i &dataWindow,
RgbaChannels rgbaChannels,
float pixelAspectRatio,
const Imath::V2f screenWindowCenter,
float screenWindowWidth,
LineOrder lineOrder,
Compression compression,
int numThreads)
:
_data (new Data)
{
checkCompression (compression);
Header newHeader (displayWindow,
dataWindow.isEmpty()? displayWindow: dataWindow,
pixelAspectRatio,
screenWindowCenter,
screenWindowWidth,
lineOrder,
compression);
addChromaticities (newHeader, acesChromaticities());
addAdoptedNeutral (newHeader, acesChromaticities().white);
_data->rgbaFile = new RgbaOutputFile (name.c_str(),
newHeader,
rgbaChannels,
numThreads);
_data->rgbaFile->setYCRounding (7, 6);
}
AcesOutputFile::AcesOutputFile
(const std::string &name,
int width,
int height,
RgbaChannels rgbaChannels,
float pixelAspectRatio,
const Imath::V2f screenWindowCenter,
float screenWindowWidth,
LineOrder lineOrder,
Compression compression,
int numThreads)
:
_data (new Data)
{
checkCompression (compression);
Header newHeader (width,
height,
pixelAspectRatio,
screenWindowCenter,
screenWindowWidth,
lineOrder,
compression);
addChromaticities (newHeader, acesChromaticities());
addAdoptedNeutral (newHeader, acesChromaticities().white);
_data->rgbaFile = new RgbaOutputFile (name.c_str(),
newHeader,
rgbaChannels,
numThreads);
_data->rgbaFile->setYCRounding (7, 6);
}
AcesOutputFile::~AcesOutputFile ()
{
delete _data;
}
void
AcesOutputFile::setFrameBuffer
(const Rgba *base,
size_t xStride,
size_t yStride)
{
_data->rgbaFile->setFrameBuffer (base, xStride, yStride);
}
void
AcesOutputFile::writePixels (int numScanLines)
{
_data->rgbaFile->writePixels (numScanLines);
}
int
AcesOutputFile::currentScanLine () const
{
return _data->rgbaFile->currentScanLine();
}
const Header &
AcesOutputFile::header () const
{
return _data->rgbaFile->header();
}
const Imath::Box2i &
AcesOutputFile::displayWindow () const
{
return _data->rgbaFile->displayWindow();
}
const Imath::Box2i &
AcesOutputFile::dataWindow () const
{
return _data->rgbaFile->dataWindow();
}
float
AcesOutputFile::pixelAspectRatio () const
{
return _data->rgbaFile->pixelAspectRatio();
}
const Imath::V2f
AcesOutputFile::screenWindowCenter () const
{
return _data->rgbaFile->screenWindowCenter();
}
float
AcesOutputFile::screenWindowWidth () const
{
return _data->rgbaFile->screenWindowWidth();
}
LineOrder
AcesOutputFile::lineOrder () const
{
return _data->rgbaFile->lineOrder();
}
Compression
AcesOutputFile::compression () const
{
return _data->rgbaFile->compression();
}
RgbaChannels
AcesOutputFile::channels () const
{
return _data->rgbaFile->channels();
}
void
AcesOutputFile::updatePreviewImage (const PreviewRgba pixels[])
{
_data->rgbaFile->updatePreviewImage (pixels);
}
class AcesInputFile::Data
{
public:
Data();
~Data();
void initColorConversion ();
RgbaInputFile * rgbaFile;
Rgba * fbBase;
size_t fbXStride;
size_t fbYStride;
int minX;
int maxX;
bool mustConvertColor;
M44f fileToAces;
};
AcesInputFile::Data::Data ():
rgbaFile (0),
fbBase (0),
fbXStride (0),
fbYStride (0),
minX (0),
maxX (0),
mustConvertColor (false)
{
// empty
}
AcesInputFile::Data::~Data ()
{
delete rgbaFile;
}
void
AcesInputFile::Data::initColorConversion ()
{
const Header &header = rgbaFile->header();
Chromaticities fileChr;
if (hasChromaticities (header))
fileChr = chromaticities (header);
V2f fileNeutral = fileChr.white;
if (hasAdoptedNeutral (header))
fileNeutral = adoptedNeutral (header);
const Chromaticities acesChr = acesChromaticities();
V2f acesNeutral = acesChr.white;
if (fileChr.red == acesChr.red &&
fileChr.green == acesChr.green &&
fileChr.blue == acesChr.blue &&
fileChr.white == acesChr.white &&
fileNeutral == acesNeutral)
{
//
// The file already contains ACES data,
// color conversion is not necessary.
return;
}
mustConvertColor = true;
minX = header.dataWindow().min.x;
maxX = header.dataWindow().max.x;
//
// Create a matrix that transforms colors from the
// RGB space of the input file into the ACES space
// using a color adaptation transform to move the
// white point.
//
//
// We'll need the Bradford cone primary matrix and its inverse
//
static const M44f bradfordCPM
(0.895100, -0.750200, 0.038900, 0.000000,
0.266400, 1.713500, -0.068500, 0.000000,
-0.161400, 0.036700, 1.029600, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000);
const static M44f inverseBradfordCPM
(0.986993, 0.432305, -0.008529, 0.000000,
-0.147054, 0.518360, 0.040043, 0.000000,
0.159963, 0.049291, 0.968487, 0.000000,
0.000000, 0.000000, 0.000000, 1.000000);
//
// Convert the white points of the two RGB spaces to XYZ
//
float fx = fileNeutral.x;
float fy = fileNeutral.y;
V3f fileNeutralXYZ (fx / fy, 1, (1 - fx - fy) / fy);
float ax = acesNeutral.x;
float ay = acesNeutral.y;
V3f acesNeutralXYZ (ax / ay, 1, (1 - ax - ay) / ay);
//
// Compute the Bradford transformation matrix
//
V3f ratio ((acesNeutralXYZ * bradfordCPM) /
(fileNeutralXYZ * bradfordCPM));
M44f ratioMat (ratio[0], 0, 0, 0,
0, ratio[1], 0, 0,
0, 0, ratio[2], 0,
0, 0, 0, 1);
M44f bradfordTrans = bradfordCPM *
ratioMat *
inverseBradfordCPM;
//
// Build a combined file-RGB-to-ACES-RGB conversion matrix
//
fileToAces = RGBtoXYZ (fileChr, 1) * bradfordTrans * XYZtoRGB (acesChr, 1);
}
AcesInputFile::AcesInputFile (const std::string &name, int numThreads):
_data (new Data)
{
_data->rgbaFile = new RgbaInputFile (name.c_str(), numThreads);
_data->initColorConversion();
}
AcesInputFile::AcesInputFile (IStream &is, int numThreads):
_data (new Data)
{
_data->rgbaFile = new RgbaInputFile (is, numThreads);
_data->initColorConversion();
}
AcesInputFile::~AcesInputFile ()
{
delete _data;
}
void
AcesInputFile::setFrameBuffer (Rgba *base, size_t xStride, size_t yStride)
{
_data->rgbaFile->setFrameBuffer (base, xStride, yStride);
_data->fbBase = base;
_data->fbXStride = xStride;
_data->fbYStride = yStride;
}
void
AcesInputFile::readPixels (int scanLine1, int scanLine2)
{
//
// Copy the pixels from the RgbaInputFile into the frame buffer.
//
_data->rgbaFile->readPixels (scanLine1, scanLine2);
//
// If the RGB space of the input file is not the same as the ACES
// RGB space, then the pixels in the frame buffer must be transformed
// into the ACES RGB space.
//
if (!_data->mustConvertColor)
return;
int minY = min (scanLine1, scanLine2);
int maxY = max (scanLine1, scanLine2);
for (int y = minY; y <= maxY; ++y)
{
Rgba *base = _data->fbBase +
_data->fbXStride * _data->minX +
_data->fbYStride * y;
for (int x = _data->minX; x <= _data->maxX; ++x)
{
V3f aces = V3f (base->r, base->g, base->b) * _data->fileToAces;
base->r = aces[0];
base->g = aces[1];
base->b = aces[2];
base += _data->fbXStride;
}
}
}
void
AcesInputFile::readPixels (int scanLine)
{
readPixels (scanLine, scanLine);
}
const Header &
AcesInputFile::header () const
{
return _data->rgbaFile->header();
}
const Imath::Box2i &
AcesInputFile::displayWindow () const
{
return _data->rgbaFile->displayWindow();
}
const Imath::Box2i &
AcesInputFile::dataWindow () const
{
return _data->rgbaFile->dataWindow();
}
float
AcesInputFile::pixelAspectRatio () const
{
return _data->rgbaFile->pixelAspectRatio();
}
const Imath::V2f
AcesInputFile::screenWindowCenter () const
{
return _data->rgbaFile->screenWindowCenter();
}
float
AcesInputFile::screenWindowWidth () const
{
return _data->rgbaFile->screenWindowWidth();
}
LineOrder
AcesInputFile::lineOrder () const
{
return _data->rgbaFile->lineOrder();
}
Compression
AcesInputFile::compression () const
{
return _data->rgbaFile->compression();
}
RgbaChannels
AcesInputFile::channels () const
{
return _data->rgbaFile->channels();
}
const char *
AcesInputFile::fileName () const
{
return _data->rgbaFile->fileName();
}
bool
AcesInputFile::isComplete () const
{
return _data->rgbaFile->isComplete();
}
int
AcesInputFile::version () const
{
return _data->rgbaFile->version();
}
} // namespace Imf

322
3rdparty/openexr/IlmImf/ImfAcesFile.h vendored Normal file
View File

@ -0,0 +1,322 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IMF_ACES_FILE_H
#define INCLUDED_IMF_ACES_FILE_H
//-----------------------------------------------------------------------------
//
// ACES image file I/O.
//
// This header file declares two classes that directly support
// image file input and output according to the Academy Image
// Interchange Framework.
//
// The Academy Image Interchange file format is a subset of OpenEXR:
//
// - Images are stored as scanlines. Tiles are not allowed.
//
// - Images contain three color channels, either
// R, G, B (red, green, blue) or
// Y, RY, BY (luminance, sub-sampled chroma)
//
// - Images may optionally contain an alpha channel.
//
// - Only three compression types are allowed:
// - NO_COMPRESSION (file is not compressed)
// - PIZ_COMPRESSION (lossless)
// - B44A_COMPRESSION (lossy)
//
// - The "chromaticities" header attribute must specify
// the ACES RGB primaries and white point.
//
// class AcesOutputFile writes an OpenEXR file, enforcing the
// restrictions listed above. Pixel data supplied by application
// software must already be in the ACES RGB space.
//
// class AcesInputFile reads an OpenEXR file. Pixel data delivered
// to application software is guaranteed to be in the ACES RGB space.
// If the RGB space of the file is not the same as the ACES space,
// then the pixels are automatically converted: the pixels are
// converted to CIE XYZ, a color adaptation transform shifts the
// white point, and the result is converted to ACES RGB.
//
//-----------------------------------------------------------------------------
#include <ImfHeader.h>
#include <ImfRgba.h>
#include "ImathVec.h"
#include "ImathBox.h"
#include <ImfThreading.h>
#include <string>
namespace Imf {
class RgbaOutputFile;
class RgbaInputFile;
struct PreviewRgba;
struct Chromaticities;
//
// ACES red, green, blue and white-point chromaticities.
//
const Chromaticities & acesChromaticities ();
//
// ACES output file.
//
class AcesOutputFile
{
public:
//---------------------------------------------------
// Constructor -- header is constructed by the caller
//---------------------------------------------------
AcesOutputFile (const std::string &name,
const Header &header,
RgbaChannels rgbaChannels = WRITE_RGBA,
int numThreads = globalThreadCount());
//----------------------------------------------------
// Constructor -- header is constructed by the caller,
// file is opened by the caller, destructor will not
// automatically close the file.
//----------------------------------------------------
AcesOutputFile (OStream &os,
const Header &header,
RgbaChannels rgbaChannels = WRITE_RGBA,
int numThreads = globalThreadCount());
//----------------------------------------------------------------
// Constructor -- header data are explicitly specified as function
// call arguments (empty dataWindow means "same as displayWindow")
//----------------------------------------------------------------
AcesOutputFile (const std::string &name,
const Imath::Box2i &displayWindow,
const Imath::Box2i &dataWindow = Imath::Box2i(),
RgbaChannels rgbaChannels = WRITE_RGBA,
float pixelAspectRatio = 1,
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
float screenWindowWidth = 1,
LineOrder lineOrder = INCREASING_Y,
Compression compression = PIZ_COMPRESSION,
int numThreads = globalThreadCount());
//-----------------------------------------------
// Constructor -- like the previous one, but both
// the display window and the data window are
// Box2i (V2i (0, 0), V2i (width - 1, height -1))
//-----------------------------------------------
AcesOutputFile (const std::string &name,
int width,
int height,
RgbaChannels rgbaChannels = WRITE_RGBA,
float pixelAspectRatio = 1,
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
float screenWindowWidth = 1,
LineOrder lineOrder = INCREASING_Y,
Compression compression = PIZ_COMPRESSION,
int numThreads = globalThreadCount());
//-----------
// Destructor
//-----------
virtual ~AcesOutputFile ();
//------------------------------------------------
// Define a frame buffer as the pixel data source:
// Pixel (x, y) is at address
//
// base + x * xStride + y * yStride
//
//------------------------------------------------
void setFrameBuffer (const Rgba *base,
size_t xStride,
size_t yStride);
//-------------------------------------------------
// Write pixel data (see class Imf::OutputFile)
// The pixels are assumed to contain ACES RGB data.
//-------------------------------------------------
void writePixels (int numScanLines = 1);
int currentScanLine () const;
//--------------------------
// Access to the file header
//--------------------------
const Header & header () const;
const Imath::Box2i & displayWindow () const;
const Imath::Box2i & dataWindow () const;
float pixelAspectRatio () const;
const Imath::V2f screenWindowCenter () const;
float screenWindowWidth () const;
LineOrder lineOrder () const;
Compression compression () const;
RgbaChannels channels () const;
// --------------------------------------------------------------------
// Update the preview image (see Imf::OutputFile::updatePreviewImage())
// --------------------------------------------------------------------
void updatePreviewImage (const PreviewRgba[]);
private:
AcesOutputFile (const AcesOutputFile &); // not implemented
AcesOutputFile & operator = (const AcesOutputFile &); // not implemented
class Data;
Data * _data;
};
//
// ACES input file
//
class AcesInputFile
{
public:
//-------------------------------------------------------
// Constructor -- opens the file with the specified name,
// destructor will automatically close the file.
//-------------------------------------------------------
AcesInputFile (const std::string &name,
int numThreads = globalThreadCount());
//-----------------------------------------------------------
// Constructor -- attaches the new AcesInputFile object to a
// file that has already been opened by the caller.
// Destroying the AcesInputFile object will not automatically
// close the file.
//-----------------------------------------------------------
AcesInputFile (IStream &is,
int numThreads = globalThreadCount());
//-----------
// Destructor
//-----------
virtual ~AcesInputFile ();
//-----------------------------------------------------
// Define a frame buffer as the pixel data destination:
// Pixel (x, y) is at address
//
// base + x * xStride + y * yStride
//
//-----------------------------------------------------
void setFrameBuffer (Rgba *base,
size_t xStride,
size_t yStride);
//--------------------------------------------
// Read pixel data (see class Imf::InputFile)
// Pixels returned will contain ACES RGB data.
//--------------------------------------------
void readPixels (int scanLine1, int scanLine2);
void readPixels (int scanLine);
//--------------------------
// Access to the file header
//--------------------------
const Header & header () const;
const Imath::Box2i & displayWindow () const;
const Imath::Box2i & dataWindow () const;
float pixelAspectRatio () const;
const Imath::V2f screenWindowCenter () const;
float screenWindowWidth () const;
LineOrder lineOrder () const;
Compression compression () const;
RgbaChannels channels () const;
const char * fileName () const;
bool isComplete () const;
//----------------------------------
// Access to the file format version
//----------------------------------
int version () const;
private:
AcesInputFile (const AcesInputFile &); // not implemented
AcesInputFile & operator = (const AcesInputFile &); // not implemented
class Data;
Data * _data;
};
} // namespace Imf
#endif

261
3rdparty/openexr/IlmImf/ImfArray.h vendored Normal file
View File

@ -0,0 +1,261 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
#ifndef INCLUDED_IMF_ARRAY_H
#define INCLUDED_IMF_ARRAY_H
//-------------------------------------------------------------------------
//
// class Array
// class Array2D
//
// "Arrays of T" whose sizes are not known at compile time.
// When an array goes out of scope, its elements are automatically
// deleted.
//
// Usage example:
//
// struct C
// {
// C () {std::cout << "C::C (" << this << ")\n";};
// virtual ~C () {std::cout << "C::~C (" << this << ")\n";};
// };
//
// int
// main ()
// {
// Array <C> a(3);
//
// C &b = a[1];
// const C &c = a[1];
// C *d = a + 2;
// const C *e = a;
//
// return 0;
// }
//
//-------------------------------------------------------------------------
namespace Imf {
template <class T>
class Array
{
public:
//-----------------------------
// Constructors and destructors
//-----------------------------
Array () {_data = 0;}
Array (long size) {_data = new T[size];}
~Array () {delete [] _data;}
//-----------------------------
// Access to the array elements
//-----------------------------
operator T * () {return _data;}
operator const T * () const {return _data;}
//------------------------------------------------------
// Resize and clear the array (the contents of the array
// are not preserved across the resize operation).
//
// resizeEraseUnsafe() is more memory efficient than
// resizeErase() because it deletes the old memory block
// before allocating a new one, but if allocating the
// new block throws an exception, resizeEraseUnsafe()
// leaves the array in an unusable state.
//
//------------------------------------------------------
void resizeErase (long size);
void resizeEraseUnsafe (long size);
private:
Array (const Array &); // Copying and assignment
Array & operator = (const Array &); // are not implemented
T * _data;
};
template <class T>
class Array2D
{
public:
//-----------------------------
// Constructors and destructors
//-----------------------------
Array2D (); // empty array, 0 by 0 elements
Array2D (long sizeX, long sizeY); // sizeX by sizeY elements
~Array2D ();
//-----------------------------
// Access to the array elements
//-----------------------------
T * operator [] (long x);
const T * operator [] (long x) const;
//------------------------------------------------------
// Resize and clear the array (the contents of the array
// are not preserved across the resize operation).
//
// resizeEraseUnsafe() is more memory efficient than
// resizeErase() because it deletes the old memory block
// before allocating a new one, but if allocating the
// new block throws an exception, resizeEraseUnsafe()
// leaves the array in an unusable state.
//
//------------------------------------------------------
void resizeErase (long sizeX, long sizeY);
void resizeEraseUnsafe (long sizeX, long sizeY);
private:
Array2D (const Array2D &); // Copying and assignment
Array2D & operator = (const Array2D &); // are not implemented
long _sizeY;
T * _data;
};
//---------------
// Implementation
//---------------
template <class T>
inline void
Array<T>::resizeErase (long size)
{
T *tmp = new T[size];
delete [] _data;
_data = tmp;
}
template <class T>
inline void
Array<T>::resizeEraseUnsafe (long size)
{
delete [] _data;
_data = 0;
_data = new T[size];
}
template <class T>
inline
Array2D<T>::Array2D ():
_sizeY (0), _data (0)
{
// emtpy
}
template <class T>
inline
Array2D<T>::Array2D (long sizeX, long sizeY):
_sizeY (sizeY), _data (new T[sizeX * sizeY])
{
// emtpy
}
template <class T>
inline
Array2D<T>::~Array2D ()
{
delete [] _data;
}
template <class T>
inline T *
Array2D<T>::operator [] (long x)
{
return _data + x * _sizeY;
}
template <class T>
inline const T *
Array2D<T>::operator [] (long x) const
{
return _data + x * _sizeY;
}
template <class T>
inline void
Array2D<T>::resizeErase (long sizeX, long sizeY)
{
T *tmp = new T[sizeX * sizeY];
delete [] _data;
_sizeY = sizeY;
_data = tmp;
}
template <class T>
inline void
Array2D<T>::resizeEraseUnsafe (long sizeX, long sizeY)
{
delete [] _data;
_data = 0;
_sizeY = 0;
_data = new T[sizeX * sizeY];
_sizeY = sizeY;
}
} // namespace Imf
#endif

156
3rdparty/openexr/IlmImf/ImfAttribute.cpp vendored Normal file
View File

@ -0,0 +1,156 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// class Attribute
//
//-----------------------------------------------------------------------------
#include <ImfAttribute.h>
#include "IlmThreadMutex.h"
#include "Iex.h"
#include <string.h>
#include <map>
namespace Imf {
using IlmThread::Mutex;
using IlmThread::Lock;
Attribute::Attribute () {}
Attribute::~Attribute () {}
namespace {
struct NameCompare: std::binary_function <const char *, const char *, bool>
{
bool
operator () (const char *x, const char *y) const
{
return strcmp (x, y) < 0;
}
};
typedef Attribute* (*Constructor)();
typedef std::map <const char *, Constructor, NameCompare> TypeMap;
class LockedTypeMap: public TypeMap
{
public:
Mutex mutex;
};
LockedTypeMap &
typeMap ()
{
static Mutex criticalSection;
Lock lock (criticalSection);
static LockedTypeMap* typeMap = 0;
if (typeMap == 0)
typeMap = new LockedTypeMap ();
return *typeMap;
}
} // namespace
bool
Attribute::knownType (const char typeName[])
{
LockedTypeMap& tMap = typeMap();
Lock lock (tMap.mutex);
return tMap.find (typeName) != tMap.end();
}
void
Attribute::registerAttributeType (const char typeName[],
Attribute *(*newAttribute)())
{
LockedTypeMap& tMap = typeMap();
Lock lock (tMap.mutex);
if (tMap.find (typeName) != tMap.end())
THROW (Iex::ArgExc, "Cannot register image file attribute "
"type \"" << typeName << "\". "
"The type has already been registered.");
tMap.insert (TypeMap::value_type (typeName, newAttribute));
}
void
Attribute::unRegisterAttributeType (const char typeName[])
{
LockedTypeMap& tMap = typeMap();
Lock lock (tMap.mutex);
tMap.erase (typeName);
}
Attribute *
Attribute::newAttribute (const char typeName[])
{
LockedTypeMap& tMap = typeMap();
Lock lock (tMap.mutex);
TypeMap::const_iterator i = tMap.find (typeName);
if (i == tMap.end())
THROW (Iex::ArgExc, "Cannot create image file attribute of "
"unknown type \"" << typeName << "\".");
return (i->second)();
}
} // namespace Imf

Some files were not shown because too many files have changed in this diff Show More