mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
Added OpenEXR library v1.7.1
This commit is contained in:
parent
3fb3851c7a
commit
867777f825
123
3rdparty/ilmimf/README
vendored
123
3rdparty/ilmimf/README
vendored
@ -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.
|
||||
|
21
3rdparty/openexr/AUTHORS.ilmbase
vendored
Normal file
21
3rdparty/openexr/AUTHORS.ilmbase
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Developers:
|
||||
-----------
|
||||
|
||||
Florian Kainz <kainz@ilm.com>
|
||||
Rod Bogart <rgb@ilm.com>
|
||||
Drew Hess <dhess@ilm.com>
|
||||
Bill Anderson <wja@ilm.com>
|
||||
Wojciech Jarosz <wjarosz@ucsd.edu>
|
||||
|
||||
Contributors:
|
||||
-------------
|
||||
|
||||
Rito Trevino
|
||||
Josh Pines
|
||||
Christian Rouet
|
||||
|
||||
Win32 build system:
|
||||
-------------------
|
||||
|
||||
Nick Porcino <NPorcino@lucasarts.com>
|
||||
Kimball Thurston
|
41
3rdparty/openexr/AUTHORS.openexr
vendored
Normal file
41
3rdparty/openexr/AUTHORS.openexr
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
Developers:
|
||||
-----------
|
||||
|
||||
Florian Kainz <kainz@ilm.com>
|
||||
Rod Bogart <rgb@ilm.com>
|
||||
Drew Hess <dhess@ilm.com>
|
||||
Paul Schneider <paultschneider@mac.com>
|
||||
Bill Anderson <wja@ilm.com>
|
||||
Wojciech Jarosz <wjarosz@ucsd.edu>
|
||||
Andrew Kunz <akunz@ilm.com>
|
||||
|
||||
Contributors:
|
||||
-------------
|
||||
|
||||
Simon Green <SGreen@nvidia.com>
|
||||
Rito Trevino <etrevino@ilm.com>
|
||||
Josh Pines
|
||||
Christian Rouet
|
||||
Rodrigo Damazio <rdamazio@lsi.usp.br>
|
||||
Greg Ward <gward@lmi.net>
|
||||
Joseph Goldstone <joseph@lp.com>
|
||||
Loren Carpenter, Pixar Animation Studios
|
||||
|
||||
Win32 build system:
|
||||
-------------------
|
||||
|
||||
Nick Porcino <NPorcino@lucasarts.com>
|
||||
Kimball Thurston
|
||||
|
||||
Win32 port contributors:
|
||||
------------------------
|
||||
|
||||
Dustin Graves <dgraves@computer.org>
|
||||
Jukka Liimatta <jukka.liimatta@twilight3d.com>
|
||||
Baumann Konstantin <Konstantin.Baumann@hpi.uni-potsdam.de>
|
||||
Daniel Koch <daniel@eyeonline.com>
|
||||
E. Scott Larsen <larsene@cs.unc.edu>
|
||||
stephan mantler <step@acm.org>
|
||||
Andreas Kahler <AKahler@nxn-software.com>
|
||||
Frank Jargstorff <fjargstorff@nvidia.com>
|
||||
Lutz Latta
|
62
3rdparty/openexr/CMakeLists.txt
vendored
Normal file
62
3rdparty/openexr/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# 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
|
||||
/wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4244 /wd4245 /wd4267 /wd4305 /wd4334 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800)
|
||||
|
||||
add_library(IlmImf STATIC ${lib_hdrs} ${lib_srcs})
|
||||
target_link_libraries(IlmImf ${ZLIB_LIBRARIES})
|
||||
|
||||
set_target_properties(IlmImf
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "IlmImf"
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
||||
)
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(IlmImf PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS IlmImf ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT main)
|
||||
endif()
|
||||
|
||||
set(OPENEXR_INCLUDE_PATHS ${OPENEXR_INCLUDE_PATHS} PARENT_SCOPE)
|
||||
set(OPENEXR_VERSION "1.7.1" PARENT_SCOPE)
|
109
3rdparty/openexr/ChangeLog.ilmbase
vendored
Normal file
109
3rdparty/openexr/ChangeLog.ilmbase
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
Version 1.0.3
|
||||
* Added support for enabling/disabling large stack optimisations, used in
|
||||
halfFunction.h.
|
||||
(Piotr Stanczyk)
|
||||
* Added ImathNoise.(h/cpp) files. Initializes Perlin noise to match the
|
||||
Renderman implmenetation.
|
||||
(Pixar Contribution)
|
||||
* Fixed a number of missing includes to comply with stricter
|
||||
enforcement by gnu compilers.
|
||||
(Piotr Stanczyk)
|
||||
* Depracated compiler flag: -Wno-long-double since it is no longer
|
||||
supported under OS X.
|
||||
(Piotr Stanczyk)
|
||||
* A minor API change to Imath::Frustum has been made: the functions
|
||||
'near' and 'far' have been renamed to 'nearPlane' and 'farPlane' due
|
||||
to conflicts with certain windows headers. The former alternate
|
||||
accessor names for these values on windows ('hither' and 'yon')
|
||||
remain, though should be considered deprecated.
|
||||
(David Lenihan)
|
||||
* Added SVD, eigenvalue solver, and procrustes fit calculations
|
||||
to ImathMatrixAlgo.
|
||||
(Chris Twigg, Ji Hun Yu)
|
||||
* Added Imath::FrustumTest for frustum visibility testing.
|
||||
(Eric Johnston)
|
||||
* Fixed a stack corruption in the matrix minorOf functions.
|
||||
(Nick Rasmussen)
|
||||
* Visual studio 2008 project files have been added to the vc/vc9
|
||||
directory, and several minor visual studio compile fixes have
|
||||
been applied.
|
||||
(Nick Rasmussen)
|
||||
* Updated the so verison to 7.
|
||||
(Piotr Stanczyk)
|
||||
* Depracated the MacCode_Warrior and Shake submodules.
|
||||
(Piotr Stanczyk)
|
||||
|
||||
Version 1.0.2
|
||||
* Added support for targetting builds on 64bit Windows and minimising
|
||||
number of compiler warnings on Windows. Thanks to Ger Hobbelt for his
|
||||
contributions to CreateDLL.
|
||||
(Ji Hun Yu)
|
||||
* Removed a spurious restrict qualifier in the matrix manipulation code
|
||||
that was causing the 64-bit MS compiler to generate code in release
|
||||
mode that caused incorrect results.
|
||||
(Ji Hun Yu)
|
||||
* Added patches for improving universal binaries on OS X. Thanks to
|
||||
Paul Schneider for the contribution
|
||||
(Piotr Stanczyk)
|
||||
* Imath::Box optimization: remove loops from methods by partially
|
||||
specializing the class, for boxes of two and three dimensions.
|
||||
(Piotr Stanczyk)
|
||||
* Added explicit copy constructors to Imath::Matrix33<T> and
|
||||
ImathMatrix44<T> to make conversions between float and double
|
||||
matrices more convenient.
|
||||
(Florian Kainz)
|
||||
* Added slerpShortestArc() and euclideanInnerProduct() functions
|
||||
to Imath::Quat<T>.
|
||||
(Nick Porcino)
|
||||
* Added 4D vector class template Imath::Vec4<T>.
|
||||
(Nick Porcino)
|
||||
* Copy constructors and assignment operators for Matrix33<T>
|
||||
and Matrix44<T> are up to 25% faster. Added matrix constructors
|
||||
that do not initialize the matrix (this is faster in cases where
|
||||
the initial value of the matrix is immediately overwritten anyway).
|
||||
(Nick Porcino)
|
||||
* Rewrote function closestPointOnBox(point,box). Shortened
|
||||
the code, improved numerical accuracy, fixed a bug where
|
||||
closestPointOnBox(box.center(),box) would return the center
|
||||
of the +Z side of the box, even if the +/-X or +/-Y sides
|
||||
were closer.
|
||||
(Florian Kainz)
|
||||
* Rewrote function findEntryAndExitPoints() in ImathBoxAlgo.h.
|
||||
Results are now consistent with those from intersect(), also
|
||||
in ImathBoxAlgo.h.
|
||||
(Florian Kainz)
|
||||
* Made Vec2<T>::length() and Vec3<T>::length() more accurate for
|
||||
vectors whose length is less than sqrt(limits<T>::smallest());
|
||||
(Florian Kainz)
|
||||
* Made Quat<T>::angle() more accurate for small angles.
|
||||
(Don Hatch)
|
||||
|
||||
Version 1.0.1:
|
||||
* Removed Windows .suo files from distribution.
|
||||
(Eric Wimmer)
|
||||
|
||||
Version 1.0.0:
|
||||
* Bumped DSO version number to 6.0
|
||||
(Florian Kainz)
|
||||
* Rounding during float-to-half conversion now implements
|
||||
"round to nearest even" mode: if the original float value
|
||||
is exactly in the middle between the two closest half values
|
||||
then rounding chooses the half value whose least significant
|
||||
bit is zero.
|
||||
(Florian Kainz)
|
||||
* Installation Tuning:
|
||||
- Corrected version number on dso's (libtool) - now 5.0
|
||||
- Separated ILMBASE_LDFLAGS and ILMBASE_LIBS so that test programs
|
||||
in configure scripts of packages dependent on IlmBase can link
|
||||
with static libraries properly
|
||||
- eliminated some warning messages during install
|
||||
(Andrew Kunz)
|
||||
|
||||
Version 0.9.0:
|
||||
* Initial release of this code as a separate library.
|
||||
Previously the libraries contained were part of
|
||||
version 1.4.0 of OpenEXR
|
||||
* New build scripts for Linux/Unix
|
||||
(Andrew Kunz)
|
||||
* New Windows project files and build scripts
|
||||
(Kimball Thurston)
|
666
3rdparty/openexr/ChangeLog.openexr
vendored
Normal file
666
3rdparty/openexr/ChangeLog.openexr
vendored
Normal file
@ -0,0 +1,666 @@
|
||||
Version 1.7.1:
|
||||
* Updated the .so verison to 7.
|
||||
(Piotr Stanczyk)
|
||||
|
||||
Version 1.7.0:
|
||||
* Added support for targetting builds on 64bit Windows and minimising
|
||||
number of compiler warnings on Windows. Thanks to Ger Hobbelt for his
|
||||
contributions to CreateDLL.
|
||||
(Ji Hun Yu)
|
||||
* Added new atttribute types:
|
||||
M33dAttribute 3x3 double-precision matrix
|
||||
M44dAttribute 4x4 double-precision matrix
|
||||
V2d 2D double-precision vector
|
||||
V3d 3D double-precision vector
|
||||
(Florian Kainz)
|
||||
* Bug fix: crash when reading a damaged image file (found
|
||||
by Apple). An exception thrown inside the PIZ Huffman
|
||||
decoder bypasses initialization of an array of pointers.
|
||||
The uninitialized pointers are later passed to operator
|
||||
delete.
|
||||
(Florian Kainz)
|
||||
* Bug fix: crash when reading a damaged image file (found by
|
||||
Apple). Computing the size of input certain buffers may
|
||||
overflow and wrap around to a small number, later causing
|
||||
writes beyond the end of the buffer.
|
||||
(Florian Kainz)
|
||||
* In the "Technical Introduction" document, added
|
||||
Premultiplied vs. Un-Premulitiplied Color section:
|
||||
states explicitly that pixels with zero alpha and non-zero
|
||||
RGB are allowed, points out that preserving such a pixel can
|
||||
be a problem in application programs with un-premultiplied
|
||||
internal image representations.
|
||||
(Florian Kainz)
|
||||
* exrenvmap improvements:
|
||||
- New command line flags set the type of the input image to
|
||||
latitude-longitude map or cube-face map, overriding the
|
||||
envmap attribute in the input file header.
|
||||
- Cube-face maps can now be assembled from or split into six
|
||||
square sub-images.
|
||||
- Converting a cube-face map into a new cube-face map with
|
||||
the same face size copies the image instead of resampling
|
||||
it. This avoids blurring when a cube-face map is assembled
|
||||
from or split into sub-images.
|
||||
(Florian Kainz)
|
||||
* Updated standard chromaticities in ImfAcesFile.cpp to match
|
||||
final ACES (Academy Color Encoding Specification) document.
|
||||
(Florian Kainz)
|
||||
* Added worldToCamera and worldToNDC matrices to
|
||||
ImfStandardAttributes.h (Florian Kainz)
|
||||
* Increased the maximum length of attribute and channel names
|
||||
from 31 to 255 characters. For files that do contain names
|
||||
longer than 31 characters, a new LONG_NAMES_FLAG in the fil
|
||||
version number is set. This flag causes older versions of
|
||||
the IlmImf library (1.6.1 and earlier) to reject files with
|
||||
long names. Without the flag, older library versions would
|
||||
mis-interpret files with long names as broken.
|
||||
(Florian Kainz)
|
||||
* Reading luminance/chroma-encoded files via the RGBA
|
||||
interface is faster: buffer padding avoids cache thrashing
|
||||
for certain image sizes, redundant calls to saturation()
|
||||
have been eliminated.
|
||||
(Mike Wall)
|
||||
* Added "hemispherical blur" option to exrenvmap.
|
||||
(Florian Kainz)
|
||||
* Added experimental version of I/O classes for ACES file
|
||||
format (restricted OpenEXR format with special primaries
|
||||
and white point); added exr2aces file converter.
|
||||
(Florian Kainz)
|
||||
* Added new constructors to classes Imf::RgbaInputFile and
|
||||
Imf::TiledRgbaInputFile. The new constructors have a
|
||||
layerName parameter, which allows the caller to specify
|
||||
which layer of a multi-layer or multi-view image will
|
||||
be read.
|
||||
(Florian Kainz)
|
||||
* A number of member functions in classes Imf::Header,
|
||||
Imf::ChannelList and Imf::FrameBuffer have parameters
|
||||
of type "const char *". Added equivalent functions that
|
||||
take "const std::string &" parameters.
|
||||
(Florian Kainz)
|
||||
* Added library support for Weta Digital multi-view images:
|
||||
StringVector attribute type, multiView standard attribute
|
||||
of type StringVector, utility functions related to grouping
|
||||
channels into separate views.
|
||||
(Peter Hillman, Florian Kainz)
|
||||
|
||||
Version 1.6.1:
|
||||
* Removed Windows .suo files from distribution.
|
||||
(Eric Wimmer)
|
||||
* Bug fix: crashes, memory leaks and file descriptor leaks
|
||||
when reading damaged image files (some reported by Apple,
|
||||
others found by running IlmImfFuzzTest).
|
||||
(Florian Kainz)
|
||||
* Added new IlmImfFuzzTest program to test how resilient the
|
||||
IlmImf library is with respect broken input files: the program
|
||||
first damages OpenEXR files by partially overwriting them with
|
||||
random data; then it tries to read the damaged files. If all
|
||||
goes well, the program doesn't crash.
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.6.0:
|
||||
* Bumped DSO version number to 6.0
|
||||
(Florian Kainz)
|
||||
* Added new standard attributes related to color rendering with
|
||||
CTL (Color Transformation Language): renderingTransform,
|
||||
lookModTransform and adoptedNeutral.
|
||||
(Florian Kainz)
|
||||
* Bug fix: for pixels with luminance near HALF_MIN, conversion
|
||||
from RGB to luminance/chroma produces NaNs and infinities
|
||||
(Florian Kainz)
|
||||
* Bug fix: excessive desaturation of small details with certain
|
||||
colors after repeatedly loading and saving luminance/chroma
|
||||
encoded images with B44 compression.
|
||||
(Florian Kainz)
|
||||
* Added B44A compression, a minor variation of B44: in most cases,
|
||||
the compression ratio is 2.28:1, the same as with B44, but in
|
||||
uniform image areas where all pixels have the same value, the
|
||||
compression ratio increases to 10.66:1. Uniform areas occur, for
|
||||
example, in an image's alpha channel, which typically contains
|
||||
large patches that are solid black or white, or in computer-
|
||||
generated images with a black background.
|
||||
(Florian Kainz)
|
||||
* Added flag to configure.ac to enable or disable use of large
|
||||
auto arrays in the IlmImf library. Default is "enable" for
|
||||
Linux, "disable" for everything else.
|
||||
(Darby Johnston, Florian Kainz)
|
||||
* corrected version number on dso's (libtool) - now 5.0
|
||||
* Separated ILMBASE_LDFLAGS and ILMBASE_LIBS so that test programs
|
||||
can link with static libraries properly
|
||||
* eliminated some warning messages during install
|
||||
(Andrew Kunz)
|
||||
|
||||
Version 1.5.0:
|
||||
* reorganized packaging of OpenEXR libraries to facilitate
|
||||
integration with CTL. Now this library depends on the library
|
||||
IlmBase. Some functionality has been moved into OpenEXR_Viewers,
|
||||
which depends on two other libraries, CTL and OpenEXR_CTL.
|
||||
Note: previously there were separate releases of
|
||||
OpenEXR-related plugins for Renderman, Shake and Photoshop.
|
||||
OpenEXR is supported natively by Rendermand and Photoshop, so
|
||||
these plugins will not be supported for this or future
|
||||
versions of OpenEXR.
|
||||
(Andrew Kunz)
|
||||
* New build scripts for Linux/Unix
|
||||
(Andrew Kunz)
|
||||
* New Windows project files and build scripts
|
||||
(Kimball Thurston)
|
||||
* float-to-half conversion now preserves the sign of float zeroes
|
||||
and of floats that are so small that they become half zeroes.
|
||||
(Florian Kainz)
|
||||
* Bug fix: Imath::Frustum<T>::planes() returns incorrect planes
|
||||
if the frustum is orthogonal.
|
||||
(Philip Hubbard)
|
||||
* added new framesPerSecond optional standard attribute
|
||||
(Florian Kainz)
|
||||
* Imath cleanup:
|
||||
- Rewrote function Imath::Quat<T>::setRotation() to make it
|
||||
numerically more accurate, added confidence tests
|
||||
- Rewrote function Imath::Quat<T>::slerp() using Don Hatch's
|
||||
method, which is numerically more accurate, added confidence
|
||||
tests.
|
||||
- Rewrote functions Imath::closestPoints(), Imath::intersect(),
|
||||
added confidence tests.
|
||||
- Removed broken function Imath::nearestPointOnTriangle().
|
||||
- Rewrote Imath::drand48(), Imath::lrand48(), etc. to make
|
||||
them functionally identical with the Unix/Linux versions
|
||||
of drand48(), lrand48() and friends.
|
||||
- Replaced redundant definitions of Int64 in Imath and IlmImf
|
||||
with a single definition in ImathInt64.h.
|
||||
(Florian Kainz)
|
||||
* exrdisplay: if the file's and the display's RGB chromaticities
|
||||
differ, the pixels RGB values are transformed from the file's
|
||||
to the display's RGB space.
|
||||
(Florian Kainz)
|
||||
* Added new lossy B44 compression method. HALF channels are
|
||||
compressed with a fixed ratio of 2.28:1. UINT and FLOAT
|
||||
channels are stored verbatim, without compression.
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.4.0a:
|
||||
* Fixed the ReleaseDLL targets for Visual Studio 2003.
|
||||
(Barnaby Robson)
|
||||
|
||||
Version 1.4.0:
|
||||
* Production release.
|
||||
* Bug Fix: calling setFrameBuffer() for every scan line
|
||||
while reading a tiled file through the scan line API
|
||||
returns bad pixel data. (Paul Schneider, Florian Kainz)
|
||||
|
||||
Version 1.3.1:
|
||||
* Fixed the ReleaseDLL targets for Visual Studio 2005.
|
||||
(Nick Porcino, Drew Hess)
|
||||
* Fixes/enhancements for createDLL.
|
||||
(Nick Porcino)
|
||||
|
||||
Version 1.3.0:
|
||||
* Removed openexr.spec file, it's out of date and broken to
|
||||
boot.
|
||||
(Drew Hess)
|
||||
* Support for Visual Studio 2005.
|
||||
(Drew Hess, Nick Porcino)
|
||||
* When compiling against OpenEXR headers on Windows, you
|
||||
no longer need to define any HAVE_* or PLATFORM_*
|
||||
macros in your projects. If you are using any OpenEXR
|
||||
DLLs, however, you must define OPENEXR_DLL in your
|
||||
project's preprocessor directives.
|
||||
(Drew Hess)
|
||||
* Many fixes to the Windows VC7 build system.
|
||||
(Drew Hess, Nick Porcino)
|
||||
* Support for building universal binaries on OS X 10.4.
|
||||
(Drew Hess, Paul Schneider)
|
||||
* Minor configure.ac fix to accomodate OS X's automake.
|
||||
(Drew Hess)
|
||||
* Removed CPU-specific optimizations from configure.ac,
|
||||
autoconf's guess at the CPU type isn't very useful,
|
||||
anyway. Closes #13429.
|
||||
(Drew Hess)
|
||||
* Fixed quoting for tests in configure.ac. Closes #13428.
|
||||
(Drew Hess)
|
||||
* Use host specification instead of target in configure.ac.
|
||||
Closes #13427.
|
||||
(Drew Hess)
|
||||
* Fix use of AC_ARG_ENABLE in configure.ac. Closes
|
||||
#13426.
|
||||
(Drew Hess)
|
||||
* Removed workaround for OS X istream::read bug.
|
||||
(Drew Hess)
|
||||
* Added pthread support to OpenEXR pkg-config file.
|
||||
(Drew Hess)
|
||||
* Added -no-undefined to LDFLAGS and required libs to LIBADD
|
||||
for library projects with other library dependencies, per
|
||||
Rex Dieter's patch.
|
||||
(Drew Hess)
|
||||
* HAVE_* macros are now defined in the OpenEXRConfig.h header
|
||||
file instead of via compiler flags. There are a handful of
|
||||
public headers which rely on the value of these macros,
|
||||
and projects including these headers have previously needed
|
||||
to define the same macros and values as used by OpenEXR's
|
||||
'configure', which is bad form. Now 'configure' writes these
|
||||
values to the OpenEXRConfig.h header file, which is included
|
||||
by any OpenEXR source files that need these macros. This
|
||||
method of specifying HAVE_* macros guarantees that projects
|
||||
will get the proper settings without needing to add compile-
|
||||
time flags to accomodate OpenEXR. Note that this isn't
|
||||
implemented properly for Windows yet.
|
||||
(Drew Hess)
|
||||
* Platform cleanups:
|
||||
- No more support for IRIX or OSF1.
|
||||
- No more explicit support for SunOS, because we have no way to
|
||||
verify that it's working. I suspect that newish versions of
|
||||
SunOS will just work out of the box, but let me know if not.
|
||||
- No more PLATFORM_* macros (vestiges of the ILM internal build
|
||||
system). PLATFORM_DARWIN_PPC is replaced by HAVE_DARWIN.
|
||||
PLATFORM_REDHAT_IA32 (which was only used in IlmImfTest) is
|
||||
replaced by HAVE_LINUX_PROCFS.
|
||||
- OS X 10.4, which is the minimum version we're going to support
|
||||
with this version, appears to have support for nrand48 and friends,
|
||||
so no need to use the Imath-supplied version of them anymore.
|
||||
(Drew Hess)
|
||||
* No more PLATFORM_WINDOWS or PLATFORM_WIN32, replace with
|
||||
proper standard Windows macros. (Drew Hess)
|
||||
* Remove support for gcc 2.95, no longer supported. (Drew Hess)
|
||||
* Eliminate HAVE_IOS_BASE macro, OpenEXR now requires support for
|
||||
ios_base. (Drew Hess)
|
||||
* Eliminate HAVE_STL_LIMITS macro, OpenEXR now requires the ISO C++
|
||||
<limits> header. (Drew Hess)
|
||||
* Use double quote-style include dirctives for OpenEXR
|
||||
includes. (Drew Hess)
|
||||
* Added a document that gives an overview of the on-disk
|
||||
layout of OpenEXR files (Florian Kainz)
|
||||
* Added sections on layers and on memory-mapped file input
|
||||
to the documentation. (Florian Kainz)
|
||||
* Bug fix: reading an incomplete file causes a deadlock while
|
||||
waiting on a semaphore. (Florian Kainz)
|
||||
* Updated documentation (ReadingAndWritingImageFiles.sxw) and
|
||||
sample code (IlmImfExamples):
|
||||
Added a section about multi-threading, updated section on
|
||||
thread-safety, changed documentation and sample code to use
|
||||
readTiles()/writeTiles() instead of readTile()/writeTile()
|
||||
where possible, mentioned that environment maps contain
|
||||
redundant pixels, updated section on testing if a file is
|
||||
an OpenEXR file.
|
||||
(Florian Kainz)
|
||||
* Multi-threading bug fixes (exceptions could be thrown
|
||||
multiple times, some operations were not thread safe),
|
||||
updated some comments, added comments, more multithreaded
|
||||
testing.
|
||||
(Florian Kainz)
|
||||
* Added multi-threading support: multiple threads
|
||||
cooperate to read or write a single OpenEXR file.
|
||||
(Wojciech Jarosz)
|
||||
* Added operator== and operator!= to Imath::Frustum.
|
||||
(Andre Mazzone)
|
||||
* Bug fix: Reading a PIZ-compressed file with an invalid
|
||||
Huffman code table caused crashes by indexing off the
|
||||
end of an array.
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.2.2:
|
||||
* Updated README to remove option for building with Visual C++ 6.0.
|
||||
(Drew Hess)
|
||||
* Some older versions of gcc don't support a full iomanip
|
||||
implemenation; check for this during configuration.
|
||||
(Drew Hess)
|
||||
* Install PDF versions of documentation, remove old/out-of-date
|
||||
HTML documentation. (Florian Kainz)
|
||||
* Removed vc/vc6 directory; Visual C++ 6.0 is no longer
|
||||
supported. (Drew Hess)
|
||||
* Updated README.win32 with details of new build system.
|
||||
(Florian Kainz, Drew Hess)
|
||||
* New build system for Windows / Visual C++ 7 builds both
|
||||
static libraries and DLLs.
|
||||
(Nick Porcino)
|
||||
* Removed Imath::TMatrix<T> and related classes, which are not
|
||||
used anywhere in OpenEXR.
|
||||
(Florian Kainz)
|
||||
* Added minimal support for "image layers" to class Imf::ChannelList
|
||||
(Florian Kainz)
|
||||
* Added new isComplete() method to InputFile, TiledInputFile
|
||||
etc., that checks if a file is complete or if any pixels
|
||||
are missing (for example, because writing the file was
|
||||
aborted prematurely).
|
||||
(Florian Kainz)
|
||||
* Exposed staticInitialize() function in ImfHeader.h in order
|
||||
to allow thread-safe library initialization in multithreaded
|
||||
programs.
|
||||
(Florian Kainz)
|
||||
* Added a new "time code" attribute
|
||||
(Florian Kainz)
|
||||
* exrmaketiled: when a MIPMAP_LEVELS or RIPMAP_LEVELS image
|
||||
is produced, low-pass filtering takes samples outside the
|
||||
image's data window. This requires extrapolating the image.
|
||||
The user can now specify how the image is extrapolated
|
||||
horizontally and vertically (image is surrounded by black /
|
||||
outermost row of pixels repeats / entire image repeats /
|
||||
entire image repeats, every other copy is a mirror image).
|
||||
exrdisplay: added option to swap the top and botton half,
|
||||
and the left and right half of an image, so that the image's
|
||||
four corners end up in the center. This is useful for checking
|
||||
the seams of wrap-around texture map images.
|
||||
IlmImf library: Added new "wrapmodes" standard attribute
|
||||
to indicate the extrapolation mode for MIPMAP_LEVELS and
|
||||
RIPMAP_LEVELS images.
|
||||
(Florian Kainz)
|
||||
* Added a new "key code" attribute to identify motion picture
|
||||
film frames.
|
||||
(Florian Kainz)
|
||||
* Removed #include <Iex.h> from ImfAttribute.h, ImfHeader.h
|
||||
and ImfXdr.h so that including header files such as
|
||||
ImfInputFile.h no longer defines ASSERT and THROW macros,
|
||||
which may conflict with similar macros defined by
|
||||
application programs.
|
||||
(Florian Kainz)
|
||||
* Converted HTML documentation to OpenOffice format to
|
||||
make maintaining the documents easier:
|
||||
api.html -> ReadingAndWritingImageFiles.sxw
|
||||
details.html -> TechnicalIntroduction.sxw
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.2.1:
|
||||
* exrenvmap and exrmaketiled use slightly less memory
|
||||
(Florian Kainz)
|
||||
* Added functions to IlmImf for quickly testing if a file
|
||||
is an OpenEXR file, and whether the file is scan-line
|
||||
based or tiled. (Florian Kainz)
|
||||
* Added preview image examples to IlmImfExamples. Added
|
||||
description of preview images and environment maps to
|
||||
docs/api.html (Florian Kainz)
|
||||
* Bug fix: PXR24 compression did not work properly for channels
|
||||
with ySampling != 1.
|
||||
(Florian Kainz)
|
||||
* Made template <class T> become template <class S, class T> for
|
||||
the transform(ObjectS, ObjectT) methods. This was done to allow
|
||||
for differing templated objects to be passed in e.g. say a
|
||||
Box<Vec3<S>> and a Matrix44<T>, where S=float and T=double.
|
||||
(Jeff Yost, Arkell Rasiah)
|
||||
* New method Matrix44::setTheMatrix(). Used for assigning a
|
||||
M44f to a M44d. (Jeff Yost, Arkell Rasiah)
|
||||
* Added convenience Color typedefs for half versions of Color3
|
||||
and Color4. Note the Makefile.am for both Imath and ImathTest
|
||||
have been updated with -I and/or -L pathing to Half.
|
||||
(Max Chen, Arkell Rasiah)
|
||||
* Methods equalWithAbsError() and equalWithRelError() are now
|
||||
declared as const. (Colette Mullenhoff, Arkell Rasiah)
|
||||
* Fixes for gcc34. Mainly typename/template/using/this syntax
|
||||
correctness changes. (Nick Ramussen, Arkell Rasiah)
|
||||
* Added Custom low-level file I/O examples to IlmImfExamples
|
||||
and to the docs/api.html document. (Florian Kainz)
|
||||
* Eliminated most warnings messages when OpenEXR is compiled
|
||||
with Visual C++. The OpenEXR code uses lots of (intentional
|
||||
and unintended) implicit type conversions. By default, Visual
|
||||
C++ warns about almost all of them. Most implicit conversions
|
||||
have been removed from the .h files, so that including them
|
||||
should not generate warnings even at warning level 3. Most
|
||||
.cpp files are now compiled with warning level 1.
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.2.0:
|
||||
* Production-ready release.
|
||||
* Disable long double warnings on OS X. (Drew Hess)
|
||||
* Add new source files to VC7 IlmImfDll target. (Drew Hess)
|
||||
* Iex: change the way that APPEND_EXC and REPLACE_EXC modify
|
||||
their what() string to work around an issue with Visual C++
|
||||
7.1. (Florian Kainz, Nick Porcino)
|
||||
* Bumped OpenEXR version to 1.2 and .so versions to 2.0.0 in
|
||||
preparation for the release. (Drew Hess)
|
||||
* Imath: fixed ImathTMatrix.h to work with gcc 3.4. (Drew Hess)
|
||||
* Another quoting fix in openexr.m4. (Drew Hess)
|
||||
* Quoting fix in acinclude.m4 for automake 1.8. (Brad Hards)
|
||||
* Imath: put inline at beginning of declaration in ImathMatrix.h
|
||||
to fix a warning. (Ken McGaugh)
|
||||
* Imath: made Vec equalWith*Error () methods const.
|
||||
* Cleaned up compile-time Win32 support. (Florian Kainz)
|
||||
* Bug fix: Reading a particular broken PIZ-compressed file
|
||||
caused crashes by indexing off the end of an array.
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.1.1:
|
||||
* Half: operator= and variants now return by reference rather
|
||||
than by value. This brings half into conformance with
|
||||
built-in types. (Drew Hess)
|
||||
* Half: remove copy constructor, let compiler supply its
|
||||
own. This improves performance up to 25% on some
|
||||
expressions using half. (Drew Hess)
|
||||
* configure: don't try to be fancy with CXXFLAGS, just use
|
||||
what the user supplies or let configure choose a sensible
|
||||
default if CXXFLAGS is not defined.
|
||||
* IlmImf: fixed a bug in reading scanline files on big-endian
|
||||
architectures. (Drew Hess)
|
||||
* exrmaketiled: Added an option to select compression type.
|
||||
(Florian Kainz)
|
||||
* exrenvmap: Added an option to select compression type.
|
||||
(Florian Kainz)
|
||||
* exrdisplay: Added some new command-line options. (Florian Kainz)
|
||||
* IlmImf: Added Pixar's new "slightly lossy" image compression
|
||||
method. The new method, named PXR24, preserves HALF and
|
||||
UINT data without loss, but FLOAT pixels are converted to
|
||||
a 24-bit representation. PXR24 appears to compress
|
||||
FLOAT depth buffers very well without losing much accuracy.
|
||||
(Loren Carpenter, Florian Kainz)
|
||||
* Changed top-level LICENSE file to allow for other copyright
|
||||
holders for individual files.
|
||||
* IlmImf: TILED FILE FORMAT CHANGE. TiledOutputFile was
|
||||
incorrectly interleaving channels and scanlines before
|
||||
passing pixel data to a compressor. The lossless compressors
|
||||
still work, but lossy compressors do not. Fix the bug by
|
||||
interleaving channels and scanlines in tiled files in the
|
||||
same way as ScanLineOutputFile does. Programs compiled with
|
||||
the new version of IlmImf cannot read tiled images produced
|
||||
with version 1.1.0. (Florian Kainz)
|
||||
* IlmImf: ImfXdr.h fix for 64-bit architectures. (Florian Kainz)
|
||||
* IlmImf: OpenEXR now supports YCA (luminance/chroma/alpha)
|
||||
images with subsampled chroma channels. When an image
|
||||
is written with the RGBA convenience interface, selecting
|
||||
WRITE_YCA instead of WRITE_RGBA causes the library to
|
||||
convert the pixels to YCA format. If WRITE_Y is selected,
|
||||
only luminance is stored in the file (for black and white
|
||||
images). When an image file is read with the RGBA convenience
|
||||
interface, YCA data are automatically converted back to RGBA.
|
||||
(Florian Kainz)
|
||||
* IlmImf: speed up reading tiled files as scan lines.
|
||||
(Florian Kainz)
|
||||
* Half: Fixed subtle bug in Half where signaling float NaNs
|
||||
were being converted to inf in half. (Florian Kainz)
|
||||
* gcc 3.3 compiler warning cleanups. (various)
|
||||
* Imath: ImathEuler.h fixes for gcc 3.4. (Garrick Meeker)
|
||||
|
||||
Version 1.1.0:
|
||||
* Added new targets to Visual C++ .NET 2003 project
|
||||
for exrmaketiled, exrenvmap, exrmakepreview, and exrstdattr.
|
||||
(Drew Hess)
|
||||
* A few assorted Win32 fixes for Imath. (Drew Hess)
|
||||
* GNU autoconf builds now produce versioned libraries.
|
||||
This release is 1:0:0. (Drew Hess)
|
||||
* Fixes for Visual C++ .NET 2003. (Paul Schneider)
|
||||
* Updated Visual C++ zlib project file to zlib 1.2.1.
|
||||
(Drew Hess)
|
||||
* exrdisplay: Fixed fragment shader version. (Drew Hess)
|
||||
* *Test: Fixed some compiler issues. (Drew Hess)
|
||||
* Imath: Handle "restrict" keyword properly. (Drew Hess)
|
||||
* IlmImfExamples: Updated to latest versions of example
|
||||
source code, includes tiling and multi-res images.
|
||||
(Florian Kainz)
|
||||
* exrmakepreview: A new utility to create preview images.
|
||||
(Florian Kainz)
|
||||
* exrenvmap: A new utility to create OpenEXR environment
|
||||
maps. (Florian Kainz)
|
||||
* exrstdattr: A new utility to modify standard
|
||||
attributes. (Florian Kainz)
|
||||
* Updated exrheader to print level rounding mode and
|
||||
preview image size. (Florian Kainz)
|
||||
* Updated exrmaketiled to use level rounding mode.
|
||||
(Florian Kainz)
|
||||
* IlmImf: Changed the orientation of lat-long envmaps to
|
||||
match typical panoramic camera setups. (Florian Kainz)
|
||||
* IlmImf: Fixed a bug where partially-completed files with
|
||||
DECREASING_Y could not be read. (Florian Kainz)
|
||||
* IlmImf: Added support for selectable rounding mode (up/down)
|
||||
when generating multiresolution files. (Florian Kainz)
|
||||
* exrdisplay: Support for tiled images, mip/ripmaps, preview
|
||||
images, and display windows. (Florian Kainz, Drew Hess)
|
||||
* exrmaketiled: A new utility which generates tiled
|
||||
versions of OpenEXR images. (Florian Kainz)
|
||||
* IlmImf: Changed Imf::VERSION to Imf::EXR_VERSION to
|
||||
work around problems with autoconf VERSION macro
|
||||
conflict. (Drew Hess)
|
||||
* exrheader: Support for tiles, mipmaps, environment
|
||||
maps. (Florian Kainz)
|
||||
* IlmImf: Environment map support. (Florian Kainz)
|
||||
* IlmImf: Abstracted stream I/O support. (Florian Kainz)
|
||||
* IlmImf: Support for tiled and mip/ripmapped files;
|
||||
requires new file format. (Wojciech Jarosz, Florian Kainz)
|
||||
* Imath: TMatrix*, generic 2D matricies and algorithms.
|
||||
(Francesco Callari)
|
||||
* Imath: major quaternions cleanup. (Cary Phillips)
|
||||
* Imath: added GLBegin, GLPushAttrib, GLPushMatrix objects
|
||||
for automatic cleanup on exceptions. (Cary Phillips)
|
||||
* Imath: removed implicit scalar->vector promotions and vector
|
||||
comparisons. (Nick Rasmussen)
|
||||
|
||||
Version 1.0.7:
|
||||
* Fixed a typo in one of the IlmImfTest tests. (Paul Schneider)
|
||||
* Fixed a bug in exrdisplay that causes the image to display
|
||||
as all black if there's a NaN or infinity in an OpenEXR
|
||||
image. (Florian Kainz)
|
||||
* Updated exrheader per recent changes to IlmImf library.
|
||||
(Florian Kainz)
|
||||
* Changed an errant float to a T in ImathFrame.h nextFrame().
|
||||
(Cary Phillips)
|
||||
* Support for new "optional standard" attributes
|
||||
(chromaticities, luminance, comments, etc.).
|
||||
(Florian Kainz, Greg Ward, Joseph Goldstone)
|
||||
* Fixed a buffer overrun in ImfOpaqueAttribute. (Paul Schneider)
|
||||
* Added new function, isImfMagic (). (Florian Kainz)
|
||||
|
||||
Version 1.0.6:
|
||||
* Added README.win32 to disted files.
|
||||
* Fixed OpenEXR.pc.in pkg-config file, OpenEXR now works
|
||||
with pkg-config.
|
||||
* Random fixes to readme files for new release.
|
||||
* Fixed openexr.m4, now looks in /usr by default.
|
||||
* Added Visual Studio .NET 2003 "solution."
|
||||
* Fixes for Visual Studio .NET 2003 w/ Microsoft C++ compiler.
|
||||
(Various)
|
||||
* Random Imath fixes and enhancements. Note that
|
||||
extractSHRT now takes an additional optional
|
||||
argument, see ImathMatrixAlgo.h for details. (Various)
|
||||
* Added Wojciech Jarosz to AUTHORS file.
|
||||
* Added test cases for uncompressed case, preview images,
|
||||
frame buffer type conversion. (Wojciech Jarosz,
|
||||
Florian Kainz)
|
||||
* Fix a bug in IlmImf where uncompressed data doesn't get
|
||||
read/written correctly. (Wojciech Jarosz)
|
||||
* Added support for preview images and preview image
|
||||
attributes (thumbnail images) in IlmImf. (Florian Kainz)
|
||||
* Added support for automatic frame buffer type conversion
|
||||
in IlmImf. (Florian Kainz)
|
||||
* Cleaned up some compile-time checks.
|
||||
* Added HalfTest unit tests.
|
||||
* [exrdisplay] Download half framebuffer to texture memory
|
||||
instead of converting to float first. Requires latest
|
||||
Nvidia drivers.
|
||||
|
||||
Version 1.0.5:
|
||||
* Fixed IlmImf.dll to use static runtime libs (Andreas).
|
||||
* Added exrheader project to Visual Studio 6.0 workspace.
|
||||
* Added some example code showing how to use the IlmImf library.
|
||||
(Florian)
|
||||
* Use DLL runtime libs for Win32 libraries rather than static
|
||||
runtime libs.
|
||||
* Add an exrdisplay_fragshader project to the Visual Studio 6.0
|
||||
workspace to enable fragment shaders in Win32.
|
||||
* Add an IlmImfDll project to the Visual Studio 6.0 workspace.
|
||||
* In Win32, export the ImfCRgbaFile C interface via a DLL so
|
||||
that Visual C++ 6.0 users can link against an Intel-compiled
|
||||
IlmImf. (Andreas Kahler)
|
||||
* Use auto_ptr in ImfAutoArray on Win32, it doesn't like large
|
||||
automatic stacks.
|
||||
* Performance improvements in PIZ decoding, between
|
||||
20 and 60% speedup on Athlon and Pentium 4 systems.
|
||||
(Florian)
|
||||
* Updated the README with various information, made
|
||||
some cosmetic changes for readability.
|
||||
* Added fragment shader support to exrdisplay.
|
||||
* Bumped the version to 1.0.5 in prep for release.
|
||||
* Updated README and README.OSX to talk about CodeWarrior
|
||||
project files.
|
||||
* Incorporated Rodrigo Damazio's patch for an openexr.m4
|
||||
macro file and an openexr.spec file for building RPMs.
|
||||
* Small change in ImfAttribute.h to make IlmImf compile with gcc 2.95.
|
||||
* Updated ImfDoubleAttribute.h for Codewarrior on MacOS.
|
||||
* Added exrheader utility.
|
||||
* Update to AUTHORS file.
|
||||
* Added a README.win32 file.
|
||||
* Added project files for Visual Studio 6.0.
|
||||
* Initial Win32 port. Requires Visual Studio 6.0 and Intel C++
|
||||
compiler version 7.0.
|
||||
* Added new intersectT method in ImathSphere.h
|
||||
* Fixed some bugs in ImathQuat.h
|
||||
* Proper use of fltk-config to get platform-specific FLTK
|
||||
compile- and link-time flags.
|
||||
* exrdisplay uses Imath::Math<T>::pow instead of powf now.
|
||||
powf is not availble on all platforms.
|
||||
* Roll OS X "hack" into the source until Apple fixes their
|
||||
istream implementation.
|
||||
|
||||
Version 1.0.4:
|
||||
* OpenEXR is now covered by a modified BSD license. See LICENSE
|
||||
for the new terms.
|
||||
|
||||
Version 1.0.3:
|
||||
|
||||
* OpenEXR is now in sf.net CVS.
|
||||
* Imf::Xdr namespace cleanups.
|
||||
* Some IlmImfTest cleanups for OS X.
|
||||
* Use .cpp extension in exrdisplay sources.
|
||||
* Iex cleanups.
|
||||
* Make IlmImf compile with Metrowerks Codewarrior.
|
||||
* Change large automatic stacks in ImfHuf.C to auto_ptrs allocated
|
||||
off the heap. MacOS X default stack size isn't large enough.
|
||||
* std::ios fix for MacOS X in ImfInputFile.C.
|
||||
* Added new FP predecessor/successor functions to Imath, added
|
||||
tests to ImathTest
|
||||
* Fixed a bug in Imath::extractSHRT for 3x3 matricies when
|
||||
exactly one of the original scaling factors is negative, updated
|
||||
ImathTest to check this case.
|
||||
* Install include files when 'make install' is run.
|
||||
* exrdisplay requires fltk 1.1+ now in an effort to support
|
||||
a MacOS X display program (fltk 1.1 runs on OS X), though this
|
||||
is untested.
|
||||
* renamed configure.in to configure.ac
|
||||
* Removed some tests from IexTest that are no longer used.
|
||||
* Removed ImfHalfXdr.h, it's not used anymore.
|
||||
* Revamped the autoconf system, added some compile-time
|
||||
optimizations, a pkgconfig target, and some maintainer-specific
|
||||
stuff.
|
||||
|
||||
Version 1.0.2:
|
||||
|
||||
* More OS X fixes in Imath, IlmImf and IlmImfTest.
|
||||
* Imath updates.
|
||||
* Fixed a rotation bug in Imath
|
||||
|
||||
Version 1.0.1:
|
||||
|
||||
* Used autoconf 2.53 and automake 1.6 to generate build environment.
|
||||
* Makefile.am cleanups.
|
||||
* OS X fixes.
|
||||
* removed images directory (now distributed separately).
|
||||
|
||||
Version 1.0:
|
||||
|
||||
* first official release.
|
||||
* added some high-level documentation, removed the old OpenEXR.html
|
||||
documentation.
|
||||
* fixed a few nagging build problems.
|
||||
* bumped IMV_VERSION_NUMBER to 2
|
||||
|
||||
Version 0.9:
|
||||
|
||||
* added exrdisplay viewer application.
|
||||
* cleanup _data in Imf::InputFile and Imf::OutputFile constructors.
|
||||
* removed old ILM copyright notices.
|
||||
|
||||
Version 0.8:
|
||||
|
||||
* Initial release.
|
114
3rdparty/openexr/Half/eLut.cpp
vendored
Normal file
114
3rdparty/openexr/Half/eLut.cpp
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Compute a lookup table for float-to-half conversion.
|
||||
//
|
||||
// When indexed with the combined sign and exponent of
|
||||
// a float, the table either returns the combined sign
|
||||
// and exponent of the corresponding half, or zero if
|
||||
// the corresponding half may not be normalized (zero,
|
||||
// denormalized, overflow).
|
||||
//-----------------------------------------------------
|
||||
|
||||
void
|
||||
initELut (unsigned short eLut[])
|
||||
{
|
||||
for (int i = 0; i < 0x100; i++)
|
||||
{
|
||||
int e = (i & 0x0ff) - (127 - 15);
|
||||
|
||||
if (e <= 0 || e >= 30)
|
||||
{
|
||||
//
|
||||
// Special case
|
||||
//
|
||||
|
||||
eLut[i] = 0;
|
||||
eLut[i | 0x100] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Common case - normalized half, no exponent overflow possible
|
||||
//
|
||||
|
||||
eLut[i] = (e << 10);
|
||||
eLut[i | 0x100] = ((e << 10) | 0x8000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Main - prints the sign-and-exponent conversion lookup table
|
||||
//------------------------------------------------------------
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
const int tableSize = 1 << 9;
|
||||
unsigned short eLut[tableSize];
|
||||
initELut (eLut);
|
||||
|
||||
cout << "//\n"
|
||||
"// This is an automatically generated file.\n"
|
||||
"// Do not edit.\n"
|
||||
"//\n\n";
|
||||
|
||||
cout << "{\n ";
|
||||
|
||||
for (int i = 0; i < tableSize; i++)
|
||||
{
|
||||
cout << setw (5) << eLut[i] << ", ";
|
||||
|
||||
if (i % 8 == 7)
|
||||
{
|
||||
cout << "\n";
|
||||
|
||||
if (i < tableSize - 1)
|
||||
cout << " ";
|
||||
}
|
||||
}
|
||||
|
||||
cout << "};\n";
|
||||
return 0;
|
||||
}
|
71
3rdparty/openexr/Half/eLut.h
vendored
Normal file
71
3rdparty/openexr/Half/eLut.h
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
//
|
||||
// This is an automatically generated file.
|
||||
// Do not edit.
|
||||
//
|
||||
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1024, 2048, 3072, 4096, 5120, 6144, 7168,
|
||||
8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360,
|
||||
16384, 17408, 18432, 19456, 20480, 21504, 22528, 23552,
|
||||
24576, 25600, 26624, 27648, 28672, 29696, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 33792, 34816, 35840, 36864, 37888, 38912, 39936,
|
||||
40960, 41984, 43008, 44032, 45056, 46080, 47104, 48128,
|
||||
49152, 50176, 51200, 52224, 53248, 54272, 55296, 56320,
|
||||
57344, 58368, 59392, 60416, 61440, 62464, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
311
3rdparty/openexr/Half/half.cpp
vendored
Normal file
311
3rdparty/openexr/Half/half.cpp
vendored
Normal file
@ -0,0 +1,311 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// class half --
|
||||
// implementation of non-inline members
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include <assert.h>
|
||||
#include "half.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Lookup tables for half-to-float and float-to-half conversion
|
||||
//-------------------------------------------------------------
|
||||
|
||||
HALF_EXPORT_CONST half::uif half::_toFloat[1 << 16] =
|
||||
#include "toFloat.h"
|
||||
HALF_EXPORT_CONST unsigned short half::_eLut[1 << 9] =
|
||||
#include "eLut.h"
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Overflow handler for float-to-half conversion;
|
||||
// generates a hardware floating-point overflow,
|
||||
// which may be trapped by the operating system.
|
||||
//-----------------------------------------------
|
||||
|
||||
float
|
||||
half::overflow ()
|
||||
{
|
||||
volatile float f = 1e10;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
f *= f; // this will overflow before
|
||||
// the forloop terminates
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Float-to-half conversion -- general case, including
|
||||
// zeroes, denormalized numbers and exponent overflows.
|
||||
//-----------------------------------------------------
|
||||
|
||||
short
|
||||
half::convert (int i)
|
||||
{
|
||||
//
|
||||
// Our floating point number, f, is represented by the bit
|
||||
// pattern in integer i. Disassemble that bit pattern into
|
||||
// the sign, s, the exponent, e, and the significand, m.
|
||||
// Shift s into the position where it will go in in the
|
||||
// resulting half number.
|
||||
// Adjust e, accounting for the different exponent bias
|
||||
// of float and half (127 versus 15).
|
||||
//
|
||||
|
||||
register int s = (i >> 16) & 0x00008000;
|
||||
register int e = ((i >> 23) & 0x000000ff) - (127 - 15);
|
||||
register int m = i & 0x007fffff;
|
||||
|
||||
//
|
||||
// Now reassemble s, e and m into a half:
|
||||
//
|
||||
|
||||
if (e <= 0)
|
||||
{
|
||||
if (e < -10)
|
||||
{
|
||||
//
|
||||
// E is less than -10. The absolute value of f is
|
||||
// less than HALF_MIN (f may be a small normalized
|
||||
// float, a denormalized float or a zero).
|
||||
//
|
||||
// We convert f to a half zero with the same sign as f.
|
||||
//
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//
|
||||
// E is between -10 and 0. F is a normalized float
|
||||
// whose magnitude is less than HALF_NRM_MIN.
|
||||
//
|
||||
// We convert f to a denormalized half.
|
||||
//
|
||||
|
||||
//
|
||||
// Add an explicit leading 1 to the significand.
|
||||
//
|
||||
|
||||
m = m | 0x00800000;
|
||||
|
||||
//
|
||||
// Round to m to the nearest (10+e)-bit value (with e between
|
||||
// -10 and 0); in case of a tie, round to the nearest even value.
|
||||
//
|
||||
// Rounding may cause the significand to overflow and make
|
||||
// our number normalized. Because of the way a half's bits
|
||||
// are laid out, we don't have to treat this case separately;
|
||||
// the code below will handle it correctly.
|
||||
//
|
||||
|
||||
int t = 14 - e;
|
||||
int a = (1 << (t - 1)) - 1;
|
||||
int b = (m >> t) & 1;
|
||||
|
||||
m = (m + a + b) >> t;
|
||||
|
||||
//
|
||||
// Assemble the half from s, e (zero) and m.
|
||||
//
|
||||
|
||||
return s | m;
|
||||
}
|
||||
else if (e == 0xff - (127 - 15))
|
||||
{
|
||||
if (m == 0)
|
||||
{
|
||||
//
|
||||
// F is an infinity; convert f to a half
|
||||
// infinity with the same sign as f.
|
||||
//
|
||||
|
||||
return s | 0x7c00;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// F is a NAN; we produce a half NAN that preserves
|
||||
// the sign bit and the 10 leftmost bits of the
|
||||
// significand of f, with one exception: If the 10
|
||||
// leftmost bits are all zero, the NAN would turn
|
||||
// into an infinity, so we have to set at least one
|
||||
// bit in the significand.
|
||||
//
|
||||
|
||||
m >>= 13;
|
||||
return s | 0x7c00 | m | (m == 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// E is greater than zero. F is a normalized float.
|
||||
// We try to convert f to a normalized half.
|
||||
//
|
||||
|
||||
//
|
||||
// Round to m to the nearest 10-bit value. In case of
|
||||
// a tie, round to the nearest even value.
|
||||
//
|
||||
|
||||
m = m + 0x00000fff + ((m >> 13) & 1);
|
||||
|
||||
if (m & 0x00800000)
|
||||
{
|
||||
m = 0; // overflow in significand,
|
||||
e += 1; // adjust exponent
|
||||
}
|
||||
|
||||
//
|
||||
// Handle exponent overflow
|
||||
//
|
||||
|
||||
if (e > 30)
|
||||
{
|
||||
overflow (); // Cause a hardware floating point overflow;
|
||||
return s | 0x7c00; // if this returns, the half becomes an
|
||||
} // infinity with the same sign as f.
|
||||
|
||||
//
|
||||
// Assemble the half from s, e and m.
|
||||
//
|
||||
|
||||
return s | (e << 10) | (m >> 13);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
// Stream I/O operators
|
||||
//---------------------
|
||||
|
||||
ostream &
|
||||
operator << (ostream &os, half h)
|
||||
{
|
||||
os << float (h);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
istream &
|
||||
operator >> (istream &is, half &h)
|
||||
{
|
||||
float f;
|
||||
is >> f;
|
||||
h = half (f);
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
// Functions to print the bit-layout of
|
||||
// floats and halfs, mostly for debugging
|
||||
//---------------------------------------
|
||||
|
||||
void
|
||||
printBits (ostream &os, half h)
|
||||
{
|
||||
unsigned short b = h.bits();
|
||||
|
||||
for (int i = 15; i >= 0; i--)
|
||||
{
|
||||
os << (((b >> i) & 1)? '1': '0');
|
||||
|
||||
if (i == 15 || i == 10)
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
printBits (ostream &os, float f)
|
||||
{
|
||||
half::uif x;
|
||||
x.f = f;
|
||||
|
||||
for (int i = 31; i >= 0; i--)
|
||||
{
|
||||
os << (((x.i >> i) & 1)? '1': '0');
|
||||
|
||||
if (i == 31 || i == 23)
|
||||
os << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
printBits (char c[19], half h)
|
||||
{
|
||||
unsigned short b = h.bits();
|
||||
|
||||
for (int i = 15, j = 0; i >= 0; i--, j++)
|
||||
{
|
||||
c[j] = (((b >> i) & 1)? '1': '0');
|
||||
|
||||
if (i == 15 || i == 10)
|
||||
c[++j] = ' ';
|
||||
}
|
||||
|
||||
c[18] = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
printBits (char c[35], float f)
|
||||
{
|
||||
half::uif x;
|
||||
x.f = f;
|
||||
|
||||
for (int i = 31, j = 0; i >= 0; i--, j++)
|
||||
{
|
||||
c[j] = (((x.i >> i) & 1)? '1': '0');
|
||||
|
||||
if (i == 31 || i == 23)
|
||||
c[++j] = ' ';
|
||||
}
|
||||
|
||||
c[34] = 0;
|
||||
}
|
766
3rdparty/openexr/Half/half.h
vendored
Normal file
766
3rdparty/openexr/Half/half.h
vendored
Normal file
@ -0,0 +1,766 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// half -- a 16-bit floating point number class:
|
||||
//
|
||||
// Type half can represent positive and negative numbers whose
|
||||
// magnitude is between roughly 6.1e-5 and 6.5e+4 with a relative
|
||||
// error of 9.8e-4; numbers smaller than 6.1e-5 can be represented
|
||||
// with an absolute error of 6.0e-8. All integers from -2048 to
|
||||
// +2048 can be represented exactly.
|
||||
//
|
||||
// Type half behaves (almost) like the built-in C++ floating point
|
||||
// types. In arithmetic expressions, half, float and double can be
|
||||
// mixed freely. Here are a few examples:
|
||||
//
|
||||
// half a (3.5);
|
||||
// float b (a + sqrt (a));
|
||||
// a += b;
|
||||
// b += a;
|
||||
// b = a + 7;
|
||||
//
|
||||
// Conversions from half to float are lossless; all half numbers
|
||||
// are exactly representable as floats.
|
||||
//
|
||||
// Conversions from float to half may not preserve a float's value
|
||||
// exactly. If a float is not representable as a half, then the
|
||||
// float value is rounded to the nearest representable half. If a
|
||||
// float value is exactly in the middle between the two closest
|
||||
// representable half values, then the float value is rounded to
|
||||
// the closest half whose least significant bit is zero.
|
||||
//
|
||||
// Overflows during float-to-half conversions cause arithmetic
|
||||
// exceptions. An overflow occurs when the float value to be
|
||||
// converted is too large to be represented as a half, or if the
|
||||
// float value is an infinity or a NAN.
|
||||
//
|
||||
// The implementation of type half makes the following assumptions
|
||||
// about the implementation of the built-in C++ types:
|
||||
//
|
||||
// float is an IEEE 754 single-precision number
|
||||
// sizeof (float) == 4
|
||||
// sizeof (unsigned int) == sizeof (float)
|
||||
// alignof (unsigned int) == alignof (float)
|
||||
// sizeof (unsigned short) == 2
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef _HALF_H_
|
||||
#define _HALF_H_
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(OPENEXR_DLL)
|
||||
#if defined(HALF_EXPORTS)
|
||||
#define HALF_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define HALF_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#define HALF_EXPORT_CONST
|
||||
#else
|
||||
#define HALF_EXPORT
|
||||
#define HALF_EXPORT_CONST const
|
||||
#endif
|
||||
|
||||
class HALF_EXPORT half
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
half (); // no initialization
|
||||
half (float f);
|
||||
|
||||
|
||||
//--------------------
|
||||
// Conversion to float
|
||||
//--------------------
|
||||
|
||||
operator float () const;
|
||||
|
||||
|
||||
//------------
|
||||
// Unary minus
|
||||
//------------
|
||||
|
||||
half operator - () const;
|
||||
|
||||
|
||||
//-----------
|
||||
// Assignment
|
||||
//-----------
|
||||
|
||||
half & operator = (half h);
|
||||
half & operator = (float f);
|
||||
|
||||
half & operator += (half h);
|
||||
half & operator += (float f);
|
||||
|
||||
half & operator -= (half h);
|
||||
half & operator -= (float f);
|
||||
|
||||
half & operator *= (half h);
|
||||
half & operator *= (float f);
|
||||
|
||||
half & operator /= (half h);
|
||||
half & operator /= (float f);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Round to n-bit precision (n should be between 0 and 10).
|
||||
// After rounding, the significand's 10-n least significant
|
||||
// bits will be zero.
|
||||
//---------------------------------------------------------
|
||||
|
||||
half round (unsigned int n) const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Classification:
|
||||
//
|
||||
// h.isFinite() returns true if h is a normalized number,
|
||||
// a denormalized number or zero
|
||||
//
|
||||
// h.isNormalized() returns true if h is a normalized number
|
||||
//
|
||||
// h.isDenormalized() returns true if h is a denormalized number
|
||||
//
|
||||
// h.isZero() returns true if h is zero
|
||||
//
|
||||
// h.isNan() returns true if h is a NAN
|
||||
//
|
||||
// h.isInfinity() returns true if h is a positive
|
||||
// or a negative infinity
|
||||
//
|
||||
// h.isNegative() returns true if the sign bit of h
|
||||
// is set (negative)
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
bool isFinite () const;
|
||||
bool isNormalized () const;
|
||||
bool isDenormalized () const;
|
||||
bool isZero () const;
|
||||
bool isNan () const;
|
||||
bool isInfinity () const;
|
||||
bool isNegative () const;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Special values
|
||||
//
|
||||
// posInf() returns +infinity
|
||||
//
|
||||
// negInf() returns -infinity
|
||||
//
|
||||
// qNan() returns a NAN with the bit
|
||||
// pattern 0111111111111111
|
||||
//
|
||||
// sNan() returns a NAN with the bit
|
||||
// pattern 0111110111111111
|
||||
//--------------------------------------------
|
||||
|
||||
static half posInf ();
|
||||
static half negInf ();
|
||||
static half qNan ();
|
||||
static half sNan ();
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Access to the internal representation
|
||||
//--------------------------------------
|
||||
|
||||
unsigned short bits () const;
|
||||
void setBits (unsigned short bits);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
union uif
|
||||
{
|
||||
unsigned int i;
|
||||
float f;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
static short convert (int i);
|
||||
static float overflow ();
|
||||
|
||||
unsigned short _h;
|
||||
|
||||
static HALF_EXPORT_CONST uif _toFloat[1 << 16];
|
||||
static HALF_EXPORT_CONST unsigned short _eLut[1 << 9];
|
||||
};
|
||||
|
||||
//-----------
|
||||
// Stream I/O
|
||||
//-----------
|
||||
|
||||
HALF_EXPORT std::ostream & operator << (std::ostream &os, half h);
|
||||
HALF_EXPORT std::istream & operator >> (std::istream &is, half &h);
|
||||
|
||||
|
||||
//----------
|
||||
// Debugging
|
||||
//----------
|
||||
|
||||
HALF_EXPORT void printBits (std::ostream &os, half h);
|
||||
HALF_EXPORT void printBits (std::ostream &os, float f);
|
||||
HALF_EXPORT void printBits (char c[19], half h);
|
||||
HALF_EXPORT void printBits (char c[35], float f);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Limits
|
||||
//
|
||||
// Visual C++ will complain if HALF_MIN, HALF_NRM_MIN etc. are not float
|
||||
// constants, but at least one other compiler (gcc 2.96) produces incorrect
|
||||
// results if they are.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
|
||||
#define HALF_MIN 5.96046448e-08f // Smallest positive half
|
||||
|
||||
#define HALF_NRM_MIN 6.10351562e-05f // Smallest positive normalized half
|
||||
|
||||
#define HALF_MAX 65504.0f // Largest positive half
|
||||
|
||||
#define HALF_EPSILON 0.00097656f // Smallest positive e for which
|
||||
// half (1.0 + e) != half (1.0)
|
||||
#else
|
||||
|
||||
#define HALF_MIN 5.96046448e-08 // Smallest positive half
|
||||
|
||||
#define HALF_NRM_MIN 6.10351562e-05 // Smallest positive normalized half
|
||||
|
||||
#define HALF_MAX 65504.0 // Largest positive half
|
||||
|
||||
#define HALF_EPSILON 0.00097656 // Smallest positive e for which
|
||||
// half (1.0 + e) != half (1.0)
|
||||
#endif
|
||||
|
||||
|
||||
#define HALF_MANT_DIG 11 // Number of digits in mantissa
|
||||
// (significand + hidden leading 1)
|
||||
|
||||
#define HALF_DIG 2 // Number of base 10 digits that
|
||||
// can be represented without change
|
||||
|
||||
#define HALF_RADIX 2 // Base of the exponent
|
||||
|
||||
#define HALF_MIN_EXP -13 // Minimum negative integer such that
|
||||
// HALF_RADIX raised to the power of
|
||||
// one less than that integer is a
|
||||
// normalized half
|
||||
|
||||
#define HALF_MAX_EXP 16 // Maximum positive integer such that
|
||||
// HALF_RADIX raised to the power of
|
||||
// one less than that integer is a
|
||||
// normalized half
|
||||
|
||||
#define HALF_MIN_10_EXP -4 // Minimum positive integer such
|
||||
// that 10 raised to that power is
|
||||
// a normalized half
|
||||
|
||||
#define HALF_MAX_10_EXP 4 // Maximum positive integer such
|
||||
// that 10 raised to that power is
|
||||
// a normalized half
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Implementation --
|
||||
//
|
||||
// Representation of a float:
|
||||
//
|
||||
// We assume that a float, f, is an IEEE 754 single-precision
|
||||
// floating point number, whose bits are arranged as follows:
|
||||
//
|
||||
// 31 (msb)
|
||||
// |
|
||||
// | 30 23
|
||||
// | | |
|
||||
// | | | 22 0 (lsb)
|
||||
// | | | | |
|
||||
// X XXXXXXXX XXXXXXXXXXXXXXXXXXXXXXX
|
||||
//
|
||||
// s e m
|
||||
//
|
||||
// S is the sign-bit, e is the exponent and m is the significand.
|
||||
//
|
||||
// If e is between 1 and 254, f is a normalized number:
|
||||
//
|
||||
// s e-127
|
||||
// f = (-1) * 2 * 1.m
|
||||
//
|
||||
// If e is 0, and m is not zero, f is a denormalized number:
|
||||
//
|
||||
// s -126
|
||||
// f = (-1) * 2 * 0.m
|
||||
//
|
||||
// If e and m are both zero, f is zero:
|
||||
//
|
||||
// f = 0.0
|
||||
//
|
||||
// If e is 255, f is an "infinity" or "not a number" (NAN),
|
||||
// depending on whether m is zero or not.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// 0 00000000 00000000000000000000000 = 0.0
|
||||
// 0 01111110 00000000000000000000000 = 0.5
|
||||
// 0 01111111 00000000000000000000000 = 1.0
|
||||
// 0 10000000 00000000000000000000000 = 2.0
|
||||
// 0 10000000 10000000000000000000000 = 3.0
|
||||
// 1 10000101 11110000010000000000000 = -124.0625
|
||||
// 0 11111111 00000000000000000000000 = +infinity
|
||||
// 1 11111111 00000000000000000000000 = -infinity
|
||||
// 0 11111111 10000000000000000000000 = NAN
|
||||
// 1 11111111 11111111111111111111111 = NAN
|
||||
//
|
||||
// Representation of a half:
|
||||
//
|
||||
// Here is the bit-layout for a half number, h:
|
||||
//
|
||||
// 15 (msb)
|
||||
// |
|
||||
// | 14 10
|
||||
// | | |
|
||||
// | | | 9 0 (lsb)
|
||||
// | | | | |
|
||||
// X XXXXX XXXXXXXXXX
|
||||
//
|
||||
// s e m
|
||||
//
|
||||
// S is the sign-bit, e is the exponent and m is the significand.
|
||||
//
|
||||
// If e is between 1 and 30, h is a normalized number:
|
||||
//
|
||||
// s e-15
|
||||
// h = (-1) * 2 * 1.m
|
||||
//
|
||||
// If e is 0, and m is not zero, h is a denormalized number:
|
||||
//
|
||||
// S -14
|
||||
// h = (-1) * 2 * 0.m
|
||||
//
|
||||
// If e and m are both zero, h is zero:
|
||||
//
|
||||
// h = 0.0
|
||||
//
|
||||
// If e is 31, h is an "infinity" or "not a number" (NAN),
|
||||
// depending on whether m is zero or not.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// 0 00000 0000000000 = 0.0
|
||||
// 0 01110 0000000000 = 0.5
|
||||
// 0 01111 0000000000 = 1.0
|
||||
// 0 10000 0000000000 = 2.0
|
||||
// 0 10000 1000000000 = 3.0
|
||||
// 1 10101 1111000001 = -124.0625
|
||||
// 0 11111 0000000000 = +infinity
|
||||
// 1 11111 0000000000 = -infinity
|
||||
// 0 11111 1000000000 = NAN
|
||||
// 1 11111 1111111111 = NAN
|
||||
//
|
||||
// Conversion:
|
||||
//
|
||||
// Converting from a float to a half requires some non-trivial bit
|
||||
// manipulations. In some cases, this makes conversion relatively
|
||||
// slow, but the most common case is accelerated via table lookups.
|
||||
//
|
||||
// Converting back from a half to a float is easier because we don't
|
||||
// have to do any rounding. In addition, there are only 65536
|
||||
// different half numbers; we can convert each of those numbers once
|
||||
// and store the results in a table. Later, all conversions can be
|
||||
// done using only simple table lookups.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------
|
||||
// Simple constructors
|
||||
//--------------------
|
||||
|
||||
inline
|
||||
half::half ()
|
||||
{
|
||||
// no initialization
|
||||
}
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Half-from-float constructor
|
||||
//----------------------------
|
||||
|
||||
inline
|
||||
half::half (float f)
|
||||
{
|
||||
uif x;
|
||||
|
||||
x.f = f;
|
||||
|
||||
if (f == 0)
|
||||
{
|
||||
//
|
||||
// Common special case - zero.
|
||||
// Preserve the zero's sign bit.
|
||||
//
|
||||
|
||||
_h = (x.i >> 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// We extract the combined sign and exponent, e, from our
|
||||
// floating-point number, f. Then we convert e to the sign
|
||||
// and exponent of the half number via a table lookup.
|
||||
//
|
||||
// For the most common case, where a normalized half is produced,
|
||||
// the table lookup returns a non-zero value; in this case, all
|
||||
// we have to do is round f's significand to 10 bits and combine
|
||||
// the result with e.
|
||||
//
|
||||
// For all other cases (overflow, zeroes, denormalized numbers
|
||||
// resulting from underflow, infinities and NANs), the table
|
||||
// lookup returns zero, and we call a longer, non-inline function
|
||||
// to do the float-to-half conversion.
|
||||
//
|
||||
|
||||
register int e = (x.i >> 23) & 0x000001ff;
|
||||
|
||||
e = _eLut[e];
|
||||
|
||||
if (e)
|
||||
{
|
||||
//
|
||||
// Simple case - round the significand, m, to 10
|
||||
// bits and combine it with the sign and exponent.
|
||||
//
|
||||
|
||||
register int m = x.i & 0x007fffff;
|
||||
_h = e + ((m + 0x00000fff + ((m >> 13) & 1)) >> 13);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Difficult case - call a function.
|
||||
//
|
||||
|
||||
_h = convert (x.i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// Half-to-float conversion via table lookup
|
||||
//------------------------------------------
|
||||
|
||||
inline
|
||||
half::operator float () const
|
||||
{
|
||||
return _toFloat[_h].f;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------
|
||||
// Round to n-bit precision
|
||||
//-------------------------
|
||||
|
||||
inline half
|
||||
half::round (unsigned int n) const
|
||||
{
|
||||
//
|
||||
// Parameter check.
|
||||
//
|
||||
|
||||
if (n >= 10)
|
||||
return *this;
|
||||
|
||||
//
|
||||
// Disassemble h into the sign, s,
|
||||
// and the combined exponent and significand, e.
|
||||
//
|
||||
|
||||
unsigned short s = _h & 0x8000;
|
||||
unsigned short e = _h & 0x7fff;
|
||||
|
||||
//
|
||||
// Round the exponent and significand to the nearest value
|
||||
// where ones occur only in the (10-n) most significant bits.
|
||||
// Note that the exponent adjusts automatically if rounding
|
||||
// up causes the significand to overflow.
|
||||
//
|
||||
|
||||
e >>= 9 - n;
|
||||
e += e & 1;
|
||||
e <<= 9 - n;
|
||||
|
||||
//
|
||||
// Check for exponent overflow.
|
||||
//
|
||||
|
||||
if (e >= 0x7c00)
|
||||
{
|
||||
//
|
||||
// Overflow occurred -- truncate instead of rounding.
|
||||
//
|
||||
|
||||
e = _h;
|
||||
e >>= 10 - n;
|
||||
e <<= 10 - n;
|
||||
}
|
||||
|
||||
//
|
||||
// Put the original sign bit back.
|
||||
//
|
||||
|
||||
half h;
|
||||
h._h = s | e;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------
|
||||
// Other inline functions
|
||||
//-----------------------
|
||||
|
||||
inline half
|
||||
half::operator - () const
|
||||
{
|
||||
half h;
|
||||
h._h = _h ^ 0x8000;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator = (half h)
|
||||
{
|
||||
_h = h._h;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator = (float f)
|
||||
{
|
||||
*this = half (f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator += (half h)
|
||||
{
|
||||
*this = half (float (*this) + float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator += (float f)
|
||||
{
|
||||
*this = half (float (*this) + f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator -= (half h)
|
||||
{
|
||||
*this = half (float (*this) - float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator -= (float f)
|
||||
{
|
||||
*this = half (float (*this) - f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator *= (half h)
|
||||
{
|
||||
*this = half (float (*this) * float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator *= (float f)
|
||||
{
|
||||
*this = half (float (*this) * f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator /= (half h)
|
||||
{
|
||||
*this = half (float (*this) / float (h));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline half &
|
||||
half::operator /= (float f)
|
||||
{
|
||||
*this = half (float (*this) / f);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isFinite () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
return e < 31;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isNormalized () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
return e > 0 && e < 31;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isDenormalized () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
unsigned short m = _h & 0x3ff;
|
||||
return e == 0 && m != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isZero () const
|
||||
{
|
||||
return (_h & 0x7fff) == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isNan () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
unsigned short m = _h & 0x3ff;
|
||||
return e == 31 && m != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isInfinity () const
|
||||
{
|
||||
unsigned short e = (_h >> 10) & 0x001f;
|
||||
unsigned short m = _h & 0x3ff;
|
||||
return e == 31 && m == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
half::isNegative () const
|
||||
{
|
||||
return (_h & 0x8000) != 0;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::posInf ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0x7c00;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::negInf ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0xfc00;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::qNan ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0x7fff;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline half
|
||||
half::sNan ()
|
||||
{
|
||||
half h;
|
||||
h._h = 0x7dff;
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
inline unsigned short
|
||||
half::bits () const
|
||||
{
|
||||
return _h;
|
||||
}
|
||||
|
||||
|
||||
inline void
|
||||
half::setBits (unsigned short bits)
|
||||
{
|
||||
_h = bits;
|
||||
}
|
||||
|
||||
#endif
|
178
3rdparty/openexr/Half/halfFunction.h
vendored
Normal file
178
3rdparty/openexr/Half/halfFunction.h
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// halfFunction<T> -- a class for fast evaluation
|
||||
// of half --> T functions
|
||||
//
|
||||
// The constructor for a halfFunction object,
|
||||
//
|
||||
// halfFunction (function,
|
||||
// domainMin, domainMax,
|
||||
// defaultValue,
|
||||
// posInfValue, negInfValue,
|
||||
// nanValue);
|
||||
//
|
||||
// evaluates the function for all finite half values in the interval
|
||||
// [domainMin, domainMax], and stores the results in a lookup table.
|
||||
// For finite half values that are not in [domainMin, domainMax], the
|
||||
// constructor stores defaultValue in the table. For positive infinity,
|
||||
// negative infinity and NANs, posInfValue, negInfValue and nanValue
|
||||
// are stored in the table.
|
||||
//
|
||||
// The tabulated function can then be evaluated quickly for arbitrary
|
||||
// half values by calling the the halfFunction object's operator()
|
||||
// method.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// #include <math.h>
|
||||
// #include <halfFunction.h>
|
||||
//
|
||||
// halfFunction<half> hsin (sin);
|
||||
//
|
||||
// halfFunction<half> hsqrt (sqrt, // function
|
||||
// 0, HALF_MAX, // domain
|
||||
// half::qNan(), // sqrt(x) for x < 0
|
||||
// half::posInf(), // sqrt(+inf)
|
||||
// half::qNan(), // sqrt(-inf)
|
||||
// half::qNan()); // sqrt(nan)
|
||||
//
|
||||
// half x = hsin (1);
|
||||
// half y = hsqrt (3.5);
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef _HALF_FUNCTION_H_
|
||||
#define _HALF_FUNCTION_H_
|
||||
|
||||
#include "half.h"
|
||||
|
||||
#include <IlmBaseConfig.h>
|
||||
#ifndef ILMBASE_HAVE_LARGE_STACK
|
||||
#include <string.h> // need this for memset
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include <float.h>
|
||||
|
||||
|
||||
template <class T>
|
||||
class halfFunction
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
template <class Function>
|
||||
halfFunction (Function f,
|
||||
half domainMin = -HALF_MAX,
|
||||
half domainMax = HALF_MAX,
|
||||
T defaultValue = 0,
|
||||
T posInfValue = 0,
|
||||
T negInfValue = 0,
|
||||
T nanValue = 0);
|
||||
|
||||
#ifndef ILMBASE_HAVE_LARGE_STACK
|
||||
~halfFunction () { delete [] _lut; }
|
||||
#endif
|
||||
|
||||
//-----------
|
||||
// Evaluation
|
||||
//-----------
|
||||
|
||||
T operator () (half x) const;
|
||||
|
||||
private:
|
||||
#ifdef ILMBASE_HAVE_LARGE_STACK
|
||||
T _lut[1 << 16];
|
||||
#else
|
||||
T * _lut;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
template <class Function>
|
||||
halfFunction<T>::halfFunction (Function f,
|
||||
half domainMin,
|
||||
half domainMax,
|
||||
T defaultValue,
|
||||
T posInfValue,
|
||||
T negInfValue,
|
||||
T nanValue)
|
||||
{
|
||||
#ifndef ILMBASE_HAVE_LARGE_STACK
|
||||
_lut = new T[1<<16];
|
||||
memset (_lut, 0 , (1<<16) * sizeof(T));
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < (1 << 16); i++)
|
||||
{
|
||||
half x;
|
||||
x.setBits (i);
|
||||
|
||||
if (x.isNan())
|
||||
_lut[i] = nanValue;
|
||||
else if (x.isInfinity())
|
||||
_lut[i] = x.isNegative()? negInfValue: posInfValue;
|
||||
else if (x < domainMin || x > domainMax)
|
||||
_lut[i] = defaultValue;
|
||||
else
|
||||
_lut[i] = f (x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T
|
||||
halfFunction<T>::operator () (half x) const
|
||||
{
|
||||
return _lut[x.bits()];
|
||||
}
|
||||
|
||||
|
||||
#endif
|
102
3rdparty/openexr/Half/halfLimits.h
vendored
Normal file
102
3rdparty/openexr/Half/halfLimits.h
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Primary authors:
|
||||
// Florian Kainz <kainz@ilm.com>
|
||||
// Rod Bogart <rgb@ilm.com>
|
||||
|
||||
|
||||
#ifndef INCLUDED_HALF_LIMITS_H
|
||||
#define INCLUDED_HALF_LIMITS_H
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
//
|
||||
// C++ standard library-style numeric_limits for class half
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
#include <limits>
|
||||
#include "half.h"
|
||||
|
||||
namespace std {
|
||||
|
||||
template <>
|
||||
class numeric_limits <half>
|
||||
{
|
||||
public:
|
||||
|
||||
static const bool is_specialized = true;
|
||||
|
||||
static half min () throw () {return HALF_NRM_MIN;}
|
||||
static half max () throw () {return HALF_MAX;}
|
||||
|
||||
static const int digits = HALF_MANT_DIG;
|
||||
static const int digits10 = HALF_DIG;
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = false;
|
||||
static const bool is_exact = false;
|
||||
static const int radix = HALF_RADIX;
|
||||
static half epsilon () throw () {return HALF_EPSILON;}
|
||||
static half round_error () throw () {return HALF_EPSILON / 2;}
|
||||
|
||||
static const int min_exponent = HALF_MIN_EXP;
|
||||
static const int min_exponent10 = HALF_MIN_10_EXP;
|
||||
static const int max_exponent = HALF_MAX_EXP;
|
||||
static const int max_exponent10 = HALF_MAX_10_EXP;
|
||||
|
||||
static const bool has_infinity = true;
|
||||
static const bool has_quiet_NaN = true;
|
||||
static const bool has_signaling_NaN = true;
|
||||
static const float_denorm_style has_denorm = denorm_present;
|
||||
static const bool has_denorm_loss = false;
|
||||
static half infinity () throw () {return half::posInf();}
|
||||
static half quiet_NaN () throw () {return half::qNan();}
|
||||
static half signaling_NaN () throw () {return half::sNan();}
|
||||
static half denorm_min () throw () {return HALF_MIN;}
|
||||
|
||||
static const bool is_iec559 = false;
|
||||
static const bool is_bounded = false;
|
||||
static const bool is_modulo = false;
|
||||
|
||||
static const bool traps = true;
|
||||
static const bool tinyness_before = false;
|
||||
static const float_round_style round_style = round_to_nearest;
|
||||
};
|
||||
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif
|
164
3rdparty/openexr/Half/toFloat.cpp
vendored
Normal file
164
3rdparty/openexr/Half/toFloat.cpp
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// toFloat
|
||||
//
|
||||
// A program to generate the lookup table for half-to-float
|
||||
// conversion needed by class half.
|
||||
// The program loops over all 65536 possible half numbers,
|
||||
// converts each of them to a float, and prints the result.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//---------------------------------------------------
|
||||
// Interpret an unsigned short bit pattern as a half,
|
||||
// and convert that half to the corresponding float's
|
||||
// bit pattern.
|
||||
//---------------------------------------------------
|
||||
|
||||
unsigned int
|
||||
halfToFloat (unsigned short y)
|
||||
{
|
||||
|
||||
int s = (y >> 15) & 0x00000001;
|
||||
int e = (y >> 10) & 0x0000001f;
|
||||
int m = y & 0x000003ff;
|
||||
|
||||
if (e == 0)
|
||||
{
|
||||
if (m == 0)
|
||||
{
|
||||
//
|
||||
// Plus or minus zero
|
||||
//
|
||||
|
||||
return s << 31;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Denormalized number -- renormalize it
|
||||
//
|
||||
|
||||
while (!(m & 0x00000400))
|
||||
{
|
||||
m <<= 1;
|
||||
e -= 1;
|
||||
}
|
||||
|
||||
e += 1;
|
||||
m &= ~0x00000400;
|
||||
}
|
||||
}
|
||||
else if (e == 31)
|
||||
{
|
||||
if (m == 0)
|
||||
{
|
||||
//
|
||||
// Positive or negative infinity
|
||||
//
|
||||
|
||||
return (s << 31) | 0x7f800000;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Nan -- preserve sign and significand bits
|
||||
//
|
||||
|
||||
return (s << 31) | 0x7f800000 | (m << 13);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Normalized number
|
||||
//
|
||||
|
||||
e = e + (127 - 15);
|
||||
m = m << 13;
|
||||
|
||||
//
|
||||
// Assemble s, e and m.
|
||||
//
|
||||
|
||||
return (s << 31) | (e << 23) | m;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------
|
||||
// Main - prints the half-to-float lookup table
|
||||
//---------------------------------------------
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
cout.precision (9);
|
||||
cout.setf (ios_base::hex, ios_base::basefield);
|
||||
|
||||
cout << "//\n"
|
||||
"// This is an automatically generated file.\n"
|
||||
"// Do not edit.\n"
|
||||
"//\n\n";
|
||||
|
||||
cout << "{\n ";
|
||||
|
||||
const int iMax = (1 << 16);
|
||||
|
||||
for (int i = 0; i < iMax; i++)
|
||||
{
|
||||
cout << "{0x" << setfill ('0') << setw (8) << halfToFloat (i) << "}, ";
|
||||
|
||||
if (i % 4 == 3)
|
||||
{
|
||||
cout << "\n";
|
||||
|
||||
if (i < iMax - 1)
|
||||
cout << " ";
|
||||
}
|
||||
}
|
||||
|
||||
cout << "};\n";
|
||||
return 0;
|
||||
}
|
16391
3rdparty/openexr/Half/toFloat.h
vendored
Normal file
16391
3rdparty/openexr/Half/toFloat.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
60
3rdparty/openexr/Iex/Iex.h
vendored
Normal file
60
3rdparty/openexr/Iex/Iex.h
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IEX_H
|
||||
#define INCLUDED_IEX_H
|
||||
|
||||
|
||||
//--------------------------------
|
||||
//
|
||||
// Exception handling
|
||||
//
|
||||
//--------------------------------
|
||||
|
||||
|
||||
#include "IexMacros.h"
|
||||
#include "IexBaseExc.h"
|
||||
#include "IexMathExc.h"
|
||||
#include "IexThrowErrnoExc.h"
|
||||
|
||||
// Note that we do not include file IexErrnoExc.h here. That file
|
||||
// defines over 150 classes and significantly slows down compilation.
|
||||
// If you throw ErrnoExc exceptions using the throwErrnoExc() function,
|
||||
// you don't need IexErrnoExc.h. You have to include IexErrnoExc.h
|
||||
// only if you want to catch specific subclasses of ErrnoExc.
|
||||
|
||||
|
||||
#endif
|
129
3rdparty/openexr/Iex/IexBaseExc.cpp
vendored
Normal file
129
3rdparty/openexr/Iex/IexBaseExc.cpp
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// Constructors and destructors for our exception base class.
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
namespace {
|
||||
|
||||
|
||||
StackTracer currentStackTracer = 0;
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void
|
||||
setStackTracer (StackTracer stackTracer)
|
||||
{
|
||||
currentStackTracer = stackTracer;
|
||||
}
|
||||
|
||||
|
||||
StackTracer
|
||||
stackTracer ()
|
||||
{
|
||||
return currentStackTracer;
|
||||
}
|
||||
|
||||
|
||||
BaseExc::BaseExc (const char* s) throw () :
|
||||
std::string (s? s: ""),
|
||||
_stackTrace (currentStackTracer? currentStackTracer(): "")
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
BaseExc::BaseExc (const std::string &s) throw () :
|
||||
std::string (s),
|
||||
_stackTrace (currentStackTracer? currentStackTracer(): "")
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
BaseExc::BaseExc (std::stringstream &s) throw () :
|
||||
std::string (s.str()),
|
||||
_stackTrace (currentStackTracer? currentStackTracer(): "")
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
BaseExc::BaseExc (const BaseExc &be) throw () :
|
||||
std::string (be),
|
||||
_stackTrace (be._stackTrace)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
BaseExc::~BaseExc () throw ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
BaseExc::what () const throw ()
|
||||
{
|
||||
return c_str();
|
||||
}
|
||||
|
||||
|
||||
BaseExc &
|
||||
BaseExc::assign (std::stringstream &s)
|
||||
{
|
||||
std::string::assign (s.str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
BaseExc &
|
||||
BaseExc::append (std::stringstream &s)
|
||||
{
|
||||
std::string::append (s.str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Iex
|
266
3rdparty/openexr/Iex/IexBaseExc.h
vendored
Normal file
266
3rdparty/openexr/Iex/IexBaseExc.h
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IEXBASEEXC_H
|
||||
#define INCLUDED_IEXBASEEXC_H
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
//
|
||||
// A general exception base class, and a few
|
||||
// useful exceptions derived from the base class.
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
#include <string>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
|
||||
namespace Iex {
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
// Tell MS VC++ to suppress exception specification warnings
|
||||
#pragma warning(disable:4290)
|
||||
#endif
|
||||
|
||||
//-------------------------------
|
||||
// Our most basic exception class
|
||||
//-------------------------------
|
||||
|
||||
class BaseExc: public std::string, public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------
|
||||
// Constructors and destructor
|
||||
//----------------------------
|
||||
|
||||
BaseExc (const char *s = 0) throw(); // std::string (s)
|
||||
BaseExc (const std::string &s) throw(); // std::string (s)
|
||||
BaseExc (std::stringstream &s) throw(); // std::string (s.str())
|
||||
|
||||
BaseExc (const BaseExc &be) throw();
|
||||
virtual ~BaseExc () throw ();
|
||||
|
||||
//--------------------------------------------
|
||||
// what() method -- e.what() returns e.c_str()
|
||||
//--------------------------------------------
|
||||
|
||||
virtual const char * what () const throw ();
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Convenient methods to change the exception's text
|
||||
//--------------------------------------------------
|
||||
|
||||
BaseExc & assign (std::stringstream &s); // assign (s.str())
|
||||
BaseExc & operator = (std::stringstream &s);
|
||||
|
||||
BaseExc & append (std::stringstream &s); // append (s.str())
|
||||
BaseExc & operator += (std::stringstream &s);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// These methods from the base class get obscured by
|
||||
// the definitions above.
|
||||
//--------------------------------------------------
|
||||
|
||||
BaseExc & assign (const char *s);
|
||||
BaseExc & operator = (const char *s);
|
||||
|
||||
BaseExc & append (const char *s);
|
||||
BaseExc & operator += (const char *s);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Stack trace for the point at which the exception
|
||||
// was thrown. The stack trace will be an empty
|
||||
// string unless a working stack-tracing routine
|
||||
// has been installed (see below, setStackTracer()).
|
||||
//--------------------------------------------------
|
||||
|
||||
const std::string & stackTrace () const;
|
||||
|
||||
private:
|
||||
|
||||
std::string _stackTrace;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// A macro to save typing when declararing an exception
|
||||
// class derived directly or indirectly from BaseExc:
|
||||
//-----------------------------------------------------
|
||||
|
||||
#define DEFINE_EXC(name, base) \
|
||||
class name: public base \
|
||||
{ \
|
||||
public: \
|
||||
name (const char* text=0) throw(): base (text) {} \
|
||||
name (const std::string &text) throw(): base (text) {} \
|
||||
name (std::stringstream &text) throw(): base (text) {} \
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Some exceptions which should be useful in most programs
|
||||
//--------------------------------------------------------
|
||||
|
||||
DEFINE_EXC (ArgExc, BaseExc) // Invalid arguments to a function call
|
||||
|
||||
DEFINE_EXC (LogicExc, BaseExc) // General error in a program's logic,
|
||||
// for example, a function was called
|
||||
// in a context where the call does
|
||||
// not make sense.
|
||||
|
||||
DEFINE_EXC (InputExc, BaseExc) // Invalid input data, e.g. from a file
|
||||
|
||||
DEFINE_EXC (IoExc, BaseExc) // Input or output operation failed
|
||||
|
||||
DEFINE_EXC (MathExc, BaseExc) // Arithmetic exception; more specific
|
||||
// exceptions derived from this class
|
||||
// are defined in ExcMath.h
|
||||
|
||||
DEFINE_EXC (ErrnoExc, BaseExc) // Base class for exceptions corresponding
|
||||
// to errno values (see errno.h); more
|
||||
// specific exceptions derived from this
|
||||
// class are defined in ExcErrno.h
|
||||
|
||||
DEFINE_EXC (NoImplExc, BaseExc) // Missing method exception e.g. from a
|
||||
// call to a method that is only partially
|
||||
// or not at all implemented. A reminder
|
||||
// to lazy software people to get back
|
||||
// to work.
|
||||
|
||||
DEFINE_EXC (NullExc, BaseExc) // A pointer is inappropriately null.
|
||||
|
||||
DEFINE_EXC (TypeExc, BaseExc) // An object is an inappropriate type,
|
||||
// i.e. a dynamnic_cast failed.
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Stack-tracing support:
|
||||
//
|
||||
// setStackTracer(st)
|
||||
//
|
||||
// installs a stack-tracing routine, st, which will be called from
|
||||
// class BaseExc's constructor every time an exception derived from
|
||||
// BaseExc is thrown. The stack-tracing routine should return a
|
||||
// string that contains a printable representation of the program's
|
||||
// current call stack. This string will be stored in the BaseExc
|
||||
// object; the string is accesible via the BaseExc::stackTrace()
|
||||
// method.
|
||||
//
|
||||
// setStackTracer(0)
|
||||
//
|
||||
// removes the current stack tracing routine. When an exception
|
||||
// derived from BaseExc is thrown, the stack trace string stored
|
||||
// in the BaseExc object will be empty.
|
||||
//
|
||||
// stackTracer()
|
||||
//
|
||||
// returns a pointer to the current stack-tracing routine, or 0
|
||||
// if there is no current stack stack-tracing routine.
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
typedef std::string (* StackTracer) ();
|
||||
|
||||
void setStackTracer (StackTracer stackTracer);
|
||||
StackTracer stackTracer ();
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline functions
|
||||
//-----------------
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator = (std::stringstream &s)
|
||||
{
|
||||
return assign (s);
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator += (std::stringstream &s)
|
||||
{
|
||||
return append (s);
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::assign (const char *s)
|
||||
{
|
||||
std::string::assign(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator = (const char *s)
|
||||
{
|
||||
return assign(s);
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::append (const char *s)
|
||||
{
|
||||
std::string::append(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline BaseExc &
|
||||
BaseExc::operator += (const char *s)
|
||||
{
|
||||
return append(s);
|
||||
}
|
||||
|
||||
|
||||
inline const std::string &
|
||||
BaseExc::stackTrace () const
|
||||
{
|
||||
return _stackTrace;
|
||||
}
|
||||
|
||||
#if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
|
||||
#pragma warning(default:4290)
|
||||
#endif
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
210
3rdparty/openexr/Iex/IexErrnoExc.h
vendored
Normal file
210
3rdparty/openexr/Iex/IexErrnoExc.h
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IEXERRNOEXC_H
|
||||
#define INCLUDED_IEXERRNOEXC_H
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//
|
||||
// Exceptions which correspond to "errno" error codes.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
|
||||
|
||||
DEFINE_EXC (EpermExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoentExc, ErrnoExc)
|
||||
DEFINE_EXC (EsrchExc, ErrnoExc)
|
||||
DEFINE_EXC (EintrExc, ErrnoExc)
|
||||
DEFINE_EXC (EioExc, ErrnoExc)
|
||||
DEFINE_EXC (EnxioExc, ErrnoExc)
|
||||
DEFINE_EXC (E2bigExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoexecExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadfExc, ErrnoExc)
|
||||
DEFINE_EXC (EchildExc, ErrnoExc)
|
||||
DEFINE_EXC (EagainExc, ErrnoExc)
|
||||
DEFINE_EXC (EnomemExc, ErrnoExc)
|
||||
DEFINE_EXC (EaccesExc, ErrnoExc)
|
||||
DEFINE_EXC (EfaultExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotblkExc, ErrnoExc)
|
||||
DEFINE_EXC (EbusyExc, ErrnoExc)
|
||||
DEFINE_EXC (EexistExc, ErrnoExc)
|
||||
DEFINE_EXC (ExdevExc, ErrnoExc)
|
||||
DEFINE_EXC (EnodevExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotdirExc, ErrnoExc)
|
||||
DEFINE_EXC (EisdirExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvalExc, ErrnoExc)
|
||||
DEFINE_EXC (EnfileExc, ErrnoExc)
|
||||
DEFINE_EXC (EmfileExc, ErrnoExc)
|
||||
DEFINE_EXC (EnottyExc, ErrnoExc)
|
||||
DEFINE_EXC (EtxtbsyExc, ErrnoExc)
|
||||
DEFINE_EXC (EfbigExc, ErrnoExc)
|
||||
DEFINE_EXC (EnospcExc, ErrnoExc)
|
||||
DEFINE_EXC (EspipeExc, ErrnoExc)
|
||||
DEFINE_EXC (ErofsExc, ErrnoExc)
|
||||
DEFINE_EXC (EmlinkExc, ErrnoExc)
|
||||
DEFINE_EXC (EpipeExc, ErrnoExc)
|
||||
DEFINE_EXC (EdomExc, ErrnoExc)
|
||||
DEFINE_EXC (ErangeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnomsgExc, ErrnoExc)
|
||||
DEFINE_EXC (EidrmExc, ErrnoExc)
|
||||
DEFINE_EXC (EchrngExc, ErrnoExc)
|
||||
DEFINE_EXC (El2nsyncExc, ErrnoExc)
|
||||
DEFINE_EXC (El3hltExc, ErrnoExc)
|
||||
DEFINE_EXC (El3rstExc, ErrnoExc)
|
||||
DEFINE_EXC (ElnrngExc, ErrnoExc)
|
||||
DEFINE_EXC (EunatchExc, ErrnoExc)
|
||||
DEFINE_EXC (EnocsiExc, ErrnoExc)
|
||||
DEFINE_EXC (El2hltExc, ErrnoExc)
|
||||
DEFINE_EXC (EdeadlkExc, ErrnoExc)
|
||||
DEFINE_EXC (EnolckExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadeExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadrExc, ErrnoExc)
|
||||
DEFINE_EXC (ExfullExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoanoExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadrqcExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadsltExc, ErrnoExc)
|
||||
DEFINE_EXC (EdeadlockExc, ErrnoExc)
|
||||
DEFINE_EXC (EbfontExc, ErrnoExc)
|
||||
DEFINE_EXC (EnostrExc, ErrnoExc)
|
||||
DEFINE_EXC (EnodataExc, ErrnoExc)
|
||||
DEFINE_EXC (EtimeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnosrExc, ErrnoExc)
|
||||
DEFINE_EXC (EnonetExc, ErrnoExc)
|
||||
DEFINE_EXC (EnopkgExc, ErrnoExc)
|
||||
DEFINE_EXC (EremoteExc, ErrnoExc)
|
||||
DEFINE_EXC (EnolinkExc, ErrnoExc)
|
||||
DEFINE_EXC (EadvExc, ErrnoExc)
|
||||
DEFINE_EXC (EsrmntExc, ErrnoExc)
|
||||
DEFINE_EXC (EcommExc, ErrnoExc)
|
||||
DEFINE_EXC (EprotoExc, ErrnoExc)
|
||||
DEFINE_EXC (EmultihopExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadmsgExc, ErrnoExc)
|
||||
DEFINE_EXC (EnametoolongExc, ErrnoExc)
|
||||
DEFINE_EXC (EoverflowExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotuniqExc, ErrnoExc)
|
||||
DEFINE_EXC (EbadfdExc, ErrnoExc)
|
||||
DEFINE_EXC (EremchgExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibaccExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibbadExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibscnExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibmaxExc, ErrnoExc)
|
||||
DEFINE_EXC (ElibexecExc, ErrnoExc)
|
||||
DEFINE_EXC (EilseqExc, ErrnoExc)
|
||||
DEFINE_EXC (EnosysExc, ErrnoExc)
|
||||
DEFINE_EXC (EloopExc, ErrnoExc)
|
||||
DEFINE_EXC (ErestartExc, ErrnoExc)
|
||||
DEFINE_EXC (EstrpipeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotemptyExc, ErrnoExc)
|
||||
DEFINE_EXC (EusersExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotsockExc, ErrnoExc)
|
||||
DEFINE_EXC (EdestaddrreqExc, ErrnoExc)
|
||||
DEFINE_EXC (EmsgsizeExc, ErrnoExc)
|
||||
DEFINE_EXC (EprototypeExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoprotooptExc, ErrnoExc)
|
||||
DEFINE_EXC (EprotonosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EsocktnosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EopnotsuppExc, ErrnoExc)
|
||||
DEFINE_EXC (EpfnosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EafnosupportExc, ErrnoExc)
|
||||
DEFINE_EXC (EaddrinuseExc, ErrnoExc)
|
||||
DEFINE_EXC (EaddrnotavailExc, ErrnoExc)
|
||||
DEFINE_EXC (EnetdownExc, ErrnoExc)
|
||||
DEFINE_EXC (EnetunreachExc, ErrnoExc)
|
||||
DEFINE_EXC (EnetresetExc, ErrnoExc)
|
||||
DEFINE_EXC (EconnabortedExc, ErrnoExc)
|
||||
DEFINE_EXC (EconnresetExc, ErrnoExc)
|
||||
DEFINE_EXC (EnobufsExc, ErrnoExc)
|
||||
DEFINE_EXC (EisconnExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotconnExc, ErrnoExc)
|
||||
DEFINE_EXC (EshutdownExc, ErrnoExc)
|
||||
DEFINE_EXC (EtoomanyrefsExc, ErrnoExc)
|
||||
DEFINE_EXC (EtimedoutExc, ErrnoExc)
|
||||
DEFINE_EXC (EconnrefusedExc, ErrnoExc)
|
||||
DEFINE_EXC (EhostdownExc, ErrnoExc)
|
||||
DEFINE_EXC (EhostunreachExc, ErrnoExc)
|
||||
DEFINE_EXC (EalreadyExc, ErrnoExc)
|
||||
DEFINE_EXC (EinprogressExc, ErrnoExc)
|
||||
DEFINE_EXC (EstaleExc, ErrnoExc)
|
||||
DEFINE_EXC (EioresidExc, ErrnoExc)
|
||||
DEFINE_EXC (EucleanExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotnamExc, ErrnoExc)
|
||||
DEFINE_EXC (EnavailExc, ErrnoExc)
|
||||
DEFINE_EXC (EisnamExc, ErrnoExc)
|
||||
DEFINE_EXC (EremoteioExc, ErrnoExc)
|
||||
DEFINE_EXC (EinitExc, ErrnoExc)
|
||||
DEFINE_EXC (EremdevExc, ErrnoExc)
|
||||
DEFINE_EXC (EcanceledExc, ErrnoExc)
|
||||
DEFINE_EXC (EnolimfileExc, ErrnoExc)
|
||||
DEFINE_EXC (EproclimExc, ErrnoExc)
|
||||
DEFINE_EXC (EdisjointExc, ErrnoExc)
|
||||
DEFINE_EXC (EnologinExc, ErrnoExc)
|
||||
DEFINE_EXC (EloginlimExc, ErrnoExc)
|
||||
DEFINE_EXC (EgrouploopExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoattachExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotsupExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoattrExc, ErrnoExc)
|
||||
DEFINE_EXC (EdircorruptedExc, ErrnoExc)
|
||||
DEFINE_EXC (EdquotExc, ErrnoExc)
|
||||
DEFINE_EXC (EnfsremoteExc, ErrnoExc)
|
||||
DEFINE_EXC (EcontrollerExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotcontrollerExc, ErrnoExc)
|
||||
DEFINE_EXC (EenqueuedExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotenqueuedExc, ErrnoExc)
|
||||
DEFINE_EXC (EjoinedExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotjoinedExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoprocExc, ErrnoExc)
|
||||
DEFINE_EXC (EmustrunExc, ErrnoExc)
|
||||
DEFINE_EXC (EnotstoppedExc, ErrnoExc)
|
||||
DEFINE_EXC (EclockcpuExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvalstateExc, ErrnoExc)
|
||||
DEFINE_EXC (EnoexistExc, ErrnoExc)
|
||||
DEFINE_EXC (EendofminorExc, ErrnoExc)
|
||||
DEFINE_EXC (EbufsizeExc, ErrnoExc)
|
||||
DEFINE_EXC (EemptyExc, ErrnoExc)
|
||||
DEFINE_EXC (EnointrgroupExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvalmodeExc, ErrnoExc)
|
||||
DEFINE_EXC (EcantextentExc, ErrnoExc)
|
||||
DEFINE_EXC (EinvaltimeExc, ErrnoExc)
|
||||
DEFINE_EXC (EdestroyedExc, ErrnoExc)
|
||||
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
148
3rdparty/openexr/Iex/IexMacros.h
vendored
Normal file
148
3rdparty/openexr/Iex/IexMacros.h
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IEXMACROS_H
|
||||
#define INCLUDED_IEXMACROS_H
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//
|
||||
// Macros which make throwing exceptions more convenient
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// A macro to throw exceptions whose text is assembled using stringstreams.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// THROW (InputExc, "Syntax error in line " << line ", " << file << ".");
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define THROW(type, text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
throw type (s); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Macros to add to or to replace the text of an exception.
|
||||
// The new text is assembled using stringstreams.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// Append to end of an exception's text:
|
||||
//
|
||||
// catch (BaseExc &e)
|
||||
// {
|
||||
// APPEND_EXC (e, " Directory " << name << " does not exist.");
|
||||
// throw;
|
||||
// }
|
||||
//
|
||||
// Replace an exception's text:
|
||||
//
|
||||
// catch (BaseExc &e)
|
||||
// {
|
||||
// REPLACE_EXC (e, "Directory " << name << " does not exist. " << e);
|
||||
// throw;
|
||||
// }
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define APPEND_EXC(exc, text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
exc.append (s); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
#define REPLACE_EXC(exc, text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
exc.assign (s); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// A macro to throw ErrnoExc exceptions whose text is assembled
|
||||
// using stringstreams:
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// THROW_ERRNO ("Cannot open file " << name << " (%T).");
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#define THROW_ERRNO(text) \
|
||||
do \
|
||||
{ \
|
||||
std::stringstream s; \
|
||||
s << text; \
|
||||
::Iex::throwErrnoExc (s.str()); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// A macro to throw exceptions if an assertion is false.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// ASSERT (ptr != NULL, NullExc, "Null pointer" );
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
|
||||
#define ASSERT(assertion, type, text) \
|
||||
do \
|
||||
{ \
|
||||
if ((assertion) == false) \
|
||||
THROW (type, text); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
||||
#endif
|
58
3rdparty/openexr/Iex/IexMathExc.h
vendored
Normal file
58
3rdparty/openexr/Iex/IexMathExc.h
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IEXMATHEXC_H
|
||||
#define INCLUDED_IEXMATHEXC_H
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Exception classess which correspond to specific floating
|
||||
// point exceptions.
|
||||
//---------------------------------------------------------
|
||||
|
||||
DEFINE_EXC (OverflowExc, MathExc) // Overflow
|
||||
DEFINE_EXC (UnderflowExc, MathExc) // Underflow
|
||||
DEFINE_EXC (DivzeroExc, MathExc) // Division by zero
|
||||
DEFINE_EXC (InexactExc, MathExc) // Inexact result
|
||||
DEFINE_EXC (InvalidFpOpExc, MathExc) // Invalid operation
|
||||
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
859
3rdparty/openexr/Iex/IexThrowErrnoExc.cpp
vendored
Normal file
859
3rdparty/openexr/Iex/IexThrowErrnoExc.cpp
vendored
Normal file
@ -0,0 +1,859 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
//
|
||||
// Exceptions that correspond to "errno" error codes,
|
||||
// and a function to make throwing those exceptions easy.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#include "IexThrowErrnoExc.h"
|
||||
#include "IexErrnoExc.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
namespace Iex {
|
||||
|
||||
|
||||
void throwErrnoExc (const std::string &text, int errnum)
|
||||
{
|
||||
const char *entext = strerror (errnum);
|
||||
std::string tmp (text);
|
||||
std::string::size_type pos;
|
||||
|
||||
while (std::string::npos != (pos = tmp.find ("%T")))
|
||||
tmp.replace (pos, 2, entext, strlen (entext));
|
||||
|
||||
switch (errnum)
|
||||
{
|
||||
#if defined (EPERM)
|
||||
case EPERM:
|
||||
throw EpermExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOENT)
|
||||
case ENOENT:
|
||||
throw EnoentExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESRCH)
|
||||
case ESRCH:
|
||||
throw EsrchExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINTR)
|
||||
case EINTR:
|
||||
throw EintrExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EIO)
|
||||
case EIO:
|
||||
throw EioExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENXIO)
|
||||
case ENXIO:
|
||||
throw EnxioExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (E2BIG)
|
||||
case E2BIG:
|
||||
throw E2bigExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOEXEC)
|
||||
case ENOEXEC:
|
||||
throw EnoexecExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADF)
|
||||
case EBADF:
|
||||
throw EbadfExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECHILD)
|
||||
case ECHILD:
|
||||
throw EchildExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EAGAIN)
|
||||
case EAGAIN:
|
||||
throw EagainExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOMEM)
|
||||
case ENOMEM:
|
||||
throw EnomemExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EACCES)
|
||||
case EACCES:
|
||||
throw EaccesExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EFAULT)
|
||||
case EFAULT:
|
||||
throw EfaultExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTBLK)
|
||||
case ENOTBLK:
|
||||
throw EnotblkExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBUSY)
|
||||
case EBUSY:
|
||||
throw EbusyExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EEXIST)
|
||||
case EEXIST:
|
||||
throw EexistExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EXDEV)
|
||||
case EXDEV:
|
||||
throw ExdevExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENODEV)
|
||||
case ENODEV:
|
||||
throw EnodevExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTDIR)
|
||||
case ENOTDIR:
|
||||
throw EnotdirExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EISDIR)
|
||||
case EISDIR:
|
||||
throw EisdirExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINVAL)
|
||||
case EINVAL:
|
||||
throw EinvalExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENFILE)
|
||||
case ENFILE:
|
||||
throw EnfileExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EMFILE)
|
||||
case EMFILE:
|
||||
throw EmfileExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTTY)
|
||||
case ENOTTY:
|
||||
throw EnottyExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ETXTBSY)
|
||||
case ETXTBSY:
|
||||
throw EtxtbsyExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EFBIG)
|
||||
case EFBIG:
|
||||
throw EfbigExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOSPC)
|
||||
case ENOSPC:
|
||||
throw EnospcExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESPIPE)
|
||||
case ESPIPE:
|
||||
throw EspipeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EROFS)
|
||||
case EROFS:
|
||||
throw ErofsExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EMLINK)
|
||||
case EMLINK:
|
||||
throw EmlinkExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EPIPE)
|
||||
case EPIPE:
|
||||
throw EpipeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDOM)
|
||||
case EDOM:
|
||||
throw EdomExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ERANGE)
|
||||
case ERANGE:
|
||||
throw ErangeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOMSG)
|
||||
case ENOMSG:
|
||||
throw EnomsgExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EIDRM)
|
||||
case EIDRM:
|
||||
throw EidrmExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECHRNG)
|
||||
case ECHRNG:
|
||||
throw EchrngExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EL2NSYNC)
|
||||
case EL2NSYNC:
|
||||
throw El2nsyncExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EL3HLT)
|
||||
case EL3HLT:
|
||||
throw El3hltExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EL3RST)
|
||||
case EL3RST:
|
||||
throw El3rstExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELNRNG)
|
||||
case ELNRNG:
|
||||
throw ElnrngExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EUNATCH)
|
||||
case EUNATCH:
|
||||
throw EunatchExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOSCI)
|
||||
case ENOCSI:
|
||||
throw EnocsiExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EL2HLT)
|
||||
case EL2HLT:
|
||||
throw El2hltExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDEADLK)
|
||||
case EDEADLK:
|
||||
throw EdeadlkExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOLCK)
|
||||
case ENOLCK:
|
||||
throw EnolckExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADE)
|
||||
case EBADE:
|
||||
throw EbadeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADR)
|
||||
case EBADR:
|
||||
throw EbadrExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EXFULL)
|
||||
case EXFULL:
|
||||
throw ExfullExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOANO)
|
||||
case ENOANO:
|
||||
throw EnoanoExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADRQC)
|
||||
case EBADRQC:
|
||||
throw EbadrqcExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADSLT)
|
||||
case EBADSLT:
|
||||
throw EbadsltExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDEADLOCK) && defined (EDEADLK)
|
||||
#if EDEADLOCK != EDEADLK
|
||||
case EDEADLOCK:
|
||||
throw EdeadlockExc (tmp);
|
||||
#endif
|
||||
#elif defined (EDEADLOCK)
|
||||
case EDEADLOCK:
|
||||
throw EdeadlockExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBFONT)
|
||||
case EBFONT:
|
||||
throw EbfontExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOSTR)
|
||||
case ENOSTR:
|
||||
throw EnostrExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENODATA)
|
||||
case ENODATA:
|
||||
throw EnodataExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ETIME)
|
||||
case ETIME:
|
||||
throw EtimeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOSR)
|
||||
case ENOSR:
|
||||
throw EnosrExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENONET)
|
||||
case ENONET:
|
||||
throw EnonetExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOPKG)
|
||||
case ENOPKG:
|
||||
throw EnopkgExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EREMOTE)
|
||||
case EREMOTE:
|
||||
throw EremoteExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOLINK)
|
||||
case ENOLINK:
|
||||
throw EnolinkExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EADV)
|
||||
case EADV:
|
||||
throw EadvExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESRMNT)
|
||||
case ESRMNT:
|
||||
throw EsrmntExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECOMM)
|
||||
case ECOMM:
|
||||
throw EcommExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EPROTO)
|
||||
case EPROTO:
|
||||
throw EprotoExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EMULTIHOP)
|
||||
case EMULTIHOP:
|
||||
throw EmultihopExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADMSG)
|
||||
case EBADMSG:
|
||||
throw EbadmsgExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENAMETOOLONG)
|
||||
case ENAMETOOLONG:
|
||||
throw EnametoolongExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EOVERFLOW)
|
||||
case EOVERFLOW:
|
||||
throw EoverflowExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTUNIQ)
|
||||
case ENOTUNIQ:
|
||||
throw EnotuniqExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBADFD)
|
||||
case EBADFD:
|
||||
throw EbadfdExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EREMCHG)
|
||||
case EREMCHG:
|
||||
throw EremchgExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELIBACC)
|
||||
case ELIBACC:
|
||||
throw ElibaccExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELIBBAD)
|
||||
case ELIBBAD:
|
||||
throw ElibbadExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELIBSCN)
|
||||
case ELIBSCN:
|
||||
throw ElibscnExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELIBMAX)
|
||||
case ELIBMAX:
|
||||
throw ElibmaxExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELIBEXEC)
|
||||
case ELIBEXEC:
|
||||
throw ElibexecExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EILSEQ)
|
||||
case EILSEQ:
|
||||
throw EilseqExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOSYS)
|
||||
case ENOSYS:
|
||||
throw EnosysExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELOOP)
|
||||
case ELOOP:
|
||||
throw EloopExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ERESTART)
|
||||
case ERESTART:
|
||||
throw ErestartExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESTRPIPE)
|
||||
case ESTRPIPE:
|
||||
throw EstrpipeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTEMPTY)
|
||||
case ENOTEMPTY:
|
||||
throw EnotemptyExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EUSERS)
|
||||
case EUSERS:
|
||||
throw EusersExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTSOCK)
|
||||
case ENOTSOCK:
|
||||
throw EnotsockExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDESTADDRREQ)
|
||||
case EDESTADDRREQ:
|
||||
throw EdestaddrreqExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EMSGSIZE)
|
||||
case EMSGSIZE:
|
||||
throw EmsgsizeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EPROTOTYPE)
|
||||
case EPROTOTYPE:
|
||||
throw EprototypeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOPROTOOPT)
|
||||
case ENOPROTOOPT:
|
||||
throw EnoprotooptExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EPROTONOSUPPORT)
|
||||
case EPROTONOSUPPORT:
|
||||
throw EprotonosupportExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESOCKTNOSUPPORT)
|
||||
case ESOCKTNOSUPPORT:
|
||||
throw EsocktnosupportExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EOPNOTSUPP)
|
||||
case EOPNOTSUPP:
|
||||
throw EopnotsuppExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EPFNOSUPPORT)
|
||||
case EPFNOSUPPORT:
|
||||
throw EpfnosupportExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EAFNOSUPPORT)
|
||||
case EAFNOSUPPORT:
|
||||
throw EafnosupportExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EADDRINUSE)
|
||||
case EADDRINUSE:
|
||||
throw EaddrinuseExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EADDRNOTAVAIL)
|
||||
case EADDRNOTAVAIL:
|
||||
throw EaddrnotavailExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENETDOWN)
|
||||
case ENETDOWN:
|
||||
throw EnetdownExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENETUNREACH)
|
||||
case ENETUNREACH:
|
||||
throw EnetunreachExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENETRESET)
|
||||
case ENETRESET:
|
||||
throw EnetresetExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECONNABORTED)
|
||||
case ECONNABORTED:
|
||||
throw EconnabortedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECONNRESET)
|
||||
case ECONNRESET:
|
||||
throw EconnresetExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOBUFS)
|
||||
case ENOBUFS:
|
||||
throw EnobufsExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EISCONN)
|
||||
case EISCONN:
|
||||
throw EisconnExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTCONN)
|
||||
case ENOTCONN:
|
||||
throw EnotconnExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESHUTDOWN)
|
||||
case ESHUTDOWN:
|
||||
throw EshutdownExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ETOOMANYREFS)
|
||||
case ETOOMANYREFS:
|
||||
throw EtoomanyrefsExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ETIMEDOUT)
|
||||
case ETIMEDOUT:
|
||||
throw EtimedoutExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECONNREFUSED)
|
||||
case ECONNREFUSED:
|
||||
throw EconnrefusedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EHOSTDOWN)
|
||||
case EHOSTDOWN:
|
||||
throw EhostdownExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EHOSTUNREACH)
|
||||
case EHOSTUNREACH:
|
||||
throw EhostunreachExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EALREADY)
|
||||
case EALREADY:
|
||||
throw EalreadyExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINPROGRESS)
|
||||
case EINPROGRESS:
|
||||
throw EinprogressExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ESTALE)
|
||||
case ESTALE:
|
||||
throw EstaleExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EIORESID)
|
||||
case EIORESID:
|
||||
throw EioresidExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EUCLEAN)
|
||||
case EUCLEAN:
|
||||
throw EucleanExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTNAM)
|
||||
case ENOTNAM:
|
||||
throw EnotnamExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENAVAIL)
|
||||
case ENAVAIL:
|
||||
throw EnavailExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EISNAM)
|
||||
case EISNAM:
|
||||
throw EisnamExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EREMOTEIO)
|
||||
case EREMOTEIO:
|
||||
throw EremoteioExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINIT)
|
||||
case EINIT:
|
||||
throw EinitExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EREMDEV)
|
||||
case EREMDEV:
|
||||
throw EremdevExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECANCELED)
|
||||
case ECANCELED:
|
||||
throw EcanceledExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOLIMFILE)
|
||||
case ENOLIMFILE:
|
||||
throw EnolimfileExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EPROCLIM)
|
||||
case EPROCLIM:
|
||||
throw EproclimExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDISJOINT)
|
||||
case EDISJOINT:
|
||||
throw EdisjointExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOLOGIN)
|
||||
case ENOLOGIN:
|
||||
throw EnologinExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ELOGINLIM)
|
||||
case ELOGINLIM:
|
||||
throw EloginlimExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EGROUPLOOP)
|
||||
case EGROUPLOOP:
|
||||
throw EgrouploopExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOATTACH)
|
||||
case ENOATTACH:
|
||||
throw EnoattachExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTSUP) && defined (EOPNOTSUPP)
|
||||
#if ENOTSUP != EOPNOTSUPP
|
||||
case ENOTSUP:
|
||||
throw EnotsupExc (tmp);
|
||||
#endif
|
||||
#elif defined (ENOTSUP)
|
||||
case ENOTSUP:
|
||||
throw EnotsupExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOATTR)
|
||||
case ENOATTR:
|
||||
throw EnoattrExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDIRCORRUPTED)
|
||||
case EDIRCORRUPTED:
|
||||
throw EdircorruptedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDQUOT)
|
||||
case EDQUOT:
|
||||
throw EdquotExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENFSREMOTE)
|
||||
case ENFSREMOTE:
|
||||
throw EnfsremoteExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECONTROLLER)
|
||||
case ECONTROLLER:
|
||||
throw EcontrollerExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTCONTROLLER)
|
||||
case ENOTCONTROLLER:
|
||||
throw EnotcontrollerExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EENQUEUED)
|
||||
case EENQUEUED:
|
||||
throw EenqueuedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTENQUEUED)
|
||||
case ENOTENQUEUED:
|
||||
throw EnotenqueuedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EJOINED)
|
||||
case EJOINED:
|
||||
throw EjoinedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTJOINED)
|
||||
case ENOTJOINED:
|
||||
throw EnotjoinedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOPROC)
|
||||
case ENOPROC:
|
||||
throw EnoprocExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EMUSTRUN)
|
||||
case EMUSTRUN:
|
||||
throw EmustrunExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOTSTOPPED)
|
||||
case ENOTSTOPPED:
|
||||
throw EnotstoppedExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECLOCKCPU)
|
||||
case ECLOCKCPU:
|
||||
throw EclockcpuExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINVALSTATE)
|
||||
case EINVALSTATE:
|
||||
throw EinvalstateExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOEXIST)
|
||||
case ENOEXIST:
|
||||
throw EnoexistExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EENDOFMINOR)
|
||||
case EENDOFMINOR:
|
||||
throw EendofminorExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EBUFSIZE)
|
||||
case EBUFSIZE:
|
||||
throw EbufsizeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EEMPTY)
|
||||
case EEMPTY:
|
||||
throw EemptyExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ENOINTRGROUP)
|
||||
case ENOINTRGROUP:
|
||||
throw EnointrgroupExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINVALMODE)
|
||||
case EINVALMODE:
|
||||
throw EinvalmodeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (ECANTEXTENT)
|
||||
case ECANTEXTENT:
|
||||
throw EcantextentExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EINVALTIME)
|
||||
case EINVALTIME:
|
||||
throw EinvaltimeExc (tmp);
|
||||
#endif
|
||||
|
||||
#if defined (EDESTROYED)
|
||||
case EDESTROYED:
|
||||
throw EdestroyedExc (tmp);
|
||||
#endif
|
||||
}
|
||||
|
||||
throw ErrnoExc (tmp);
|
||||
}
|
||||
|
||||
|
||||
void throwErrnoExc (const std::string &text)
|
||||
{
|
||||
throwErrnoExc (text, errno);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Iex
|
96
3rdparty/openexr/Iex/IexThrowErrnoExc.h
vendored
Normal file
96
3rdparty/openexr/Iex/IexThrowErrnoExc.h
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IEXTHROWERRNOEXC_H
|
||||
#define INCLUDED_IEXTHROWERRNOEXC_H
|
||||
|
||||
//----------------------------------------------------------
|
||||
//
|
||||
// A function which throws ExcErrno exceptions
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
|
||||
namespace Iex {
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
// Function throwErrnoExc() throws an exception which corresponds to
|
||||
// error code errnum. The exception text is initialized with a copy
|
||||
// of the string passed to throwErrnoExc(), where all occurrences of
|
||||
// "%T" have been replaced with the output of strerror(oserror()).
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// If opening file /tmp/output failed with an ENOENT error code,
|
||||
// calling
|
||||
//
|
||||
// throwErrnoExc ();
|
||||
//
|
||||
// or
|
||||
//
|
||||
// throwErrnoExc ("%T.");
|
||||
//
|
||||
// will throw an EnoentExc whose text reads
|
||||
//
|
||||
// No such file or directory.
|
||||
//
|
||||
// More detailed messages can be assembled using stringstreams:
|
||||
//
|
||||
// std::stringstream s;
|
||||
// s << "Cannot open file " << name << " (%T).";
|
||||
// throwErrnoExc (s);
|
||||
//
|
||||
// The resulting exception contains the following text:
|
||||
//
|
||||
// Cannot open file /tmp/output (No such file or directory).
|
||||
//
|
||||
// Alternatively, you may want to use the THROW_ERRNO macro defined
|
||||
// in IexMacros.h:
|
||||
//
|
||||
// THROW_ERRNO ("Cannot open file " << name << " (%T).")
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void throwErrnoExc (const std::string &txt, int errnum);
|
||||
void throwErrnoExc (const std::string &txt = "%T." /*, int errnum = oserror() */);
|
||||
|
||||
|
||||
} // namespace Iex
|
||||
|
||||
#endif
|
30
3rdparty/openexr/IlmBaseConfig.h.cmakein
vendored
Normal file
30
3rdparty/openexr/IlmBaseConfig.h.cmakein
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Define and set to 1 if the target system has POSIX thread support
|
||||
// and you want IlmBase to use it for multithreaded file I/O.
|
||||
//
|
||||
|
||||
#cmakedefine01 HAVE_PTHREAD
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system supports POSIX semaphores
|
||||
// and you want OpenEXR to use them; otherwise, OpenEXR will use its
|
||||
// own semaphore implementation.
|
||||
//
|
||||
|
||||
#cmakedefine01 HAVE_POSIX_SEMAPHORES
|
||||
|
||||
#undef HAVE_UCONTEXT_H
|
||||
|
||||
//
|
||||
// Define and set to 1 if the target system has support for large
|
||||
// stack sizes.
|
||||
//
|
||||
|
||||
#undef ILMBASE_HAVE_LARGE_STACK
|
||||
|
||||
|
||||
//
|
||||
// Version string for runtime access
|
||||
//
|
||||
#define ILMBASE_VERSION_STRING "1.0.3"
|
||||
#define ILMBASE_PACKAGE_STRING "IlmBase 1.0.3"
|
631
3rdparty/openexr/IlmImf/ImfAcesFile.cpp
vendored
Normal file
631
3rdparty/openexr/IlmImf/ImfAcesFile.cpp
vendored
Normal file
@ -0,0 +1,631 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ACES image file I/O.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAcesFile.h>
|
||||
#include <ImfRgbaFile.h>
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <Iex.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Imath;
|
||||
using namespace Iex;
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
const Chromaticities &
|
||||
acesChromaticities ()
|
||||
{
|
||||
static const Chromaticities acesChr
|
||||
(V2f (0.73470, 0.26530), // red
|
||||
V2f (0.00000, 1.00000), // green
|
||||
V2f (0.00010, -0.07700), // blue
|
||||
V2f (0.32168, 0.33767)); // white
|
||||
|
||||
return acesChr;
|
||||
}
|
||||
|
||||
|
||||
class AcesOutputFile::Data
|
||||
{
|
||||
public:
|
||||
|
||||
Data();
|
||||
~Data();
|
||||
|
||||
RgbaOutputFile * rgbaFile;
|
||||
};
|
||||
|
||||
|
||||
AcesOutputFile::Data::Data ():
|
||||
rgbaFile (0)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
AcesOutputFile::Data::~Data ()
|
||||
{
|
||||
delete rgbaFile;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
checkCompression (Compression compression)
|
||||
{
|
||||
//
|
||||
// Not all compression methods are allowed in ACES files.
|
||||
//
|
||||
|
||||
switch (compression)
|
||||
{
|
||||
case NO_COMPRESSION:
|
||||
case PIZ_COMPRESSION:
|
||||
case B44A_COMPRESSION:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ArgExc ("Invalid compression type for ACES file.");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
AcesOutputFile::AcesOutputFile
|
||||
(const std::string &name,
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels,
|
||||
int numThreads)
|
||||
:
|
||||
_data (new Data)
|
||||
{
|
||||
checkCompression (header.compression());
|
||||
|
||||
Header newHeader = header;
|
||||
addChromaticities (newHeader, acesChromaticities());
|
||||
addAdoptedNeutral (newHeader, acesChromaticities().white);
|
||||
|
||||
_data->rgbaFile = new RgbaOutputFile (name.c_str(),
|
||||
newHeader,
|
||||
rgbaChannels,
|
||||
numThreads);
|
||||
|
||||
_data->rgbaFile->setYCRounding (7, 6);
|
||||
}
|
||||
|
||||
|
||||
AcesOutputFile::AcesOutputFile
|
||||
(OStream &os,
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels,
|
||||
int numThreads)
|
||||
:
|
||||
_data (new Data)
|
||||
{
|
||||
checkCompression (header.compression());
|
||||
|
||||
Header newHeader = header;
|
||||
addChromaticities (newHeader, acesChromaticities());
|
||||
addAdoptedNeutral (newHeader, acesChromaticities().white);
|
||||
|
||||
_data->rgbaFile = new RgbaOutputFile (os,
|
||||
header,
|
||||
rgbaChannels,
|
||||
numThreads);
|
||||
|
||||
_data->rgbaFile->setYCRounding (7, 6);
|
||||
}
|
||||
|
||||
|
||||
AcesOutputFile::AcesOutputFile
|
||||
(const std::string &name,
|
||||
const Imath::Box2i &displayWindow,
|
||||
const Imath::Box2i &dataWindow,
|
||||
RgbaChannels rgbaChannels,
|
||||
float pixelAspectRatio,
|
||||
const Imath::V2f screenWindowCenter,
|
||||
float screenWindowWidth,
|
||||
LineOrder lineOrder,
|
||||
Compression compression,
|
||||
int numThreads)
|
||||
:
|
||||
_data (new Data)
|
||||
{
|
||||
checkCompression (compression);
|
||||
|
||||
Header newHeader (displayWindow,
|
||||
dataWindow.isEmpty()? displayWindow: dataWindow,
|
||||
pixelAspectRatio,
|
||||
screenWindowCenter,
|
||||
screenWindowWidth,
|
||||
lineOrder,
|
||||
compression);
|
||||
|
||||
addChromaticities (newHeader, acesChromaticities());
|
||||
addAdoptedNeutral (newHeader, acesChromaticities().white);
|
||||
|
||||
_data->rgbaFile = new RgbaOutputFile (name.c_str(),
|
||||
newHeader,
|
||||
rgbaChannels,
|
||||
numThreads);
|
||||
|
||||
_data->rgbaFile->setYCRounding (7, 6);
|
||||
}
|
||||
|
||||
|
||||
AcesOutputFile::AcesOutputFile
|
||||
(const std::string &name,
|
||||
int width,
|
||||
int height,
|
||||
RgbaChannels rgbaChannels,
|
||||
float pixelAspectRatio,
|
||||
const Imath::V2f screenWindowCenter,
|
||||
float screenWindowWidth,
|
||||
LineOrder lineOrder,
|
||||
Compression compression,
|
||||
int numThreads)
|
||||
:
|
||||
_data (new Data)
|
||||
{
|
||||
checkCompression (compression);
|
||||
|
||||
Header newHeader (width,
|
||||
height,
|
||||
pixelAspectRatio,
|
||||
screenWindowCenter,
|
||||
screenWindowWidth,
|
||||
lineOrder,
|
||||
compression);
|
||||
|
||||
addChromaticities (newHeader, acesChromaticities());
|
||||
addAdoptedNeutral (newHeader, acesChromaticities().white);
|
||||
|
||||
_data->rgbaFile = new RgbaOutputFile (name.c_str(),
|
||||
newHeader,
|
||||
rgbaChannels,
|
||||
numThreads);
|
||||
|
||||
_data->rgbaFile->setYCRounding (7, 6);
|
||||
}
|
||||
|
||||
|
||||
AcesOutputFile::~AcesOutputFile ()
|
||||
{
|
||||
delete _data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesOutputFile::setFrameBuffer
|
||||
(const Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride)
|
||||
{
|
||||
_data->rgbaFile->setFrameBuffer (base, xStride, yStride);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesOutputFile::writePixels (int numScanLines)
|
||||
{
|
||||
_data->rgbaFile->writePixels (numScanLines);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AcesOutputFile::currentScanLine () const
|
||||
{
|
||||
return _data->rgbaFile->currentScanLine();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
AcesOutputFile::header () const
|
||||
{
|
||||
return _data->rgbaFile->header();
|
||||
}
|
||||
|
||||
|
||||
const Imath::Box2i &
|
||||
AcesOutputFile::displayWindow () const
|
||||
{
|
||||
return _data->rgbaFile->displayWindow();
|
||||
}
|
||||
|
||||
|
||||
const Imath::Box2i &
|
||||
AcesOutputFile::dataWindow () const
|
||||
{
|
||||
return _data->rgbaFile->dataWindow();
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
AcesOutputFile::pixelAspectRatio () const
|
||||
{
|
||||
return _data->rgbaFile->pixelAspectRatio();
|
||||
}
|
||||
|
||||
|
||||
const Imath::V2f
|
||||
AcesOutputFile::screenWindowCenter () const
|
||||
{
|
||||
return _data->rgbaFile->screenWindowCenter();
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
AcesOutputFile::screenWindowWidth () const
|
||||
{
|
||||
return _data->rgbaFile->screenWindowWidth();
|
||||
}
|
||||
|
||||
|
||||
LineOrder
|
||||
AcesOutputFile::lineOrder () const
|
||||
{
|
||||
return _data->rgbaFile->lineOrder();
|
||||
}
|
||||
|
||||
|
||||
Compression
|
||||
AcesOutputFile::compression () const
|
||||
{
|
||||
return _data->rgbaFile->compression();
|
||||
}
|
||||
|
||||
|
||||
RgbaChannels
|
||||
AcesOutputFile::channels () const
|
||||
{
|
||||
return _data->rgbaFile->channels();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesOutputFile::updatePreviewImage (const PreviewRgba pixels[])
|
||||
{
|
||||
_data->rgbaFile->updatePreviewImage (pixels);
|
||||
}
|
||||
|
||||
|
||||
class AcesInputFile::Data
|
||||
{
|
||||
public:
|
||||
|
||||
Data();
|
||||
~Data();
|
||||
|
||||
void initColorConversion ();
|
||||
|
||||
RgbaInputFile * rgbaFile;
|
||||
|
||||
Rgba * fbBase;
|
||||
size_t fbXStride;
|
||||
size_t fbYStride;
|
||||
int minX;
|
||||
int maxX;
|
||||
|
||||
bool mustConvertColor;
|
||||
M44f fileToAces;
|
||||
};
|
||||
|
||||
|
||||
AcesInputFile::Data::Data ():
|
||||
rgbaFile (0),
|
||||
fbBase (0),
|
||||
fbXStride (0),
|
||||
fbYStride (0),
|
||||
minX (0),
|
||||
maxX (0),
|
||||
mustConvertColor (false)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
AcesInputFile::Data::~Data ()
|
||||
{
|
||||
delete rgbaFile;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesInputFile::Data::initColorConversion ()
|
||||
{
|
||||
const Header &header = rgbaFile->header();
|
||||
|
||||
Chromaticities fileChr;
|
||||
|
||||
if (hasChromaticities (header))
|
||||
fileChr = chromaticities (header);
|
||||
|
||||
V2f fileNeutral = fileChr.white;
|
||||
|
||||
if (hasAdoptedNeutral (header))
|
||||
fileNeutral = adoptedNeutral (header);
|
||||
|
||||
const Chromaticities acesChr = acesChromaticities();
|
||||
|
||||
V2f acesNeutral = acesChr.white;
|
||||
|
||||
if (fileChr.red == acesChr.red &&
|
||||
fileChr.green == acesChr.green &&
|
||||
fileChr.blue == acesChr.blue &&
|
||||
fileChr.white == acesChr.white &&
|
||||
fileNeutral == acesNeutral)
|
||||
{
|
||||
//
|
||||
// The file already contains ACES data,
|
||||
// color conversion is not necessary.
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mustConvertColor = true;
|
||||
minX = header.dataWindow().min.x;
|
||||
maxX = header.dataWindow().max.x;
|
||||
|
||||
//
|
||||
// Create a matrix that transforms colors from the
|
||||
// RGB space of the input file into the ACES space
|
||||
// using a color adaptation transform to move the
|
||||
// white point.
|
||||
//
|
||||
|
||||
//
|
||||
// We'll need the Bradford cone primary matrix and its inverse
|
||||
//
|
||||
|
||||
static const M44f bradfordCPM
|
||||
(0.895100, -0.750200, 0.038900, 0.000000,
|
||||
0.266400, 1.713500, -0.068500, 0.000000,
|
||||
-0.161400, 0.036700, 1.029600, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 1.000000);
|
||||
|
||||
const static M44f inverseBradfordCPM
|
||||
(0.986993, 0.432305, -0.008529, 0.000000,
|
||||
-0.147054, 0.518360, 0.040043, 0.000000,
|
||||
0.159963, 0.049291, 0.968487, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 1.000000);
|
||||
|
||||
//
|
||||
// Convert the white points of the two RGB spaces to XYZ
|
||||
//
|
||||
|
||||
float fx = fileNeutral.x;
|
||||
float fy = fileNeutral.y;
|
||||
V3f fileNeutralXYZ (fx / fy, 1, (1 - fx - fy) / fy);
|
||||
|
||||
float ax = acesNeutral.x;
|
||||
float ay = acesNeutral.y;
|
||||
V3f acesNeutralXYZ (ax / ay, 1, (1 - ax - ay) / ay);
|
||||
|
||||
//
|
||||
// Compute the Bradford transformation matrix
|
||||
//
|
||||
|
||||
V3f ratio ((acesNeutralXYZ * bradfordCPM) /
|
||||
(fileNeutralXYZ * bradfordCPM));
|
||||
|
||||
M44f ratioMat (ratio[0], 0, 0, 0,
|
||||
0, ratio[1], 0, 0,
|
||||
0, 0, ratio[2], 0,
|
||||
0, 0, 0, 1);
|
||||
|
||||
M44f bradfordTrans = bradfordCPM *
|
||||
ratioMat *
|
||||
inverseBradfordCPM;
|
||||
|
||||
//
|
||||
// Build a combined file-RGB-to-ACES-RGB conversion matrix
|
||||
//
|
||||
|
||||
fileToAces = RGBtoXYZ (fileChr, 1) * bradfordTrans * XYZtoRGB (acesChr, 1);
|
||||
}
|
||||
|
||||
|
||||
AcesInputFile::AcesInputFile (const std::string &name, int numThreads):
|
||||
_data (new Data)
|
||||
{
|
||||
_data->rgbaFile = new RgbaInputFile (name.c_str(), numThreads);
|
||||
_data->initColorConversion();
|
||||
}
|
||||
|
||||
|
||||
AcesInputFile::AcesInputFile (IStream &is, int numThreads):
|
||||
_data (new Data)
|
||||
{
|
||||
_data->rgbaFile = new RgbaInputFile (is, numThreads);
|
||||
_data->initColorConversion();
|
||||
}
|
||||
|
||||
|
||||
AcesInputFile::~AcesInputFile ()
|
||||
{
|
||||
delete _data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesInputFile::setFrameBuffer (Rgba *base, size_t xStride, size_t yStride)
|
||||
{
|
||||
_data->rgbaFile->setFrameBuffer (base, xStride, yStride);
|
||||
_data->fbBase = base;
|
||||
_data->fbXStride = xStride;
|
||||
_data->fbYStride = yStride;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesInputFile::readPixels (int scanLine1, int scanLine2)
|
||||
{
|
||||
//
|
||||
// Copy the pixels from the RgbaInputFile into the frame buffer.
|
||||
//
|
||||
|
||||
_data->rgbaFile->readPixels (scanLine1, scanLine2);
|
||||
|
||||
//
|
||||
// If the RGB space of the input file is not the same as the ACES
|
||||
// RGB space, then the pixels in the frame buffer must be transformed
|
||||
// into the ACES RGB space.
|
||||
//
|
||||
|
||||
if (!_data->mustConvertColor)
|
||||
return;
|
||||
|
||||
int minY = min (scanLine1, scanLine2);
|
||||
int maxY = max (scanLine1, scanLine2);
|
||||
|
||||
for (int y = minY; y <= maxY; ++y)
|
||||
{
|
||||
Rgba *base = _data->fbBase +
|
||||
_data->fbXStride * _data->minX +
|
||||
_data->fbYStride * y;
|
||||
|
||||
for (int x = _data->minX; x <= _data->maxX; ++x)
|
||||
{
|
||||
V3f aces = V3f (base->r, base->g, base->b) * _data->fileToAces;
|
||||
|
||||
base->r = aces[0];
|
||||
base->g = aces[1];
|
||||
base->b = aces[2];
|
||||
|
||||
base += _data->fbXStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AcesInputFile::readPixels (int scanLine)
|
||||
{
|
||||
readPixels (scanLine, scanLine);
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
AcesInputFile::header () const
|
||||
{
|
||||
return _data->rgbaFile->header();
|
||||
}
|
||||
|
||||
|
||||
const Imath::Box2i &
|
||||
AcesInputFile::displayWindow () const
|
||||
{
|
||||
return _data->rgbaFile->displayWindow();
|
||||
}
|
||||
|
||||
|
||||
const Imath::Box2i &
|
||||
AcesInputFile::dataWindow () const
|
||||
{
|
||||
return _data->rgbaFile->dataWindow();
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
AcesInputFile::pixelAspectRatio () const
|
||||
{
|
||||
return _data->rgbaFile->pixelAspectRatio();
|
||||
}
|
||||
|
||||
|
||||
const Imath::V2f
|
||||
AcesInputFile::screenWindowCenter () const
|
||||
{
|
||||
return _data->rgbaFile->screenWindowCenter();
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
AcesInputFile::screenWindowWidth () const
|
||||
{
|
||||
return _data->rgbaFile->screenWindowWidth();
|
||||
}
|
||||
|
||||
|
||||
LineOrder
|
||||
AcesInputFile::lineOrder () const
|
||||
{
|
||||
return _data->rgbaFile->lineOrder();
|
||||
}
|
||||
|
||||
|
||||
Compression
|
||||
AcesInputFile::compression () const
|
||||
{
|
||||
return _data->rgbaFile->compression();
|
||||
}
|
||||
|
||||
|
||||
RgbaChannels
|
||||
AcesInputFile::channels () const
|
||||
{
|
||||
return _data->rgbaFile->channels();
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
AcesInputFile::fileName () const
|
||||
{
|
||||
return _data->rgbaFile->fileName();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
AcesInputFile::isComplete () const
|
||||
{
|
||||
return _data->rgbaFile->isComplete();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
AcesInputFile::version () const
|
||||
{
|
||||
return _data->rgbaFile->version();
|
||||
}
|
||||
|
||||
} // namespace Imf
|
322
3rdparty/openexr/IlmImf/ImfAcesFile.h
vendored
Normal file
322
3rdparty/openexr/IlmImf/ImfAcesFile.h
vendored
Normal file
@ -0,0 +1,322 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IMF_ACES_FILE_H
|
||||
#define INCLUDED_IMF_ACES_FILE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ACES image file I/O.
|
||||
//
|
||||
// This header file declares two classes that directly support
|
||||
// image file input and output according to the Academy Image
|
||||
// Interchange Framework.
|
||||
//
|
||||
// The Academy Image Interchange file format is a subset of OpenEXR:
|
||||
//
|
||||
// - Images are stored as scanlines. Tiles are not allowed.
|
||||
//
|
||||
// - Images contain three color channels, either
|
||||
// R, G, B (red, green, blue) or
|
||||
// Y, RY, BY (luminance, sub-sampled chroma)
|
||||
//
|
||||
// - Images may optionally contain an alpha channel.
|
||||
//
|
||||
// - Only three compression types are allowed:
|
||||
// - NO_COMPRESSION (file is not compressed)
|
||||
// - PIZ_COMPRESSION (lossless)
|
||||
// - B44A_COMPRESSION (lossy)
|
||||
//
|
||||
// - The "chromaticities" header attribute must specify
|
||||
// the ACES RGB primaries and white point.
|
||||
//
|
||||
// class AcesOutputFile writes an OpenEXR file, enforcing the
|
||||
// restrictions listed above. Pixel data supplied by application
|
||||
// software must already be in the ACES RGB space.
|
||||
//
|
||||
// class AcesInputFile reads an OpenEXR file. Pixel data delivered
|
||||
// to application software is guaranteed to be in the ACES RGB space.
|
||||
// If the RGB space of the file is not the same as the ACES space,
|
||||
// then the pixels are automatically converted: the pixels are
|
||||
// converted to CIE XYZ, a color adaptation transform shifts the
|
||||
// white point, and the result is converted to ACES RGB.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfRgba.h>
|
||||
#include "ImathVec.h"
|
||||
#include "ImathBox.h"
|
||||
#include <ImfThreading.h>
|
||||
#include <string>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class RgbaOutputFile;
|
||||
class RgbaInputFile;
|
||||
struct PreviewRgba;
|
||||
class Chromaticities;
|
||||
|
||||
//
|
||||
// ACES red, green, blue and white-point chromaticities.
|
||||
//
|
||||
|
||||
const Chromaticities & acesChromaticities ();
|
||||
|
||||
|
||||
//
|
||||
// ACES output file.
|
||||
//
|
||||
|
||||
class AcesOutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------------------------------------
|
||||
// Constructor -- header is constructed by the caller
|
||||
//---------------------------------------------------
|
||||
|
||||
AcesOutputFile (const std::string &name,
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Constructor -- header is constructed by the caller,
|
||||
// file is opened by the caller, destructor will not
|
||||
// automatically close the file.
|
||||
//----------------------------------------------------
|
||||
|
||||
AcesOutputFile (OStream &os,
|
||||
const Header &header,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Constructor -- header data are explicitly specified as function
|
||||
// call arguments (empty dataWindow means "same as displayWindow")
|
||||
//----------------------------------------------------------------
|
||||
|
||||
AcesOutputFile (const std::string &name,
|
||||
const Imath::Box2i &displayWindow,
|
||||
const Imath::Box2i &dataWindow = Imath::Box2i(),
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression compression = PIZ_COMPRESSION,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Constructor -- like the previous one, but both
|
||||
// the display window and the data window are
|
||||
// Box2i (V2i (0, 0), V2i (width - 1, height -1))
|
||||
//-----------------------------------------------
|
||||
|
||||
AcesOutputFile (const std::string &name,
|
||||
int width,
|
||||
int height,
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression compression = PIZ_COMPRESSION,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~AcesOutputFile ();
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// Define a frame buffer as the pixel data source:
|
||||
// Pixel (x, y) is at address
|
||||
//
|
||||
// base + x * xStride + y * yStride
|
||||
//
|
||||
//------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Write pixel data (see class Imf::OutputFile)
|
||||
// The pixels are assumed to contain ACES RGB data.
|
||||
//-------------------------------------------------
|
||||
|
||||
void writePixels (int numScanLines = 1);
|
||||
int currentScanLine () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const Imath::V2f screenWindowCenter () const;
|
||||
float screenWindowWidth () const;
|
||||
LineOrder lineOrder () const;
|
||||
Compression compression () const;
|
||||
RgbaChannels channels () const;
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Update the preview image (see Imf::OutputFile::updatePreviewImage())
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba[]);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
AcesOutputFile (const AcesOutputFile &); // not implemented
|
||||
AcesOutputFile & operator = (const AcesOutputFile &); // not implemented
|
||||
|
||||
class Data;
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ACES input file
|
||||
//
|
||||
|
||||
class AcesInputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Constructor -- opens the file with the specified name,
|
||||
// destructor will automatically close the file.
|
||||
//-------------------------------------------------------
|
||||
|
||||
AcesInputFile (const std::string &name,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Constructor -- attaches the new AcesInputFile object to a
|
||||
// file that has already been opened by the caller.
|
||||
// Destroying the AcesInputFile object will not automatically
|
||||
// close the file.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
AcesInputFile (IStream &is,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~AcesInputFile ();
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Define a frame buffer as the pixel data destination:
|
||||
// Pixel (x, y) is at address
|
||||
//
|
||||
// base + x * xStride + y * yStride
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
|
||||
void setFrameBuffer (Rgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Read pixel data (see class Imf::InputFile)
|
||||
// Pixels returned will contain ACES RGB data.
|
||||
//--------------------------------------------
|
||||
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const Imath::V2f screenWindowCenter () const;
|
||||
float screenWindowWidth () const;
|
||||
LineOrder lineOrder () const;
|
||||
Compression compression () const;
|
||||
RgbaChannels channels () const;
|
||||
const char * fileName () const;
|
||||
bool isComplete () const;
|
||||
|
||||
|
||||
//----------------------------------
|
||||
// Access to the file format version
|
||||
//----------------------------------
|
||||
|
||||
int version () const;
|
||||
|
||||
private:
|
||||
|
||||
AcesInputFile (const AcesInputFile &); // not implemented
|
||||
AcesInputFile & operator = (const AcesInputFile &); // not implemented
|
||||
|
||||
class Data;
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
261
3rdparty/openexr/IlmImf/ImfArray.h
vendored
Normal file
261
3rdparty/openexr/IlmImf/ImfArray.h
vendored
Normal file
@ -0,0 +1,261 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef INCLUDED_IMF_ARRAY_H
|
||||
#define INCLUDED_IMF_ARRAY_H
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// class Array
|
||||
// class Array2D
|
||||
//
|
||||
// "Arrays of T" whose sizes are not known at compile time.
|
||||
// When an array goes out of scope, its elements are automatically
|
||||
// deleted.
|
||||
//
|
||||
// Usage example:
|
||||
//
|
||||
// struct C
|
||||
// {
|
||||
// C () {std::cout << "C::C (" << this << ")\n";};
|
||||
// virtual ~C () {std::cout << "C::~C (" << this << ")\n";};
|
||||
// };
|
||||
//
|
||||
// int
|
||||
// main ()
|
||||
// {
|
||||
// Array <C> a(3);
|
||||
//
|
||||
// C &b = a[1];
|
||||
// const C &c = a[1];
|
||||
// C *d = a + 2;
|
||||
// const C *e = a;
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------
|
||||
// Constructors and destructors
|
||||
//-----------------------------
|
||||
|
||||
Array () {_data = 0;}
|
||||
Array (long size) {_data = new T[size];}
|
||||
~Array () {delete [] _data;}
|
||||
|
||||
|
||||
//-----------------------------
|
||||
// Access to the array elements
|
||||
//-----------------------------
|
||||
|
||||
operator T * () {return _data;}
|
||||
operator const T * () const {return _data;}
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Resize and clear the array (the contents of the array
|
||||
// are not preserved across the resize operation).
|
||||
//
|
||||
// resizeEraseUnsafe() is more memory efficient than
|
||||
// resizeErase() because it deletes the old memory block
|
||||
// before allocating a new one, but if allocating the
|
||||
// new block throws an exception, resizeEraseUnsafe()
|
||||
// leaves the array in an unusable state.
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
void resizeErase (long size);
|
||||
void resizeEraseUnsafe (long size);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array (const Array &); // Copying and assignment
|
||||
Array & operator = (const Array &); // are not implemented
|
||||
|
||||
T * _data;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class Array2D
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------
|
||||
// Constructors and destructors
|
||||
//-----------------------------
|
||||
|
||||
Array2D (); // empty array, 0 by 0 elements
|
||||
Array2D (long sizeX, long sizeY); // sizeX by sizeY elements
|
||||
~Array2D ();
|
||||
|
||||
|
||||
//-----------------------------
|
||||
// Access to the array elements
|
||||
//-----------------------------
|
||||
|
||||
T * operator [] (long x);
|
||||
const T * operator [] (long x) const;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Resize and clear the array (the contents of the array
|
||||
// are not preserved across the resize operation).
|
||||
//
|
||||
// resizeEraseUnsafe() is more memory efficient than
|
||||
// resizeErase() because it deletes the old memory block
|
||||
// before allocating a new one, but if allocating the
|
||||
// new block throws an exception, resizeEraseUnsafe()
|
||||
// leaves the array in an unusable state.
|
||||
//
|
||||
//------------------------------------------------------
|
||||
|
||||
void resizeErase (long sizeX, long sizeY);
|
||||
void resizeEraseUnsafe (long sizeX, long sizeY);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array2D (const Array2D &); // Copying and assignment
|
||||
Array2D & operator = (const Array2D &); // are not implemented
|
||||
|
||||
long _sizeY;
|
||||
T * _data;
|
||||
};
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array<T>::resizeErase (long size)
|
||||
{
|
||||
T *tmp = new T[size];
|
||||
delete [] _data;
|
||||
_data = tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array<T>::resizeEraseUnsafe (long size)
|
||||
{
|
||||
delete [] _data;
|
||||
_data = 0;
|
||||
_data = new T[size];
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::Array2D ():
|
||||
_sizeY (0), _data (0)
|
||||
{
|
||||
// emtpy
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::Array2D (long sizeX, long sizeY):
|
||||
_sizeY (sizeY), _data (new T[sizeX * sizeY])
|
||||
{
|
||||
// emtpy
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::~Array2D ()
|
||||
{
|
||||
delete [] _data;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T *
|
||||
Array2D<T>::operator [] (long x)
|
||||
{
|
||||
return _data + x * _sizeY;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T *
|
||||
Array2D<T>::operator [] (long x) const
|
||||
{
|
||||
return _data + x * _sizeY;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array2D<T>::resizeErase (long sizeX, long sizeY)
|
||||
{
|
||||
T *tmp = new T[sizeX * sizeY];
|
||||
delete [] _data;
|
||||
_sizeY = sizeY;
|
||||
_data = tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array2D<T>::resizeEraseUnsafe (long sizeX, long sizeY)
|
||||
{
|
||||
delete [] _data;
|
||||
_data = 0;
|
||||
_sizeY = 0;
|
||||
_data = new T[sizeX * sizeY];
|
||||
_sizeY = sizeY;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
156
3rdparty/openexr/IlmImf/ImfAttribute.cpp
vendored
Normal file
156
3rdparty/openexr/IlmImf/ImfAttribute.cpp
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Attribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include "IlmThreadMutex.h"
|
||||
#include "Iex.h"
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
using IlmThread::Mutex;
|
||||
using IlmThread::Lock;
|
||||
|
||||
|
||||
Attribute::Attribute () {}
|
||||
|
||||
|
||||
Attribute::~Attribute () {}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
struct NameCompare: std::binary_function <const char *, const char *, bool>
|
||||
{
|
||||
bool
|
||||
operator () (const char *x, const char *y) const
|
||||
{
|
||||
return strcmp (x, y) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef Attribute* (*Constructor)();
|
||||
typedef std::map <const char *, Constructor, NameCompare> TypeMap;
|
||||
|
||||
|
||||
class LockedTypeMap: public TypeMap
|
||||
{
|
||||
public:
|
||||
|
||||
Mutex mutex;
|
||||
};
|
||||
|
||||
|
||||
LockedTypeMap &
|
||||
typeMap ()
|
||||
{
|
||||
static Mutex criticalSection;
|
||||
Lock lock (criticalSection);
|
||||
|
||||
static LockedTypeMap* typeMap = 0;
|
||||
|
||||
if (typeMap == 0)
|
||||
typeMap = new LockedTypeMap ();
|
||||
|
||||
return *typeMap;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
bool
|
||||
Attribute::knownType (const char typeName[])
|
||||
{
|
||||
LockedTypeMap& tMap = typeMap();
|
||||
Lock lock (tMap.mutex);
|
||||
|
||||
return tMap.find (typeName) != tMap.end();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Attribute::registerAttributeType (const char typeName[],
|
||||
Attribute *(*newAttribute)())
|
||||
{
|
||||
LockedTypeMap& tMap = typeMap();
|
||||
Lock lock (tMap.mutex);
|
||||
|
||||
if (tMap.find (typeName) != tMap.end())
|
||||
THROW (Iex::ArgExc, "Cannot register image file attribute "
|
||||
"type \"" << typeName << "\". "
|
||||
"The type has already been registered.");
|
||||
|
||||
tMap.insert (TypeMap::value_type (typeName, newAttribute));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Attribute::unRegisterAttributeType (const char typeName[])
|
||||
{
|
||||
LockedTypeMap& tMap = typeMap();
|
||||
Lock lock (tMap.mutex);
|
||||
|
||||
tMap.erase (typeName);
|
||||
}
|
||||
|
||||
|
||||
Attribute *
|
||||
Attribute::newAttribute (const char typeName[])
|
||||
{
|
||||
LockedTypeMap& tMap = typeMap();
|
||||
Lock lock (tMap.mutex);
|
||||
|
||||
TypeMap::const_iterator i = tMap.find (typeName);
|
||||
|
||||
if (i == tMap.end())
|
||||
THROW (Iex::ArgExc, "Cannot create image file attribute of "
|
||||
"unknown type \"" << typeName << "\".");
|
||||
|
||||
return (i->second)();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
427
3rdparty/openexr/IlmImf/ImfAttribute.h
vendored
Normal file
427
3rdparty/openexr/IlmImf/ImfAttribute.h
vendored
Normal file
@ -0,0 +1,427 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Attribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "IexBaseExc.h"
|
||||
#include <ImfIO.h>
|
||||
#include <ImfXdr.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------------
|
||||
// Constructor and destructor
|
||||
//---------------------------
|
||||
|
||||
Attribute ();
|
||||
virtual ~Attribute ();
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Get this attribute's type name
|
||||
//-------------------------------
|
||||
|
||||
virtual const char * typeName () const = 0;
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Make a copy of this attribute
|
||||
//------------------------------
|
||||
|
||||
virtual Attribute * copy () const = 0;
|
||||
|
||||
|
||||
//----------------------------------------
|
||||
// Type-specific attribute I/O and copying
|
||||
//----------------------------------------
|
||||
|
||||
virtual void writeValueTo (OStream &os,
|
||||
int version) const = 0;
|
||||
|
||||
virtual void readValueFrom (IStream &is,
|
||||
int size,
|
||||
int version) = 0;
|
||||
|
||||
virtual void copyValueFrom (const Attribute &other) = 0;
|
||||
|
||||
|
||||
//------------------
|
||||
// Attribute factory
|
||||
//------------------
|
||||
|
||||
static Attribute * newAttribute (const char typeName[]);
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Test if a given attribute type has already been registered
|
||||
//-----------------------------------------------------------
|
||||
|
||||
static bool knownType (const char typeName[]);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------
|
||||
// Register an attribute type so that newAttribute()
|
||||
// knows how to make objects of this type.
|
||||
//--------------------------------------------------
|
||||
|
||||
static void registerAttributeType (const char typeName[],
|
||||
Attribute *(*newAttribute)());
|
||||
|
||||
//------------------------------------------------------
|
||||
// Un-register an attribute type so that newAttribute()
|
||||
// no longer knows how to make objects of this type (for
|
||||
// debugging only).
|
||||
//------------------------------------------------------
|
||||
|
||||
static void unRegisterAttributeType (const char typeName[]);
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Class template for attributes of a specific type
|
||||
//-------------------------------------------------
|
||||
|
||||
template <class T>
|
||||
class TypedAttribute: public Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------
|
||||
// Constructors and destructor
|
||||
//------------_---------------
|
||||
|
||||
TypedAttribute ();
|
||||
TypedAttribute (const T &value);
|
||||
TypedAttribute (const TypedAttribute<T> &other);
|
||||
virtual ~TypedAttribute ();
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Access to the attribute's value
|
||||
//--------------------------------
|
||||
|
||||
T & value ();
|
||||
const T & value () const;
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Get this attribute's type name.
|
||||
//--------------------------------
|
||||
|
||||
virtual const char * typeName () const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Static version of typeName()
|
||||
// This function must be specialized for each value type T.
|
||||
//---------------------------------------------------------
|
||||
|
||||
static const char * staticTypeName ();
|
||||
|
||||
|
||||
//---------------------
|
||||
// Make a new attribute
|
||||
//---------------------
|
||||
|
||||
static Attribute * makeNewAttribute ();
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Make a copy of this attribute
|
||||
//------------------------------
|
||||
|
||||
virtual Attribute * copy () const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Type-specific attribute I/O and copying.
|
||||
// Depending on type T, these functions may have to be specialized.
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
virtual void writeValueTo (OStream &os,
|
||||
int version) const;
|
||||
|
||||
virtual void readValueFrom (IStream &is,
|
||||
int size,
|
||||
int version);
|
||||
|
||||
virtual void copyValueFrom (const Attribute &other);
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Dynamic casts that throw exceptions instead of returning 0.
|
||||
//------------------------------------------------------------
|
||||
|
||||
static TypedAttribute * cast (Attribute *attribute);
|
||||
static const TypedAttribute * cast (const Attribute *attribute);
|
||||
static TypedAttribute & cast (Attribute &attribute);
|
||||
static const TypedAttribute & cast (const Attribute &attribute);
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Register this attribute type so that Attribute::newAttribute()
|
||||
// knows how to make objects of this type.
|
||||
//
|
||||
// Note that this function is not thread-safe because it modifies
|
||||
// a global variable in the IlmIlm library. A thread in a multi-
|
||||
// threaded program may call registerAttributeType() only when no
|
||||
// other thread is accessing any functions or classes in the
|
||||
// IlmImf library.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
static void registerAttributeType ();
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Un-register this attribute type (for debugging only)
|
||||
//-----------------------------------------------------
|
||||
|
||||
static void unRegisterAttributeType ();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
T _value;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------
|
||||
// Implementation of TypedAttribute<T>
|
||||
//------------------------------------
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::TypedAttribute ():
|
||||
Attribute (),
|
||||
_value (T())
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::TypedAttribute (const T &value):
|
||||
Attribute (),
|
||||
_value (value)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::TypedAttribute (const TypedAttribute<T> &other):
|
||||
Attribute (other),
|
||||
_value ()
|
||||
{
|
||||
copyValueFrom (other);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T>::~TypedAttribute ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T &
|
||||
TypedAttribute<T>::value ()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T &
|
||||
TypedAttribute<T>::value () const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const char *
|
||||
TypedAttribute<T>::typeName () const
|
||||
{
|
||||
return staticTypeName();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Attribute *
|
||||
TypedAttribute<T>::makeNewAttribute ()
|
||||
{
|
||||
return new TypedAttribute<T>();
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
Attribute *
|
||||
TypedAttribute<T>::copy () const
|
||||
{
|
||||
Attribute * attribute = new TypedAttribute<T>();
|
||||
attribute->copyValueFrom (*this);
|
||||
return attribute;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::copyValueFrom (const Attribute &other)
|
||||
{
|
||||
_value = cast(other)._value;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedAttribute<T> *
|
||||
TypedAttribute<T>::cast (Attribute *attribute)
|
||||
{
|
||||
TypedAttribute<T> *t =
|
||||
dynamic_cast <TypedAttribute<T> *> (attribute);
|
||||
|
||||
if (t == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const TypedAttribute<T> *
|
||||
TypedAttribute<T>::cast (const Attribute *attribute)
|
||||
{
|
||||
const TypedAttribute<T> *t =
|
||||
dynamic_cast <const TypedAttribute<T> *> (attribute);
|
||||
|
||||
if (t == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline TypedAttribute<T> &
|
||||
TypedAttribute<T>::cast (Attribute &attribute)
|
||||
{
|
||||
return *cast (&attribute);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const TypedAttribute<T> &
|
||||
TypedAttribute<T>::cast (const Attribute &attribute)
|
||||
{
|
||||
return *cast (&attribute);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
TypedAttribute<T>::registerAttributeType ()
|
||||
{
|
||||
Attribute::registerAttributeType (staticTypeName(), makeNewAttribute);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
TypedAttribute<T>::unRegisterAttributeType ()
|
||||
{
|
||||
Attribute::unRegisterAttributeType (staticTypeName());
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#if defined(OPENEXR_DLL) && defined(_MSC_VER)
|
||||
// Tell MS VC++ to disable "non dll-interface class used as base
|
||||
// for dll-interface class" and "no suitable definition provided
|
||||
// for explicit template"
|
||||
#pragma warning (disable : 4275 4661)
|
||||
|
||||
#if defined (ILMIMF_EXPORTS)
|
||||
#define IMF_EXPIMP_TEMPLATE
|
||||
#else
|
||||
#define IMF_EXPIMP_TEMPLATE extern
|
||||
#endif
|
||||
|
||||
IMF_EXPIMP_TEMPLATE template class Imf::TypedAttribute<float>;
|
||||
IMF_EXPIMP_TEMPLATE template class Imf::TypedAttribute<double>;
|
||||
|
||||
#pragma warning(default : 4251)
|
||||
#undef EXTERN_TEMPLATE
|
||||
#endif
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
93
3rdparty/openexr/IlmImf/ImfAutoArray.h
vendored
Normal file
93
3rdparty/openexr/IlmImf/ImfAutoArray.h
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_AUTO_ARRAY_H
|
||||
#define INCLUDED_IMF_AUTO_ARRAY_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class AutoArray -- a workaround for systems with
|
||||
// insufficient stack space for large auto arrays.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "OpenEXRConfig.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
#if !defined (HAVE_LARGE_STACK)
|
||||
|
||||
|
||||
template <class T, int size>
|
||||
class AutoArray
|
||||
{
|
||||
public:
|
||||
|
||||
AutoArray (): _data (new T [size]) { memset(_data, 0, size*sizeof(T)); }
|
||||
~AutoArray () {delete [] _data;}
|
||||
|
||||
operator T * () {return _data;}
|
||||
operator const T * () const {return _data;}
|
||||
|
||||
private:
|
||||
|
||||
T *_data;
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
template <class T, int size>
|
||||
class AutoArray
|
||||
{
|
||||
public:
|
||||
|
||||
operator T * () {return _data;}
|
||||
operator const T * () const {return _data;}
|
||||
|
||||
private:
|
||||
|
||||
T _data[size];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
1069
3rdparty/openexr/IlmImf/ImfB44Compressor.cpp
vendored
Normal file
1069
3rdparty/openexr/IlmImf/ImfB44Compressor.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
117
3rdparty/openexr/IlmImf/ImfB44Compressor.h
vendored
Normal file
117
3rdparty/openexr/IlmImf/ImfB44Compressor.h
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006, 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_B44_COMPRESSOR_H
|
||||
#define INCLUDED_IMF_B44_COMPRESSOR_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class B44Compressor -- lossy compression of 4x4 pixel blocks
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfCompressor.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class ChannelList;
|
||||
|
||||
|
||||
class B44Compressor: public Compressor
|
||||
{
|
||||
public:
|
||||
|
||||
B44Compressor (const Header &hdr,
|
||||
size_t maxScanLineSize,
|
||||
size_t numScanLines,
|
||||
bool optFlatFields);
|
||||
|
||||
virtual ~B44Compressor ();
|
||||
|
||||
virtual int numScanLines () const;
|
||||
|
||||
virtual Format format () const;
|
||||
|
||||
virtual int compress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr);
|
||||
|
||||
virtual int compressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
virtual int uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr);
|
||||
|
||||
virtual int uncompressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
private:
|
||||
|
||||
struct ChannelData;
|
||||
|
||||
int compress (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
int uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
int _maxScanLineSize;
|
||||
bool _optFlatFields;
|
||||
Format _format;
|
||||
int _numScanLines;
|
||||
unsigned short * _tmpBuffer;
|
||||
char * _outBuffer;
|
||||
int _numChans;
|
||||
const ChannelList & _channels;
|
||||
ChannelData * _channelData;
|
||||
int _minX;
|
||||
int _maxX;
|
||||
int _maxY;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
110
3rdparty/openexr/IlmImf/ImfBoxAttribute.cpp
vendored
Normal file
110
3rdparty/openexr/IlmImf/ImfBoxAttribute.cpp
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 Box2iAttribute
|
||||
// class Box2fAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfBoxAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
Box2iAttribute::staticTypeName ()
|
||||
{
|
||||
return "box2i";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
Box2iAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value.min.x);
|
||||
Xdr::write <StreamIO> (os, _value.min.y);
|
||||
Xdr::write <StreamIO> (os, _value.max.x);
|
||||
Xdr::write <StreamIO> (os, _value.max.y);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
Box2iAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value.min.x);
|
||||
Xdr::read <StreamIO> (is, _value.min.y);
|
||||
Xdr::read <StreamIO> (is, _value.max.x);
|
||||
Xdr::read <StreamIO> (is, _value.max.y);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
Box2fAttribute::staticTypeName ()
|
||||
{
|
||||
return "box2f";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
Box2fAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value.min.x);
|
||||
Xdr::write <StreamIO> (os, _value.min.y);
|
||||
Xdr::write <StreamIO> (os, _value.max.x);
|
||||
Xdr::write <StreamIO> (os, _value.max.y);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
Box2fAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value.min.x);
|
||||
Xdr::read <StreamIO> (is, _value.min.y);
|
||||
Xdr::read <StreamIO> (is, _value.max.x);
|
||||
Xdr::read <StreamIO> (is, _value.max.y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
73
3rdparty/openexr/IlmImf/ImfBoxAttribute.h
vendored
Normal file
73
3rdparty/openexr/IlmImf/ImfBoxAttribute.h
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_BOX_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_BOX_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Box2iAttribute
|
||||
// class Box2fAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include "ImathBox.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::Box2i> Box2iAttribute;
|
||||
template <> const char *Box2iAttribute::staticTypeName ();
|
||||
template <> void Box2iAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void Box2iAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::Box2f> Box2fAttribute;
|
||||
template <> const char *Box2fAttribute::staticTypeName ();
|
||||
template <> void Box2fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void Box2fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfBoxAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
1434
3rdparty/openexr/IlmImf/ImfCRgbaFile.cpp
vendored
Normal file
1434
3rdparty/openexr/IlmImf/ImfCRgbaFile.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
467
3rdparty/openexr/IlmImf/ImfCRgbaFile.h
vendored
Normal file
467
3rdparty/openexr/IlmImf/ImfCRgbaFile.h
vendored
Normal file
@ -0,0 +1,467 @@
|
||||
/*
|
||||
|
||||
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_C_RGBA_FILE_H
|
||||
#define INCLUDED_IMF_C_RGBA_FILE_H
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Interpreting unsigned shorts as 16-bit floating point numbers
|
||||
*/
|
||||
|
||||
typedef unsigned short ImfHalf;
|
||||
|
||||
void ImfFloatToHalf (float f,
|
||||
ImfHalf *h);
|
||||
|
||||
void ImfFloatToHalfArray (int n,
|
||||
const float f[/*n*/],
|
||||
ImfHalf h[/*n*/]);
|
||||
|
||||
float ImfHalfToFloat (ImfHalf h);
|
||||
|
||||
void ImfHalfToFloatArray (int n,
|
||||
const ImfHalf h[/*n*/],
|
||||
float f[/*n*/]);
|
||||
|
||||
/*
|
||||
** RGBA pixel; memory layout must be the same as struct Imf::Rgba.
|
||||
*/
|
||||
|
||||
struct ImfRgba
|
||||
{
|
||||
ImfHalf r;
|
||||
ImfHalf g;
|
||||
ImfHalf b;
|
||||
ImfHalf a;
|
||||
};
|
||||
|
||||
typedef struct ImfRgba ImfRgba;
|
||||
|
||||
/*
|
||||
** Magic number; this must be the same as Imf::MAGIC
|
||||
*/
|
||||
|
||||
#define IMF_MAGIC 20000630
|
||||
|
||||
/*
|
||||
** Version number; this must be the same as Imf::EXR_VERSION
|
||||
*/
|
||||
|
||||
#define IMF_VERSION_NUMBER 2
|
||||
|
||||
/*
|
||||
** Line order; values must the the same as in Imf::LineOrder.
|
||||
*/
|
||||
|
||||
#define IMF_INCREASING_Y 0
|
||||
#define IMF_DECREASING_Y 1
|
||||
#define IMF_RAMDOM_Y 2
|
||||
|
||||
|
||||
/*
|
||||
** Compression types; values must be the same as in Imf::Compression.
|
||||
*/
|
||||
|
||||
#define IMF_NO_COMPRESSION 0
|
||||
#define IMF_RLE_COMPRESSION 1
|
||||
#define IMF_ZIPS_COMPRESSION 2
|
||||
#define IMF_ZIP_COMPRESSION 3
|
||||
#define IMF_PIZ_COMPRESSION 4
|
||||
#define IMF_PXR24_COMPRESSION 5
|
||||
#define IMF_B44_COMPRESSION 6
|
||||
#define IMF_B44A_COMPRESSION 7
|
||||
|
||||
|
||||
/*
|
||||
** Channels; values must be the same as in Imf::RgbaChannels.
|
||||
*/
|
||||
|
||||
#define IMF_WRITE_R 0x01
|
||||
#define IMF_WRITE_G 0x02
|
||||
#define IMF_WRITE_B 0x04
|
||||
#define IMF_WRITE_A 0x08
|
||||
#define IMF_WRITE_Y 0x10
|
||||
#define IMF_WRITE_C 0x20
|
||||
#define IMF_WRITE_RGB 0x07
|
||||
#define IMF_WRITE_RGBA 0x0f
|
||||
#define IMF_WRITE_YC 0x30
|
||||
#define IMF_WRITE_YA 0x18
|
||||
#define IMF_WRITE_YCA 0x38
|
||||
|
||||
|
||||
/*
|
||||
** Level modes; values must be the same as in Imf::LevelMode
|
||||
*/
|
||||
|
||||
#define IMF_ONE_LEVEL 0
|
||||
#define IMF_MIPMAP_LEVELS 1
|
||||
#define IMF_RIPMAP_LEVELS 2
|
||||
|
||||
|
||||
/*
|
||||
** Level rounding modes; values must be the same as in Imf::LevelRoundingMode
|
||||
*/
|
||||
|
||||
#define IMF_ROUND_DOWN 0
|
||||
#define IMF_ROUND_UP 1
|
||||
|
||||
|
||||
/*
|
||||
** RGBA file header
|
||||
*/
|
||||
|
||||
struct ImfHeader;
|
||||
typedef struct ImfHeader ImfHeader;
|
||||
|
||||
ImfHeader * ImfNewHeader (void);
|
||||
|
||||
void ImfDeleteHeader (ImfHeader *hdr);
|
||||
|
||||
ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetDisplayWindow (ImfHeader *hdr,
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
void ImfHeaderDisplayWindow (const ImfHeader *hdr,
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
void ImfHeaderSetDataWindow (ImfHeader *hdr,
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
void ImfHeaderDataWindow (const ImfHeader *hdr,
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
|
||||
float pixelAspectRatio);
|
||||
|
||||
float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
|
||||
float x, float y);
|
||||
|
||||
void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
|
||||
float *x, float *y);
|
||||
|
||||
void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
|
||||
float width);
|
||||
|
||||
float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetLineOrder (ImfHeader *hdr,
|
||||
int lineOrder);
|
||||
|
||||
int ImfHeaderLineOrder (const ImfHeader *hdr);
|
||||
|
||||
void ImfHeaderSetCompression (ImfHeader *hdr,
|
||||
int compression);
|
||||
|
||||
int ImfHeaderCompression (const ImfHeader *hdr);
|
||||
|
||||
int ImfHeaderSetIntAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int value);
|
||||
|
||||
int ImfHeaderIntAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *value);
|
||||
|
||||
int ImfHeaderSetFloatAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float value);
|
||||
|
||||
int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
double value);
|
||||
|
||||
int ImfHeaderFloatAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *value);
|
||||
|
||||
int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
double *value);
|
||||
|
||||
int ImfHeaderSetStringAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const char value[]);
|
||||
|
||||
int ImfHeaderStringAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
const char **value);
|
||||
|
||||
int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float xMin, float yMin,
|
||||
float xMax, float yMax);
|
||||
|
||||
int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *xMin, float *yMin,
|
||||
float *xMax, float *yMax);
|
||||
|
||||
int ImfHeaderSetV2iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int x, int y);
|
||||
|
||||
int ImfHeaderV2iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *x, int *y);
|
||||
|
||||
int ImfHeaderSetV2fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float x, float y);
|
||||
|
||||
int ImfHeaderV2fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *x, float *y);
|
||||
|
||||
int ImfHeaderSetV3iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int x, int y, int z);
|
||||
|
||||
int ImfHeaderV3iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *x, int *y, int *z);
|
||||
|
||||
int ImfHeaderSetV3fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float x, float y, float z);
|
||||
|
||||
int ImfHeaderV3fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *x, float *y, float *z);
|
||||
|
||||
int ImfHeaderSetM33fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const float m[3][3]);
|
||||
|
||||
int ImfHeaderM33fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float m[3][3]);
|
||||
|
||||
int ImfHeaderSetM44fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const float m[4][4]);
|
||||
|
||||
int ImfHeaderM44fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float m[4][4]);
|
||||
|
||||
/*
|
||||
** RGBA output file
|
||||
*/
|
||||
|
||||
struct ImfOutputFile;
|
||||
typedef struct ImfOutputFile ImfOutputFile;
|
||||
|
||||
ImfOutputFile * ImfOpenOutputFile (const char name[],
|
||||
const ImfHeader *hdr,
|
||||
int channels);
|
||||
|
||||
int ImfCloseOutputFile (ImfOutputFile *out);
|
||||
|
||||
int ImfOutputSetFrameBuffer (ImfOutputFile *out,
|
||||
const ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfOutputWritePixels (ImfOutputFile *out,
|
||||
int numScanLines);
|
||||
|
||||
int ImfOutputCurrentScanLine (const ImfOutputFile *out);
|
||||
|
||||
const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
|
||||
|
||||
int ImfOutputChannels (const ImfOutputFile *out);
|
||||
|
||||
|
||||
/*
|
||||
** Tiled RGBA output file
|
||||
*/
|
||||
|
||||
struct ImfTiledOutputFile;
|
||||
typedef struct ImfTiledOutputFile ImfTiledOutputFile;
|
||||
|
||||
ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],
|
||||
const ImfHeader *hdr,
|
||||
int channels,
|
||||
int xSize, int ySize,
|
||||
int mode, int rmode);
|
||||
|
||||
int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
|
||||
const ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
|
||||
int dx, int dy,
|
||||
int lx, int ly);
|
||||
|
||||
int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
|
||||
int dxMin, int dxMax,
|
||||
int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputChannels (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
|
||||
|
||||
int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
|
||||
int ImfTiledOutputLevelRoundingMode
|
||||
(const ImfTiledOutputFile *out);
|
||||
|
||||
|
||||
/*
|
||||
** RGBA input file
|
||||
*/
|
||||
|
||||
struct ImfInputFile;
|
||||
typedef struct ImfInputFile ImfInputFile;
|
||||
|
||||
ImfInputFile * ImfOpenInputFile (const char name[]);
|
||||
|
||||
int ImfCloseInputFile (ImfInputFile *in);
|
||||
|
||||
int ImfInputSetFrameBuffer (ImfInputFile *in,
|
||||
ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfInputReadPixels (ImfInputFile *in,
|
||||
int scanLine1,
|
||||
int scanLine2);
|
||||
|
||||
const ImfHeader * ImfInputHeader (const ImfInputFile *in);
|
||||
|
||||
int ImfInputChannels (const ImfInputFile *in);
|
||||
|
||||
const char * ImfInputFileName (const ImfInputFile *in);
|
||||
|
||||
|
||||
/*
|
||||
** Tiled RGBA input file
|
||||
*/
|
||||
|
||||
struct ImfTiledInputFile;
|
||||
typedef struct ImfTiledInputFile ImfTiledInputFile;
|
||||
|
||||
ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);
|
||||
|
||||
int ImfCloseTiledInputFile (ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
|
||||
ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
int ImfTiledInputReadTile (ImfTiledInputFile *in,
|
||||
int dx, int dy,
|
||||
int lx, int ly);
|
||||
|
||||
int ImfTiledInputReadTiles (ImfTiledInputFile *in,
|
||||
int dxMin, int dxMax,
|
||||
int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputChannels (const ImfTiledInputFile *in);
|
||||
|
||||
const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputTileXSize (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputTileYSize (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputLevelMode (const ImfTiledInputFile *in);
|
||||
|
||||
int ImfTiledInputLevelRoundingMode
|
||||
(const ImfTiledInputFile *in);
|
||||
|
||||
/*
|
||||
** Lookup tables
|
||||
*/
|
||||
|
||||
struct ImfLut;
|
||||
typedef struct ImfLut ImfLut;
|
||||
|
||||
ImfLut * ImfNewRound12logLut (int channels);
|
||||
|
||||
ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
|
||||
|
||||
void ImfDeleteLut (ImfLut *lut);
|
||||
|
||||
void ImfApplyLut (ImfLut *lut,
|
||||
ImfRgba *data,
|
||||
int nData,
|
||||
int stride);
|
||||
/*
|
||||
** Most recent error message
|
||||
*/
|
||||
|
||||
const char * ImfErrorMessage (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
321
3rdparty/openexr/IlmImf/ImfChannelList.cpp
vendored
Normal file
321
3rdparty/openexr/IlmImf/ImfChannelList.cpp
vendored
Normal file
@ -0,0 +1,321 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 Channel
|
||||
// class ChannelList
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfChannelList.h>
|
||||
#include <Iex.h>
|
||||
|
||||
|
||||
using std::string;
|
||||
using std::set;
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
Channel::Channel (PixelType t, int xs, int ys, bool pl):
|
||||
type (t),
|
||||
xSampling (xs),
|
||||
ySampling (ys),
|
||||
pLinear (pl)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Channel::operator == (const Channel &other) const
|
||||
{
|
||||
return type == other.type &&
|
||||
xSampling == other.xSampling &&
|
||||
ySampling == other.ySampling &&
|
||||
pLinear == other.pLinear;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::insert (const char name[], const Channel &channel)
|
||||
{
|
||||
if (name[0] == 0)
|
||||
THROW (Iex::ArgExc, "Image channel name cannot be an empty string.");
|
||||
|
||||
_map[name] = channel;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::insert (const string &name, const Channel &channel)
|
||||
{
|
||||
insert (name.c_str(), channel);
|
||||
}
|
||||
|
||||
|
||||
Channel &
|
||||
ChannelList::operator [] (const char name[])
|
||||
{
|
||||
ChannelMap::iterator i = _map.find (name);
|
||||
|
||||
if (i == _map.end())
|
||||
THROW (Iex::ArgExc, "Cannot find image channel \"" << name << "\".");
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
const Channel &
|
||||
ChannelList::operator [] (const char name[]) const
|
||||
{
|
||||
ChannelMap::const_iterator i = _map.find (name);
|
||||
|
||||
if (i == _map.end())
|
||||
THROW (Iex::ArgExc, "Cannot find image channel \"" << name << "\".");
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
Channel &
|
||||
ChannelList::operator [] (const string &name)
|
||||
{
|
||||
return this->operator[] (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const Channel &
|
||||
ChannelList::operator [] (const string &name) const
|
||||
{
|
||||
return this->operator[] (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
Channel *
|
||||
ChannelList::findChannel (const char name[])
|
||||
{
|
||||
ChannelMap::iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: &i->second;
|
||||
}
|
||||
|
||||
|
||||
const Channel *
|
||||
ChannelList::findChannel (const char name[]) const
|
||||
{
|
||||
ChannelMap::const_iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: &i->second;
|
||||
}
|
||||
|
||||
|
||||
Channel *
|
||||
ChannelList::findChannel (const string &name)
|
||||
{
|
||||
return findChannel (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const Channel *
|
||||
ChannelList::findChannel (const string &name) const
|
||||
{
|
||||
return findChannel (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelList::begin ()
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
ChannelList::ConstIterator
|
||||
ChannelList::begin () const
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelList::end ()
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
ChannelList::ConstIterator
|
||||
ChannelList::end () const
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelList::find (const char name[])
|
||||
{
|
||||
return _map.find (name);
|
||||
}
|
||||
|
||||
|
||||
ChannelList::ConstIterator
|
||||
ChannelList::find (const char name[]) const
|
||||
{
|
||||
return _map.find (name);
|
||||
}
|
||||
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelList::find (const string &name)
|
||||
{
|
||||
return find (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
ChannelList::ConstIterator
|
||||
ChannelList::find (const string &name) const
|
||||
{
|
||||
return find (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::layers (set <string> &layerNames) const
|
||||
{
|
||||
layerNames.clear();
|
||||
|
||||
for (ConstIterator i = begin(); i != end(); ++i)
|
||||
{
|
||||
string layerName = i.name();
|
||||
size_t pos = layerName.rfind ('.');
|
||||
|
||||
if (pos != string::npos && pos != 0 && pos + 1 < layerName.size())
|
||||
{
|
||||
layerName.erase (pos);
|
||||
layerNames.insert (layerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::channelsInLayer (const string &layerName,
|
||||
Iterator &first,
|
||||
Iterator &last)
|
||||
{
|
||||
channelsWithPrefix (layerName + '.', first, last);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::channelsInLayer (const string &layerName,
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const
|
||||
{
|
||||
channelsWithPrefix (layerName + '.', first, last);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::channelsWithPrefix (const char prefix[],
|
||||
Iterator &first,
|
||||
Iterator &last)
|
||||
{
|
||||
first = last = _map.lower_bound (prefix);
|
||||
int n = strlen (prefix);
|
||||
|
||||
while (last != Iterator (_map.end()) &&
|
||||
strncmp (last.name(), prefix, n) <= 0)
|
||||
{
|
||||
++last;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::channelsWithPrefix (const char prefix[],
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const
|
||||
{
|
||||
first = last = _map.lower_bound (prefix);
|
||||
int n = strlen (prefix);
|
||||
|
||||
while (last != ConstIterator (_map.end()) &&
|
||||
strncmp (last.name(), prefix, n) <= 0)
|
||||
{
|
||||
++last;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::channelsWithPrefix (const string &prefix,
|
||||
Iterator &first,
|
||||
Iterator &last)
|
||||
{
|
||||
return channelsWithPrefix (prefix.c_str(), first, last);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChannelList::channelsWithPrefix (const string &prefix,
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const
|
||||
{
|
||||
return channelsWithPrefix (prefix.c_str(), first, last);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ChannelList::operator == (const ChannelList &other) const
|
||||
{
|
||||
ConstIterator i = begin();
|
||||
ConstIterator j = other.begin();
|
||||
|
||||
while (i != end() && j != other.end())
|
||||
{
|
||||
if (!(i.channel() == j.channel()))
|
||||
return false;
|
||||
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
|
||||
return i == end() && j == other.end();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
433
3rdparty/openexr/IlmImf/ImfChannelList.h
vendored
Normal file
433
3rdparty/openexr/IlmImf/ImfChannelList.h
vendored
Normal file
@ -0,0 +1,433 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_CHANNEL_LIST_H
|
||||
#define INCLUDED_IMF_CHANNEL_LIST_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Channel
|
||||
// class ChannelList
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfName.h>
|
||||
#include <ImfPixelType.h>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
struct Channel
|
||||
{
|
||||
//------------------------------
|
||||
// Data type; see ImfPixelType.h
|
||||
//------------------------------
|
||||
|
||||
PixelType type;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Subsampling: pixel (x, y) is present in the
|
||||
// channel only if
|
||||
//
|
||||
// x % xSampling == 0 && y % ySampling == 0
|
||||
//
|
||||
//--------------------------------------------
|
||||
|
||||
int xSampling;
|
||||
int ySampling;
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Hint to lossy compression methods that indicates whether
|
||||
// human perception of the quantity represented by this channel
|
||||
// is closer to linear or closer to logarithmic. Compression
|
||||
// methods may optimize image quality by adjusting pixel data
|
||||
// quantization acording to this hint.
|
||||
// For example, perception of red, green, blue and luminance is
|
||||
// approximately logarithmic; the difference between 0.1 and 0.2
|
||||
// is perceived to be roughly the same as the difference between
|
||||
// 1.0 and 2.0. Perception of chroma coordinates tends to be
|
||||
// closer to linear than logarithmic; the difference between 0.1
|
||||
// and 0.2 is perceived to be roughly the same as the difference
|
||||
// between 1.0 and 1.1.
|
||||
//--------------------------------------------------------------
|
||||
|
||||
bool pLinear;
|
||||
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Channel (PixelType type = HALF,
|
||||
int xSampling = 1,
|
||||
int ySampling = 1,
|
||||
bool pLinear = false);
|
||||
|
||||
|
||||
//------------
|
||||
// Operator ==
|
||||
//------------
|
||||
|
||||
bool operator == (const Channel &other) const;
|
||||
};
|
||||
|
||||
|
||||
class ChannelList
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------
|
||||
// Add a channel
|
||||
//--------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Channel &channel);
|
||||
|
||||
void insert (const std::string &name,
|
||||
const Channel &channel);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to existing channels:
|
||||
//
|
||||
// [n] Returns a reference to the channel with name n.
|
||||
// If no channel with name n exists, an Iex::ArgExc
|
||||
// is thrown.
|
||||
//
|
||||
// findChannel(n) Returns a pointer to the channel with name n,
|
||||
// or 0 if no channel with name n exists.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
Channel & operator [] (const char name[]);
|
||||
const Channel & operator [] (const char name[]) const;
|
||||
|
||||
Channel & operator [] (const std::string &name);
|
||||
const Channel & operator [] (const std::string &name) const;
|
||||
|
||||
Channel * findChannel (const char name[]);
|
||||
const Channel * findChannel (const char name[]) const;
|
||||
|
||||
Channel * findChannel (const std::string &name);
|
||||
const Channel * findChannel (const std::string &name) const;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Iterator-style access to existing channels
|
||||
//-------------------------------------------
|
||||
|
||||
typedef std::map <Name, Channel> ChannelMap;
|
||||
|
||||
class Iterator;
|
||||
class ConstIterator;
|
||||
|
||||
Iterator begin ();
|
||||
ConstIterator begin () const;
|
||||
|
||||
Iterator end ();
|
||||
ConstIterator end () const;
|
||||
|
||||
Iterator find (const char name[]);
|
||||
ConstIterator find (const char name[]) const;
|
||||
|
||||
Iterator find (const std::string &name);
|
||||
ConstIterator find (const std::string &name) const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Support for image layers:
|
||||
//
|
||||
// In an image file with many channels it is sometimes useful to
|
||||
// group the channels into "layers", that is, into sets of channels
|
||||
// that logically belong together. Grouping channels into layers
|
||||
// is done using a naming convention: channel C in layer L is
|
||||
// called "L.C".
|
||||
//
|
||||
// For example, a computer graphic image may contain separate
|
||||
// R, G and B channels for light that originated at each of
|
||||
// several different virtual light sources. The channels in
|
||||
// this image might be called "light1.R", "light1.G", "light1.B",
|
||||
// "light2.R", "light2.G", "light2.B", etc.
|
||||
//
|
||||
// Note that this naming convention allows layers to be nested;
|
||||
// for example, "light1.specular.R" identifies the "R" channel
|
||||
// in the "specular" sub-layer of layer "light1".
|
||||
//
|
||||
// Channel names that don't contain a "." or that contain a
|
||||
// "." only at the beginning or at the end are not considered
|
||||
// to be part of any layer.
|
||||
//
|
||||
// layers(lns) sorts the channels in this ChannelList
|
||||
// into layers and stores the names of
|
||||
// all layers, sorted alphabetically,
|
||||
// into string set lns.
|
||||
//
|
||||
// channelsInLayer(ln,f,l) stores a pair of iterators in f and l
|
||||
// such that the loop
|
||||
//
|
||||
// for (ConstIterator i = f; i != l; ++i)
|
||||
// ...
|
||||
//
|
||||
// iterates over all channels in layer ln.
|
||||
// channelsInLayer (ln, l, p) calls
|
||||
// channelsWithPrefix (ln + ".", l, p).
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
void layers (std::set <std::string> &layerNames) const;
|
||||
|
||||
void channelsInLayer (const std::string &layerName,
|
||||
Iterator &first,
|
||||
Iterator &last);
|
||||
|
||||
void channelsInLayer (const std::string &layerName,
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Find all channels whose name begins with a given prefix:
|
||||
//
|
||||
// channelsWithPrefix(p,f,l) stores a pair of iterators in f and l
|
||||
// such that the following loop iterates over all channels whose name
|
||||
// begins with string p:
|
||||
//
|
||||
// for (ConstIterator i = f; i != l; ++i)
|
||||
// ...
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void channelsWithPrefix (const char prefix[],
|
||||
Iterator &first,
|
||||
Iterator &last);
|
||||
|
||||
void channelsWithPrefix (const char prefix[],
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const;
|
||||
|
||||
void channelsWithPrefix (const std::string &prefix,
|
||||
Iterator &first,
|
||||
Iterator &last);
|
||||
|
||||
void channelsWithPrefix (const std::string &prefix,
|
||||
ConstIterator &first,
|
||||
ConstIterator &last) const;
|
||||
|
||||
//------------
|
||||
// Operator ==
|
||||
//------------
|
||||
|
||||
bool operator == (const ChannelList &other) const;
|
||||
|
||||
private:
|
||||
|
||||
ChannelMap _map;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class ChannelList::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const ChannelList::ChannelMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
Channel & channel () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class ChannelList::ConstIterator;
|
||||
|
||||
ChannelList::ChannelMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class ChannelList::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const ChannelList::ChannelMap::const_iterator &i);
|
||||
ConstIterator (const ChannelList::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const Channel & channel () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
ChannelList::ChannelMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
inline
|
||||
ChannelList::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
ChannelList::Iterator::Iterator (const ChannelList::ChannelMap::iterator &i):
|
||||
_i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline ChannelList::Iterator &
|
||||
ChannelList::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline ChannelList::Iterator
|
||||
ChannelList::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
ChannelList::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline Channel &
|
||||
ChannelList::Iterator::channel () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
ChannelList::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
ChannelList::ConstIterator::ConstIterator
|
||||
(const ChannelList::ChannelMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
ChannelList::ConstIterator::ConstIterator (const ChannelList::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline ChannelList::ConstIterator &
|
||||
ChannelList::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline ChannelList::ConstIterator
|
||||
ChannelList::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
ChannelList::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
inline const Channel &
|
||||
ChannelList::ConstIterator::channel () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const ChannelList::ConstIterator &x,
|
||||
const ChannelList::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const ChannelList::ConstIterator &x,
|
||||
const ChannelList::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
145
3rdparty/openexr/IlmImf/ImfChannelListAttribute.cpp
vendored
Normal file
145
3rdparty/openexr/IlmImf/ImfChannelListAttribute.cpp
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ChannelListAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfChannelListAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
namespace {
|
||||
|
||||
template <size_t N>
|
||||
void checkIsNullTerminated (const char (&str)[N], const char *what)
|
||||
{
|
||||
for (int i = 0; i < N; ++i) {
|
||||
if (str[i] == '\0')
|
||||
return;
|
||||
}
|
||||
std::stringstream s;
|
||||
s << "Invalid " << what << ": it is more than " << (N - 1)
|
||||
<< " characters long.";
|
||||
throw Iex::InputExc(s);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
template <>
|
||||
const char *
|
||||
ChannelListAttribute::staticTypeName ()
|
||||
{
|
||||
return "chlist";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
ChannelListAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
for (ChannelList::ConstIterator i = _value.begin();
|
||||
i != _value.end();
|
||||
++i)
|
||||
{
|
||||
//
|
||||
// Write name
|
||||
//
|
||||
|
||||
Xdr::write <StreamIO> (os, i.name());
|
||||
|
||||
//
|
||||
// Write Channel struct
|
||||
//
|
||||
|
||||
Xdr::write <StreamIO> (os, int (i.channel().type));
|
||||
Xdr::write <StreamIO> (os, i.channel().pLinear);
|
||||
Xdr::pad <StreamIO> (os, 3);
|
||||
Xdr::write <StreamIO> (os, i.channel().xSampling);
|
||||
Xdr::write <StreamIO> (os, i.channel().ySampling);
|
||||
}
|
||||
|
||||
//
|
||||
// Write end of list marker
|
||||
//
|
||||
|
||||
Xdr::write <StreamIO> (os, "");
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
ChannelListAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//
|
||||
// Read name; zero length name means end of channel list
|
||||
//
|
||||
|
||||
char name[Name::SIZE];
|
||||
Xdr::read <StreamIO> (is, Name::MAX_LENGTH, name);
|
||||
|
||||
if (name[0] == 0)
|
||||
break;
|
||||
|
||||
checkIsNullTerminated (name, "channel name");
|
||||
|
||||
//
|
||||
// Read Channel struct
|
||||
//
|
||||
|
||||
int type;
|
||||
bool pLinear;
|
||||
int xSampling;
|
||||
int ySampling;
|
||||
|
||||
Xdr::read <StreamIO> (is, type);
|
||||
Xdr::read <StreamIO> (is, pLinear);
|
||||
Xdr::skip <StreamIO> (is, 3);
|
||||
Xdr::read <StreamIO> (is, xSampling);
|
||||
Xdr::read <StreamIO> (is, ySampling);
|
||||
|
||||
_value.insert
|
||||
(name, Channel (PixelType (type), xSampling, ySampling, pLinear));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
67
3rdparty/openexr/IlmImf/ImfChannelListAttribute.h
vendored
Normal file
67
3rdparty/openexr/IlmImf/ImfChannelListAttribute.h
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_CHANNEL_LIST_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_CHANNEL_LIST_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ChannelListAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfChannelList.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<ChannelList> ChannelListAttribute;
|
||||
template <> const char *ChannelListAttribute::staticTypeName ();
|
||||
template <> void ChannelListAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void ChannelListAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfChannelListAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
161
3rdparty/openexr/IlmImf/ImfCheckedArithmetic.h
vendored
Normal file
161
3rdparty/openexr/IlmImf/ImfCheckedArithmetic.h
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2009, 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_CHECKED_ARITHMETIC_H
|
||||
#define INCLUDED_IMF_CHECKED_ARITHMETIC_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Integer arithmetic operations that throw exceptions
|
||||
// on overflow, underflow or division by zero.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <limits>
|
||||
#include <IexMathExc.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
template <bool b> struct StaticAssertionFailed;
|
||||
template <> struct StaticAssertionFailed <true> {};
|
||||
|
||||
#define IMF_STATIC_ASSERT(x) \
|
||||
do {StaticAssertionFailed <x> staticAssertionFailed;} while (false)
|
||||
|
||||
|
||||
template <class T>
|
||||
T
|
||||
uiMult (T a, T b)
|
||||
{
|
||||
//
|
||||
// Unsigned integer multiplication
|
||||
//
|
||||
|
||||
IMF_STATIC_ASSERT (!std::numeric_limits<T>::is_signed &&
|
||||
std::numeric_limits<T>::is_integer);
|
||||
|
||||
if (a > 0 && b > std::numeric_limits<T>::max() / a)
|
||||
throw Iex::OverflowExc ("Integer multiplication overflow.");
|
||||
|
||||
return a * b;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T
|
||||
uiDiv (T a, T b)
|
||||
{
|
||||
//
|
||||
// Unsigned integer division
|
||||
//
|
||||
|
||||
IMF_STATIC_ASSERT (!std::numeric_limits<T>::is_signed &&
|
||||
std::numeric_limits<T>::is_integer);
|
||||
|
||||
if (b == 0)
|
||||
throw Iex::DivzeroExc ("Integer division by zero.");
|
||||
|
||||
return a / b;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T
|
||||
uiAdd (T a, T b)
|
||||
{
|
||||
//
|
||||
// Unsigned integer addition
|
||||
//
|
||||
|
||||
IMF_STATIC_ASSERT (!std::numeric_limits<T>::is_signed &&
|
||||
std::numeric_limits<T>::is_integer);
|
||||
|
||||
if (a > std::numeric_limits<T>::max() - b)
|
||||
throw Iex::OverflowExc ("Integer addition overflow.");
|
||||
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T
|
||||
uiSub (T a, T b)
|
||||
{
|
||||
//
|
||||
// Unsigned integer subtraction
|
||||
//
|
||||
|
||||
IMF_STATIC_ASSERT (!std::numeric_limits<T>::is_signed &&
|
||||
std::numeric_limits<T>::is_integer);
|
||||
|
||||
if (a < b)
|
||||
throw Iex::UnderflowExc ("Integer subtraction underflow.");
|
||||
|
||||
return a - b;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
size_t
|
||||
checkArraySize (T n, size_t s)
|
||||
{
|
||||
//
|
||||
// Verify that the size, in bytes, of an array with n elements
|
||||
// of size s can be computed without overflowing:
|
||||
//
|
||||
// If computing
|
||||
//
|
||||
// size_t (n) * s
|
||||
//
|
||||
// would overflow, then throw an Iex::OverflowExc exception.
|
||||
// Otherwise return
|
||||
//
|
||||
// size_t (n).
|
||||
//
|
||||
|
||||
IMF_STATIC_ASSERT (!std::numeric_limits<T>::is_signed &&
|
||||
std::numeric_limits<T>::is_integer);
|
||||
|
||||
IMF_STATIC_ASSERT (sizeof (T) <= sizeof (size_t));
|
||||
|
||||
if (size_t (n) > std::numeric_limits<size_t>::max() / s)
|
||||
throw Iex::OverflowExc ("Integer multiplication overflow.");
|
||||
|
||||
return size_t (n);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
135
3rdparty/openexr/IlmImf/ImfChromaticities.cpp
vendored
Normal file
135
3rdparty/openexr/IlmImf/ImfChromaticities.cpp
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// CIE (x,y) chromaticities, and conversions between
|
||||
// RGB tiples and CIE XYZ tristimulus values.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfChromaticities.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
Chromaticities::Chromaticities (const Imath::V2f &red,
|
||||
const Imath::V2f &green,
|
||||
const Imath::V2f &blue,
|
||||
const Imath::V2f &white)
|
||||
:
|
||||
red (red),
|
||||
green (green),
|
||||
blue (blue),
|
||||
white (white)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Imath::M44f
|
||||
RGBtoXYZ (const Chromaticities chroma, float Y)
|
||||
{
|
||||
//
|
||||
// For an explanation of how the color conversion matrix is derived,
|
||||
// see Roy Hall, "Illumination and Color in Computer Generated Imagery",
|
||||
// Springer-Verlag, 1989, chapter 3, "Perceptual Response"; and
|
||||
// Charles A. Poynton, "A Technical Introduction to Digital Video",
|
||||
// John Wiley & Sons, 1996, chapter 7, "Color science for video".
|
||||
//
|
||||
|
||||
//
|
||||
// X and Z values of RGB value (1, 1, 1), or "white"
|
||||
//
|
||||
|
||||
float X = chroma.white.x * Y / chroma.white.y;
|
||||
float Z = (1 - chroma.white.x - chroma.white.y) * Y / chroma.white.y;
|
||||
|
||||
//
|
||||
// Scale factors for matrix rows
|
||||
//
|
||||
|
||||
float d = chroma.red.x * (chroma.blue.y - chroma.green.y) +
|
||||
chroma.blue.x * (chroma.green.y - chroma.red.y) +
|
||||
chroma.green.x * (chroma.red.y - chroma.blue.y);
|
||||
|
||||
float Sr = (X * (chroma.blue.y - chroma.green.y) -
|
||||
chroma.green.x * (Y * (chroma.blue.y - 1) +
|
||||
chroma.blue.y * (X + Z)) +
|
||||
chroma.blue.x * (Y * (chroma.green.y - 1) +
|
||||
chroma.green.y * (X + Z))) / d;
|
||||
|
||||
float Sg = (X * (chroma.red.y - chroma.blue.y) +
|
||||
chroma.red.x * (Y * (chroma.blue.y - 1) +
|
||||
chroma.blue.y * (X + Z)) -
|
||||
chroma.blue.x * (Y * (chroma.red.y - 1) +
|
||||
chroma.red.y * (X + Z))) / d;
|
||||
|
||||
float Sb = (X * (chroma.green.y - chroma.red.y) -
|
||||
chroma.red.x * (Y * (chroma.green.y - 1) +
|
||||
chroma.green.y * (X + Z)) +
|
||||
chroma.green.x * (Y * (chroma.red.y - 1) +
|
||||
chroma.red.y * (X + Z))) / d;
|
||||
|
||||
//
|
||||
// Assemble the matrix
|
||||
//
|
||||
|
||||
Imath::M44f M;
|
||||
|
||||
M[0][0] = Sr * chroma.red.x;
|
||||
M[0][1] = Sr * chroma.red.y;
|
||||
M[0][2] = Sr * (1 - chroma.red.x - chroma.red.y);
|
||||
|
||||
M[1][0] = Sg * chroma.green.x;
|
||||
M[1][1] = Sg * chroma.green.y;
|
||||
M[1][2] = Sg * (1 - chroma.green.x - chroma.green.y);
|
||||
|
||||
M[2][0] = Sb * chroma.blue.x;
|
||||
M[2][1] = Sb * chroma.blue.y;
|
||||
M[2][2] = Sb * (1 - chroma.blue.x - chroma.blue.y);
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
|
||||
Imath::M44f
|
||||
XYZtoRGB (const Chromaticities chroma, float Y)
|
||||
{
|
||||
return RGBtoXYZ (chroma, Y).inverse();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
120
3rdparty/openexr/IlmImf/ImfChromaticities.h
vendored
Normal file
120
3rdparty/openexr/IlmImf/ImfChromaticities.h
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, 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_CHROMATICITIES_H
|
||||
#define INCLUDED_IMF_CHROMATICITIES_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// CIE (x,y) chromaticities, and conversions between
|
||||
// RGB tiples and CIE XYZ tristimulus values.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathVec.h"
|
||||
#include "ImathMatrix.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
struct Chromaticities
|
||||
{
|
||||
//-----------------------------------------------
|
||||
// The CIE x and y coordinates of the RGB triples
|
||||
// (1,0,0), (0,1,0), (0,0,1) and (1,1,1).
|
||||
//-----------------------------------------------
|
||||
|
||||
Imath::V2f red;
|
||||
Imath::V2f green;
|
||||
Imath::V2f blue;
|
||||
Imath::V2f white;
|
||||
|
||||
//--------------------------------------------
|
||||
// Default constructor produces chromaticities
|
||||
// according to Rec. ITU-R BT.709-3
|
||||
//--------------------------------------------
|
||||
|
||||
Chromaticities (const Imath::V2f &red = Imath::V2f (0.6400f, 0.3300f),
|
||||
const Imath::V2f &green = Imath::V2f (0.3000f, 0.6000f),
|
||||
const Imath::V2f &blue = Imath::V2f (0.1500f, 0.0600f),
|
||||
const Imath::V2f &white = Imath::V2f (0.3127f, 0.3290f));
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Conversions between RGB and CIE XYZ
|
||||
//
|
||||
// RGB to XYZ:
|
||||
//
|
||||
// Given a set of chromaticities, c, and the luminance, Y, of the RGB
|
||||
// triple (1,1,1), or "white", RGBtoXYZ(c,Y) computes a matrix, M, so
|
||||
// that multiplying an RGB value, v, with M produces an equivalent
|
||||
// XYZ value, w. (w == v * M)
|
||||
//
|
||||
// If we define that
|
||||
//
|
||||
// (Xr, Yr, Zr) == (1, 0, 0) * M
|
||||
// (Xg, Yg, Zg) == (0, 1, 0) * M
|
||||
// (Xb, Yb, Zb) == (0, 0, 1) * M
|
||||
// (Xw, Yw, Zw) == (1, 1, 1) * M,
|
||||
//
|
||||
// then the following statements are true:
|
||||
//
|
||||
// Xr / (Xr + Yr + Zr) == c.red.x
|
||||
// Yr / (Xr + Yr + Zr) == c.red.y
|
||||
//
|
||||
// Xg / (Xg + Yg + Zg) == c.red.x
|
||||
// Yg / (Xg + Yg + Zg) == c.red.y
|
||||
//
|
||||
// Xb / (Xb + Yb + Zb) == c.red.x
|
||||
// Yb / (Xb + Yb + Zb) == c.red.y
|
||||
//
|
||||
// Xw / (Xw + Yw + Zw) == c.red.x
|
||||
// Yw / (Xw + Yw + Zw) == c.red.y
|
||||
//
|
||||
// Yw == Y.
|
||||
//
|
||||
// XYZ to RGB:
|
||||
//
|
||||
// YYZtoRGB(c,Y) returns RGBtoXYZ(c,Y).inverse().
|
||||
//
|
||||
|
||||
Imath::M44f RGBtoXYZ (const Chromaticities chroma, float Y);
|
||||
Imath::M44f XYZtoRGB (const Chromaticities chroma, float Y);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
86
3rdparty/openexr/IlmImf/ImfChromaticitiesAttribute.cpp
vendored
Normal file
86
3rdparty/openexr/IlmImf/ImfChromaticitiesAttribute.cpp
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, 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 ChromaticitiesAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfChromaticitiesAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
ChromaticitiesAttribute::staticTypeName ()
|
||||
{
|
||||
return "chromaticities";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
ChromaticitiesAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value.red.x);
|
||||
Xdr::write <StreamIO> (os, _value.red.y);
|
||||
Xdr::write <StreamIO> (os, _value.green.x);
|
||||
Xdr::write <StreamIO> (os, _value.green.y);
|
||||
Xdr::write <StreamIO> (os, _value.blue.x);
|
||||
Xdr::write <StreamIO> (os, _value.blue.y);
|
||||
Xdr::write <StreamIO> (os, _value.white.x);
|
||||
Xdr::write <StreamIO> (os, _value.white.y);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
ChromaticitiesAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value.red.x);
|
||||
Xdr::read <StreamIO> (is, _value.red.y);
|
||||
Xdr::read <StreamIO> (is, _value.green.x);
|
||||
Xdr::read <StreamIO> (is, _value.green.y);
|
||||
Xdr::read <StreamIO> (is, _value.blue.x);
|
||||
Xdr::read <StreamIO> (is, _value.blue.y);
|
||||
Xdr::read <StreamIO> (is, _value.white.x);
|
||||
Xdr::read <StreamIO> (is, _value.white.y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
72
3rdparty/openexr/IlmImf/ImfChromaticitiesAttribute.h
vendored
Normal file
72
3rdparty/openexr/IlmImf/ImfChromaticitiesAttribute.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, 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_CHROMATICITIES_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_CHROMATICITIES_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ChromaticitiesAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfChromaticities.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Chromaticities> ChromaticitiesAttribute;
|
||||
|
||||
template <>
|
||||
const char *ChromaticitiesAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void ChromaticitiesAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void ChromaticitiesAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfChromaticitiesAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
75
3rdparty/openexr/IlmImf/ImfCompression.h
vendored
Normal file
75
3rdparty/openexr/IlmImf/ImfCompression.h
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_COMPRESSION_H
|
||||
#define INCLUDED_IMF_COMPRESSION_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum Compression
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum Compression
|
||||
{
|
||||
NO_COMPRESSION = 0, // no compression
|
||||
|
||||
RLE_COMPRESSION = 1, // run length encoding
|
||||
|
||||
ZIPS_COMPRESSION = 2, // zlib compression, one scan line at a time
|
||||
|
||||
ZIP_COMPRESSION = 3, // zlib compression, in blocks of 16 scan lines
|
||||
|
||||
PIZ_COMPRESSION = 4, // piz-based wavelet compression
|
||||
|
||||
PXR24_COMPRESSION = 5, // lossy 24-bit float compression
|
||||
|
||||
B44_COMPRESSION = 6, // lossy 4-by-4 pixel block compression,
|
||||
// fixed compression rate
|
||||
|
||||
B44A_COMPRESSION = 7, // lossy 4-by-4 pixel block compression,
|
||||
// flat fields are compressed more
|
||||
|
||||
NUM_COMPRESSION_METHODS // number of different compression methods
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
76
3rdparty/openexr/IlmImf/ImfCompressionAttribute.cpp
vendored
Normal file
76
3rdparty/openexr/IlmImf/ImfCompressionAttribute.cpp
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 CompressionAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfCompressionAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
CompressionAttribute::staticTypeName ()
|
||||
{
|
||||
return "compression";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
CompressionAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
unsigned char tmp = _value;
|
||||
Xdr::write <StreamIO> (os, tmp);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
CompressionAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
unsigned char tmp;
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value = Compression (tmp);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
66
3rdparty/openexr/IlmImf/ImfCompressionAttribute.h
vendored
Normal file
66
3rdparty/openexr/IlmImf/ImfCompressionAttribute.h
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_COMPRESSION_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_COMPRESSION_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class CompressionAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfCompression.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Compression> CompressionAttribute;
|
||||
template <> const char *CompressionAttribute::staticTypeName ();
|
||||
template <> void CompressionAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void CompressionAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfCompressionAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
192
3rdparty/openexr/IlmImf/ImfCompressor.cpp
vendored
Normal file
192
3rdparty/openexr/IlmImf/ImfCompressor.cpp
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 Compressor
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfCompressor.h>
|
||||
#include <ImfRleCompressor.h>
|
||||
#include <ImfZipCompressor.h>
|
||||
#include <ImfPizCompressor.h>
|
||||
#include <ImfPxr24Compressor.h>
|
||||
#include <ImfB44Compressor.h>
|
||||
#include <ImfCheckedArithmetic.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
using Imath::Box2i;
|
||||
|
||||
|
||||
Compressor::Compressor (const Header &hdr): _header (hdr) {}
|
||||
|
||||
|
||||
Compressor::~Compressor () {}
|
||||
|
||||
|
||||
Compressor::Format
|
||||
Compressor::format () const
|
||||
{
|
||||
return XDR;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Compressor::compressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Box2i range,
|
||||
const char *&outPtr)
|
||||
{
|
||||
return compress (inPtr, inSize, range.min.y, outPtr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Compressor::uncompressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Box2i range,
|
||||
const char *&outPtr)
|
||||
{
|
||||
return uncompress (inPtr, inSize, range.min.y, outPtr);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
isValidCompression (Compression c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case NO_COMPRESSION:
|
||||
case RLE_COMPRESSION:
|
||||
case ZIPS_COMPRESSION:
|
||||
case ZIP_COMPRESSION:
|
||||
case PIZ_COMPRESSION:
|
||||
case PXR24_COMPRESSION:
|
||||
case B44_COMPRESSION:
|
||||
case B44A_COMPRESSION:
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Compressor *
|
||||
newCompressor (Compression c, size_t maxScanLineSize, const Header &hdr)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case RLE_COMPRESSION:
|
||||
|
||||
return new RleCompressor (hdr, maxScanLineSize);
|
||||
|
||||
case ZIPS_COMPRESSION:
|
||||
|
||||
return new ZipCompressor (hdr, maxScanLineSize, 1);
|
||||
|
||||
case ZIP_COMPRESSION:
|
||||
|
||||
return new ZipCompressor (hdr, maxScanLineSize, 16);
|
||||
|
||||
case PIZ_COMPRESSION:
|
||||
|
||||
return new PizCompressor (hdr, maxScanLineSize, 32);
|
||||
|
||||
case PXR24_COMPRESSION:
|
||||
|
||||
return new Pxr24Compressor (hdr, maxScanLineSize, 16);
|
||||
|
||||
case B44_COMPRESSION:
|
||||
|
||||
return new B44Compressor (hdr, maxScanLineSize, 32, false);
|
||||
|
||||
case B44A_COMPRESSION:
|
||||
|
||||
return new B44Compressor (hdr, maxScanLineSize, 32, true);
|
||||
|
||||
default:
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Compressor *
|
||||
newTileCompressor (Compression c,
|
||||
size_t tileLineSize,
|
||||
size_t numTileLines,
|
||||
const Header &hdr)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case RLE_COMPRESSION:
|
||||
|
||||
return new RleCompressor (hdr, uiMult (tileLineSize, numTileLines));
|
||||
|
||||
case ZIPS_COMPRESSION:
|
||||
case ZIP_COMPRESSION:
|
||||
|
||||
return new ZipCompressor (hdr, tileLineSize, numTileLines);
|
||||
|
||||
case PIZ_COMPRESSION:
|
||||
|
||||
return new PizCompressor (hdr, tileLineSize, numTileLines);
|
||||
|
||||
case PXR24_COMPRESSION:
|
||||
|
||||
return new Pxr24Compressor (hdr, tileLineSize, numTileLines);
|
||||
|
||||
case B44_COMPRESSION:
|
||||
|
||||
return new B44Compressor (hdr, tileLineSize, numTileLines, false);
|
||||
|
||||
case B44A_COMPRESSION:
|
||||
|
||||
return new B44Compressor (hdr, tileLineSize, numTileLines, true);
|
||||
|
||||
default:
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
252
3rdparty/openexr/IlmImf/ImfCompressor.h
vendored
Normal file
252
3rdparty/openexr/IlmImf/ImfCompressor.h
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_COMPRESSOR_H
|
||||
#define INCLUDED_IMF_COMPRESSOR_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Compressor
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfCompression.h>
|
||||
#include "ImathBox.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class Header;
|
||||
|
||||
|
||||
class Compressor
|
||||
{
|
||||
public:
|
||||
|
||||
//---------------------------------------------
|
||||
// Constructor -- hdr is the header of the file
|
||||
// that will be compressed or uncompressed
|
||||
//---------------------------------------------
|
||||
|
||||
Compressor (const Header &hdr);
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~Compressor ();
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
// Maximum number of scan lines processed by
|
||||
// a single call to compress() and uncompress().
|
||||
//----------------------------------------------
|
||||
|
||||
virtual int numScanLines () const = 0;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Format of the pixel data read and written
|
||||
// by the compress() and uncompress() methods.
|
||||
// The default implementation of format()
|
||||
// returns XDR.
|
||||
//--------------------------------------------
|
||||
|
||||
enum Format
|
||||
{
|
||||
NATIVE, // the machine's native format
|
||||
XDR // Xdr format
|
||||
};
|
||||
|
||||
virtual Format format () const;
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Access to the file's header
|
||||
//----------------------------
|
||||
|
||||
const Header & header () const {return _header;}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Compress an array of bytes that represents the contents of up to
|
||||
// numScanLines() scan lines:
|
||||
//
|
||||
// inPtr Input buffer (uncompressed data).
|
||||
//
|
||||
// inSize Number of bytes in the input buffer
|
||||
//
|
||||
// minY Minimum y coordinate of the scan lines to
|
||||
// be compressed
|
||||
//
|
||||
// outPtr Pointer to output buffer
|
||||
//
|
||||
// return value Size of compressed data in output buffer
|
||||
//
|
||||
// Arrangement of uncompressed pixel data in the input buffer:
|
||||
//
|
||||
// Before calling
|
||||
//
|
||||
// compress (buf, size, minY, ...);
|
||||
//
|
||||
// the InputFile::writePixels() method gathers pixel data from the
|
||||
// frame buffer, fb, and places them in buffer buf, like this:
|
||||
//
|
||||
// char *endOfBuf = buf;
|
||||
//
|
||||
// for (int y = minY;
|
||||
// y <= min (minY + numScanLines() - 1, header().dataWindow().max.y);
|
||||
// ++y)
|
||||
// {
|
||||
// for (ChannelList::ConstIterator c = header().channels().begin();
|
||||
// c != header().channels().end();
|
||||
// ++c)
|
||||
// {
|
||||
// if (modp (y, c.channel().ySampling) != 0)
|
||||
// continue;
|
||||
//
|
||||
// for (int x = header().dataWindow().min.x;
|
||||
// x <= header().dataWindow().max.x;
|
||||
// ++x)
|
||||
// {
|
||||
// if (modp (x, c.channel().xSampling) != 0)
|
||||
// continue;
|
||||
//
|
||||
// Xdr::write<CharPtrIO> (endOfBuf, fb.pixel (c, x, y));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int size = endOfBuf - buf;
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
virtual int compress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr) = 0;
|
||||
|
||||
virtual int compressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Uncompress an array of bytes that has been compressed by compress():
|
||||
//
|
||||
// inPtr Input buffer (compressed data).
|
||||
//
|
||||
// inSize Number of bytes in the input buffer
|
||||
//
|
||||
// minY Minimum y coordinate of the scan lines to
|
||||
// be uncompressed
|
||||
//
|
||||
// outPtr Pointer to output buffer
|
||||
//
|
||||
// return value Size of uncompressed data in output buffer
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
virtual int uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr) = 0;
|
||||
|
||||
virtual int uncompressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
private:
|
||||
|
||||
const Header & _header;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Test if c is a valid compression type
|
||||
//--------------------------------------
|
||||
|
||||
bool isValidCompression (Compression c);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Construct a Compressor for compression type c:
|
||||
//
|
||||
// maxScanLineSize Maximum number of bytes per uncompressed
|
||||
// scan line.
|
||||
//
|
||||
// header Header of the input or output file whose
|
||||
// pixels will be compressed or uncompressed.
|
||||
//
|
||||
// return value A pointer to a new Compressor object (it
|
||||
// is the caller's responsibility to delete
|
||||
// the object), or 0 (if c is NO_COMPRESSION).
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
Compressor * newCompressor (Compression c,
|
||||
size_t maxScanLineSize,
|
||||
const Header &hdr);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
// Construct a Compressor for compression type c for a tiled image:
|
||||
//
|
||||
// tileLineSize Maximum number of bytes per uncompressed
|
||||
// line in a tile.
|
||||
//
|
||||
// numTileLines Maximum number of lines in a tile.
|
||||
//
|
||||
// header Header of the input or output file whose
|
||||
// pixels will be compressed or uncompressed.
|
||||
//
|
||||
// return value A pointer to a new Compressor object (it
|
||||
// is the caller's responsibility to delete
|
||||
// the object), or 0 (if c is NO_COMPRESSION).
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
Compressor * newTileCompressor (Compression c,
|
||||
size_t tileLineSize,
|
||||
size_t numTileLines,
|
||||
const Header &hdr);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
139
3rdparty/openexr/IlmImf/ImfConvert.cpp
vendored
Normal file
139
3rdparty/openexr/IlmImf/ImfConvert.cpp
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Routines for converting between pixel data types,
|
||||
// with well-defined behavior for exceptional cases.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfConvert.h>
|
||||
#include <limits.h>
|
||||
|
||||
namespace Imf {
|
||||
namespace {
|
||||
|
||||
inline bool
|
||||
isNegative (float f)
|
||||
{
|
||||
union {float f; int i;} u;
|
||||
u.f = f;
|
||||
return (u.i & 0x80000000) != 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
isNan (float f)
|
||||
{
|
||||
union {float f; int i;} u;
|
||||
u.f = f;
|
||||
return (u.i & 0x7fffffff) > 0x7f800000;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
isInfinity (float f)
|
||||
{
|
||||
union {float f; int i;} u;
|
||||
u.f = f;
|
||||
return (u.i & 0x7fffffff) == 0x7f800000;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
isFinite (float f)
|
||||
{
|
||||
union {float f; int i;} u;
|
||||
u.f = f;
|
||||
return (u.i & 0x7f800000) != 0x7f800000;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
unsigned int
|
||||
halfToUint (half h)
|
||||
{
|
||||
if (h.isNegative() || h.isNan())
|
||||
return 0;
|
||||
|
||||
if (h.isInfinity())
|
||||
return UINT_MAX;
|
||||
|
||||
return (unsigned int) h;
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
floatToUint (float f)
|
||||
{
|
||||
if (isNegative (f) || isNan (f))
|
||||
return 0;
|
||||
|
||||
if (isInfinity (f) || f > UINT_MAX)
|
||||
return UINT_MAX;
|
||||
|
||||
return (unsigned int) f;
|
||||
}
|
||||
|
||||
|
||||
half
|
||||
uintToHalf (unsigned int ui)
|
||||
{
|
||||
if (ui > HALF_MAX)
|
||||
return half::posInf();
|
||||
|
||||
return half (ui);
|
||||
}
|
||||
|
||||
|
||||
half
|
||||
floatToHalf (float f)
|
||||
{
|
||||
if (isFinite (f))
|
||||
{
|
||||
if (f > HALF_MAX)
|
||||
return half::posInf();
|
||||
|
||||
if (f < -HALF_MAX)
|
||||
return half::negInf();
|
||||
}
|
||||
|
||||
return half (f);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
104
3rdparty/openexr/IlmImf/ImfConvert.h
vendored
Normal file
104
3rdparty/openexr/IlmImf/ImfConvert.h
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_CONVERT_H
|
||||
#define INCLUDED_IMF_CONVERT_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Routines for converting between pixel data types,
|
||||
// with well-defined behavior for exceptional cases,
|
||||
// without depending on how hardware and operating
|
||||
// system handle integer overflows and floating-point
|
||||
// exceptions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "half.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Conversion from half or float to unsigned int:
|
||||
//
|
||||
// input result
|
||||
// ---------------------------------------------------
|
||||
//
|
||||
// finite, >= 0 input, cast to unsigned int
|
||||
// (rounds towards zero)
|
||||
//
|
||||
// finite, < 0 0
|
||||
//
|
||||
// NaN 0
|
||||
//
|
||||
// +infinity UINT_MAX
|
||||
//
|
||||
// -infinity 0
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int halfToUint (half h);
|
||||
unsigned int floatToUint (float f);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Conversion from unsigned int or float to half:
|
||||
//
|
||||
// input result
|
||||
// ---------------------------------------------------
|
||||
//
|
||||
// finite, closest possible half
|
||||
// magnitude <= HALF_MAX
|
||||
//
|
||||
// finite, > HALF_MAX +infinity
|
||||
//
|
||||
// finite, < -HALF_MAX -infinity
|
||||
//
|
||||
// NaN NaN
|
||||
//
|
||||
// +infinity +infinity
|
||||
//
|
||||
// -infinity -infinity
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
half uintToHalf (unsigned int ui);
|
||||
half floatToHalf (float f);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
57
3rdparty/openexr/IlmImf/ImfDoubleAttribute.cpp
vendored
Normal file
57
3rdparty/openexr/IlmImf/ImfDoubleAttribute.cpp
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 DoubleAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfDoubleAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
DoubleAttribute::staticTypeName ()
|
||||
{
|
||||
return "double";
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
63
3rdparty/openexr/IlmImf/ImfDoubleAttribute.h
vendored
Normal file
63
3rdparty/openexr/IlmImf/ImfDoubleAttribute.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_DOUBLE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_DOUBLE_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DoubleAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<double> DoubleAttribute;
|
||||
template <> const char *DoubleAttribute::staticTypeName ();
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfDoubleAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
328
3rdparty/openexr/IlmImf/ImfEnvmap.cpp
vendored
Normal file
328
3rdparty/openexr/IlmImf/ImfEnvmap.cpp
vendored
Normal file
@ -0,0 +1,328 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Environment maps
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfEnvmap.h>
|
||||
#include "ImathFun.h"
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Imath;
|
||||
|
||||
namespace Imf {
|
||||
namespace LatLongMap {
|
||||
|
||||
V2f
|
||||
latLong (const V3f &dir)
|
||||
{
|
||||
float r = sqrt (dir.z * dir.z + dir.x * dir.x);
|
||||
|
||||
float latitude = (r < abs (dir.y))?
|
||||
acos (r / dir.length()) * sign (dir.y):
|
||||
asin (dir.y / dir.length());
|
||||
|
||||
float longitude = (dir.z == 0 && dir.x == 0)? 0: atan2 (dir.x, dir.z);
|
||||
|
||||
return V2f (latitude, longitude);
|
||||
}
|
||||
|
||||
|
||||
V2f
|
||||
latLong (const Box2i &dataWindow, const V2f &pixelPosition)
|
||||
{
|
||||
float latitude, longitude;
|
||||
|
||||
if (dataWindow.max.y > dataWindow.min.y)
|
||||
{
|
||||
latitude = -M_PI *
|
||||
((pixelPosition.y - dataWindow.min.y) /
|
||||
(dataWindow.max.y - dataWindow.min.y) - 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
latitude = 0;
|
||||
}
|
||||
|
||||
if (dataWindow.max.x > dataWindow.min.x)
|
||||
{
|
||||
longitude = -2 * M_PI *
|
||||
((pixelPosition.x - dataWindow.min.x) /
|
||||
(dataWindow.max.x - dataWindow.min.x) - 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
longitude = 0;
|
||||
}
|
||||
|
||||
return V2f (latitude, longitude);
|
||||
}
|
||||
|
||||
|
||||
V2f
|
||||
pixelPosition (const Box2i &dataWindow, const V2f &latLong)
|
||||
{
|
||||
float x = latLong.y / (-2 * M_PI) + 0.5f;
|
||||
float y = latLong.x / -M_PI + 0.5f;
|
||||
|
||||
return V2f (x * (dataWindow.max.x - dataWindow.min.x) + dataWindow.min.x,
|
||||
y * (dataWindow.max.y - dataWindow.min.y) + dataWindow.min.y);
|
||||
}
|
||||
|
||||
|
||||
V2f
|
||||
pixelPosition (const Box2i &dataWindow, const V3f &direction)
|
||||
{
|
||||
return pixelPosition (dataWindow, latLong (direction));
|
||||
}
|
||||
|
||||
|
||||
V3f
|
||||
direction (const Box2i &dataWindow, const V2f &pixelPosition)
|
||||
{
|
||||
V2f ll = latLong (dataWindow, pixelPosition);
|
||||
|
||||
return V3f (sin (ll.y) * cos (ll.x),
|
||||
sin (ll.x),
|
||||
cos (ll.y) * cos (ll.x));
|
||||
}
|
||||
|
||||
} // namespace LatLongMap
|
||||
|
||||
|
||||
namespace CubeMap {
|
||||
|
||||
int
|
||||
sizeOfFace (const Box2i &dataWindow)
|
||||
{
|
||||
return min ((dataWindow.max.x - dataWindow.min.x + 1),
|
||||
(dataWindow.max.y - dataWindow.min.y + 1) / 6);
|
||||
}
|
||||
|
||||
|
||||
Box2i
|
||||
dataWindowForFace (CubeMapFace face, const Box2i &dataWindow)
|
||||
{
|
||||
int sof = sizeOfFace (dataWindow);
|
||||
Box2i dwf;
|
||||
|
||||
dwf.min.x = 0;
|
||||
dwf.min.y = int (face) * sof;
|
||||
|
||||
dwf.max.x = dwf.min.x + sof - 1;
|
||||
dwf.max.y = dwf.min.y + sof - 1;
|
||||
|
||||
return dwf;
|
||||
}
|
||||
|
||||
|
||||
V2f
|
||||
pixelPosition (CubeMapFace face, const Box2i &dataWindow, V2f positionInFace)
|
||||
{
|
||||
Box2i dwf = dataWindowForFace (face, dataWindow);
|
||||
V2f pos (0, 0);
|
||||
|
||||
switch (face)
|
||||
{
|
||||
case CUBEFACE_POS_X:
|
||||
|
||||
pos.x = dwf.min.x + positionInFace.y;
|
||||
pos.y = dwf.max.y - positionInFace.x;
|
||||
break;
|
||||
|
||||
case CUBEFACE_NEG_X:
|
||||
|
||||
pos.x = dwf.max.x - positionInFace.y;
|
||||
pos.y = dwf.max.y - positionInFace.x;
|
||||
break;
|
||||
|
||||
case CUBEFACE_POS_Y:
|
||||
|
||||
pos.x = dwf.min.x + positionInFace.x;
|
||||
pos.y = dwf.max.y - positionInFace.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_NEG_Y:
|
||||
|
||||
pos.x = dwf.min.x + positionInFace.x;
|
||||
pos.y = dwf.min.y + positionInFace.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_POS_Z:
|
||||
|
||||
pos.x = dwf.max.x - positionInFace.x;
|
||||
pos.y = dwf.max.y - positionInFace.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_NEG_Z:
|
||||
|
||||
pos.x = dwf.min.x + positionInFace.x;
|
||||
pos.y = dwf.max.y - positionInFace.y;
|
||||
break;
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
faceAndPixelPosition (const V3f &direction,
|
||||
const Box2i &dataWindow,
|
||||
CubeMapFace &face,
|
||||
V2f &pif)
|
||||
{
|
||||
int sof = sizeOfFace (dataWindow);
|
||||
float absx = abs (direction.x);
|
||||
float absy = abs (direction.y);
|
||||
float absz = abs (direction.z);
|
||||
|
||||
if (absx >= absy && absx >= absz)
|
||||
{
|
||||
if (absx == 0)
|
||||
{
|
||||
//
|
||||
// Special case - direction is (0, 0, 0)
|
||||
//
|
||||
|
||||
face = CUBEFACE_POS_X;
|
||||
pif = V2f (0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
pif.x = (direction.y / absx + 1) / 2 * (sof - 1);
|
||||
pif.y = (direction.z / absx + 1) / 2 * (sof - 1);
|
||||
|
||||
if (direction.x > 0)
|
||||
face = CUBEFACE_POS_X;
|
||||
else
|
||||
face = CUBEFACE_NEG_X;
|
||||
}
|
||||
else if (absy >= absz)
|
||||
{
|
||||
pif.x = (direction.x / absy + 1) / 2 * (sof - 1);
|
||||
pif.y = (direction.z / absy + 1) / 2 * (sof - 1);
|
||||
|
||||
if (direction.y > 0)
|
||||
face = CUBEFACE_POS_Y;
|
||||
else
|
||||
face = CUBEFACE_NEG_Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
pif.x = (direction.x / absz + 1) / 2 * (sof - 1);
|
||||
pif.y = (direction.y / absz + 1) / 2 * (sof - 1);
|
||||
|
||||
if (direction.z > 0)
|
||||
face = CUBEFACE_POS_Z;
|
||||
else
|
||||
face = CUBEFACE_NEG_Z;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
V3f
|
||||
direction (CubeMapFace face, const Box2i &dataWindow, const V2f &positionInFace)
|
||||
{
|
||||
int sof = sizeOfFace (dataWindow);
|
||||
|
||||
V2f pos;
|
||||
|
||||
if (sof > 1)
|
||||
{
|
||||
pos = V2f (positionInFace.x / (sof - 1) * 2 - 1,
|
||||
positionInFace.y / (sof - 1) * 2 - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = V2f (0, 0);
|
||||
}
|
||||
|
||||
V3f dir (1, 0, 0);
|
||||
|
||||
switch (face)
|
||||
{
|
||||
case CUBEFACE_POS_X:
|
||||
|
||||
dir.x = 1;
|
||||
dir.y = pos.x;
|
||||
dir.z = pos.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_NEG_X:
|
||||
|
||||
dir.x = -1;
|
||||
dir.y = pos.x;
|
||||
dir.z = pos.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_POS_Y:
|
||||
|
||||
dir.x = pos.x;
|
||||
dir.y = 1;
|
||||
dir.z = pos.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_NEG_Y:
|
||||
|
||||
dir.x = pos.x;
|
||||
dir.y = -1;
|
||||
dir.z = pos.y;
|
||||
break;
|
||||
|
||||
case CUBEFACE_POS_Z:
|
||||
|
||||
dir.x = pos.x;
|
||||
dir.y = pos.y;
|
||||
dir.z = 1;
|
||||
break;
|
||||
|
||||
case CUBEFACE_NEG_Z:
|
||||
|
||||
dir.x = pos.x;
|
||||
dir.y = pos.y;
|
||||
dir.z = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
} // namespace CubeMap
|
||||
} // namespace Imf
|
322
3rdparty/openexr/IlmImf/ImfEnvmap.h
vendored
Normal file
322
3rdparty/openexr/IlmImf/ImfEnvmap.h
vendored
Normal file
@ -0,0 +1,322 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_ENVMAP_H
|
||||
#define INCLUDED_IMF_ENVMAP_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Environment maps
|
||||
//
|
||||
// Environment maps define a mapping from 3D directions to 2D
|
||||
// pixel space locations. Environment maps are typically used
|
||||
// in 3D rendering, for effects such as quickly approximating
|
||||
// how shiny surfaces reflect their environment.
|
||||
//
|
||||
// Environment maps can be stored in scanline-based or in tiled
|
||||
// OpenEXR files. The fact that an image is an environment map
|
||||
// is indicated by the presence of an EnvmapAttribute whose name
|
||||
// is "envmap". (Convenience functions to access this attribute
|
||||
// are defined in header file ImfStandardAttributes.h.)
|
||||
// The attribute's value defines the mapping from 3D directions
|
||||
// to 2D pixel space locations.
|
||||
//
|
||||
// This header file defines the set of possible EnvmapAttribute
|
||||
// values.
|
||||
//
|
||||
// For each possible EnvmapAttribute value, this header file also
|
||||
// defines a set of convienience functions to convert between 3D
|
||||
// directions and 2D pixel locations.
|
||||
//
|
||||
// Most of the convenience functions defined below require a
|
||||
// dataWindow parameter. For scanline-based images, and for
|
||||
// tiled images with level mode ONE_LEVEL, the dataWindow
|
||||
// parameter should be set to the image's data window, as
|
||||
// defined in the image header. For tiled images with level
|
||||
// mode MIPMAP_LEVELS or RIPMAP_LEVELS, the data window of the
|
||||
// image level that is being accessed should be used instead.
|
||||
// (See the dataWindowForLevel() methods in ImfTiledInputFile.h
|
||||
// and ImfTiledOutputFile.h.)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathBox.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//--------------------------------
|
||||
// Supported environment map types
|
||||
//--------------------------------
|
||||
|
||||
enum Envmap
|
||||
{
|
||||
ENVMAP_LATLONG = 0, // Latitude-longitude environment map
|
||||
ENVMAP_CUBE = 1, // Cube map
|
||||
|
||||
NUM_ENVMAPTYPES // Number of different environment map types
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Latitude-Longitude Map:
|
||||
//
|
||||
// The environment is projected onto the image using polar coordinates
|
||||
// (latitude and longitude). A pixel's x coordinate corresponds to
|
||||
// its longitude, and the y coordinate corresponds to its latitude.
|
||||
// Pixel (dataWindow.min.x, dataWindow.min.y) has latitude +pi/2 and
|
||||
// longitude +pi; pixel (dataWindow.max.x, dataWindow.max.y) has
|
||||
// latitude -pi/2 and longitude -pi.
|
||||
//
|
||||
// In 3D space, latitudes -pi/2 and +pi/2 correspond to the negative and
|
||||
// positive y direction. Latitude 0, longitude 0 points into positive
|
||||
// z direction; and latitude 0, longitude pi/2 points into positive x
|
||||
// direction.
|
||||
//
|
||||
// The size of the data window should be 2*N by N pixels (width by height),
|
||||
// where N can be any integer greater than 0.
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
namespace LatLongMap
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// Convert a 3D direction to a 2D vector whose x and y
|
||||
// components represent the corresponding latitude
|
||||
// and longitude.
|
||||
//----------------------------------------------------
|
||||
|
||||
Imath::V2f latLong (const Imath::V3f &direction);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Convert the position of a pixel to a 2D vector whose
|
||||
// x and y components represent the corresponding latitude
|
||||
// and longitude.
|
||||
//--------------------------------------------------------
|
||||
|
||||
Imath::V2f latLong (const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &pixelPosition);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Convert a 2D vector, whose x and y components represent
|
||||
// longitude and latitude, into a corresponding pixel position.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
Imath::V2f pixelPosition (const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &latLong);
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Convert a 3D direction vector into a corresponding
|
||||
// pixel position. pixelPosition(dw,dir) is equivalent
|
||||
// to pixelPosition(dw,latLong(dw,dir)).
|
||||
//-----------------------------------------------------
|
||||
|
||||
Imath::V2f pixelPosition (const Imath::Box2i &dataWindow,
|
||||
const Imath::V3f &direction);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Convert the position of a pixel in a latitude-longitude
|
||||
// map into a corresponding 3D direction.
|
||||
//--------------------------------------------------------
|
||||
|
||||
Imath::V3f direction (const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &pixelPosition);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Cube Map:
|
||||
//
|
||||
// The environment is projected onto the six faces of an
|
||||
// axis-aligned cube. The cube's faces are then arranged
|
||||
// in a 2D image as shown below.
|
||||
//
|
||||
// 2-----------3
|
||||
// / /|
|
||||
// / / | Y
|
||||
// / / | |
|
||||
// 6-----------7 | |
|
||||
// | | | |
|
||||
// | | | |
|
||||
// | 0 | 1 *------- X
|
||||
// | | / /
|
||||
// | | / /
|
||||
// | |/ /
|
||||
// 4-----------5 Z
|
||||
//
|
||||
// dataWindow.min
|
||||
// /
|
||||
// /
|
||||
// +-----------+
|
||||
// |3 Y 7|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---Z | +X face
|
||||
// | | |
|
||||
// | | |
|
||||
// |1 5|
|
||||
// +-----------+
|
||||
// |6 Y 2|
|
||||
// | | |
|
||||
// | | |
|
||||
// | Z---+--- | -X face
|
||||
// | | |
|
||||
// | | |
|
||||
// |4 0|
|
||||
// +-----------+
|
||||
// |6 Z 7|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---X | +Y face
|
||||
// | | |
|
||||
// | | |
|
||||
// |2 3|
|
||||
// +-----------+
|
||||
// |0 1|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---X | -Y face
|
||||
// | | |
|
||||
// | | |
|
||||
// |4 Z 5|
|
||||
// +-----------+
|
||||
// |7 Y 6|
|
||||
// | | |
|
||||
// | | |
|
||||
// | X---+--- | +Z face
|
||||
// | | |
|
||||
// | | |
|
||||
// |5 4|
|
||||
// +-----------+
|
||||
// |2 Y 3|
|
||||
// | | |
|
||||
// | | |
|
||||
// | ---+---X | -Z face
|
||||
// | | |
|
||||
// | | |
|
||||
// |0 1|
|
||||
// +-----------+
|
||||
// /
|
||||
// /
|
||||
// dataWindow.max
|
||||
//
|
||||
// The size of the data window should be N by 6*N pixels
|
||||
// (width by height), where N can be any integer greater
|
||||
// than 0.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
//------------------------------------
|
||||
// Names for the six faces of the cube
|
||||
//------------------------------------
|
||||
|
||||
enum CubeMapFace
|
||||
{
|
||||
CUBEFACE_POS_X, // +X face
|
||||
CUBEFACE_NEG_X, // -X face
|
||||
CUBEFACE_POS_Y, // +Y face
|
||||
CUBEFACE_NEG_Y, // -Y face
|
||||
CUBEFACE_POS_Z, // +Z face
|
||||
CUBEFACE_NEG_Z // -Z face
|
||||
};
|
||||
|
||||
namespace CubeMap
|
||||
{
|
||||
//---------------------------------------------
|
||||
// Width and height of a cube's face, in pixels
|
||||
//---------------------------------------------
|
||||
|
||||
int sizeOfFace (const Imath::Box2i &dataWindow);
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// Compute the region in the environment map
|
||||
// that is covered by the specified face.
|
||||
//------------------------------------------
|
||||
|
||||
Imath::Box2i dataWindowForFace (CubeMapFace face,
|
||||
const Imath::Box2i &dataWindow);
|
||||
|
||||
|
||||
//----------------------------------------------------
|
||||
// Convert the coordinates of a pixel within a face
|
||||
// [in the range from (0,0) to (s-1,s-1), where
|
||||
// s == sizeOfFace(dataWindow)] to pixel coordinates
|
||||
// in the environment map.
|
||||
//----------------------------------------------------
|
||||
|
||||
Imath::V2f pixelPosition (CubeMapFace face,
|
||||
const Imath::Box2i &dataWindow,
|
||||
Imath::V2f positionInFace);
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Convert a 3D direction into a cube face, and a pixel position
|
||||
// within that face.
|
||||
//
|
||||
// If you have a 3D direction, dir, the following code fragment
|
||||
// finds the position, pos, of the corresponding pixel in an
|
||||
// environment map with data window dw:
|
||||
//
|
||||
// CubeMapFace f;
|
||||
// V2f pif, pos;
|
||||
//
|
||||
// faceAndPixelPosition (dir, dw, f, pif);
|
||||
// pos = pixelPosition (f, dw, pif);
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void faceAndPixelPosition (const Imath::V3f &direction,
|
||||
const Imath::Box2i &dataWindow,
|
||||
CubeMapFace &face,
|
||||
Imath::V2f &positionInFace);
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// Given a cube face and a pixel position within that face,
|
||||
// compute the corresponding 3D direction.
|
||||
// --------------------------------------------------------
|
||||
|
||||
Imath::V3f direction (CubeMapFace face,
|
||||
const Imath::Box2i &dataWindow,
|
||||
const Imath::V2f &positionInFace);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
75
3rdparty/openexr/IlmImf/ImfEnvmapAttribute.cpp
vendored
Normal file
75
3rdparty/openexr/IlmImf/ImfEnvmapAttribute.cpp
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 EnvmapAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfEnvmapAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
EnvmapAttribute::staticTypeName ()
|
||||
{
|
||||
return "envmap";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
EnvmapAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
unsigned char tmp = _value;
|
||||
Xdr::write <StreamIO> (os, tmp);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
EnvmapAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
unsigned char tmp;
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value = Envmap (tmp);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
65
3rdparty/openexr/IlmImf/ImfEnvmapAttribute.h
vendored
Normal file
65
3rdparty/openexr/IlmImf/ImfEnvmapAttribute.h
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_ENVMAP_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_ENVMAP_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class EnvmapAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfEnvmap.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Envmap> EnvmapAttribute;
|
||||
template <> const char *EnvmapAttribute::staticTypeName ();
|
||||
template <> void EnvmapAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void EnvmapAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfEnvmapAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
57
3rdparty/openexr/IlmImf/ImfFloatAttribute.cpp
vendored
Normal file
57
3rdparty/openexr/IlmImf/ImfFloatAttribute.cpp
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 FloatAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfFloatAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
FloatAttribute::staticTypeName ()
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
63
3rdparty/openexr/IlmImf/ImfFloatAttribute.h
vendored
Normal file
63
3rdparty/openexr/IlmImf/ImfFloatAttribute.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_FLOAT_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_FLOAT_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class FloatAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<float> FloatAttribute;
|
||||
template <> const char *FloatAttribute::staticTypeName ();
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfFloatAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
226
3rdparty/openexr/IlmImf/ImfFrameBuffer.cpp
vendored
Normal file
226
3rdparty/openexr/IlmImf/ImfFrameBuffer.cpp
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 Slice
|
||||
// class FrameBuffer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include "Iex.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Imf {
|
||||
|
||||
Slice::Slice (PixelType t,
|
||||
char *b,
|
||||
size_t xst,
|
||||
size_t yst,
|
||||
int xsm,
|
||||
int ysm,
|
||||
double fv,
|
||||
bool xtc,
|
||||
bool ytc)
|
||||
:
|
||||
type (t),
|
||||
base (b),
|
||||
xStride (xst),
|
||||
yStride (yst),
|
||||
xSampling (xsm),
|
||||
ySampling (ysm),
|
||||
fillValue (fv),
|
||||
xTileCoords (xtc),
|
||||
yTileCoords (ytc)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FrameBuffer::insert (const char name[], const Slice &slice)
|
||||
{
|
||||
if (name[0] == 0)
|
||||
{
|
||||
THROW (Iex::ArgExc,
|
||||
"Frame buffer slice name cannot be an empty string.");
|
||||
}
|
||||
|
||||
_map[name] = slice;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FrameBuffer::insert (const string &name, const Slice &slice)
|
||||
{
|
||||
insert (name.c_str(), slice);
|
||||
}
|
||||
|
||||
|
||||
Slice &
|
||||
FrameBuffer::operator [] (const char name[])
|
||||
{
|
||||
SliceMap::iterator i = _map.find (name);
|
||||
|
||||
if (i == _map.end())
|
||||
{
|
||||
THROW (Iex::ArgExc,
|
||||
"Cannot find frame buffer slice \"" << name << "\".");
|
||||
}
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
const Slice &
|
||||
FrameBuffer::operator [] (const char name[]) const
|
||||
{
|
||||
SliceMap::const_iterator i = _map.find (name);
|
||||
|
||||
if (i == _map.end())
|
||||
{
|
||||
THROW (Iex::ArgExc,
|
||||
"Cannot find frame buffer slice \"" << name << "\".");
|
||||
}
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
Slice &
|
||||
FrameBuffer::operator [] (const string &name)
|
||||
{
|
||||
return this->operator[] (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const Slice &
|
||||
FrameBuffer::operator [] (const string &name) const
|
||||
{
|
||||
return this->operator[] (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
Slice *
|
||||
FrameBuffer::findSlice (const char name[])
|
||||
{
|
||||
SliceMap::iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: &i->second;
|
||||
}
|
||||
|
||||
|
||||
const Slice *
|
||||
FrameBuffer::findSlice (const char name[]) const
|
||||
{
|
||||
SliceMap::const_iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: &i->second;
|
||||
}
|
||||
|
||||
|
||||
Slice *
|
||||
FrameBuffer::findSlice (const string &name)
|
||||
{
|
||||
return findSlice (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const Slice *
|
||||
FrameBuffer::findSlice (const string &name) const
|
||||
{
|
||||
return findSlice (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::Iterator
|
||||
FrameBuffer::begin ()
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::ConstIterator
|
||||
FrameBuffer::begin () const
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::Iterator
|
||||
FrameBuffer::end ()
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::ConstIterator
|
||||
FrameBuffer::end () const
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::Iterator
|
||||
FrameBuffer::find (const char name[])
|
||||
{
|
||||
return _map.find (name);
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::ConstIterator
|
||||
FrameBuffer::find (const char name[]) const
|
||||
{
|
||||
return _map.find (name);
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::Iterator
|
||||
FrameBuffer::find (const string &name)
|
||||
{
|
||||
return find (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
FrameBuffer::ConstIterator
|
||||
FrameBuffer::find (const string &name) const
|
||||
{
|
||||
return find (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
383
3rdparty/openexr/IlmImf/ImfFrameBuffer.h
vendored
Normal file
383
3rdparty/openexr/IlmImf/ImfFrameBuffer.h
vendored
Normal file
@ -0,0 +1,383 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_FRAME_BUFFER_H
|
||||
#define INCLUDED_IMF_FRAME_BUFFER_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Slice
|
||||
// class FrameBuffer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfName.h>
|
||||
#include <ImfPixelType.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Description of a single slice of the frame buffer:
|
||||
//
|
||||
// Note -- terminology: as part of a file, a component of
|
||||
// an image (e.g. red, green, blue, depth etc.) is called
|
||||
// a "channel". As part of a frame buffer, an image
|
||||
// component is called a "slice".
|
||||
//-------------------------------------------------------
|
||||
|
||||
struct Slice
|
||||
{
|
||||
//------------------------------
|
||||
// Data type; see ImfPixelType.h
|
||||
//------------------------------
|
||||
|
||||
PixelType type;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Memory layout: The address of pixel (x, y) is
|
||||
//
|
||||
// base + (xp / xSampling) * xStride + (yp / ySampling) * yStride
|
||||
//
|
||||
// where xp and yp are computed as follows:
|
||||
//
|
||||
// * If we are reading or writing a scanline-based file:
|
||||
//
|
||||
// xp = x
|
||||
// yp = y
|
||||
//
|
||||
// * If we are reading a tile whose upper left coorner is at (xt, yt):
|
||||
//
|
||||
// if xTileCoords is true then xp = x - xt, else xp = x
|
||||
// if yTileCoords is true then yp = y - yt, else yp = y
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
char * base;
|
||||
size_t xStride;
|
||||
size_t yStride;
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
// Subsampling: pixel (x, y) is present in the
|
||||
// slice only if
|
||||
//
|
||||
// x % xSampling == 0 && y % ySampling == 0
|
||||
//
|
||||
//--------------------------------------------
|
||||
|
||||
int xSampling;
|
||||
int ySampling;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Default value, used to fill the slice when a file without
|
||||
// a channel that corresponds to this slice is read.
|
||||
//----------------------------------------------------------
|
||||
|
||||
double fillValue;
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// For tiled files, the xTileCoords and yTileCoords flags
|
||||
// determine whether pixel addressing is performed using
|
||||
// absolute coordinates or coordinates relative to a
|
||||
// tile's upper left corner. (See the comment on base,
|
||||
// xStride and yStride, above.)
|
||||
//
|
||||
// For scanline-based files these flags have no effect;
|
||||
// pixel addressing is always done using absolute
|
||||
// coordinates.
|
||||
//-------------------------------------------------------
|
||||
|
||||
bool xTileCoords;
|
||||
bool yTileCoords;
|
||||
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Slice (PixelType type = HALF,
|
||||
char * base = 0,
|
||||
size_t xStride = 0,
|
||||
size_t yStride = 0,
|
||||
int xSampling = 1,
|
||||
int ySampling = 1,
|
||||
double fillValue = 0.0,
|
||||
bool xTileCoords = false,
|
||||
bool yTileCoords = false);
|
||||
};
|
||||
|
||||
|
||||
class FrameBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Add a slice
|
||||
//------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Slice &slice);
|
||||
|
||||
void insert (const std::string &name,
|
||||
const Slice &slice);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Access to existing slices:
|
||||
//
|
||||
// [n] Returns a reference to the slice with name n.
|
||||
// If no slice with name n exists, an Iex::ArgExc
|
||||
// is thrown.
|
||||
//
|
||||
// findSlice(n) Returns a pointer to the slice with name n,
|
||||
// or 0 if no slice with name n exists.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Slice & operator [] (const char name[]);
|
||||
const Slice & operator [] (const char name[]) const;
|
||||
|
||||
Slice & operator [] (const std::string &name);
|
||||
const Slice & operator [] (const std::string &name) const;
|
||||
|
||||
Slice * findSlice (const char name[]);
|
||||
const Slice * findSlice (const char name[]) const;
|
||||
|
||||
Slice * findSlice (const std::string &name);
|
||||
const Slice * findSlice (const std::string &name) const;
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Iterator-style access to existing slices
|
||||
//-----------------------------------------
|
||||
|
||||
typedef std::map <Name, Slice> SliceMap;
|
||||
|
||||
class Iterator;
|
||||
class ConstIterator;
|
||||
|
||||
Iterator begin ();
|
||||
ConstIterator begin () const;
|
||||
|
||||
Iterator end ();
|
||||
ConstIterator end () const;
|
||||
|
||||
Iterator find (const char name[]);
|
||||
ConstIterator find (const char name[]) const;
|
||||
|
||||
Iterator find (const std::string &name);
|
||||
ConstIterator find (const std::string &name) const;
|
||||
|
||||
private:
|
||||
|
||||
SliceMap _map;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class FrameBuffer::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const FrameBuffer::SliceMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
Slice & slice () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class FrameBuffer::ConstIterator;
|
||||
|
||||
FrameBuffer::SliceMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class FrameBuffer::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const FrameBuffer::SliceMap::const_iterator &i);
|
||||
ConstIterator (const FrameBuffer::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const Slice & slice () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
FrameBuffer::SliceMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
inline
|
||||
FrameBuffer::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
FrameBuffer::Iterator::Iterator (const FrameBuffer::SliceMap::iterator &i):
|
||||
_i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline FrameBuffer::Iterator &
|
||||
FrameBuffer::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline FrameBuffer::Iterator
|
||||
FrameBuffer::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
FrameBuffer::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline Slice &
|
||||
FrameBuffer::Iterator::slice () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
FrameBuffer::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
FrameBuffer::ConstIterator::ConstIterator
|
||||
(const FrameBuffer::SliceMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
FrameBuffer::ConstIterator::ConstIterator (const FrameBuffer::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline FrameBuffer::ConstIterator &
|
||||
FrameBuffer::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline FrameBuffer::ConstIterator
|
||||
FrameBuffer::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
FrameBuffer::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
inline const Slice &
|
||||
FrameBuffer::ConstIterator::slice () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const FrameBuffer::ConstIterator &x,
|
||||
const FrameBuffer::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const FrameBuffer::ConstIterator &x,
|
||||
const FrameBuffer::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
75
3rdparty/openexr/IlmImf/ImfFramesPerSecond.cpp
vendored
Normal file
75
3rdparty/openexr/IlmImf/ImfFramesPerSecond.cpp
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Convenience functions related to the framesPerSecond attribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfFramesPerSecond.h>
|
||||
#include "ImathFun.h"
|
||||
|
||||
using namespace Imath;
|
||||
|
||||
namespace Imf {
|
||||
|
||||
Rational
|
||||
guessExactFps (double fps)
|
||||
{
|
||||
return guessExactFps (Rational (fps));
|
||||
}
|
||||
|
||||
|
||||
Rational
|
||||
guessExactFps (const Rational &fps)
|
||||
{
|
||||
const double e = 0.002;
|
||||
|
||||
if (abs (double (fps) - double (fps_23_976())) < e)
|
||||
return fps_23_976();
|
||||
|
||||
if (abs (double (fps) - double (fps_29_97())) < e)
|
||||
return fps_29_97();
|
||||
|
||||
if (abs (double (fps) - double (fps_47_952())) < e)
|
||||
return fps_47_952();
|
||||
|
||||
if (abs (double (fps) - double (fps_59_94())) < e)
|
||||
return fps_59_94();
|
||||
|
||||
return fps;
|
||||
}
|
||||
|
||||
} // namespace Imf
|
88
3rdparty/openexr/IlmImf/ImfFramesPerSecond.h
vendored
Normal file
88
3rdparty/openexr/IlmImf/ImfFramesPerSecond.h
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006, 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_FRAMES_PER_SECOND_H
|
||||
#define INCLUDED_IMF_FRAMES_PER_SECOND_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Convenience functions related to the framesPerSecond attribute
|
||||
//
|
||||
// Functions that return the exact values for commonly used frame rates:
|
||||
//
|
||||
// name frames per second
|
||||
//
|
||||
// fps_23_976() 23.976023...
|
||||
// fps_24() 24.0 35mm film frames
|
||||
// fps_25() 25.0 PAL video frames
|
||||
// fps_29_97() 29.970029... NTSC video frames
|
||||
// fps_30() 30.0 60Hz HDTV frames
|
||||
// fps_47_952() 47.952047...
|
||||
// fps_48() 48.0
|
||||
// fps_50() 50.0 PAL video fields
|
||||
// fps_59_94() 59.940059... NTSC video fields
|
||||
// fps_60() 60.0 60Hz HDTV fields
|
||||
//
|
||||
// Functions that try to convert inexact frame rates into exact ones:
|
||||
//
|
||||
// Given a frame rate, fps, that is close to one of the pre-defined
|
||||
// frame rates fps_23_976(), fps_29_97(), fps_47_952() or fps_59_94(),
|
||||
// guessExactFps(fps) returns the corresponding pre-defined frame
|
||||
// rate. If fps is not close to one of the pre-defined frame rates,
|
||||
// then guessExactFps(fps) returns Rational(fps).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfRational.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
inline Rational fps_23_976 () {return Rational (24000, 1001);}
|
||||
inline Rational fps_24 () {return Rational (24, 1);}
|
||||
inline Rational fps_25 () {return Rational (25, 1);}
|
||||
inline Rational fps_29_97 () {return Rational (30000, 1001);}
|
||||
inline Rational fps_30 () {return Rational (30, 1);}
|
||||
inline Rational fps_47_952 () {return Rational (48000, 1001);}
|
||||
inline Rational fps_48 () {return Rational (48, 1);}
|
||||
inline Rational fps_50 () {return Rational (50, 1);}
|
||||
inline Rational fps_59_94 () {return Rational (60000, 1001);}
|
||||
inline Rational fps_60 () {return Rational (60, 1);}
|
||||
|
||||
Rational guessExactFps (double fps);
|
||||
Rational guessExactFps (const Rational &fps);
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
1106
3rdparty/openexr/IlmImf/ImfHeader.cpp
vendored
Normal file
1106
3rdparty/openexr/IlmImf/ImfHeader.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
627
3rdparty/openexr/IlmImf/ImfHeader.h
vendored
Normal file
627
3rdparty/openexr/IlmImf/ImfHeader.h
vendored
Normal file
@ -0,0 +1,627 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_HEADER_H
|
||||
#define INCLUDED_IMF_HEADER_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class Header
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfLineOrder.h>
|
||||
#include <ImfCompression.h>
|
||||
#include <ImfName.h>
|
||||
#include <ImfTileDescription.h>
|
||||
#include <ImfInt64.h>
|
||||
#include "ImathVec.h"
|
||||
#include "ImathBox.h"
|
||||
#include "IexBaseExc.h"
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class Attribute;
|
||||
class ChannelList;
|
||||
class IStream;
|
||||
class OStream;
|
||||
class PreviewImage;
|
||||
|
||||
|
||||
class Header
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Default constructor -- the display window and the data window
|
||||
// are both set to Box2i (V2i (0, 0), V2i (width-1, height-1).
|
||||
//----------------------------------------------------------------
|
||||
|
||||
Header (int width = 64,
|
||||
int height = 64,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f &screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression = ZIP_COMPRESSION);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Constructor -- the data window is specified explicitly; the display
|
||||
// window is set to Box2i (V2i (0, 0), V2i (width-1, height-1).
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
Header (int width,
|
||||
int height,
|
||||
const Imath::Box2i &dataWindow,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f &screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression = ZIP_COMPRESSION);
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Constructor -- the display window and the data window are
|
||||
// both specified explicitly.
|
||||
//----------------------------------------------------------
|
||||
|
||||
Header (const Imath::Box2i &displayWindow,
|
||||
const Imath::Box2i &dataWindow,
|
||||
float pixelAspectRatio = 1,
|
||||
const Imath::V2f &screenWindowCenter = Imath::V2f (0, 0),
|
||||
float screenWindowWidth = 1,
|
||||
LineOrder lineOrder = INCREASING_Y,
|
||||
Compression = ZIP_COMPRESSION);
|
||||
|
||||
|
||||
//-----------------
|
||||
// Copy constructor
|
||||
//-----------------
|
||||
|
||||
Header (const Header &other);
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
~Header ();
|
||||
|
||||
|
||||
//-----------
|
||||
// Assignment
|
||||
//-----------
|
||||
|
||||
Header & operator = (const Header &other);
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Add an attribute:
|
||||
//
|
||||
// insert(n,attr) If no attribute with name n exists, a new
|
||||
// attribute with name n, and the same type as
|
||||
// attr, is added, and the value of attr is
|
||||
// copied into the new attribute.
|
||||
//
|
||||
// If an attribute with name n exists, and its
|
||||
// type is the same as attr, the value of attr
|
||||
// is copied into this attribute.
|
||||
//
|
||||
// If an attribute with name n exists, and its
|
||||
// type is different from attr, an Iex::TypeExc
|
||||
// is thrown.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Attribute &attribute);
|
||||
|
||||
void insert (const std::string &name,
|
||||
const Attribute &attribute);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to existing attributes:
|
||||
//
|
||||
// [n] Returns a reference to the attribute
|
||||
// with name n. If no attribute with
|
||||
// name n exists, an Iex::ArgExc is thrown.
|
||||
//
|
||||
// typedAttribute<T>(n) Returns a reference to the attribute
|
||||
// with name n and type T. If no attribute
|
||||
// with name n exists, an Iex::ArgExc is
|
||||
// thrown. If an attribute with name n
|
||||
// exists, but its type is not T, an
|
||||
// Iex::TypeExc is thrown.
|
||||
//
|
||||
// findTypedAttribute<T>(n) Returns a pointer to the attribute with
|
||||
// name n and type T, or 0 if no attribute
|
||||
// with name n and type T exists.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
Attribute & operator [] (const char name[]);
|
||||
const Attribute & operator [] (const char name[]) const;
|
||||
|
||||
Attribute & operator [] (const std::string &name);
|
||||
const Attribute & operator [] (const std::string &name) const;
|
||||
|
||||
template <class T> T& typedAttribute (const char name[]);
|
||||
template <class T> const T& typedAttribute (const char name[]) const;
|
||||
|
||||
template <class T> T& typedAttribute (const std::string &name);
|
||||
template <class T> const T& typedAttribute (const std::string &name) const;
|
||||
|
||||
template <class T> T* findTypedAttribute (const char name[]);
|
||||
template <class T> const T* findTypedAttribute (const char name[]) const;
|
||||
|
||||
template <class T> T* findTypedAttribute (const std::string &name);
|
||||
template <class T> const T* findTypedAttribute (const std::string &name)
|
||||
const;
|
||||
|
||||
//---------------------------------------------
|
||||
// Iterator-style access to existing attributes
|
||||
//---------------------------------------------
|
||||
|
||||
typedef std::map <Name, Attribute *> AttributeMap;
|
||||
|
||||
class Iterator;
|
||||
class ConstIterator;
|
||||
|
||||
Iterator begin ();
|
||||
ConstIterator begin () const;
|
||||
|
||||
Iterator end ();
|
||||
ConstIterator end () const;
|
||||
|
||||
Iterator find (const char name[]);
|
||||
ConstIterator find (const char name[]) const;
|
||||
|
||||
Iterator find (const std::string &name);
|
||||
ConstIterator find (const std::string &name) const;
|
||||
|
||||
|
||||
//--------------------------------
|
||||
// Access to predefined attributes
|
||||
//--------------------------------
|
||||
|
||||
Imath::Box2i & displayWindow ();
|
||||
const Imath::Box2i & displayWindow () const;
|
||||
|
||||
Imath::Box2i & dataWindow ();
|
||||
const Imath::Box2i & dataWindow () const;
|
||||
|
||||
float & pixelAspectRatio ();
|
||||
const float & pixelAspectRatio () const;
|
||||
|
||||
Imath::V2f & screenWindowCenter ();
|
||||
const Imath::V2f & screenWindowCenter () const;
|
||||
|
||||
float & screenWindowWidth ();
|
||||
const float & screenWindowWidth () const;
|
||||
|
||||
ChannelList & channels ();
|
||||
const ChannelList & channels () const;
|
||||
|
||||
LineOrder & lineOrder ();
|
||||
const LineOrder & lineOrder () const;
|
||||
|
||||
Compression & compression ();
|
||||
const Compression & compression () const;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Tile Description:
|
||||
//
|
||||
// The tile description is a TileDescriptionAttribute whose name
|
||||
// is "tiles". The "tiles" attribute must be present in any tiled
|
||||
// image file. When present, it describes various properties of the
|
||||
// tiles that make up the file.
|
||||
//
|
||||
// Convenience functions:
|
||||
//
|
||||
// setTileDescription(td)
|
||||
// calls insert ("tiles", TileDescriptionAttribute (td))
|
||||
//
|
||||
// tileDescription()
|
||||
// returns typedAttribute<TileDescriptionAttribute>("tiles").value()
|
||||
//
|
||||
// hasTileDescription()
|
||||
// return findTypedAttribute<TileDescriptionAttribute>("tiles") != 0
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void setTileDescription (const TileDescription & td);
|
||||
|
||||
TileDescription & tileDescription ();
|
||||
const TileDescription & tileDescription () const;
|
||||
|
||||
bool hasTileDescription() const;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Preview image:
|
||||
//
|
||||
// The preview image is a PreviewImageAttribute whose name is "preview".
|
||||
// This attribute is special -- while an image file is being written,
|
||||
// the pixels of the preview image can be changed repeatedly by calling
|
||||
// OutputFile::updatePreviewImage().
|
||||
//
|
||||
// Convenience functions:
|
||||
//
|
||||
// setPreviewImage(p)
|
||||
// calls insert ("preview", PreviewImageAttribute (p))
|
||||
//
|
||||
// previewImage()
|
||||
// returns typedAttribute<PreviewImageAttribute>("preview").value()
|
||||
//
|
||||
// hasPreviewImage()
|
||||
// return findTypedAttribute<PreviewImageAttribute>("preview") != 0
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void setPreviewImage (const PreviewImage &p);
|
||||
|
||||
PreviewImage & previewImage ();
|
||||
const PreviewImage & previewImage () const;
|
||||
|
||||
bool hasPreviewImage () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Sanity check -- examines the header, and throws an exception
|
||||
// if it finds something wrong (empty display window, negative
|
||||
// pixel aspect ratio, unknown compression sceme etc.)
|
||||
//
|
||||
// set isTiled to true if you are checking a tiled/multi-res
|
||||
// header
|
||||
//-------------------------------------------------------------
|
||||
|
||||
void sanityCheck (bool isTiled = false) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Maximum image size and maximim tile size:
|
||||
//
|
||||
// sanityCheck() will throw an exception if the width or height of
|
||||
// the data window exceeds the maximum image width or height, or
|
||||
// if the size of a tile exceeds the maximum tile width or height.
|
||||
//
|
||||
// At program startup the maximum image and tile width and height
|
||||
// are set to zero, meaning that width and height are unlimited.
|
||||
//
|
||||
// Limiting image and tile width and height limits how much memory
|
||||
// will be allocated when a file is opened. This can help protect
|
||||
// applications from running out of memory while trying to read
|
||||
// a damaged image file.
|
||||
//----------------------------------------------------------------
|
||||
|
||||
static void setMaxImageSize (int maxWidth, int maxHeight);
|
||||
static void setMaxTileSize (int maxWidth, int maxHeight);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Input and output:
|
||||
//
|
||||
// If the header contains a preview image attribute, then writeTo()
|
||||
// returns the position of that attribute in the output stream; this
|
||||
// information is used by OutputFile::updatePreviewImage().
|
||||
// If the header contains no preview image attribute, then writeTo()
|
||||
// returns 0.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
Int64 writeTo (OStream &os,
|
||||
bool isTiled = false) const;
|
||||
|
||||
void readFrom (IStream &is, int &version);
|
||||
|
||||
private:
|
||||
|
||||
AttributeMap _map;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class Header::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const Header::AttributeMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
Attribute & attribute () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class Header::ConstIterator;
|
||||
|
||||
Header::AttributeMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class Header::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const Header::AttributeMap::const_iterator &i);
|
||||
ConstIterator (const Header::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const Attribute & attribute () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
Header::AttributeMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Library initialization:
|
||||
//
|
||||
// In a multithreaded program, staticInitialize() must be called once
|
||||
// during startup, before the program accesses any other functions or
|
||||
// classes in the IlmImf library. Calling staticInitialize() in this
|
||||
// way avoids races during initialization of the library's global
|
||||
// variables.
|
||||
//
|
||||
// Single-threaded programs are not required to call staticInitialize();
|
||||
// initialization of the library's global variables happens automatically.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void staticInitialize ();
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
|
||||
inline
|
||||
Header::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Header::Iterator::Iterator (const Header::AttributeMap::iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline Header::Iterator &
|
||||
Header::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Header::Iterator
|
||||
Header::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
Header::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline Attribute &
|
||||
Header::Iterator::attribute () const
|
||||
{
|
||||
return *_i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Header::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
Header::ConstIterator::ConstIterator
|
||||
(const Header::AttributeMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Header::ConstIterator::ConstIterator (const Header::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline Header::ConstIterator &
|
||||
Header::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline Header::ConstIterator
|
||||
Header::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
Header::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline const Attribute &
|
||||
Header::ConstIterator::attribute () const
|
||||
{
|
||||
return *_i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const Header::ConstIterator &x, const Header::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const Header::ConstIterator &x, const Header::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
//---------------------
|
||||
// Template definitions
|
||||
//---------------------
|
||||
|
||||
template <class T>
|
||||
T &
|
||||
Header::typedAttribute (const char name[])
|
||||
{
|
||||
Attribute *attr = &(*this)[name];
|
||||
T *tattr = dynamic_cast <T*> (attr);
|
||||
|
||||
if (tattr == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return *tattr;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const T &
|
||||
Header::typedAttribute (const char name[]) const
|
||||
{
|
||||
const Attribute *attr = &(*this)[name];
|
||||
const T *tattr = dynamic_cast <const T*> (attr);
|
||||
|
||||
if (tattr == 0)
|
||||
throw Iex::TypeExc ("Unexpected attribute type.");
|
||||
|
||||
return *tattr;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T &
|
||||
Header::typedAttribute (const std::string &name)
|
||||
{
|
||||
return typedAttribute<T> (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const T &
|
||||
Header::typedAttribute (const std::string &name) const
|
||||
{
|
||||
return typedAttribute<T> (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T *
|
||||
Header::findTypedAttribute (const char name[])
|
||||
{
|
||||
AttributeMap::iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: dynamic_cast <T*> (i->second);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const T *
|
||||
Header::findTypedAttribute (const char name[]) const
|
||||
{
|
||||
AttributeMap::const_iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: dynamic_cast <const T*> (i->second);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T *
|
||||
Header::findTypedAttribute (const std::string &name)
|
||||
{
|
||||
return findTypedAttribute<T> (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const T *
|
||||
Header::findTypedAttribute (const std::string &name) const
|
||||
{
|
||||
return findTypedAttribute<T> (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
1086
3rdparty/openexr/IlmImf/ImfHuf.cpp
vendored
Normal file
1086
3rdparty/openexr/IlmImf/ImfHuf.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
79
3rdparty/openexr/IlmImf/ImfHuf.h
vendored
Normal file
79
3rdparty/openexr/IlmImf/ImfHuf.h
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_HUF_H
|
||||
#define INCLUDED_IMF_HUF_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// 16-bit Huffman compression and decompression:
|
||||
//
|
||||
// hufCompress (r, nr, c)
|
||||
//
|
||||
// Compresses the contents of array r (of length nr),
|
||||
// stores the compressed data in array c, and returns
|
||||
// the size of the compressed data (in bytes).
|
||||
//
|
||||
// To avoid buffer overflows, the size of array c should
|
||||
// be at least 2 * nr + 65536.
|
||||
//
|
||||
// hufUncompress (c, nc, r, nr)
|
||||
//
|
||||
// Uncompresses the data in array c (with length nc),
|
||||
// and stores the results in array r (with length nr).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
int
|
||||
hufCompress (const unsigned short raw[/*nRaw*/],
|
||||
int nRaw,
|
||||
char compressed[/*2 * nRaw + 65536*/]);
|
||||
|
||||
|
||||
void
|
||||
hufUncompress (const char compressed[/*nCompressed*/],
|
||||
int nCompressed,
|
||||
unsigned short raw[/*nRaw*/],
|
||||
int nRaw);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
109
3rdparty/openexr/IlmImf/ImfIO.cpp
vendored
Normal file
109
3rdparty/openexr/IlmImf/ImfIO.cpp
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Low-level file input and output for OpenEXR.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfIO.h>
|
||||
#include "Iex.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
IStream::IStream (const char fileName[]): _fileName (fileName)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
IStream::~IStream ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
IStream::isMemoryMapped () const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
IStream::readMemoryMapped (int n)
|
||||
{
|
||||
throw Iex::InputExc ("Attempt to perform a memory-mapped read "
|
||||
"on a file that is not memory mapped.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
IStream::clear ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
IStream::fileName () const
|
||||
{
|
||||
return _fileName.c_str();
|
||||
}
|
||||
|
||||
|
||||
OStream::OStream (const char fileName[]): _fileName (fileName)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
OStream::~OStream ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
OStream::fileName () const
|
||||
{
|
||||
return _fileName.c_str();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
252
3rdparty/openexr/IlmImf/ImfIO.h
vendored
Normal file
252
3rdparty/openexr/IlmImf/ImfIO.h
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_IO_H
|
||||
#define INCLUDED_IMF_IO_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Low-level file input and output for OpenEXR.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfInt64.h>
|
||||
#include <string>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// class IStream -- an abstract base class for input streams.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
class IStream
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~IStream ();
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Does this input stream support memory-mapped IO?
|
||||
//
|
||||
// Memory-mapped streams can avoid an extra copy;
|
||||
// memory-mapped read operations return a pointer
|
||||
// to an internal buffer instead of copying data
|
||||
// into a buffer supplied by the caller.
|
||||
//-------------------------------------------------
|
||||
|
||||
virtual bool isMemoryMapped () const;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Read from the stream:
|
||||
//
|
||||
// read(c,n) reads n bytes from the stream, and stores
|
||||
// them in array c. If the stream contains less than n
|
||||
// bytes, or if an I/O error occurs, read(c,n) throws
|
||||
// an exception. If read(c,n) reads the last byte from
|
||||
// the file it returns false, otherwise it returns true.
|
||||
//------------------------------------------------------
|
||||
|
||||
virtual bool read (char c[/*n*/], int n) = 0;
|
||||
|
||||
|
||||
//---------------------------------------------------
|
||||
// Read from a memory-mapped stream:
|
||||
//
|
||||
// readMemoryMapped(n) reads n bytes from the stream
|
||||
// and returns a pointer to the first byte. The
|
||||
// returned pointer remains valid until the stream
|
||||
// is closed. If there are less than n byte left to
|
||||
// read in the stream or if the stream is not memory-
|
||||
// mapped, readMemoryMapped(n) throws an exception.
|
||||
//---------------------------------------------------
|
||||
|
||||
virtual char * readMemoryMapped (int n);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Get the current reading position, in bytes from the
|
||||
// beginning of the file. If the next call to read() will
|
||||
// read the first byte in the file, tellg() returns 0.
|
||||
//--------------------------------------------------------
|
||||
|
||||
virtual Int64 tellg () = 0;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Set the current reading position.
|
||||
// After calling seekg(i), tellg() returns i.
|
||||
//-------------------------------------------
|
||||
|
||||
virtual void seekg (Int64 pos) = 0;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Clear error conditions after an operation has failed.
|
||||
//------------------------------------------------------
|
||||
|
||||
virtual void clear ();
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Get the name of the file associated with this stream.
|
||||
//------------------------------------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
protected:
|
||||
|
||||
IStream (const char fileName[]);
|
||||
|
||||
private:
|
||||
|
||||
IStream (const IStream &); // not implemented
|
||||
IStream & operator = (const IStream &); // not implemented
|
||||
|
||||
std::string _fileName;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// class OStream -- an abstract base class for output streams
|
||||
//-----------------------------------------------------------
|
||||
|
||||
class OStream
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~OStream ();
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Write to the stream:
|
||||
//
|
||||
// write(c,n) takes n bytes from array c, and stores them
|
||||
// in the stream. If an I/O error occurs, write(c,n) throws
|
||||
// an exception.
|
||||
//----------------------------------------------------------
|
||||
|
||||
virtual void write (const char c[/*n*/], int n) = 0;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Get the current writing position, in bytes from the
|
||||
// beginning of the file. If the next call to write() will
|
||||
// start writing at the beginning of the file, tellp()
|
||||
// returns 0.
|
||||
//---------------------------------------------------------
|
||||
|
||||
virtual Int64 tellp () = 0;
|
||||
|
||||
|
||||
//-------------------------------------------
|
||||
// Set the current writing position.
|
||||
// After calling seekp(i), tellp() returns i.
|
||||
//-------------------------------------------
|
||||
|
||||
virtual void seekp (Int64 pos) = 0;
|
||||
|
||||
|
||||
//------------------------------------------------------
|
||||
// Get the name of the file associated with this stream.
|
||||
//------------------------------------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
protected:
|
||||
|
||||
OStream (const char fileName[]);
|
||||
|
||||
private:
|
||||
|
||||
OStream (const OStream &); // not implemented
|
||||
OStream & operator = (const OStream &); // not implemented
|
||||
|
||||
std::string _fileName;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------
|
||||
// Helper classes for Xdr
|
||||
//-----------------------
|
||||
|
||||
struct StreamIO
|
||||
{
|
||||
static void
|
||||
writeChars (OStream &os, const char c[/*n*/], int n)
|
||||
{
|
||||
os.write (c, n);
|
||||
}
|
||||
|
||||
static bool
|
||||
readChars (IStream &is, char c[/*n*/], int n)
|
||||
{
|
||||
return is.read (c, n);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct CharPtrIO
|
||||
{
|
||||
static void
|
||||
writeChars (char *&op, const char c[/*n*/], int n)
|
||||
{
|
||||
while (n--)
|
||||
*op++ = *c++;
|
||||
}
|
||||
|
||||
static bool
|
||||
readChars (const char *&ip, char c[/*n*/], int n)
|
||||
{
|
||||
while (n--)
|
||||
*c++ = *ip++;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
648
3rdparty/openexr/IlmImf/ImfInputFile.cpp
vendored
Normal file
648
3rdparty/openexr/IlmImf/ImfInputFile.cpp
vendored
Normal file
@ -0,0 +1,648 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 InputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfInputFile.h>
|
||||
#include <ImfScanLineInputFile.h>
|
||||
#include <ImfTiledInputFile.h>
|
||||
#include <ImfChannelList.h>
|
||||
#include <ImfMisc.h>
|
||||
#include <ImfStdIO.h>
|
||||
#include <ImfVersion.h>
|
||||
#include "ImathFun.h"
|
||||
#include "IlmThreadMutex.h"
|
||||
#include "Iex.h"
|
||||
#include "half.h"
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
using Imath::Box2i;
|
||||
using Imath::divp;
|
||||
using Imath::modp;
|
||||
using IlmThread::Mutex;
|
||||
using IlmThread::Lock;
|
||||
|
||||
|
||||
//
|
||||
// Struct InputFile::Data stores things that will be
|
||||
// needed between calls to readPixels
|
||||
//
|
||||
|
||||
struct InputFile::Data: public Mutex
|
||||
{
|
||||
Header header;
|
||||
int version;
|
||||
IStream * is;
|
||||
bool deleteStream;
|
||||
|
||||
TiledInputFile * tFile;
|
||||
ScanLineInputFile * sFile;
|
||||
|
||||
LineOrder lineOrder; // the file's lineorder
|
||||
int minY; // data window's min y coord
|
||||
int maxY; // data window's max x coord
|
||||
|
||||
FrameBuffer tFileBuffer;
|
||||
FrameBuffer * cachedBuffer;
|
||||
|
||||
int cachedTileY;
|
||||
int offset;
|
||||
|
||||
int numThreads;
|
||||
|
||||
Data (bool del, int numThreads);
|
||||
~Data ();
|
||||
|
||||
void deleteCachedBuffer();
|
||||
};
|
||||
|
||||
|
||||
InputFile::Data::Data (bool del, int numThreads):
|
||||
is (0),
|
||||
deleteStream (del),
|
||||
tFile (0),
|
||||
sFile (0),
|
||||
cachedBuffer (0),
|
||||
cachedTileY (-1),
|
||||
numThreads (numThreads)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
InputFile::Data::~Data ()
|
||||
{
|
||||
delete tFile;
|
||||
delete sFile;
|
||||
|
||||
if (deleteStream)
|
||||
delete is;
|
||||
|
||||
deleteCachedBuffer();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::Data::deleteCachedBuffer()
|
||||
{
|
||||
//
|
||||
// Delete the cached frame buffer, and all memory
|
||||
// allocated for the slices in the cached frameBuffer.
|
||||
//
|
||||
|
||||
if (cachedBuffer)
|
||||
{
|
||||
for (FrameBuffer::Iterator k = cachedBuffer->begin();
|
||||
k != cachedBuffer->end();
|
||||
++k)
|
||||
{
|
||||
Slice &s = k.slice();
|
||||
|
||||
switch (s.type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
delete [] (((unsigned int *)s.base) + offset);
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
delete [] ((half *)s.base + offset);
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
delete [] (((float *)s.base) + offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// delete the cached frame buffer
|
||||
//
|
||||
|
||||
delete cachedBuffer;
|
||||
cachedBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
bufferedReadPixels (InputFile::Data* ifd, int scanLine1, int scanLine2)
|
||||
{
|
||||
//
|
||||
// bufferedReadPixels reads each row of tiles that intersect the
|
||||
// scan-line range (scanLine1 to scanLine2). The previous row of
|
||||
// tiles is cached in order to prevent redundent tile reads when
|
||||
// accessing scanlines sequentially.
|
||||
//
|
||||
|
||||
int minY = std::min (scanLine1, scanLine2);
|
||||
int maxY = std::max (scanLine1, scanLine2);
|
||||
|
||||
if (minY < ifd->minY || maxY > ifd->maxY)
|
||||
{
|
||||
throw Iex::ArgExc ("Tried to read scan line outside "
|
||||
"the image file's data window.");
|
||||
}
|
||||
|
||||
//
|
||||
// The minimum and maximum y tile coordinates that intersect this
|
||||
// scanline range
|
||||
//
|
||||
|
||||
int minDy = (minY - ifd->minY) / ifd->tFile->tileYSize();
|
||||
int maxDy = (maxY - ifd->minY) / ifd->tFile->tileYSize();
|
||||
|
||||
//
|
||||
// Figure out which one is first in the file so we can read without seeking
|
||||
//
|
||||
|
||||
int yStart, yEnd, yStep;
|
||||
|
||||
if (ifd->lineOrder == DECREASING_Y)
|
||||
{
|
||||
yStart = maxDy;
|
||||
yEnd = minDy - 1;
|
||||
yStep = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
yStart = minDy;
|
||||
yEnd = maxDy + 1;
|
||||
yStep = 1;
|
||||
}
|
||||
|
||||
//
|
||||
// the number of pixels in a row of tiles
|
||||
//
|
||||
|
||||
Box2i levelRange = ifd->tFile->dataWindowForLevel(0);
|
||||
|
||||
//
|
||||
// Read the tiles into our temporary framebuffer and copy them into
|
||||
// the user's buffer
|
||||
//
|
||||
|
||||
for (int j = yStart; j != yEnd; j += yStep)
|
||||
{
|
||||
Box2i tileRange = ifd->tFile->dataWindowForTile (0, j, 0);
|
||||
|
||||
int minYThisRow = std::max (minY, tileRange.min.y);
|
||||
int maxYThisRow = std::min (maxY, tileRange.max.y);
|
||||
|
||||
if (j != ifd->cachedTileY)
|
||||
{
|
||||
//
|
||||
// We don't have any valid buffered info, so we need to read in
|
||||
// from the file.
|
||||
//
|
||||
|
||||
ifd->tFile->readTiles (0, ifd->tFile->numXTiles (0) - 1, j, j);
|
||||
ifd->cachedTileY = j;
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the data from our cached framebuffer into the user's
|
||||
// framebuffer.
|
||||
//
|
||||
|
||||
for (FrameBuffer::ConstIterator k = ifd->cachedBuffer->begin();
|
||||
k != ifd->cachedBuffer->end();
|
||||
++k)
|
||||
{
|
||||
Slice fromSlice = k.slice(); // slice to write from
|
||||
Slice toSlice = ifd->tFileBuffer[k.name()]; // slice to write to
|
||||
|
||||
char *fromPtr, *toPtr;
|
||||
int size = pixelTypeSize (toSlice.type);
|
||||
|
||||
int xStart = levelRange.min.x;
|
||||
int yStart = minYThisRow;
|
||||
|
||||
while (modp (xStart, toSlice.xSampling) != 0)
|
||||
++xStart;
|
||||
|
||||
while (modp (yStart, toSlice.ySampling) != 0)
|
||||
++yStart;
|
||||
|
||||
for (int y = yStart;
|
||||
y <= maxYThisRow;
|
||||
y += toSlice.ySampling)
|
||||
{
|
||||
//
|
||||
// Set the pointers to the start of the y scanline in
|
||||
// this row of tiles
|
||||
//
|
||||
|
||||
fromPtr = fromSlice.base +
|
||||
(y - tileRange.min.y) * fromSlice.yStride +
|
||||
xStart * fromSlice.xStride;
|
||||
|
||||
toPtr = toSlice.base +
|
||||
divp (y, toSlice.ySampling) * toSlice.yStride +
|
||||
divp (xStart, toSlice.xSampling) * toSlice.xStride;
|
||||
|
||||
//
|
||||
// Copy all pixels for the scanline in this row of tiles
|
||||
//
|
||||
|
||||
for (int x = xStart;
|
||||
x <= levelRange.max.x;
|
||||
x += toSlice.xSampling)
|
||||
{
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
toPtr[i] = fromPtr[i];
|
||||
|
||||
fromPtr += fromSlice.xStride * toSlice.xSampling;
|
||||
toPtr += toSlice.xStride;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
InputFile::InputFile (const char fileName[], int numThreads):
|
||||
_data (new Data (true, numThreads))
|
||||
{
|
||||
try
|
||||
{
|
||||
_data->is = new StdIFStream (fileName);
|
||||
initialize();
|
||||
}
|
||||
catch (Iex::BaseExc &e)
|
||||
{
|
||||
delete _data;
|
||||
|
||||
REPLACE_EXC (e, "Cannot read image file "
|
||||
"\"" << fileName << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
delete _data;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InputFile::InputFile (IStream &is, int numThreads):
|
||||
_data (new Data (false, numThreads))
|
||||
{
|
||||
try
|
||||
{
|
||||
_data->is = &is;
|
||||
initialize();
|
||||
}
|
||||
catch (Iex::BaseExc &e)
|
||||
{
|
||||
delete _data;
|
||||
|
||||
REPLACE_EXC (e, "Cannot read image file "
|
||||
"\"" << is.fileName() << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
delete _data;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::initialize ()
|
||||
{
|
||||
_data->header.readFrom (*_data->is, _data->version);
|
||||
_data->header.sanityCheck (isTiled (_data->version));
|
||||
|
||||
if (isTiled (_data->version))
|
||||
{
|
||||
_data->lineOrder = _data->header.lineOrder();
|
||||
|
||||
//
|
||||
// Save the dataWindow information
|
||||
//
|
||||
|
||||
const Box2i &dataWindow = _data->header.dataWindow();
|
||||
_data->minY = dataWindow.min.y;
|
||||
_data->maxY = dataWindow.max.y;
|
||||
|
||||
_data->tFile = new TiledInputFile (_data->header,
|
||||
_data->is,
|
||||
_data->version,
|
||||
_data->numThreads);
|
||||
}
|
||||
else
|
||||
{
|
||||
_data->sFile = new ScanLineInputFile (_data->header,
|
||||
_data->is,
|
||||
_data->numThreads);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InputFile::~InputFile ()
|
||||
{
|
||||
delete _data;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
InputFile::fileName () const
|
||||
{
|
||||
return _data->is->fileName();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
InputFile::header () const
|
||||
{
|
||||
return _data->header;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
InputFile::version () const
|
||||
{
|
||||
return _data->version;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
|
||||
{
|
||||
if (isTiled (_data->version))
|
||||
{
|
||||
Lock lock (*_data);
|
||||
|
||||
//
|
||||
// We must invalidate the cached buffer if the new frame
|
||||
// buffer has a different set of channels than the old
|
||||
// frame buffer, or if the type of a channel has changed.
|
||||
//
|
||||
|
||||
const FrameBuffer &oldFrameBuffer = _data->tFileBuffer;
|
||||
|
||||
FrameBuffer::ConstIterator i = oldFrameBuffer.begin();
|
||||
FrameBuffer::ConstIterator j = frameBuffer.begin();
|
||||
|
||||
while (i != oldFrameBuffer.end() && j != frameBuffer.end())
|
||||
{
|
||||
if (strcmp (i.name(), j.name()) || i.slice().type != j.slice().type)
|
||||
break;
|
||||
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
|
||||
if (i != oldFrameBuffer.end() || j != frameBuffer.end())
|
||||
{
|
||||
//
|
||||
// Invalidate the cached buffer.
|
||||
//
|
||||
|
||||
_data->deleteCachedBuffer ();
|
||||
_data->cachedTileY = -1;
|
||||
|
||||
//
|
||||
// Create new a cached frame buffer. It can hold a single
|
||||
// row of tiles. The cached buffer can be reused for each
|
||||
// row of tiles because we set the yTileCoords parameter of
|
||||
// each Slice to true.
|
||||
//
|
||||
|
||||
const Box2i &dataWindow = _data->header.dataWindow();
|
||||
_data->cachedBuffer = new FrameBuffer();
|
||||
_data->offset = dataWindow.min.x;
|
||||
|
||||
int tileRowSize = (dataWindow.max.x - dataWindow.min.x + 1) *
|
||||
_data->tFile->tileYSize();
|
||||
|
||||
for (FrameBuffer::ConstIterator k = frameBuffer.begin();
|
||||
k != frameBuffer.end();
|
||||
++k)
|
||||
{
|
||||
Slice s = k.slice();
|
||||
|
||||
switch (s.type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
_data->cachedBuffer->insert
|
||||
(k.name(),
|
||||
Slice (UINT,
|
||||
(char *)(new unsigned int[tileRowSize] -
|
||||
_data->offset),
|
||||
sizeof (unsigned int),
|
||||
sizeof (unsigned int) *
|
||||
_data->tFile->levelWidth(0),
|
||||
1, 1,
|
||||
s.fillValue,
|
||||
false, true));
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
_data->cachedBuffer->insert
|
||||
(k.name(),
|
||||
Slice (HALF,
|
||||
(char *)(new half[tileRowSize] -
|
||||
_data->offset),
|
||||
sizeof (half),
|
||||
sizeof (half) *
|
||||
_data->tFile->levelWidth(0),
|
||||
1, 1,
|
||||
s.fillValue,
|
||||
false, true));
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
_data->cachedBuffer->insert
|
||||
(k.name(),
|
||||
Slice (FLOAT,
|
||||
(char *)(new float[tileRowSize] -
|
||||
_data->offset),
|
||||
sizeof(float),
|
||||
sizeof(float) *
|
||||
_data->tFile->levelWidth(0),
|
||||
1, 1,
|
||||
s.fillValue,
|
||||
false, true));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
|
||||
_data->tFile->setFrameBuffer (*_data->cachedBuffer);
|
||||
}
|
||||
|
||||
_data->tFileBuffer = frameBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
_data->sFile->setFrameBuffer (frameBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const FrameBuffer &
|
||||
InputFile::frameBuffer () const
|
||||
{
|
||||
if (isTiled (_data->version))
|
||||
{
|
||||
Lock lock (*_data);
|
||||
return _data->tFileBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _data->sFile->frameBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
InputFile::isComplete () const
|
||||
{
|
||||
if (isTiled (_data->version))
|
||||
return _data->tFile->isComplete();
|
||||
else
|
||||
return _data->sFile->isComplete();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::readPixels (int scanLine1, int scanLine2)
|
||||
{
|
||||
if (isTiled (_data->version))
|
||||
{
|
||||
Lock lock (*_data);
|
||||
bufferedReadPixels (_data, scanLine1, scanLine2);
|
||||
}
|
||||
else
|
||||
{
|
||||
_data->sFile->readPixels (scanLine1, scanLine2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::readPixels (int scanLine)
|
||||
{
|
||||
readPixels (scanLine, scanLine);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::rawPixelData (int firstScanLine,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isTiled (_data->version))
|
||||
{
|
||||
throw Iex::ArgExc ("Tried to read a raw scanline "
|
||||
"from a tiled image.");
|
||||
}
|
||||
|
||||
_data->sFile->rawPixelData (firstScanLine, pixelData, pixelDataSize);
|
||||
}
|
||||
catch (Iex::BaseExc &e)
|
||||
{
|
||||
REPLACE_EXC (e, "Error reading pixel data from image "
|
||||
"file \"" << fileName() << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::rawTileData (int &dx, int &dy,
|
||||
int &lx, int &ly,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!isTiled (_data->version))
|
||||
{
|
||||
throw Iex::ArgExc ("Tried to read a raw tile "
|
||||
"from a scanline-based image.");
|
||||
}
|
||||
|
||||
_data->tFile->rawTileData (dx, dy, lx, ly, pixelData, pixelDataSize);
|
||||
}
|
||||
catch (Iex::BaseExc &e)
|
||||
{
|
||||
REPLACE_EXC (e, "Error reading tile data from image "
|
||||
"file \"" << fileName() << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiledInputFile*
|
||||
InputFile::tFile()
|
||||
{
|
||||
if (!isTiled (_data->version))
|
||||
{
|
||||
throw Iex::ArgExc ("Cannot get a TiledInputFile pointer "
|
||||
"from an InputFile that is not tiled.");
|
||||
}
|
||||
|
||||
return _data->tFile;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
209
3rdparty/openexr/IlmImf/ImfInputFile.h
vendored
Normal file
209
3rdparty/openexr/IlmImf/ImfInputFile.h
vendored
Normal file
@ -0,0 +1,209 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_INPUT_FILE_H
|
||||
#define INCLUDED_IMF_INPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class InputFile -- a scanline-based interface that can be used
|
||||
// to read both scanline-based and tiled OpenEXR image files.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImfTiledOutputFile.h>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class TiledInputFile;
|
||||
class ScanLineInputFile;
|
||||
|
||||
|
||||
class InputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// A constructor that opens the file with the specified name.
|
||||
// Destroying the InputFile object will close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to read the file (see ImfThreading.h).
|
||||
//-----------------------------------------------------------
|
||||
|
||||
InputFile (const char fileName[], int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// A constructor that attaches the new InputFile object to a
|
||||
// file that has already been opened. Destroying the InputFile
|
||||
// object will not close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to read the file (see ImfThreading.h).
|
||||
//-------------------------------------------------------------
|
||||
|
||||
InputFile (IStream &is, int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~InputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// Access to the file name
|
||||
//------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
|
||||
|
||||
//----------------------------------
|
||||
// Access to the file format version
|
||||
//----------------------------------
|
||||
|
||||
int version () const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Set the current frame buffer -- copies the FrameBuffer
|
||||
// object into the InputFile object.
|
||||
//
|
||||
// The current frame buffer is the destination for the pixel
|
||||
// data read from the file. The current frame buffer must be
|
||||
// set at least once before readPixels() is called.
|
||||
// The current frame buffer can be changed after each call
|
||||
// to readPixels().
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Check if the file is complete:
|
||||
//
|
||||
// isComplete() returns true if all pixels in the data window are
|
||||
// present in the input file, or false if any pixels are missing.
|
||||
// (Another program may still be busy writing the file, or file
|
||||
// writing may have been aborted prematurely.)
|
||||
//---------------------------------------------------------------
|
||||
|
||||
bool isComplete () const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Read pixel data:
|
||||
//
|
||||
// readPixels(s1,s2) reads all scan lines with y coordinates
|
||||
// in the interval [min (s1, s2), max (s1, s2)] from the file,
|
||||
// and stores them in the current frame buffer.
|
||||
//
|
||||
// Both s1 and s2 must be within the interval
|
||||
// [header().dataWindow().min.y, header().dataWindow().max.y]
|
||||
//
|
||||
// The scan lines can be read from the file in random order, and
|
||||
// individual scan lines may be skipped or read multiple times.
|
||||
// For maximum efficiency, the scan lines should be read in the
|
||||
// order in which they were written to the file.
|
||||
//
|
||||
// readPixels(s) calls readPixels(s,s).
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
|
||||
|
||||
//----------------------------------------------
|
||||
// Read a block of raw pixel data from the file,
|
||||
// without uncompressing it (this function is
|
||||
// used to implement OutputFile::copyPixels()).
|
||||
//----------------------------------------------
|
||||
|
||||
void rawPixelData (int firstScanLine,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
//--------------------------------------------------
|
||||
// Read a tile of raw pixel data from the file,
|
||||
// without uncompressing it (this function is
|
||||
// used to implement TiledOutputFile::copyPixels()).
|
||||
//--------------------------------------------------
|
||||
|
||||
void rawTileData (int &dx, int &dy,
|
||||
int &lx, int &ly,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
InputFile (const InputFile &); // not implemented
|
||||
InputFile & operator = (const InputFile &); // not implemented
|
||||
|
||||
void initialize ();
|
||||
TiledInputFile * tFile ();
|
||||
|
||||
friend void TiledOutputFile::copyPixels (InputFile &);
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
52
3rdparty/openexr/IlmImf/ImfInt64.h
vendored
Normal file
52
3rdparty/openexr/IlmImf/ImfInt64.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2006, 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_INT64_H
|
||||
#define INCLUDED_IMF_INT64_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Int64 -- unsigned 64-bit integers, imported from namespace Imath
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "ImathInt64.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
using Imath::Int64;
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
57
3rdparty/openexr/IlmImf/ImfIntAttribute.cpp
vendored
Normal file
57
3rdparty/openexr/IlmImf/ImfIntAttribute.cpp
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 IntAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfIntAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
IntAttribute::staticTypeName ()
|
||||
{
|
||||
return "int";
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
63
3rdparty/openexr/IlmImf/ImfIntAttribute.h
vendored
Normal file
63
3rdparty/openexr/IlmImf/ImfIntAttribute.h
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_INT_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_INT_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class IntAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<int> IntAttribute;
|
||||
template <> const char *IntAttribute::staticTypeName ();
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfIntAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
216
3rdparty/openexr/IlmImf/ImfKeyCode.cpp
vendored
Normal file
216
3rdparty/openexr/IlmImf/ImfKeyCode.cpp
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 KeyCode
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfKeyCode.h>
|
||||
#include "Iex.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
KeyCode::KeyCode (int filmMfcCode,
|
||||
int filmType,
|
||||
int prefix,
|
||||
int count,
|
||||
int perfOffset,
|
||||
int perfsPerFrame,
|
||||
int perfsPerCount)
|
||||
{
|
||||
setFilmMfcCode (filmMfcCode);
|
||||
setFilmType (filmType);
|
||||
setPrefix (prefix);
|
||||
setCount (count);
|
||||
setPerfOffset (perfOffset);
|
||||
setPerfsPerFrame (perfsPerFrame);
|
||||
setPerfsPerCount (perfsPerCount);
|
||||
}
|
||||
|
||||
|
||||
KeyCode::KeyCode (const KeyCode &other)
|
||||
{
|
||||
_filmMfcCode = other._filmMfcCode;
|
||||
_filmType = other._filmType;
|
||||
_prefix = other._prefix;
|
||||
_count = other._count;
|
||||
_perfOffset = other._perfOffset;
|
||||
_perfsPerFrame = other._perfsPerFrame;
|
||||
_perfsPerCount = other._perfsPerCount;
|
||||
}
|
||||
|
||||
|
||||
KeyCode &
|
||||
KeyCode::operator = (const KeyCode &other)
|
||||
{
|
||||
_filmMfcCode = other._filmMfcCode;
|
||||
_filmType = other._filmType;
|
||||
_prefix = other._prefix;
|
||||
_count = other._count;
|
||||
_perfOffset = other._perfOffset;
|
||||
_perfsPerFrame = other._perfsPerFrame;
|
||||
_perfsPerCount = other._perfsPerCount;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
KeyCode::filmMfcCode () const
|
||||
{
|
||||
return _filmMfcCode;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setFilmMfcCode (int filmMfcCode)
|
||||
{
|
||||
if (filmMfcCode < 0 || filmMfcCode > 99)
|
||||
throw Iex::ArgExc ("Invalid key code film manufacturer code "
|
||||
"(must be between 0 and 99).");
|
||||
|
||||
_filmMfcCode = filmMfcCode;
|
||||
}
|
||||
|
||||
int
|
||||
KeyCode::filmType () const
|
||||
{
|
||||
return _filmType;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setFilmType (int filmType)
|
||||
{
|
||||
if (filmType < 0 || filmType > 99)
|
||||
throw Iex::ArgExc ("Invalid key code film type "
|
||||
"(must be between 0 and 99).");
|
||||
|
||||
_filmType = filmType;
|
||||
}
|
||||
|
||||
int
|
||||
KeyCode::prefix () const
|
||||
{
|
||||
return _prefix;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setPrefix (int prefix)
|
||||
{
|
||||
if (prefix < 0 || prefix > 999999)
|
||||
throw Iex::ArgExc ("Invalid key code prefix "
|
||||
"(must be between 0 and 999999).");
|
||||
|
||||
_prefix = prefix;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
KeyCode::count () const
|
||||
{
|
||||
return _count;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setCount (int count)
|
||||
{
|
||||
if (count < 0 || count > 9999)
|
||||
throw Iex::ArgExc ("Invalid key code count "
|
||||
"(must be between 0 and 9999).");
|
||||
|
||||
_count = count;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
KeyCode::perfOffset () const
|
||||
{
|
||||
return _perfOffset;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setPerfOffset (int perfOffset)
|
||||
{
|
||||
if (perfOffset < 0 || perfOffset > 119)
|
||||
throw Iex::ArgExc ("Invalid key code perforation offset "
|
||||
"(must be between 0 and 119).");
|
||||
|
||||
_perfOffset = perfOffset;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
KeyCode::perfsPerFrame () const
|
||||
{
|
||||
return _perfsPerFrame;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setPerfsPerFrame (int perfsPerFrame)
|
||||
{
|
||||
if (perfsPerFrame < 1 || perfsPerFrame > 15)
|
||||
throw Iex::ArgExc ("Invalid key code number of perforations per frame "
|
||||
"(must be between 1 and 15).");
|
||||
|
||||
_perfsPerFrame = perfsPerFrame;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
KeyCode::perfsPerCount () const
|
||||
{
|
||||
return _perfsPerCount;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
KeyCode::setPerfsPerCount (int perfsPerCount)
|
||||
{
|
||||
if (perfsPerCount < 20 || perfsPerCount > 120)
|
||||
throw Iex::ArgExc ("Invalid key code number of perforations per count "
|
||||
"(must be between 20 and 120).");
|
||||
|
||||
_perfsPerCount = perfsPerCount;
|
||||
}
|
||||
|
||||
} // namespace Imf
|
161
3rdparty/openexr/IlmImf/ImfKeyCode.h
vendored
Normal file
161
3rdparty/openexr/IlmImf/ImfKeyCode.h
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_KEY_CODE_H
|
||||
#define INCLUDED_IMF_KEY_CODE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class KeyCode
|
||||
//
|
||||
// A KeyCode object uniquely identifies a motion picture film frame.
|
||||
// The following fields specifiy film manufacturer, film type, film
|
||||
// roll and the frame's position within the roll:
|
||||
//
|
||||
// filmMfcCode film manufacturer code
|
||||
// range: 0 - 99
|
||||
//
|
||||
// filmType film type code
|
||||
// range: 0 - 99
|
||||
//
|
||||
// prefix prefix to identify film roll
|
||||
// range: 0 - 999999
|
||||
//
|
||||
// count count, increments once every perfsPerCount
|
||||
// perforations (see below)
|
||||
// range: 0 - 9999
|
||||
//
|
||||
// perfOffset offset of frame, in perforations from
|
||||
// zero-frame reference mark
|
||||
// range: 0 - 119
|
||||
//
|
||||
// perfsPerFrame number of perforations per frame
|
||||
// range: 1 - 15
|
||||
//
|
||||
// typical values:
|
||||
//
|
||||
// 1 for 16mm film
|
||||
// 3, 4, or 8 for 35mm film
|
||||
// 5, 8 or 15 for 65mm film
|
||||
//
|
||||
// perfsPerCount number of perforations per count
|
||||
// range: 20 - 120
|
||||
//
|
||||
// typical values:
|
||||
//
|
||||
// 20 for 16mm film
|
||||
// 64 for 35mm film
|
||||
// 80 or 120 for 65mm film
|
||||
//
|
||||
// For more information about the interpretation of those fields see
|
||||
// the following standards and recommended practice publications:
|
||||
//
|
||||
// SMPTE 254 Motion-Picture Film (35-mm) - Manufacturer-Printed
|
||||
// Latent Image Identification Information
|
||||
//
|
||||
// SMPTE 268M File Format for Digital Moving-Picture Exchange (DPX)
|
||||
// (section 6.1)
|
||||
//
|
||||
// SMPTE 270 Motion-Picture Film (65-mm) - Manufacturer- Printed
|
||||
// Latent Image Identification Information
|
||||
//
|
||||
// SMPTE 271 Motion-Picture Film (16-mm) - Manufacturer- Printed
|
||||
// Latent Image Identification Information
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class KeyCode
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------
|
||||
// Constructors and assignment operator
|
||||
//-------------------------------------
|
||||
|
||||
KeyCode (int filmMfcCode = 0,
|
||||
int filmType = 0,
|
||||
int prefix = 0,
|
||||
int count = 0,
|
||||
int perfOffset = 0,
|
||||
int perfsPerFrame = 4,
|
||||
int perfsPerCount = 64);
|
||||
|
||||
KeyCode (const KeyCode &other);
|
||||
KeyCode & operator = (const KeyCode &other);
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Access to individual fields
|
||||
//----------------------------
|
||||
|
||||
int filmMfcCode () const;
|
||||
void setFilmMfcCode (int filmMfcCode);
|
||||
|
||||
int filmType () const;
|
||||
void setFilmType (int filmType);
|
||||
|
||||
int prefix () const;
|
||||
void setPrefix (int prefix);
|
||||
|
||||
int count () const;
|
||||
void setCount (int count);
|
||||
|
||||
int perfOffset () const;
|
||||
void setPerfOffset (int perfOffset);
|
||||
|
||||
int perfsPerFrame () const;
|
||||
void setPerfsPerFrame (int perfsPerFrame);
|
||||
|
||||
int perfsPerCount () const;
|
||||
void setPerfsPerCount (int perfsPerCount);
|
||||
|
||||
private:
|
||||
|
||||
int _filmMfcCode;
|
||||
int _filmType;
|
||||
int _prefix;
|
||||
int _count;
|
||||
int _perfOffset;
|
||||
int _perfsPerFrame;
|
||||
int _perfsPerCount;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
98
3rdparty/openexr/IlmImf/ImfKeyCodeAttribute.cpp
vendored
Normal file
98
3rdparty/openexr/IlmImf/ImfKeyCodeAttribute.cpp
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 KeyCodeAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfKeyCodeAttribute.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
KeyCodeAttribute::staticTypeName ()
|
||||
{
|
||||
return "keycode";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
KeyCodeAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value.filmMfcCode());
|
||||
Xdr::write <StreamIO> (os, _value.filmType());
|
||||
Xdr::write <StreamIO> (os, _value.prefix());
|
||||
Xdr::write <StreamIO> (os, _value.count());
|
||||
Xdr::write <StreamIO> (os, _value.perfOffset());
|
||||
Xdr::write <StreamIO> (os, _value.perfsPerFrame());
|
||||
Xdr::write <StreamIO> (os, _value.perfsPerCount());
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
KeyCodeAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setFilmMfcCode (tmp);
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setFilmType (tmp);
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setPrefix (tmp);
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setCount (tmp);
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setPerfOffset (tmp);
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setPerfsPerFrame (tmp);
|
||||
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value.setPerfsPerCount (tmp);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
72
3rdparty/openexr/IlmImf/ImfKeyCodeAttribute.h
vendored
Normal file
72
3rdparty/openexr/IlmImf/ImfKeyCodeAttribute.h
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_KEY_CODE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_KEY_CODE_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class KeyCodeAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfKeyCode.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<KeyCode> KeyCodeAttribute;
|
||||
|
||||
template <>
|
||||
const char *KeyCodeAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
void KeyCodeAttribute::writeValueTo (OStream &, int) const;
|
||||
|
||||
template <>
|
||||
void KeyCodeAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfKeyCodeAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
64
3rdparty/openexr/IlmImf/ImfLineOrder.h
vendored
Normal file
64
3rdparty/openexr/IlmImf/ImfLineOrder.h
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_LINE_ORDER_H
|
||||
#define INCLUDED_IMF_LINE_ORDER_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum LineOrder
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum LineOrder
|
||||
{
|
||||
INCREASING_Y = 0, // first scan line has lowest y coordinate
|
||||
|
||||
DECREASING_Y = 1, // first scan line has highest y coordinate
|
||||
|
||||
RANDOM_Y = 2, // only for tiled files; tiles are written
|
||||
// in random order
|
||||
|
||||
NUM_LINEORDERS // number of different line orders
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
77
3rdparty/openexr/IlmImf/ImfLineOrderAttribute.cpp
vendored
Normal file
77
3rdparty/openexr/IlmImf/ImfLineOrderAttribute.cpp
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 LineOrderAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfLineOrderAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
LineOrderAttribute::staticTypeName ()
|
||||
{
|
||||
return "lineOrder";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
LineOrderAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
unsigned char tmp = _value;
|
||||
Xdr::write <StreamIO> (os, tmp);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
LineOrderAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
unsigned char tmp;
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value = LineOrder (tmp);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
66
3rdparty/openexr/IlmImf/ImfLineOrderAttribute.h
vendored
Normal file
66
3rdparty/openexr/IlmImf/ImfLineOrderAttribute.h
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_LINE_ORDER_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_LINE_ORDER_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class LineOrderAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfLineOrder.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<LineOrder> LineOrderAttribute;
|
||||
template <> const char *LineOrderAttribute::staticTypeName ();
|
||||
template <> void LineOrderAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void LineOrderAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfLineOrderAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
176
3rdparty/openexr/IlmImf/ImfLut.cpp
vendored
Normal file
176
3rdparty/openexr/IlmImf/ImfLut.cpp
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Lookup tables for efficient application
|
||||
// of half --> half functions to pixel data,
|
||||
// and some commonly applied functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfLut.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
void
|
||||
HalfLut::apply (half *data, int nData, int stride) const
|
||||
{
|
||||
while (nData)
|
||||
{
|
||||
*data = _lut (*data);
|
||||
data += stride;
|
||||
nData -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HalfLut::apply (const Slice &data, const Imath::Box2i &dataWindow) const
|
||||
{
|
||||
assert (data.type == HALF);
|
||||
assert (dataWindow.min.x % data.xSampling == 0);
|
||||
assert (dataWindow.min.y % data.ySampling == 0);
|
||||
assert ((dataWindow.max.x - dataWindow.min.x + 1) % data.xSampling == 0);
|
||||
assert ((dataWindow.max.y - dataWindow.min.y + 1) % data.ySampling == 0);
|
||||
|
||||
char *base = data.base + data.yStride *
|
||||
(dataWindow.min.y / data.ySampling);
|
||||
|
||||
for (int y = dataWindow.min.y;
|
||||
y <= dataWindow.max.y;
|
||||
y += data.ySampling)
|
||||
{
|
||||
char *pixel = base + data.xStride *
|
||||
(dataWindow.min.x / data.xSampling);
|
||||
|
||||
for (int x = dataWindow.min.x;
|
||||
x <= dataWindow.max.x;
|
||||
x += data.xSampling)
|
||||
{
|
||||
*(half *)pixel = _lut (*(half *)pixel);
|
||||
pixel += data.xStride;
|
||||
}
|
||||
|
||||
base += data.yStride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RgbaLut::apply (Rgba *data, int nData, int stride) const
|
||||
{
|
||||
while (nData)
|
||||
{
|
||||
if (_chn & WRITE_R)
|
||||
data->r = _lut (data->r);
|
||||
|
||||
if (_chn & WRITE_G)
|
||||
data->g = _lut (data->g);
|
||||
|
||||
if (_chn & WRITE_B)
|
||||
data->b = _lut (data->b);
|
||||
|
||||
if (_chn & WRITE_A)
|
||||
data->a = _lut (data->a);
|
||||
|
||||
data += stride;
|
||||
nData -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RgbaLut::apply (Rgba *base,
|
||||
int xStride, int yStride,
|
||||
const Imath::Box2i &dataWindow) const
|
||||
{
|
||||
base += dataWindow.min.y * yStride;
|
||||
|
||||
for (int y = dataWindow.min.y; y <= dataWindow.max.y; ++y)
|
||||
{
|
||||
Rgba *pixel = base + dataWindow.min.x * xStride;
|
||||
|
||||
for (int x = dataWindow.min.x; x <= dataWindow.max.x; ++x)
|
||||
{
|
||||
if (_chn & WRITE_R)
|
||||
pixel->r = _lut (pixel->r);
|
||||
|
||||
if (_chn & WRITE_G)
|
||||
pixel->g = _lut (pixel->g);
|
||||
|
||||
if (_chn & WRITE_B)
|
||||
pixel->b = _lut (pixel->b);
|
||||
|
||||
if (_chn & WRITE_A)
|
||||
pixel->a = _lut (pixel->a);
|
||||
|
||||
pixel += xStride;
|
||||
}
|
||||
|
||||
base += yStride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
half
|
||||
round12log (half x)
|
||||
{
|
||||
const float middleval = pow (2.0, -2.5);
|
||||
int int12log;
|
||||
|
||||
if (x <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int12log = int (2000.5 + 200.0 * log (x / middleval) / log (2.0));
|
||||
|
||||
if (int12log > 4095)
|
||||
int12log = 4095;
|
||||
|
||||
if (int12log < 1)
|
||||
int12log = 1;
|
||||
}
|
||||
|
||||
return middleval * pow (2.0, (int12log - 2000.0) / 200.0);
|
||||
}
|
||||
|
||||
} // namespace Imf
|
185
3rdparty/openexr/IlmImf/ImfLut.h
vendored
Normal file
185
3rdparty/openexr/IlmImf/ImfLut.h
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_LUT_H
|
||||
#define INCLUDED_IMF_LUT_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Lookup tables for efficient application
|
||||
// of half --> half functions to pixel data,
|
||||
// and some commonly applied functions.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfRgbaFile.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include "ImathBox.h"
|
||||
#include "halfFunction.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//
|
||||
// Lookup table for individual half channels.
|
||||
//
|
||||
|
||||
class HalfLut
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
template <class Function>
|
||||
HalfLut (Function f);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Apply the table to data[0], data[stride] ... data[(nData-1) * stride]
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void apply (half *data,
|
||||
int nData,
|
||||
int stride = 1) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Apply the table to a frame buffer slice (see ImfFrameBuffer.h)
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void apply (const Slice &data,
|
||||
const Imath::Box2i &dataWindow) const;
|
||||
|
||||
private:
|
||||
|
||||
halfFunction <half> _lut;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Lookup table for combined RGBA data.
|
||||
//
|
||||
|
||||
class RgbaLut
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
template <class Function>
|
||||
RgbaLut (Function f, RgbaChannels chn = WRITE_RGB);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Apply the table to data[0], data[stride] ... data[(nData-1) * stride]
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void apply (Rgba *data,
|
||||
int nData,
|
||||
int stride = 1) const;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Apply the table to a frame buffer (see RgbaOutpuFile.setFrameBuffer())
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void apply (Rgba *base,
|
||||
int xStride,
|
||||
int yStride,
|
||||
const Imath::Box2i &dataWindow) const;
|
||||
|
||||
private:
|
||||
|
||||
halfFunction <half> _lut;
|
||||
RgbaChannels _chn;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// 12bit log rounding reduces data to 20 stops with 200 steps per stop.
|
||||
// That makes 4000 numbers. An extra 96 just come along for the ride.
|
||||
// Zero explicitly remains zero. The first non-zero half will map to 1
|
||||
// in the 0-4095 12log space. A nice power of two number is placed at
|
||||
// the center [2000] and that number is near 0.18.
|
||||
//
|
||||
|
||||
half round12log (half x);
|
||||
|
||||
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
struct roundNBit
|
||||
{
|
||||
roundNBit (int n): n(n) {}
|
||||
half operator () (half x) {return x.round(n);}
|
||||
int n;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Template definitions
|
||||
//
|
||||
|
||||
|
||||
template <class Function>
|
||||
HalfLut::HalfLut (Function f):
|
||||
_lut(f, -HALF_MAX, HALF_MAX, half (0),
|
||||
half::posInf(), half::negInf(), half::qNan())
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class Function>
|
||||
RgbaLut::RgbaLut (Function f, RgbaChannels chn):
|
||||
_lut(f, -HALF_MAX, HALF_MAX, half (0),
|
||||
half::posInf(), half::negInf(), half::qNan()),
|
||||
_chn(chn)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
260
3rdparty/openexr/IlmImf/ImfMatrixAttribute.cpp
vendored
Normal file
260
3rdparty/openexr/IlmImf/ImfMatrixAttribute.cpp
vendored
Normal file
@ -0,0 +1,260 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 M33fAttribute
|
||||
// class M33dAttribute
|
||||
// class M44fAttribute
|
||||
// class M44dAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfMatrixAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
M33fAttribute::staticTypeName ()
|
||||
{
|
||||
return "m33f";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M33fAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value[0][0]);
|
||||
Xdr::write <StreamIO> (os, _value[0][1]);
|
||||
Xdr::write <StreamIO> (os, _value[0][2]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[1][0]);
|
||||
Xdr::write <StreamIO> (os, _value[1][1]);
|
||||
Xdr::write <StreamIO> (os, _value[1][2]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[2][0]);
|
||||
Xdr::write <StreamIO> (os, _value[2][1]);
|
||||
Xdr::write <StreamIO> (os, _value[2][2]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M33fAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value[0][0]);
|
||||
Xdr::read <StreamIO> (is, _value[0][1]);
|
||||
Xdr::read <StreamIO> (is, _value[0][2]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[1][0]);
|
||||
Xdr::read <StreamIO> (is, _value[1][1]);
|
||||
Xdr::read <StreamIO> (is, _value[1][2]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[2][0]);
|
||||
Xdr::read <StreamIO> (is, _value[2][1]);
|
||||
Xdr::read <StreamIO> (is, _value[2][2]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
M33dAttribute::staticTypeName ()
|
||||
{
|
||||
return "m33d";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M33dAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value[0][0]);
|
||||
Xdr::write <StreamIO> (os, _value[0][1]);
|
||||
Xdr::write <StreamIO> (os, _value[0][2]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[1][0]);
|
||||
Xdr::write <StreamIO> (os, _value[1][1]);
|
||||
Xdr::write <StreamIO> (os, _value[1][2]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[2][0]);
|
||||
Xdr::write <StreamIO> (os, _value[2][1]);
|
||||
Xdr::write <StreamIO> (os, _value[2][2]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M33dAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value[0][0]);
|
||||
Xdr::read <StreamIO> (is, _value[0][1]);
|
||||
Xdr::read <StreamIO> (is, _value[0][2]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[1][0]);
|
||||
Xdr::read <StreamIO> (is, _value[1][1]);
|
||||
Xdr::read <StreamIO> (is, _value[1][2]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[2][0]);
|
||||
Xdr::read <StreamIO> (is, _value[2][1]);
|
||||
Xdr::read <StreamIO> (is, _value[2][2]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
M44fAttribute::staticTypeName ()
|
||||
{
|
||||
return "m44f";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M44fAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value[0][0]);
|
||||
Xdr::write <StreamIO> (os, _value[0][1]);
|
||||
Xdr::write <StreamIO> (os, _value[0][2]);
|
||||
Xdr::write <StreamIO> (os, _value[0][3]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[1][0]);
|
||||
Xdr::write <StreamIO> (os, _value[1][1]);
|
||||
Xdr::write <StreamIO> (os, _value[1][2]);
|
||||
Xdr::write <StreamIO> (os, _value[1][3]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[2][0]);
|
||||
Xdr::write <StreamIO> (os, _value[2][1]);
|
||||
Xdr::write <StreamIO> (os, _value[2][2]);
|
||||
Xdr::write <StreamIO> (os, _value[2][3]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[3][0]);
|
||||
Xdr::write <StreamIO> (os, _value[3][1]);
|
||||
Xdr::write <StreamIO> (os, _value[3][2]);
|
||||
Xdr::write <StreamIO> (os, _value[3][3]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M44fAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value[0][0]);
|
||||
Xdr::read <StreamIO> (is, _value[0][1]);
|
||||
Xdr::read <StreamIO> (is, _value[0][2]);
|
||||
Xdr::read <StreamIO> (is, _value[0][3]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[1][0]);
|
||||
Xdr::read <StreamIO> (is, _value[1][1]);
|
||||
Xdr::read <StreamIO> (is, _value[1][2]);
|
||||
Xdr::read <StreamIO> (is, _value[1][3]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[2][0]);
|
||||
Xdr::read <StreamIO> (is, _value[2][1]);
|
||||
Xdr::read <StreamIO> (is, _value[2][2]);
|
||||
Xdr::read <StreamIO> (is, _value[2][3]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[3][0]);
|
||||
Xdr::read <StreamIO> (is, _value[3][1]);
|
||||
Xdr::read <StreamIO> (is, _value[3][2]);
|
||||
Xdr::read <StreamIO> (is, _value[3][3]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
M44dAttribute::staticTypeName ()
|
||||
{
|
||||
return "m44d";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M44dAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value[0][0]);
|
||||
Xdr::write <StreamIO> (os, _value[0][1]);
|
||||
Xdr::write <StreamIO> (os, _value[0][2]);
|
||||
Xdr::write <StreamIO> (os, _value[0][3]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[1][0]);
|
||||
Xdr::write <StreamIO> (os, _value[1][1]);
|
||||
Xdr::write <StreamIO> (os, _value[1][2]);
|
||||
Xdr::write <StreamIO> (os, _value[1][3]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[2][0]);
|
||||
Xdr::write <StreamIO> (os, _value[2][1]);
|
||||
Xdr::write <StreamIO> (os, _value[2][2]);
|
||||
Xdr::write <StreamIO> (os, _value[2][3]);
|
||||
|
||||
Xdr::write <StreamIO> (os, _value[3][0]);
|
||||
Xdr::write <StreamIO> (os, _value[3][1]);
|
||||
Xdr::write <StreamIO> (os, _value[3][2]);
|
||||
Xdr::write <StreamIO> (os, _value[3][3]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
M44dAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, _value[0][0]);
|
||||
Xdr::read <StreamIO> (is, _value[0][1]);
|
||||
Xdr::read <StreamIO> (is, _value[0][2]);
|
||||
Xdr::read <StreamIO> (is, _value[0][3]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[1][0]);
|
||||
Xdr::read <StreamIO> (is, _value[1][1]);
|
||||
Xdr::read <StreamIO> (is, _value[1][2]);
|
||||
Xdr::read <StreamIO> (is, _value[1][3]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[2][0]);
|
||||
Xdr::read <StreamIO> (is, _value[2][1]);
|
||||
Xdr::read <StreamIO> (is, _value[2][2]);
|
||||
Xdr::read <StreamIO> (is, _value[2][3]);
|
||||
|
||||
Xdr::read <StreamIO> (is, _value[3][0]);
|
||||
Xdr::read <StreamIO> (is, _value[3][1]);
|
||||
Xdr::read <StreamIO> (is, _value[3][2]);
|
||||
Xdr::read <StreamIO> (is, _value[3][3]);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
87
3rdparty/openexr/IlmImf/ImfMatrixAttribute.h
vendored
Normal file
87
3rdparty/openexr/IlmImf/ImfMatrixAttribute.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_MATRIX_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_MATRIX_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class M33fAttribute
|
||||
// class M33dAttribute
|
||||
// class M44fAttribute
|
||||
// class M44dAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include "ImathMatrix.h"
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::M33f> M33fAttribute;
|
||||
template <> const char *M33fAttribute::staticTypeName ();
|
||||
template <> void M33fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void M33fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::M33d> M33dAttribute;
|
||||
template <> const char *M33dAttribute::staticTypeName ();
|
||||
template <> void M33dAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void M33dAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::M44f> M44fAttribute;
|
||||
template <> const char *M44fAttribute::staticTypeName ();
|
||||
template <> void M44fAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void M44fAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<Imath::M44d> M44dAttribute;
|
||||
template <> const char *M44dAttribute::staticTypeName ();
|
||||
template <> void M44dAttribute::writeValueTo (OStream &, int) const;
|
||||
template <> void M44dAttribute::readValueFrom (IStream &, int, int);
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfMatrixAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
787
3rdparty/openexr/IlmImf/ImfMisc.cpp
vendored
Normal file
787
3rdparty/openexr/IlmImf/ImfMisc.cpp
vendored
Normal file
@ -0,0 +1,787 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Miscellaneous helper functions for OpenEXR image file I/O
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfMisc.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfCompressor.h>
|
||||
#include <ImfChannelList.h>
|
||||
#include <ImfXdr.h>
|
||||
#include <ImathFun.h>
|
||||
#include <Iex.h>
|
||||
#include <ImfStdIO.h>
|
||||
#include <ImfConvert.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
using Imath::Box2i;
|
||||
using Imath::divp;
|
||||
using Imath::modp;
|
||||
using std::vector;
|
||||
|
||||
int
|
||||
pixelTypeSize (PixelType type)
|
||||
{
|
||||
int size;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
size = Xdr::size <unsigned int> ();
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
size = Xdr::size <half> ();
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
size = Xdr::size <float> ();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel type.");
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
numSamples (int s, int a, int b)
|
||||
{
|
||||
int a1 = divp (a, s);
|
||||
int b1 = divp (b, s);
|
||||
return b1 - a1 + ((a1 * s < a)? 0: 1);
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
bytesPerLineTable (const Header &header,
|
||||
vector<size_t> &bytesPerLine)
|
||||
{
|
||||
const Box2i &dataWindow = header.dataWindow();
|
||||
const ChannelList &channels = header.channels();
|
||||
|
||||
bytesPerLine.resize (dataWindow.max.y - dataWindow.min.y + 1);
|
||||
|
||||
for (ChannelList::ConstIterator c = channels.begin();
|
||||
c != channels.end();
|
||||
++c)
|
||||
{
|
||||
int nBytes = pixelTypeSize (c.channel().type) *
|
||||
(dataWindow.max.x - dataWindow.min.x + 1) /
|
||||
c.channel().xSampling;
|
||||
|
||||
for (int y = dataWindow.min.y, i = 0; y <= dataWindow.max.y; ++y, ++i)
|
||||
if (modp (y, c.channel().ySampling) == 0)
|
||||
bytesPerLine[i] += nBytes;
|
||||
}
|
||||
|
||||
size_t maxBytesPerLine = 0;
|
||||
|
||||
for (int y = dataWindow.min.y, i = 0; y <= dataWindow.max.y; ++y, ++i)
|
||||
if (maxBytesPerLine < bytesPerLine[i])
|
||||
maxBytesPerLine = bytesPerLine[i];
|
||||
|
||||
return maxBytesPerLine;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
offsetInLineBufferTable (const vector<size_t> &bytesPerLine,
|
||||
int linesInLineBuffer,
|
||||
vector<size_t> &offsetInLineBuffer)
|
||||
{
|
||||
offsetInLineBuffer.resize (bytesPerLine.size());
|
||||
|
||||
size_t offset = 0;
|
||||
|
||||
for (int i = 0; i < bytesPerLine.size(); ++i)
|
||||
{
|
||||
if (i % linesInLineBuffer == 0)
|
||||
offset = 0;
|
||||
|
||||
offsetInLineBuffer[i] = offset;
|
||||
offset += bytesPerLine[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
lineBufferMinY (int y, int minY, int linesInLineBuffer)
|
||||
{
|
||||
return ((y - minY) / linesInLineBuffer) * linesInLineBuffer + minY;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
lineBufferMaxY (int y, int minY, int linesInLineBuffer)
|
||||
{
|
||||
return lineBufferMinY (y, minY, linesInLineBuffer) + linesInLineBuffer - 1;
|
||||
}
|
||||
|
||||
|
||||
Compressor::Format
|
||||
defaultFormat (Compressor * compressor)
|
||||
{
|
||||
return compressor? compressor->format(): Compressor::XDR;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
numLinesInBuffer (Compressor * compressor)
|
||||
{
|
||||
return compressor? compressor->numScanLines(): 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
copyIntoFrameBuffer (const char *& readPtr,
|
||||
char * writePtr,
|
||||
char * endPtr,
|
||||
size_t xStride,
|
||||
bool fill,
|
||||
double fillValue,
|
||||
Compressor::Format format,
|
||||
PixelType typeInFrameBuffer,
|
||||
PixelType typeInFile)
|
||||
{
|
||||
//
|
||||
// Copy a horizontal row of pixels from an input
|
||||
// file's line or tile buffer to a frame buffer.
|
||||
//
|
||||
|
||||
if (fill)
|
||||
{
|
||||
//
|
||||
// The file contains no data for this channel.
|
||||
// Store a default value in the frame buffer.
|
||||
//
|
||||
|
||||
switch (typeInFrameBuffer)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
{
|
||||
unsigned int fillVal = (unsigned int) (fillValue);
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
*(unsigned int *) writePtr = fillVal;
|
||||
writePtr += xStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
{
|
||||
half fillVal = half (fillValue);
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
*(half *) writePtr = fillVal;
|
||||
writePtr += xStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
{
|
||||
float fillVal = float (fillValue);
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
*(float *) writePtr = fillVal;
|
||||
writePtr += xStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
else if (format == Compressor::XDR)
|
||||
{
|
||||
//
|
||||
// The the line or tile buffer is in XDR format.
|
||||
//
|
||||
// Convert the pixels from the file's machine-
|
||||
// independent representation, and store the
|
||||
// results in the frame buffer.
|
||||
//
|
||||
|
||||
switch (typeInFrameBuffer)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
Xdr::read <CharPtrIO> (readPtr, *(unsigned int *) writePtr);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
half h;
|
||||
Xdr::read <CharPtrIO> (readPtr, h);
|
||||
*(unsigned int *) writePtr = halfToUint (h);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
float f;
|
||||
Xdr::read <CharPtrIO> (readPtr, f);
|
||||
*(unsigned int *)writePtr = floatToUint (f);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
unsigned int ui;
|
||||
Xdr::read <CharPtrIO> (readPtr, ui);
|
||||
*(half *) writePtr = uintToHalf (ui);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
Xdr::read <CharPtrIO> (readPtr, *(half *) writePtr);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
float f;
|
||||
Xdr::read <CharPtrIO> (readPtr, f);
|
||||
*(half *) writePtr = floatToHalf (f);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
unsigned int ui;
|
||||
Xdr::read <CharPtrIO> (readPtr, ui);
|
||||
*(float *) writePtr = float (ui);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
half h;
|
||||
Xdr::read <CharPtrIO> (readPtr, h);
|
||||
*(float *) writePtr = float (h);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
Xdr::read <CharPtrIO> (readPtr, *(float *) writePtr);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// The the line or tile buffer is in NATIVE format.
|
||||
// Copy the results into the frame buffer.
|
||||
//
|
||||
|
||||
switch (typeInFrameBuffer)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof (unsigned int); ++i)
|
||||
writePtr[i] = readPtr[i];
|
||||
|
||||
readPtr += sizeof (unsigned int);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
half h = *(half *) readPtr;
|
||||
*(unsigned int *) writePtr = halfToUint (h);
|
||||
readPtr += sizeof (half);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
float f;
|
||||
|
||||
for (size_t i = 0; i < sizeof (float); ++i)
|
||||
((char *)&f)[i] = readPtr[i];
|
||||
|
||||
*(unsigned int *)writePtr = floatToUint (f);
|
||||
readPtr += sizeof (float);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
unsigned int ui;
|
||||
|
||||
for (size_t i = 0; i < sizeof (unsigned int); ++i)
|
||||
((char *)&ui)[i] = readPtr[i];
|
||||
|
||||
*(half *) writePtr = uintToHalf (ui);
|
||||
readPtr += sizeof (unsigned int);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
*(half *) writePtr = *(half *)readPtr;
|
||||
readPtr += sizeof (half);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
float f;
|
||||
|
||||
for (size_t i = 0; i < sizeof (float); ++i)
|
||||
((char *)&f)[i] = readPtr[i];
|
||||
|
||||
*(half *) writePtr = floatToHalf (f);
|
||||
readPtr += sizeof (float);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
unsigned int ui;
|
||||
|
||||
for (size_t i = 0; i < sizeof (unsigned int); ++i)
|
||||
((char *)&ui)[i] = readPtr[i];
|
||||
|
||||
*(float *) writePtr = float (ui);
|
||||
readPtr += sizeof (unsigned int);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
half h = *(half *) readPtr;
|
||||
*(float *) writePtr = float (h);
|
||||
readPtr += sizeof (half);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (writePtr <= endPtr)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof (float); ++i)
|
||||
writePtr[i] = readPtr[i];
|
||||
|
||||
readPtr += sizeof (float);
|
||||
writePtr += xStride;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
skipChannel (const char *& readPtr,
|
||||
PixelType typeInFile,
|
||||
size_t xSize)
|
||||
{
|
||||
switch (typeInFile)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
Xdr::skip <CharPtrIO> (readPtr, Xdr::size <unsigned int> () * xSize);
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
Xdr::skip <CharPtrIO> (readPtr, Xdr::size <half> () * xSize);
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
Xdr::skip <CharPtrIO> (readPtr, Xdr::size <float> () * xSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
convertInPlace (char *& writePtr,
|
||||
const char *& readPtr,
|
||||
PixelType type,
|
||||
size_t numPixels)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
for (int j = 0; j < numPixels; ++j)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (writePtr, *(const unsigned int *) readPtr);
|
||||
readPtr += sizeof(unsigned int);
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
for (int j = 0; j < numPixels; ++j)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (writePtr, *(const half *) readPtr);
|
||||
readPtr += sizeof(half);
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
for (int j = 0; j < numPixels; ++j)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (writePtr, *(const float *) readPtr);
|
||||
readPtr += sizeof(float);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
copyFromFrameBuffer (char *& writePtr,
|
||||
const char *& readPtr,
|
||||
const char * endPtr,
|
||||
size_t xStride,
|
||||
Compressor::Format format,
|
||||
PixelType type)
|
||||
{
|
||||
//
|
||||
// Copy a horizontal row of pixels from a frame
|
||||
// buffer to an output file's line or tile buffer.
|
||||
//
|
||||
|
||||
if (format == Compressor::XDR)
|
||||
{
|
||||
//
|
||||
// The the line or tile buffer is in XDR format.
|
||||
//
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (readPtr <= endPtr)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (writePtr,
|
||||
*(const unsigned int *) readPtr);
|
||||
readPtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (readPtr <= endPtr)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (writePtr, *(const half *) readPtr);
|
||||
readPtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (readPtr <= endPtr)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (writePtr, *(const float *) readPtr);
|
||||
readPtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// The the line or tile buffer is in NATIVE format.
|
||||
//
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
while (readPtr <= endPtr)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof (unsigned int); ++i)
|
||||
*writePtr++ = readPtr[i];
|
||||
|
||||
readPtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
while (readPtr <= endPtr)
|
||||
{
|
||||
*(half *) writePtr = *(const half *) readPtr;
|
||||
writePtr += sizeof (half);
|
||||
readPtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
while (readPtr <= endPtr)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof (float); ++i)
|
||||
*writePtr++ = readPtr[i];
|
||||
|
||||
readPtr += xStride;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fillChannelWithZeroes (char *& writePtr,
|
||||
Compressor::Format format,
|
||||
PixelType type,
|
||||
size_t xSize)
|
||||
{
|
||||
if (format == Compressor::XDR)
|
||||
{
|
||||
//
|
||||
// Fill with data in XDR format.
|
||||
//
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
for (int j = 0; j < xSize; ++j)
|
||||
Xdr::write <CharPtrIO> (writePtr, (unsigned int) 0);
|
||||
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
for (int j = 0; j < xSize; ++j)
|
||||
Xdr::write <CharPtrIO> (writePtr, (half) 0);
|
||||
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
for (int j = 0; j < xSize; ++j)
|
||||
Xdr::write <CharPtrIO> (writePtr, (float) 0);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Fill with data in NATIVE format.
|
||||
//
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case UINT:
|
||||
|
||||
for (int j = 0; j < xSize; ++j)
|
||||
{
|
||||
static const unsigned int ui = 0;
|
||||
|
||||
for (size_t i = 0; i < sizeof (ui); ++i)
|
||||
*writePtr++ = ((char *) &ui)[i];
|
||||
}
|
||||
break;
|
||||
|
||||
case HALF:
|
||||
|
||||
for (int j = 0; j < xSize; ++j)
|
||||
{
|
||||
*(half *) writePtr = half (0);
|
||||
writePtr += sizeof (half);
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOAT:
|
||||
|
||||
for (int j = 0; j < xSize; ++j)
|
||||
{
|
||||
static const float f = 0;
|
||||
|
||||
for (size_t i = 0; i < sizeof (f); ++i)
|
||||
*writePtr++ = ((char *) &f)[i];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
throw Iex::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Imf
|
255
3rdparty/openexr/IlmImf/ImfMisc.h
vendored
Normal file
255
3rdparty/openexr/IlmImf/ImfMisc.h
vendored
Normal file
@ -0,0 +1,255 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_MISC_H
|
||||
#define INCLUDED_IMF_MISC_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Miscellaneous helper functions for OpenEXR image file I/O
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfPixelType.h>
|
||||
#include <vector>
|
||||
#include <ImfCompressor.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class Header;
|
||||
|
||||
//
|
||||
// Return the size of a single value of the indicated type,
|
||||
// in the machine's native format.
|
||||
//
|
||||
|
||||
int pixelTypeSize (PixelType type);
|
||||
|
||||
|
||||
//
|
||||
// Return the number of samples a channel with subsampling rate
|
||||
// s has in the interval [a, b]. For example, a channel with
|
||||
// subsampling rate 2 (and samples at 0, 2, 4, 6, 8, etc.) has
|
||||
// 2 samples in the interval [1, 5] and three samples in the
|
||||
// interval [2, 6].
|
||||
//
|
||||
|
||||
int numSamples (int s, int a, int b);
|
||||
|
||||
|
||||
//
|
||||
// Build a table that lists, for each scanline in a file's
|
||||
// data window, how many bytes are required to store all
|
||||
// pixels in all channels in that scanline (assuming that
|
||||
// the pixel data are tightly packed).
|
||||
//
|
||||
|
||||
size_t bytesPerLineTable (const Header &header,
|
||||
std::vector<size_t> &bytesPerLine);
|
||||
|
||||
//
|
||||
// For scanline-based files, pixels are read or written in
|
||||
// in multi-scanline blocks. Internally, class OutputFile
|
||||
// and class ScanLineInputFile store a block of scan lines
|
||||
// in a "line buffer". Function offsetInLineBufferTable()
|
||||
// builds a table that lists, for each scan line in a file's
|
||||
// data window, the location of the pixel data for the scanline
|
||||
// relative to the beginning of the line buffer.
|
||||
//
|
||||
|
||||
void offsetInLineBufferTable (const std::vector<size_t> &bytesPerLine,
|
||||
int linesInLineBuffer,
|
||||
std::vector<size_t> &offsetInLineBuffer);
|
||||
|
||||
//
|
||||
// For a scanline-based file, compute the range of scanlines
|
||||
// that occupy the same line buffer as a given scanline, y.
|
||||
// (minY is the minimum y coordinate of the file's data window.)
|
||||
//
|
||||
|
||||
int lineBufferMinY (int y, int minY, int linesInLineBuffer);
|
||||
int lineBufferMaxY (int y, int minY, int linesInLineBuffer);
|
||||
|
||||
|
||||
//
|
||||
// Return a compressor's data format (Compressor::NATIVE or Compressor::XDR).
|
||||
// If compressor is 0, return Compressor::XDR.
|
||||
//
|
||||
|
||||
Compressor::Format defaultFormat (Compressor *compressor);
|
||||
|
||||
|
||||
//
|
||||
// Return the number of scan lines a compressor wants to compress
|
||||
// or uncompress at once. If compressor is 0, return 1.
|
||||
//
|
||||
|
||||
int numLinesInBuffer (Compressor *compressor);
|
||||
|
||||
|
||||
//
|
||||
// Copy a single channel of a horizontal row of pixels from an
|
||||
// input file's internal line buffer or tile buffer into a
|
||||
// frame buffer slice. If necessary, perform on-the-fly data
|
||||
// type conversion.
|
||||
//
|
||||
// readPtr initially points to the beginning of the
|
||||
// data in the line or tile buffer. readPtr
|
||||
// is advanced as the pixel data are copied;
|
||||
// when copyIntoFrameBuffer() returns,
|
||||
// readPtr points just past the end of the
|
||||
// copied data.
|
||||
//
|
||||
// writePtr, endPtr point to the lefmost and rightmost pixels
|
||||
// in the frame buffer slice
|
||||
//
|
||||
// xStride the xStride for the frame buffer slice
|
||||
//
|
||||
// format indicates if the line or tile buffer is
|
||||
// in NATIVE or XDR format.
|
||||
//
|
||||
// typeInFrameBuffer the pixel data type of the frame buffer slice
|
||||
//
|
||||
// typeInFile the pixel data type in the input file's channel
|
||||
//
|
||||
|
||||
void copyIntoFrameBuffer (const char *&readPtr,
|
||||
char *writePtr,
|
||||
char *endPtr,
|
||||
size_t xStride,
|
||||
bool fill,
|
||||
double fillValue,
|
||||
Compressor::Format format,
|
||||
PixelType typeInFrameBuffer,
|
||||
PixelType typeInFile);
|
||||
|
||||
//
|
||||
// Given a pointer into a an input file's line buffer or tile buffer,
|
||||
// skip over the data for xSize pixels of type typeInFile.
|
||||
// readPtr initially points to the beginning of the data to be skipped;
|
||||
// when skipChannel() returns, readPtr points just past the end of the
|
||||
// skipped data.
|
||||
//
|
||||
|
||||
void skipChannel (const char *&readPtr,
|
||||
PixelType typeInFile,
|
||||
size_t xSize);
|
||||
|
||||
//
|
||||
// Convert an array of pixel data from the machine's native
|
||||
// representation to XDR format.
|
||||
//
|
||||
// toPtr, fromPtr initially point to the beginning of the input
|
||||
// and output pixel data arrays; when convertInPlace()
|
||||
// returns, toPtr and fromPtr point just past the
|
||||
// end of the input and output arrays.
|
||||
// If the native representation of the data has the
|
||||
// same size as the XDR data, then the conversion
|
||||
// can take in place, without an intermediate
|
||||
// temporary buffer (toPtr and fromPtr can point
|
||||
// to the same location).
|
||||
//
|
||||
// type the pixel data type
|
||||
//
|
||||
// numPixels number of pixels in the input and output arrays
|
||||
//
|
||||
|
||||
void convertInPlace (char *&toPtr,
|
||||
const char *&fromPtr,
|
||||
PixelType type,
|
||||
size_t numPixels);
|
||||
|
||||
//
|
||||
// Copy a single channel of a horizontal row of pixels from a
|
||||
// a frame buffer into an output file's internal line buffer or
|
||||
// tile buffer.
|
||||
//
|
||||
// writePtr initially points to the beginning of the
|
||||
// data in the line or tile buffer. writePtr
|
||||
// is advanced as the pixel data are copied;
|
||||
// when copyFromFrameBuffer() returns,
|
||||
// writePtr points just past the end of the
|
||||
// copied data.
|
||||
//
|
||||
// readPtr, endPtr point to the lefmost and rightmost pixels
|
||||
// in the frame buffer slice
|
||||
//
|
||||
// xStride the xStride for the frame buffer slice
|
||||
//
|
||||
// format indicates if the line or tile buffer is
|
||||
// in NATIVE or XDR format.
|
||||
//
|
||||
// type the pixel data type in the frame buffer
|
||||
// and in the output file's channel (function
|
||||
// copyFromFrameBuffer() doesn't do on-the-fly
|
||||
// data type conversion)
|
||||
//
|
||||
|
||||
void copyFromFrameBuffer (char *&writePtr,
|
||||
const char *&readPtr,
|
||||
const char *endPtr,
|
||||
size_t xStride,
|
||||
Compressor::Format format,
|
||||
PixelType type);
|
||||
|
||||
//
|
||||
// Fill part of an output file's line buffer or tile buffer with
|
||||
// zeroes. This routine is called when an output file contains
|
||||
// a channel for which the frame buffer contains no corresponding
|
||||
// slice.
|
||||
//
|
||||
// writePtr initially points to the beginning of the
|
||||
// data in the line or tile buffer. When
|
||||
// fillChannelWithZeroes() returns, writePtr
|
||||
// points just past the end of the zeroed
|
||||
// data.
|
||||
//
|
||||
// format indicates if the line or tile buffer is
|
||||
// in NATIVE or XDR format.
|
||||
//
|
||||
// type the pixel data type in the line or frame buffer.
|
||||
//
|
||||
// xSize number of pixels to be filled with zeroes.
|
||||
//
|
||||
|
||||
void fillChannelWithZeroes (char *&writePtr,
|
||||
Compressor::Format format,
|
||||
PixelType type,
|
||||
size_t xSize);
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
396
3rdparty/openexr/IlmImf/ImfMultiView.cpp
vendored
Normal file
396
3rdparty/openexr/IlmImf/ImfMultiView.cpp
vendored
Normal file
@ -0,0 +1,396 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007, Weta Digital Ltd
|
||||
//
|
||||
// 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 Weta Digital 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Functions related to accessing channels
|
||||
// and views in multi-view OpenEXR files.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfMultiView.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Imf {
|
||||
namespace {
|
||||
|
||||
StringVector
|
||||
parseString (string name, char c = '.')
|
||||
{
|
||||
//
|
||||
// Turn name into a list of strings, separating
|
||||
// on char 'c' with whitespace stripped.
|
||||
//
|
||||
|
||||
StringVector r;
|
||||
|
||||
while (name.size() > 0)
|
||||
{
|
||||
size_t s = name.find (c);
|
||||
string sec = name.substr (0, s);
|
||||
|
||||
//
|
||||
// Strip spaces from beginning
|
||||
//
|
||||
|
||||
while (sec.size() > 0 && sec[0] == ' ')
|
||||
sec.erase (0, 1);
|
||||
|
||||
//
|
||||
// Strip spaces from end
|
||||
//
|
||||
|
||||
while (sec.size() > 0 && sec[sec.size() - 1] == ' ')
|
||||
sec.erase (sec.size() - 1);
|
||||
|
||||
r.push_back (sec);
|
||||
|
||||
//
|
||||
// Strip off name including ending 'c'
|
||||
//
|
||||
|
||||
if (s == name.npos)
|
||||
name = "";
|
||||
else
|
||||
name = name.substr (s + 1);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
viewNum (const string &view, const StringVector &multiView)
|
||||
{
|
||||
//
|
||||
// returns which view number is called 'view'
|
||||
// returns -1 if no member of multiView is 'view'
|
||||
// (i.e. if viewNum() returns -1, 'view' isn't a view name
|
||||
// if viewNum() returns 0, 'view' is the default view
|
||||
// otherwise, it's some other (valid) view
|
||||
//
|
||||
|
||||
for (int i = 0; i < multiView.size(); ++i)
|
||||
{
|
||||
if (multiView[i] == view)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
string
|
||||
defaultViewName (const StringVector &multiView)
|
||||
{
|
||||
if (multiView.size() > 0)
|
||||
return multiView[0];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
viewFromChannelName (const string &channel,
|
||||
const StringVector &multiView)
|
||||
{
|
||||
//
|
||||
// Given the name of a channel, return the name of the view to
|
||||
// which it belongs.
|
||||
//
|
||||
|
||||
//
|
||||
// View name is penultimate section of name separated by periods ('.'s)
|
||||
//
|
||||
|
||||
StringVector s = parseString (channel, '.');
|
||||
|
||||
if (s.size() == 0)
|
||||
return ""; // nothing in, nothing out
|
||||
|
||||
if (s.size() == 1)
|
||||
{
|
||||
//
|
||||
// Return default view name.
|
||||
// The rules say ALL channels with no periods
|
||||
// in the name belong to the default view.
|
||||
//
|
||||
|
||||
return multiView[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// size >= 2 - the last part is the channel name,
|
||||
// the next-to-last part is the view name.
|
||||
// Check if that part of the name really is
|
||||
// a valid view and, if it is, return it.
|
||||
//
|
||||
|
||||
const string &viewName = s[s.size() - 2];
|
||||
|
||||
if (viewNum (viewName, multiView) >= 0)
|
||||
return viewName;
|
||||
else
|
||||
return ""; // not associated with any particular view
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ChannelList
|
||||
channelsInView (const string & viewName,
|
||||
const ChannelList & channelList,
|
||||
const StringVector & multiView)
|
||||
{
|
||||
//
|
||||
// Return a list of all channels belonging to view viewName.
|
||||
//
|
||||
|
||||
ChannelList q;
|
||||
|
||||
for (ChannelList::ConstIterator i = channelList.begin();
|
||||
i != channelList.end();
|
||||
++i)
|
||||
{
|
||||
//
|
||||
// Get view name for this channel
|
||||
//
|
||||
|
||||
string view = viewFromChannelName (i.name(), multiView);
|
||||
|
||||
|
||||
//
|
||||
// Insert channel into q if it's a member of view viewName
|
||||
//
|
||||
|
||||
if (view == viewName)
|
||||
q.insert (i.name(), i.channel());
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
ChannelList
|
||||
channelsInNoView (const ChannelList &channelList,
|
||||
const StringVector &multiView)
|
||||
{
|
||||
//
|
||||
// Return a list of channels not associated with any named view.
|
||||
//
|
||||
|
||||
return channelsInView ("", channelList, multiView);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
areCounterparts (const string &channel1,
|
||||
const string &channel2,
|
||||
const StringVector &multiView)
|
||||
{
|
||||
//
|
||||
// Given two channels, return true if they are the same
|
||||
// channel in two different views.
|
||||
//
|
||||
|
||||
StringVector chan1 = parseString (channel1);
|
||||
unsigned int size1 = chan1.size(); // number of SECTIONS in string
|
||||
// name (not string length)
|
||||
|
||||
StringVector chan2 = parseString (channel2);
|
||||
unsigned int size2 = chan2.size();
|
||||
|
||||
if (size1 == 0 || size2 == 0)
|
||||
return false;
|
||||
|
||||
//
|
||||
// channel1 and channel2 can't be counterparts
|
||||
// if either channel is in no view.
|
||||
//
|
||||
|
||||
if (size1 > 1 && viewNum (chan1[size1 - 2], multiView) == -1)
|
||||
return false;
|
||||
|
||||
if (size2 > 1 && viewNum (chan2[size2 - 2], multiView) == -1)
|
||||
return false;
|
||||
|
||||
if (viewFromChannelName (channel1, multiView) ==
|
||||
viewFromChannelName (channel2, multiView))
|
||||
{
|
||||
//
|
||||
// channel1 and channel2 are not counterparts
|
||||
// if they are in the same view.
|
||||
//
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (size1 == 1)
|
||||
{
|
||||
//
|
||||
// channel1 is a default channel - the channels will only be
|
||||
// counterparts if channel2 is of the form <view>.<channel1>
|
||||
//
|
||||
|
||||
return size2 == 2 && chan1[0] == chan2[1];
|
||||
}
|
||||
|
||||
if (size2 == 1)
|
||||
{
|
||||
//
|
||||
// channel2 is a default channel - the channels will only be
|
||||
// counterparts if channel1 is of the form <view>.<channel2>
|
||||
//
|
||||
|
||||
return size1 == 2 && chan2[0] == chan1[1];
|
||||
}
|
||||
|
||||
//
|
||||
// Neither channel is a default channel. To be counterparts both
|
||||
// channel names must have the same number of components, and
|
||||
// all components except the penultimate one must be the same.
|
||||
//
|
||||
|
||||
if (size1 != size2)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < size1; ++i)
|
||||
{
|
||||
if (i != size1 - 2 && chan1[i] != chan2[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ChannelList
|
||||
channelInAllViews (const string &channelName,
|
||||
const ChannelList &channelList,
|
||||
const StringVector &multiView)
|
||||
{
|
||||
//
|
||||
// Given the name of a channel, return a
|
||||
// list of the same channel in all views.
|
||||
//
|
||||
|
||||
ChannelList q;
|
||||
|
||||
for (ChannelList::ConstIterator i=channelList.begin();
|
||||
i != channelList.end();
|
||||
++i)
|
||||
{
|
||||
if (i.name() == channelName ||
|
||||
areCounterparts (i.name(), channelName, multiView))
|
||||
{
|
||||
q.insert (i.name(), i.channel());
|
||||
}
|
||||
}
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
channelInOtherView (const string &channelName,
|
||||
const ChannelList &channelList,
|
||||
const StringVector &multiView,
|
||||
const string &otherViewName)
|
||||
{
|
||||
//
|
||||
// Given the name of a channel in one view, return the
|
||||
// corresponding channel name for view otherViewName.
|
||||
//
|
||||
|
||||
for (ChannelList::ConstIterator i=channelList.begin();
|
||||
i != channelList.end();
|
||||
++i)
|
||||
{
|
||||
if (viewFromChannelName (i.name(), multiView) == otherViewName &&
|
||||
areCounterparts (i.name(), channelName, multiView))
|
||||
{
|
||||
return i.name();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
insertViewName (const string &channel,
|
||||
const StringVector &multiView,
|
||||
int i)
|
||||
{
|
||||
//
|
||||
// Insert multiView[i] into the channel name if appropriate.
|
||||
//
|
||||
|
||||
StringVector s = parseString (channel, '.');
|
||||
|
||||
if (s.size() == 0)
|
||||
return ""; // nothing in, nothing out
|
||||
|
||||
if (s.size() == 1 && i == 0)
|
||||
{
|
||||
//
|
||||
// Channel in the default view, with no periods in its name.
|
||||
// Do not insert view name.
|
||||
//
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
//
|
||||
// View name becomes penultimate section of new channel name.
|
||||
//
|
||||
|
||||
string newName;
|
||||
|
||||
for (int j = 0; j < s.size(); ++j)
|
||||
{
|
||||
if (j < s.size() - 1)
|
||||
newName += s[j] + ".";
|
||||
else
|
||||
newName += multiView[i] + "." + s[j];
|
||||
}
|
||||
|
||||
return newName;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
164
3rdparty/openexr/IlmImf/ImfMultiView.h
vendored
Normal file
164
3rdparty/openexr/IlmImf/ImfMultiView.h
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007, Weta Digital Ltd
|
||||
//
|
||||
// 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 Weta Digital 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_MULTIVIEW_H
|
||||
#define INCLUDED_IMF_MULTIVIEW_H
|
||||
|
||||
#include <ImfChannelList.h>
|
||||
#include <ImfStringVectorAttribute.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Functions related to accessing channels and views in multi-view
|
||||
// OpenEXR files.
|
||||
//
|
||||
// A multi-view image file contains two or more views of the same
|
||||
// scene, as seen from different viewpoints, for example, a left-eye
|
||||
// and a right-eye view for stereo displays. Each view has its own
|
||||
// set of image channels. A naming convention identifies the channels
|
||||
// that belong to a given view.
|
||||
//
|
||||
// A "multiView" attribute in the file header lists the names of the
|
||||
// views in an image (see ImfStandardAttributes.h), and channel names
|
||||
// of the form
|
||||
//
|
||||
// layer.view.channel
|
||||
//
|
||||
// allow channels to be matched with views.
|
||||
//
|
||||
// For compatibility with singe-view images, the first view listed in
|
||||
// the multiView attribute is the "default view", and channels that
|
||||
// have no periods in their names are considered part of the default
|
||||
// view.
|
||||
//
|
||||
// For example, if a file's multiView attribute lists the views
|
||||
// "left" and "right", in that order, then "left" is the default
|
||||
// view. Channels
|
||||
//
|
||||
// "R", "left.Z", "diffuse.left.R"
|
||||
//
|
||||
// are part of the "left" view; channels
|
||||
//
|
||||
// "right.R", "right.Z", "diffuse.right.R"
|
||||
//
|
||||
// are part of the "right" view; and channels
|
||||
//
|
||||
// "tmp.R", "right.diffuse.R", "diffuse.tmp.R"
|
||||
//
|
||||
// belong to no view at all.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
//
|
||||
// Return the name of the default view given a multi-view string vector,
|
||||
// that is, return the first element of the string vector. If the string
|
||||
// vector is empty, return "".
|
||||
//
|
||||
|
||||
std::string defaultViewName (const StringVector &multiView);
|
||||
|
||||
|
||||
//
|
||||
// Given the name of a channel, return the name of the view to
|
||||
// which it belongs. Returns the empty string ("") if the channel
|
||||
// is not a member of any named view.
|
||||
//
|
||||
|
||||
std::string viewFromChannelName (const std::string &channel,
|
||||
const StringVector &multiView);
|
||||
|
||||
|
||||
//
|
||||
// Return whether channel1 and channel2 are the same channel but
|
||||
// viewed in different views. (Return false if either channel
|
||||
// belongs to no view or if both channels belong to the same view.)
|
||||
//
|
||||
|
||||
bool areCounterparts (const std::string &channel1,
|
||||
const std::string &channel2,
|
||||
const StringVector &multiView);
|
||||
|
||||
//
|
||||
// Return a list of all channels belonging to view viewName.
|
||||
//
|
||||
|
||||
ChannelList channelsInView (const std::string &viewName,
|
||||
const ChannelList &channelList,
|
||||
const StringVector &multiView);
|
||||
|
||||
//
|
||||
// Return a list of channels not associated with any view.
|
||||
//
|
||||
|
||||
ChannelList channelsInNoView (const ChannelList &channelList,
|
||||
const StringVector &multiView);
|
||||
|
||||
//
|
||||
// Given the name of a channel, return a list of the same channel
|
||||
// in all views (for example, given X.left.Y return X.left.Y,
|
||||
// X.right.Y, X.centre.Y, etc.).
|
||||
//
|
||||
|
||||
ChannelList channelInAllViews (const std::string &channame,
|
||||
const ChannelList &channelList,
|
||||
const StringVector &multiView);
|
||||
|
||||
//
|
||||
// Given the name of a channel in one view, return the corresponding
|
||||
// channel name for view otherViewName. Return "" if no corresponding
|
||||
// channel exists in view otherViewName, or if view otherViewName doesn't
|
||||
// exist.
|
||||
//
|
||||
|
||||
std::string channelInOtherView (const std::string &channel,
|
||||
const ChannelList &channelList,
|
||||
const StringVector &multiView,
|
||||
const std::string &otherViewName);
|
||||
|
||||
//
|
||||
// Given a channel name that does not include a view name, insert
|
||||
// multiView[i] into the channel name at the appropriate location.
|
||||
// If i is zero and the channel name contains no periods, then do
|
||||
// not insert the view name.
|
||||
//
|
||||
|
||||
std::string insertViewName (const std::string &channel,
|
||||
const StringVector &multiView,
|
||||
int i);
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
146
3rdparty/openexr/IlmImf/ImfName.h
vendored
Normal file
146
3rdparty/openexr/IlmImf/ImfName.h
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_NAME_H
|
||||
#define INCLUDED_IMF_NAME_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ImfName -- a zero-terminated string
|
||||
// with a fixed, small maximum length
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class Name
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------
|
||||
// Constructors
|
||||
//-------------
|
||||
|
||||
Name ();
|
||||
Name (const char text[]);
|
||||
|
||||
|
||||
//--------------------
|
||||
// Assignment operator
|
||||
//--------------------
|
||||
|
||||
Name & operator = (const char text[]);
|
||||
|
||||
|
||||
//---------------------
|
||||
// Access to the string
|
||||
//---------------------
|
||||
|
||||
const char * text () const {return _text;}
|
||||
const char * operator * () const {return _text;}
|
||||
|
||||
//---------------
|
||||
// Maximum length
|
||||
//---------------
|
||||
|
||||
static const int SIZE = 256;
|
||||
static const int MAX_LENGTH = SIZE - 1;
|
||||
|
||||
private:
|
||||
|
||||
char _text[SIZE];
|
||||
};
|
||||
|
||||
|
||||
bool operator == (const Name &x, const Name &y);
|
||||
bool operator != (const Name &x, const Name &y);
|
||||
bool operator < (const Name &x, const Name &y);
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline functions
|
||||
//-----------------
|
||||
|
||||
inline Name &
|
||||
Name::operator = (const char text[])
|
||||
{
|
||||
strncpy (_text, text, MAX_LENGTH);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Name::Name ()
|
||||
{
|
||||
_text[0] = 0;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
Name::Name (const char text[])
|
||||
{
|
||||
*this = text;
|
||||
_text [MAX_LENGTH] = 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const Name &x, const Name &y)
|
||||
{
|
||||
return strcmp (*x, *y) == 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const Name &x, const Name &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator < (const Name &x, const Name &y)
|
||||
{
|
||||
return strcmp (*x, *y) < 0;
|
||||
}
|
||||
|
||||
|
||||
} // namespace IMF
|
||||
|
||||
#endif
|
125
3rdparty/openexr/IlmImf/ImfOpaqueAttribute.cpp
vendored
Normal file
125
3rdparty/openexr/IlmImf/ImfOpaqueAttribute.cpp
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 OpaqueAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfOpaqueAttribute.h>
|
||||
#include "Iex.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
OpaqueAttribute::OpaqueAttribute (const char typeName[]):
|
||||
_typeName (strlen (typeName) + 1),
|
||||
_dataSize (0)
|
||||
{
|
||||
strcpy (_typeName, typeName);
|
||||
}
|
||||
|
||||
|
||||
OpaqueAttribute::OpaqueAttribute (const OpaqueAttribute &other):
|
||||
_typeName (strlen (other._typeName) + 1),
|
||||
_dataSize (other._dataSize),
|
||||
_data (other._dataSize)
|
||||
{
|
||||
strcpy (_typeName, other._typeName);
|
||||
_data.resizeErase (other._dataSize);
|
||||
memcpy ((char *) _data, (const char *) other._data, other._dataSize);
|
||||
}
|
||||
|
||||
|
||||
OpaqueAttribute::~OpaqueAttribute ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
OpaqueAttribute::typeName () const
|
||||
{
|
||||
return _typeName;
|
||||
}
|
||||
|
||||
|
||||
Attribute *
|
||||
OpaqueAttribute::copy () const
|
||||
{
|
||||
return new OpaqueAttribute (*this);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpaqueAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _data, _dataSize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpaqueAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
_data.resizeErase (size);
|
||||
_dataSize = size;
|
||||
Xdr::read <StreamIO> (is, _data, size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OpaqueAttribute::copyValueFrom (const Attribute &other)
|
||||
{
|
||||
const OpaqueAttribute *oa = dynamic_cast <const OpaqueAttribute *> (&other);
|
||||
|
||||
if (oa == 0 || strcmp (_typeName, oa->_typeName))
|
||||
{
|
||||
THROW (Iex::TypeExc, "Cannot copy the value of an "
|
||||
"image file attribute of type "
|
||||
"\"" << other.typeName() << "\" "
|
||||
"to an attribute of type "
|
||||
"\"" << _typeName << "\".");
|
||||
}
|
||||
|
||||
_data.resizeErase (oa->_dataSize);
|
||||
_dataSize = oa->_dataSize;
|
||||
memcpy ((char *) _data, (const char *) oa->_data, oa->_dataSize);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
114
3rdparty/openexr/IlmImf/ImfOpaqueAttribute.h
vendored
Normal file
114
3rdparty/openexr/IlmImf/ImfOpaqueAttribute.h
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_OPAQUE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_OPAQUE_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class OpaqueAttribute
|
||||
//
|
||||
// When an image file is read, OpqaqueAttribute objects are used
|
||||
// to hold the values of attributes whose types are not recognized
|
||||
// by the reading program. OpaqueAttribute objects can be read
|
||||
// from an image file, copied, and written back to to another image
|
||||
// file, but their values are inaccessible.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfAttribute.h>
|
||||
#include <ImfArray.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
class OpaqueAttribute: public Attribute
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------
|
||||
// Constructors and destructor
|
||||
//----------------------------
|
||||
|
||||
OpaqueAttribute (const char typeName[]);
|
||||
OpaqueAttribute (const OpaqueAttribute &other);
|
||||
virtual ~OpaqueAttribute ();
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Get this attribute's type name
|
||||
//-------------------------------
|
||||
|
||||
virtual const char * typeName () const;
|
||||
|
||||
|
||||
//------------------------------
|
||||
// Make a copy of this attribute
|
||||
//------------------------------
|
||||
|
||||
virtual Attribute * copy () const;
|
||||
|
||||
|
||||
//----------------
|
||||
// I/O and copying
|
||||
//----------------
|
||||
|
||||
virtual void writeValueTo (OStream &os,
|
||||
int version) const;
|
||||
|
||||
virtual void readValueFrom (IStream &is,
|
||||
int size,
|
||||
int version);
|
||||
|
||||
virtual void copyValueFrom (const Attribute &other);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array<char> _typeName;
|
||||
long _dataSize;
|
||||
Array<char> _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
// Metrowerks compiler wants the .cpp file inlined, too
|
||||
#ifdef __MWERKS__
|
||||
#include <ImfOpaqueAttribute.cpp>
|
||||
#endif
|
||||
|
||||
#endif
|
1287
3rdparty/openexr/IlmImf/ImfOutputFile.cpp
vendored
Normal file
1287
3rdparty/openexr/IlmImf/ImfOutputFile.cpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
241
3rdparty/openexr/IlmImf/ImfOutputFile.h
vendored
Normal file
241
3rdparty/openexr/IlmImf/ImfOutputFile.h
vendored
Normal file
@ -0,0 +1,241 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_OUTPUT_FILE_H
|
||||
#define INCLUDED_IMF_OUTPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class OutputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImfThreading.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class InputFile;
|
||||
struct PreviewRgba;
|
||||
|
||||
|
||||
class OutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Constructor -- opens the file and writes the file header.
|
||||
// The file header is also copied into the OutputFile object,
|
||||
// and can later be accessed via the header() method.
|
||||
// Destroying this OutputFile object automatically closes
|
||||
// the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to write the file (see ImfThreading.h).
|
||||
//-----------------------------------------------------------
|
||||
|
||||
OutputFile (const char fileName[], const Header &header,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Constructor -- attaches the new OutputFile object to a file
|
||||
// that has already been opened, and writes the file header.
|
||||
// The file header is also copied into the OutputFile object,
|
||||
// and can later be accessed via the header() method.
|
||||
// Destroying this OutputFile object does not automatically
|
||||
// close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to write the file (see ImfThreading.h).
|
||||
//------------------------------------------------------------
|
||||
|
||||
OutputFile (OStream &os, const Header &header,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Destroying the OutputFile object before writing
|
||||
// all scan lines within the data window results in
|
||||
// an incomplete file.
|
||||
//-------------------------------------------------
|
||||
|
||||
virtual ~OutputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// Access to the file name
|
||||
//------------------------
|
||||
|
||||
const char * fileName () const;
|
||||
|
||||
|
||||
//--------------------------
|
||||
// Access to the file header
|
||||
//--------------------------
|
||||
|
||||
const Header & header () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Set the current frame buffer -- copies the FrameBuffer
|
||||
// object into the OutputFile object.
|
||||
//
|
||||
// The current frame buffer is the source of the pixel
|
||||
// data written to the file. The current frame buffer
|
||||
// must be set at least once before writePixels() is
|
||||
// called. The current frame buffer can be changed
|
||||
// after each call to writePixels.
|
||||
//-------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Write pixel data:
|
||||
//
|
||||
// writePixels(n) retrieves the next n scan lines worth of data from
|
||||
// the current frame buffer, starting with the scan line indicated by
|
||||
// currentScanLine(), and stores the data in the output file, and
|
||||
// progressing in the direction indicated by header.lineOrder().
|
||||
//
|
||||
// To produce a complete and correct file, exactly m scan lines must
|
||||
// be written, where m is equal to
|
||||
// header().dataWindow().max.y - header().dataWindow().min.y + 1.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void writePixels (int numScanLines = 1);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to the current scan line:
|
||||
//
|
||||
// currentScanLine() returns the y coordinate of the first scan line
|
||||
// that will be read from the current frame buffer during the next
|
||||
// call to writePixels().
|
||||
//
|
||||
// If header.lineOrder() == INCREASING_Y:
|
||||
//
|
||||
// The current scan line before the first call to writePixels()
|
||||
// is header().dataWindow().min.y. After writing each scan line,
|
||||
// the current scan line is incremented by 1.
|
||||
//
|
||||
// If header.lineOrder() == DECREASING_Y:
|
||||
//
|
||||
// The current scan line before the first call to writePixels()
|
||||
// is header().dataWindow().max.y. After writing each scan line,
|
||||
// the current scan line is decremented by 1.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
int currentScanLine () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Shortcut to copy all pixels from an InputFile into this file,
|
||||
// without uncompressing and then recompressing the pixel data.
|
||||
// This file's header must be compatible with the InputFile's
|
||||
// header: The two header's "dataWindow", "compression",
|
||||
// "lineOrder" and "channels" attributes must be the same.
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void copyPixels (InputFile &in);
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Updating the preview image:
|
||||
//
|
||||
// updatePreviewImage() supplies a new set of pixels for the
|
||||
// preview image attribute in the file's header. If the header
|
||||
// does not contain a preview image, updatePreviewImage() throws
|
||||
// an Iex::LogicExc.
|
||||
//
|
||||
// Note: updatePreviewImage() is necessary because images are
|
||||
// often stored in a file incrementally, a few scan lines at a
|
||||
// time, while the image is being generated. Since the preview
|
||||
// image is an attribute in the file's header, it gets stored in
|
||||
// the file as soon as the file is opened, but we may not know
|
||||
// what the preview image should look like until we have written
|
||||
// the last scan line of the main image.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba newPixels[]);
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Break a scan line -- for testing and debugging only:
|
||||
//
|
||||
// breakScanLine(y,p,n,c) introduces an error into the
|
||||
// output file by writing n copies of character c, starting
|
||||
// p bytes from the beginning of the pixel data block that
|
||||
// contains scan line y.
|
||||
//
|
||||
// Warning: Calling this function usually results in a
|
||||
// broken image file. The file or parts of it may not
|
||||
// be readable, or the file may contain bad data.
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
void breakScanLine (int y, int offset, int length, char c);
|
||||
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
OutputFile (const OutputFile &); // not implemented
|
||||
OutputFile & operator = (const OutputFile &); // not implemented
|
||||
|
||||
void initialize (const Header &header);
|
||||
|
||||
Data * _data;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
61
3rdparty/openexr/IlmImf/ImfPixelType.h
vendored
Normal file
61
3rdparty/openexr/IlmImf/ImfPixelType.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_PIXEL_TYPE_H
|
||||
#define INCLUDED_IMF_PIXEL_TYPE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum PixelType
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
enum PixelType
|
||||
{
|
||||
UINT = 0, // unsigned int (32 bit)
|
||||
HALF = 1, // half (16 bit floating point)
|
||||
FLOAT = 2, // float (32 bit floating point)
|
||||
|
||||
NUM_PIXELTYPES // number of different pixel types
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
666
3rdparty/openexr/IlmImf/ImfPizCompressor.cpp
vendored
Normal file
666
3rdparty/openexr/IlmImf/ImfPizCompressor.cpp
vendored
Normal file
@ -0,0 +1,666 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 PizCompressor
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfPizCompressor.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfChannelList.h>
|
||||
#include <ImfHuf.h>
|
||||
#include <ImfWav.h>
|
||||
#include <ImfMisc.h>
|
||||
#include <ImfCheckedArithmetic.h>
|
||||
#include <ImathFun.h>
|
||||
#include <ImathBox.h>
|
||||
#include <Iex.h>
|
||||
#include <ImfIO.h>
|
||||
#include <ImfXdr.h>
|
||||
#include <ImfAutoArray.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
using Imath::divp;
|
||||
using Imath::modp;
|
||||
using Imath::Box2i;
|
||||
using Imath::V2i;
|
||||
using Iex::InputExc;
|
||||
|
||||
namespace {
|
||||
|
||||
//
|
||||
// Functions to compress the range of values in the pixel data
|
||||
//
|
||||
|
||||
const int USHORT_RANGE = (1 << 16);
|
||||
const int BITMAP_SIZE = (USHORT_RANGE >> 3);
|
||||
|
||||
void
|
||||
bitmapFromData (const unsigned short data[/*nData*/],
|
||||
int nData,
|
||||
unsigned char bitmap[BITMAP_SIZE],
|
||||
unsigned short &minNonZero,
|
||||
unsigned short &maxNonZero)
|
||||
{
|
||||
for (int i = 0; i < BITMAP_SIZE; ++i)
|
||||
bitmap[i] = 0;
|
||||
|
||||
for (int i = 0; i < nData; ++i)
|
||||
bitmap[data[i] >> 3] |= (1 << (data[i] & 7));
|
||||
|
||||
bitmap[0] &= ~1; // zero is not explicitly stored in
|
||||
// the bitmap; we assume that the
|
||||
// data always contain zeroes
|
||||
minNonZero = BITMAP_SIZE - 1;
|
||||
maxNonZero = 0;
|
||||
|
||||
for (int i = 0; i < BITMAP_SIZE; ++i)
|
||||
{
|
||||
if (bitmap[i])
|
||||
{
|
||||
if (minNonZero > i)
|
||||
minNonZero = i;
|
||||
if (maxNonZero < i)
|
||||
maxNonZero = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned short
|
||||
forwardLutFromBitmap (const unsigned char bitmap[BITMAP_SIZE],
|
||||
unsigned short lut[USHORT_RANGE])
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
for (int i = 0; i < USHORT_RANGE; ++i)
|
||||
{
|
||||
if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7))))
|
||||
lut[i] = k++;
|
||||
else
|
||||
lut[i] = 0;
|
||||
}
|
||||
|
||||
return k - 1; // maximum value stored in lut[],
|
||||
} // i.e. number of ones in bitmap minus 1
|
||||
|
||||
|
||||
unsigned short
|
||||
reverseLutFromBitmap (const unsigned char bitmap[BITMAP_SIZE],
|
||||
unsigned short lut[USHORT_RANGE])
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
for (int i = 0; i < USHORT_RANGE; ++i)
|
||||
{
|
||||
if ((i == 0) || (bitmap[i >> 3] & (1 << (i & 7))))
|
||||
lut[k++] = i;
|
||||
}
|
||||
|
||||
int n = k - 1;
|
||||
|
||||
while (k < USHORT_RANGE)
|
||||
lut[k++] = 0;
|
||||
|
||||
return n; // maximum k where lut[k] is non-zero,
|
||||
} // i.e. number of ones in bitmap minus 1
|
||||
|
||||
|
||||
void
|
||||
applyLut (const unsigned short lut[USHORT_RANGE],
|
||||
unsigned short data[/*nData*/],
|
||||
int nData)
|
||||
{
|
||||
for (int i = 0; i < nData; ++i)
|
||||
data[i] = lut[data[i]];
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
struct PizCompressor::ChannelData
|
||||
{
|
||||
unsigned short * start;
|
||||
unsigned short * end;
|
||||
int nx;
|
||||
int ny;
|
||||
int ys;
|
||||
int size;
|
||||
};
|
||||
|
||||
|
||||
PizCompressor::PizCompressor
|
||||
(const Header &hdr,
|
||||
size_t maxScanLineSize,
|
||||
size_t numScanLines)
|
||||
:
|
||||
Compressor (hdr),
|
||||
_maxScanLineSize (maxScanLineSize),
|
||||
_format (XDR),
|
||||
_numScanLines (numScanLines),
|
||||
_tmpBuffer (0),
|
||||
_outBuffer (0),
|
||||
_numChans (0),
|
||||
_channels (hdr.channels()),
|
||||
_channelData (0)
|
||||
{
|
||||
size_t tmpBufferSize =
|
||||
uiMult (maxScanLineSize, numScanLines) / 2;
|
||||
|
||||
size_t outBufferSize =
|
||||
uiAdd (uiMult (maxScanLineSize, numScanLines),
|
||||
size_t (65536 + 8192));
|
||||
|
||||
_tmpBuffer = new unsigned short
|
||||
[checkArraySize (tmpBufferSize, sizeof (unsigned short))];
|
||||
|
||||
_outBuffer = new char [outBufferSize];
|
||||
|
||||
const ChannelList &channels = header().channels();
|
||||
bool onlyHalfChannels = true;
|
||||
|
||||
for (ChannelList::ConstIterator c = channels.begin();
|
||||
c != channels.end();
|
||||
++c)
|
||||
{
|
||||
_numChans++;
|
||||
|
||||
assert (pixelTypeSize (c.channel().type) % pixelTypeSize (HALF) == 0);
|
||||
|
||||
if (c.channel().type != HALF)
|
||||
onlyHalfChannels = false;
|
||||
}
|
||||
|
||||
_channelData = new ChannelData[_numChans];
|
||||
|
||||
const Box2i &dataWindow = hdr.dataWindow();
|
||||
|
||||
_minX = dataWindow.min.x;
|
||||
_maxX = dataWindow.max.x;
|
||||
_maxY = dataWindow.max.y;
|
||||
|
||||
//
|
||||
// We can support uncompressed data in the machine's native format
|
||||
// if all image channels are of type HALF, and if the Xdr and the
|
||||
// native represenations of a half have the same size.
|
||||
//
|
||||
|
||||
if (onlyHalfChannels && (sizeof (half) == pixelTypeSize (HALF)))
|
||||
_format = NATIVE;
|
||||
}
|
||||
|
||||
|
||||
PizCompressor::~PizCompressor ()
|
||||
{
|
||||
delete [] _tmpBuffer;
|
||||
delete [] _outBuffer;
|
||||
delete [] _channelData;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::numScanLines () const
|
||||
{
|
||||
return _numScanLines;
|
||||
}
|
||||
|
||||
|
||||
Compressor::Format
|
||||
PizCompressor::format () const
|
||||
{
|
||||
return _format;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::compress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr)
|
||||
{
|
||||
return compress (inPtr,
|
||||
inSize,
|
||||
Box2i (V2i (_minX, minY),
|
||||
V2i (_maxX, minY + numScanLines() - 1)),
|
||||
outPtr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::compressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr)
|
||||
{
|
||||
return compress (inPtr, inSize, range, outPtr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr)
|
||||
{
|
||||
return uncompress (inPtr,
|
||||
inSize,
|
||||
Box2i (V2i (_minX, minY),
|
||||
V2i (_maxX, minY + numScanLines() - 1)),
|
||||
outPtr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::uncompressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr)
|
||||
{
|
||||
return uncompress (inPtr, inSize, range, outPtr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::compress (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr)
|
||||
{
|
||||
//
|
||||
// This is the compress function which is used by both the tiled and
|
||||
// scanline compression routines.
|
||||
//
|
||||
|
||||
//
|
||||
// Special case - empty input buffer
|
||||
//
|
||||
|
||||
if (inSize == 0)
|
||||
{
|
||||
outPtr = _outBuffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Rearrange the pixel data so that the wavelet
|
||||
// and Huffman encoders can process them easily.
|
||||
//
|
||||
// The wavelet and Huffman encoders both handle only
|
||||
// 16-bit data, so 32-bit data must be split into smaller
|
||||
// pieces. We treat each 32-bit channel (UINT, FLOAT) as
|
||||
// two interleaved 16-bit channels.
|
||||
//
|
||||
|
||||
int minX = range.min.x;
|
||||
int maxX = range.max.x;
|
||||
int minY = range.min.y;
|
||||
int maxY = range.max.y;
|
||||
|
||||
if (maxY > _maxY)
|
||||
maxY = _maxY;
|
||||
|
||||
if (maxX > _maxX)
|
||||
maxX = _maxX;
|
||||
|
||||
unsigned short *tmpBufferEnd = _tmpBuffer;
|
||||
int i = 0;
|
||||
|
||||
for (ChannelList::ConstIterator c = _channels.begin();
|
||||
c != _channels.end();
|
||||
++c, ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
cd.start = tmpBufferEnd;
|
||||
cd.end = cd.start;
|
||||
|
||||
cd.nx = numSamples (c.channel().xSampling, minX, maxX);
|
||||
cd.ny = numSamples (c.channel().ySampling, minY, maxY);
|
||||
cd.ys = c.channel().ySampling;
|
||||
|
||||
cd.size = pixelTypeSize (c.channel().type) / pixelTypeSize (HALF);
|
||||
|
||||
tmpBufferEnd += cd.nx * cd.ny * cd.size;
|
||||
}
|
||||
|
||||
if (_format == XDR)
|
||||
{
|
||||
//
|
||||
// Machine-independent (Xdr) data format
|
||||
//
|
||||
|
||||
for (int y = minY; y <= maxY; ++y)
|
||||
{
|
||||
for (int i = 0; i < _numChans; ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
if (modp (y, cd.ys) != 0)
|
||||
continue;
|
||||
|
||||
for (int x = cd.nx * cd.size; x > 0; --x)
|
||||
{
|
||||
Xdr::read <CharPtrIO> (inPtr, *cd.end);
|
||||
++cd.end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Native, machine-dependent data format
|
||||
//
|
||||
|
||||
for (int y = minY; y <= maxY; ++y)
|
||||
{
|
||||
for (int i = 0; i < _numChans; ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
if (modp (y, cd.ys) != 0)
|
||||
continue;
|
||||
|
||||
int n = cd.nx * cd.size;
|
||||
memcpy (cd.end, inPtr, n * sizeof (unsigned short));
|
||||
inPtr += n * sizeof (unsigned short);
|
||||
cd.end += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
|
||||
for (int i = 1; i < _numChans; ++i)
|
||||
assert (_channelData[i-1].end == _channelData[i].start);
|
||||
|
||||
assert (_channelData[_numChans-1].end == tmpBufferEnd);
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Compress the range of the pixel data
|
||||
//
|
||||
|
||||
AutoArray <unsigned char, BITMAP_SIZE> bitmap;
|
||||
unsigned short minNonZero;
|
||||
unsigned short maxNonZero;
|
||||
|
||||
bitmapFromData (_tmpBuffer,
|
||||
tmpBufferEnd - _tmpBuffer,
|
||||
bitmap,
|
||||
minNonZero, maxNonZero);
|
||||
|
||||
AutoArray <unsigned short, USHORT_RANGE> lut;
|
||||
unsigned short maxValue = forwardLutFromBitmap (bitmap, lut);
|
||||
applyLut (lut, _tmpBuffer, tmpBufferEnd - _tmpBuffer);
|
||||
|
||||
//
|
||||
// Store range compression info in _outBuffer
|
||||
//
|
||||
|
||||
char *buf = _outBuffer;
|
||||
|
||||
Xdr::write <CharPtrIO> (buf, minNonZero);
|
||||
Xdr::write <CharPtrIO> (buf, maxNonZero);
|
||||
|
||||
if (minNonZero <= maxNonZero)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (buf, (char *) &bitmap[0] + minNonZero,
|
||||
maxNonZero - minNonZero + 1);
|
||||
}
|
||||
|
||||
//
|
||||
// Apply wavelet encoding
|
||||
//
|
||||
|
||||
for (int i = 0; i < _numChans; ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
for (int j = 0; j < cd.size; ++j)
|
||||
{
|
||||
wav2Encode (cd.start + j,
|
||||
cd.nx, cd.size,
|
||||
cd.ny, cd.nx * cd.size,
|
||||
maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Huffman encoding; append the result to _outBuffer
|
||||
//
|
||||
|
||||
char *lengthPtr = buf;
|
||||
Xdr::write <CharPtrIO> (buf, int(0));
|
||||
|
||||
int length = hufCompress (_tmpBuffer, tmpBufferEnd - _tmpBuffer, buf);
|
||||
Xdr::write <CharPtrIO> (lengthPtr, length);
|
||||
|
||||
outPtr = _outBuffer;
|
||||
return buf - _outBuffer + length;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PizCompressor::uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr)
|
||||
{
|
||||
//
|
||||
// This is the cunompress function which is used by both the tiled and
|
||||
// scanline decompression routines.
|
||||
//
|
||||
|
||||
//
|
||||
// Special case - empty input buffer
|
||||
//
|
||||
|
||||
if (inSize == 0)
|
||||
{
|
||||
outPtr = _outBuffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Determine the layout of the compressed pixel data
|
||||
//
|
||||
|
||||
int minX = range.min.x;
|
||||
int maxX = range.max.x;
|
||||
int minY = range.min.y;
|
||||
int maxY = range.max.y;
|
||||
|
||||
if (maxY > _maxY)
|
||||
maxY = _maxY;
|
||||
|
||||
if (maxX > _maxX)
|
||||
maxX = _maxX;
|
||||
|
||||
unsigned short *tmpBufferEnd = _tmpBuffer;
|
||||
int i = 0;
|
||||
|
||||
for (ChannelList::ConstIterator c = _channels.begin();
|
||||
c != _channels.end();
|
||||
++c, ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
cd.start = tmpBufferEnd;
|
||||
cd.end = cd.start;
|
||||
|
||||
cd.nx = numSamples (c.channel().xSampling, minX, maxX);
|
||||
cd.ny = numSamples (c.channel().ySampling, minY, maxY);
|
||||
cd.ys = c.channel().ySampling;
|
||||
|
||||
cd.size = pixelTypeSize (c.channel().type) / pixelTypeSize (HALF);
|
||||
|
||||
tmpBufferEnd += cd.nx * cd.ny * cd.size;
|
||||
}
|
||||
|
||||
//
|
||||
// Read range compression data
|
||||
//
|
||||
|
||||
unsigned short minNonZero;
|
||||
unsigned short maxNonZero;
|
||||
|
||||
AutoArray <unsigned char, BITMAP_SIZE> bitmap;
|
||||
memset (bitmap, 0, sizeof (unsigned char) * BITMAP_SIZE);
|
||||
|
||||
Xdr::read <CharPtrIO> (inPtr, minNonZero);
|
||||
Xdr::read <CharPtrIO> (inPtr, maxNonZero);
|
||||
|
||||
if (maxNonZero >= BITMAP_SIZE)
|
||||
{
|
||||
throw InputExc ("Error in header for PIZ-compressed data "
|
||||
"(invalid bitmap size).");
|
||||
}
|
||||
|
||||
if (minNonZero <= maxNonZero)
|
||||
{
|
||||
Xdr::read <CharPtrIO> (inPtr, (char *) &bitmap[0] + minNonZero,
|
||||
maxNonZero - minNonZero + 1);
|
||||
}
|
||||
|
||||
AutoArray <unsigned short, USHORT_RANGE> lut;
|
||||
unsigned short maxValue = reverseLutFromBitmap (bitmap, lut);
|
||||
|
||||
//
|
||||
// Huffman decoding
|
||||
//
|
||||
|
||||
int length;
|
||||
Xdr::read <CharPtrIO> (inPtr, length);
|
||||
|
||||
hufUncompress (inPtr, length, _tmpBuffer, tmpBufferEnd - _tmpBuffer);
|
||||
|
||||
//
|
||||
// Wavelet decoding
|
||||
//
|
||||
|
||||
for (int i = 0; i < _numChans; ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
for (int j = 0; j < cd.size; ++j)
|
||||
{
|
||||
wav2Decode (cd.start + j,
|
||||
cd.nx, cd.size,
|
||||
cd.ny, cd.nx * cd.size,
|
||||
maxValue);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Expand the pixel data to their original range
|
||||
//
|
||||
|
||||
applyLut (lut, _tmpBuffer, tmpBufferEnd - _tmpBuffer);
|
||||
|
||||
//
|
||||
// Rearrange the pixel data into the format expected by the caller.
|
||||
//
|
||||
|
||||
char *outEnd = _outBuffer;
|
||||
|
||||
if (_format == XDR)
|
||||
{
|
||||
//
|
||||
// Machine-independent (Xdr) data format
|
||||
//
|
||||
|
||||
for (int y = minY; y <= maxY; ++y)
|
||||
{
|
||||
for (int i = 0; i < _numChans; ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
if (modp (y, cd.ys) != 0)
|
||||
continue;
|
||||
|
||||
for (int x = cd.nx * cd.size; x > 0; --x)
|
||||
{
|
||||
Xdr::write <CharPtrIO> (outEnd, *cd.end);
|
||||
++cd.end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Native, machine-dependent data format
|
||||
//
|
||||
|
||||
for (int y = minY; y <= maxY; ++y)
|
||||
{
|
||||
for (int i = 0; i < _numChans; ++i)
|
||||
{
|
||||
ChannelData &cd = _channelData[i];
|
||||
|
||||
if (modp (y, cd.ys) != 0)
|
||||
continue;
|
||||
|
||||
int n = cd.nx * cd.size;
|
||||
memcpy (outEnd, cd.end, n * sizeof (unsigned short));
|
||||
outEnd += n * sizeof (unsigned short);
|
||||
cd.end += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
|
||||
for (int i = 1; i < _numChans; ++i)
|
||||
assert (_channelData[i-1].end == _channelData[i].start);
|
||||
|
||||
assert (_channelData[_numChans-1].end == tmpBufferEnd);
|
||||
|
||||
#endif
|
||||
|
||||
outPtr = _outBuffer;
|
||||
return outEnd - _outBuffer;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
115
3rdparty/openexr/IlmImf/ImfPizCompressor.h
vendored
Normal file
115
3rdparty/openexr/IlmImf/ImfPizCompressor.h
vendored
Normal file
@ -0,0 +1,115 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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_PIZ_COMPRESSOR_H
|
||||
#define INCLUDED_IMF_PIZ_COMPRESSOR_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class PizCompressor -- uses Wavelet and Huffman encoding.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfCompressor.h>
|
||||
|
||||
namespace Imf {
|
||||
|
||||
class ChannelList;
|
||||
|
||||
|
||||
class PizCompressor: public Compressor
|
||||
{
|
||||
public:
|
||||
|
||||
PizCompressor (const Header &hdr,
|
||||
size_t maxScanLineSize,
|
||||
size_t numScanLines);
|
||||
|
||||
virtual ~PizCompressor ();
|
||||
|
||||
virtual int numScanLines () const;
|
||||
|
||||
virtual Format format () const;
|
||||
|
||||
virtual int compress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr);
|
||||
|
||||
virtual int compressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
virtual int uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
int minY,
|
||||
const char *&outPtr);
|
||||
|
||||
virtual int uncompressTile (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
private:
|
||||
|
||||
struct ChannelData;
|
||||
|
||||
int compress (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
int uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
Imath::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
int _maxScanLineSize;
|
||||
Format _format;
|
||||
int _numScanLines;
|
||||
unsigned short * _tmpBuffer;
|
||||
char * _outBuffer;
|
||||
int _numChans;
|
||||
const ChannelList & _channels;
|
||||
ChannelData * _channelData;
|
||||
int _minX;
|
||||
int _maxX;
|
||||
int _maxY;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
103
3rdparty/openexr/IlmImf/ImfPreviewImage.cpp
vendored
Normal file
103
3rdparty/openexr/IlmImf/ImfPreviewImage.cpp
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, 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 PreviewImage
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfPreviewImage.h>
|
||||
#include <ImfCheckedArithmetic.h>
|
||||
#include "Iex.h"
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
PreviewImage::PreviewImage (unsigned int width,
|
||||
unsigned int height,
|
||||
const PreviewRgba pixels[])
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
_pixels = new PreviewRgba
|
||||
[checkArraySize (uiMult (_width, _height), sizeof (PreviewRgba))];
|
||||
|
||||
if (pixels)
|
||||
{
|
||||
for (unsigned int i = 0; i < _width * _height; ++i)
|
||||
_pixels[i] = pixels[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < _width * _height; ++i)
|
||||
_pixels[i] = PreviewRgba();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PreviewImage::PreviewImage (const PreviewImage &other):
|
||||
_width (other._width),
|
||||
_height (other._height),
|
||||
_pixels (new PreviewRgba [other._width * other._height])
|
||||
{
|
||||
for (unsigned int i = 0; i < _width * _height; ++i)
|
||||
_pixels[i] = other._pixels[i];
|
||||
}
|
||||
|
||||
|
||||
PreviewImage::~PreviewImage ()
|
||||
{
|
||||
delete [] _pixels;
|
||||
}
|
||||
|
||||
|
||||
PreviewImage &
|
||||
PreviewImage::operator = (const PreviewImage &other)
|
||||
{
|
||||
delete [] _pixels;
|
||||
|
||||
_width = other._width;
|
||||
_height = other._height;
|
||||
_pixels = new PreviewRgba [other._width * other._height];
|
||||
|
||||
for (unsigned int i = 0; i < _width * _height; ++i)
|
||||
_pixels[i] = other._pixels[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
131
3rdparty/openexr/IlmImf/ImfPreviewImage.h
vendored
Normal file
131
3rdparty/openexr/IlmImf/ImfPreviewImage.h
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2003, 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_PREVIEW_IMAGE_H
|
||||
#define INCLUDED_IMF_PREVIEW_IMAGE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class PreviewImage -- a usually small, low-dynamic range image,
|
||||
// that is intended to be stored in an image file's header.
|
||||
//
|
||||
// struct PreviewRgba -- holds the value of a PreviewImage pixel.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
struct PreviewRgba
|
||||
{
|
||||
unsigned char r; // Red, green and blue components of
|
||||
unsigned char g; // the pixel's color; intensity is
|
||||
unsigned char b; // proportional to pow (x/255, 2.2),
|
||||
// where x is r, g, or b.
|
||||
|
||||
unsigned char a; // The pixel's alpha; 0 == transparent,
|
||||
// 255 == opaque.
|
||||
|
||||
PreviewRgba (unsigned char r = 0,
|
||||
unsigned char g = 0,
|
||||
unsigned char b = 0,
|
||||
unsigned char a = 255)
|
||||
: r(r), g(g), b(b), a(a) {}
|
||||
};
|
||||
|
||||
|
||||
class PreviewImage
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Constructor:
|
||||
//
|
||||
// PreviewImage(w,h,p) constructs a preview image with w by h pixels
|
||||
// whose initial values are specified in pixel array p. The x and y
|
||||
// coordinates of the pixels in p go from 0 to w-1, and from 0 to h-1.
|
||||
// The pixel with coordinates (x, y) is at address p + y*w + x.
|
||||
// Pixel (0, 0) is in the upper left corner of the preview image.
|
||||
// If p is zero, the pixels in the preview image are initialized with
|
||||
// (r = 0, b = 0, g = 0, a = 255).
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
PreviewImage (unsigned int width = 0,
|
||||
unsigned int height = 0,
|
||||
const PreviewRgba pixels[] = 0);
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Copy constructor, destructor and assignment operator
|
||||
//-----------------------------------------------------
|
||||
|
||||
PreviewImage (const PreviewImage &other);
|
||||
~PreviewImage ();
|
||||
|
||||
PreviewImage & operator = (const PreviewImage &other);
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
// Access to width, height and to the pixel array
|
||||
//-----------------------------------------------
|
||||
|
||||
unsigned int width () const {return _width;}
|
||||
unsigned int height () const {return _height;}
|
||||
|
||||
PreviewRgba * pixels () {return _pixels;}
|
||||
const PreviewRgba * pixels () const {return _pixels;}
|
||||
|
||||
|
||||
//----------------------------
|
||||
// Access to individual pixels
|
||||
//----------------------------
|
||||
|
||||
PreviewRgba & pixel (unsigned int x, unsigned int y)
|
||||
{return _pixels[y * _width + x];}
|
||||
|
||||
const PreviewRgba & pixel (unsigned int x, unsigned int y) const
|
||||
{return _pixels[y * _width + x];}
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _width;
|
||||
unsigned int _height;
|
||||
PreviewRgba * _pixels;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Imf
|
||||
|
||||
#endif
|
102
3rdparty/openexr/IlmImf/ImfPreviewImageAttribute.cpp
vendored
Normal file
102
3rdparty/openexr/IlmImf/ImfPreviewImageAttribute.cpp
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, 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 PreviewImageAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfPreviewImageAttribute.h>
|
||||
|
||||
|
||||
namespace Imf {
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
PreviewImageAttribute::staticTypeName ()
|
||||
{
|
||||
return "preview";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
PreviewImageAttribute::writeValueTo (OStream &os, int version) const
|
||||
{
|
||||
Xdr::write <StreamIO> (os, _value.width());
|
||||
Xdr::write <StreamIO> (os, _value.height());
|
||||
|
||||
int numPixels = _value.width() * _value.height();
|
||||
const PreviewRgba *pixels = _value.pixels();
|
||||
|
||||
for (int i = 0; i < numPixels; ++i)
|
||||
{
|
||||
Xdr::write <StreamIO> (os, pixels[i].r);
|
||||
Xdr::write <StreamIO> (os, pixels[i].g);
|
||||
Xdr::write <StreamIO> (os, pixels[i].b);
|
||||
Xdr::write <StreamIO> (os, pixels[i].a);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
PreviewImageAttribute::readValueFrom (IStream &is, int size, int version)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
Xdr::read <StreamIO> (is, width);
|
||||
Xdr::read <StreamIO> (is, height);
|
||||
|
||||
PreviewImage p (width, height);
|
||||
|
||||
int numPixels = p.width() * p.height();
|
||||
PreviewRgba *pixels = p.pixels();
|
||||
|
||||
for (int i = 0; i < numPixels; ++i)
|
||||
{
|
||||
Xdr::read <StreamIO> (is, pixels[i].r);
|
||||
Xdr::read <StreamIO> (is, pixels[i].g);
|
||||
Xdr::read <StreamIO> (is, pixels[i].b);
|
||||
Xdr::read <StreamIO> (is, pixels[i].a);
|
||||
}
|
||||
|
||||
_value = p;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Imf
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user