commit
69020da607
1231 changed files with 286412 additions and 22652 deletions
Binary file not shown.
Binary file not shown.
@ -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.
@ -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 |
||||
|
@ -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. |
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 |
@ -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 |
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 8.5 KiB |
@ -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. |
File diff suppressed because it is too large
Load Diff
@ -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 |
@ -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 |
@ -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) |
@ -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) |
@ -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. |
@ -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; |
||||
} |
@ -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,
|
||||
}; |
@ -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 |
@ -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 |
@ -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 |
@ -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; |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -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 |
@ -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
|
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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
|
@ -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 |
@ -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" |
@ -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
|
@ -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 |
@ -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 |
@ -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
Loading…
Reference in new issue