Disabled external gits
This commit is contained in:
17
cs440-acg/ext/openexr/OpenEXR/.cvsignore
Normal file
17
cs440-acg/ext/openexr/OpenEXR/.cvsignore
Normal file
@@ -0,0 +1,17 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
config.h.in
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
libtool
|
||||
stamp-h
|
||||
aclocal.m4
|
||||
OpenEXR.pc
|
||||
autom4te.cache
|
||||
ltmain.sh
|
||||
stamp-h.in
|
||||
depcomp
|
||||
.deps
|
||||
CVS
|
||||
28
cs440-acg/ext/openexr/OpenEXR/.gitignore
vendored
Normal file
28
cs440-acg/ext/openexr/OpenEXR/.gitignore
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
IlmImf/b44ExpLogTable
|
||||
IlmImf/dwaLookups
|
||||
OpenEXR.pc
|
||||
autom4te.cache/
|
||||
config.guess
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
config/OpenEXRConfig.h
|
||||
config/stamp-h1
|
||||
configure
|
||||
depcomp
|
||||
exr2aces/exr2aces
|
||||
exrbuild/exrbuild
|
||||
exrenvmap/exrenvmap
|
||||
exrbuild/exrbuild
|
||||
exrheader/exrheader
|
||||
exrmakepreview/exrmakepreview
|
||||
exrmaketiled/exrmaketiled
|
||||
exrmultipart/exrmultipart
|
||||
exrmultiview/exrmultiview
|
||||
exrstdattr/exrstdattr
|
||||
install-sh
|
||||
libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
.metadata/
|
||||
|
||||
47
cs440-acg/ext/openexr/OpenEXR/AUTHORS
Normal file
47
cs440-acg/ext/openexr/OpenEXR/AUTHORS
Normal file
@@ -0,0 +1,47 @@
|
||||
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>
|
||||
Piotr Stanczyk <pstanczyk@ilm.com>
|
||||
Peter Hillman <peterh@weta.co.nz>
|
||||
|
||||
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
|
||||
Nicholas Yue <yue.nicholas@gmail.com>
|
||||
Yunfeng Bai (ILM)
|
||||
Pascal Jette (Autodesk)
|
||||
Karl Rasche, DreamWorks Animation <Karl.Rasche@dreamworks.com>
|
||||
|
||||
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
|
||||
280
cs440-acg/ext/openexr/OpenEXR/CMakeLists.txt
Normal file
280
cs440-acg/ext/openexr/OpenEXR/CMakeLists.txt
Normal file
@@ -0,0 +1,280 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
PROJECT (openexr)
|
||||
|
||||
SET(OPENEXR_VERSION_MAJOR "2")
|
||||
SET(OPENEXR_VERSION_MINOR "2")
|
||||
SET(OPENEXR_VERSION_PATCH "0")
|
||||
|
||||
SET(OPENEXR_VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH})
|
||||
SET(OPENEXR_VERSION_API ${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR})
|
||||
|
||||
option(OPENEXR_BUILD_TESTS "Build OpenEXR tests?" OFF)
|
||||
option(OPENEXR_BUILD_UTILS "Build OpenEXR utilities?" OFF)
|
||||
option(OPENEXR_BUILD_EXAMPLES "Build OpenEXR examples?" OFF)
|
||||
option(OPENEXR_INSTALL_EXAMPLES "Install OpenEXR examples?" OFF)
|
||||
option(OPENEXR_INSTALL_DOCS "Install OpenEXR examples?" OFF)
|
||||
|
||||
# enable the tests
|
||||
if (OPENEXR_BUILD_TESTS)
|
||||
ENABLE_TESTING()
|
||||
endif()
|
||||
|
||||
# distro building
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "${OPENEXR_VERSION_MAJOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "${OPENEXR_VERSION_MINOR}")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "${OPENEXR_VERSION_PATCH}")
|
||||
SET(CPACK_SOURCE_GENERATOR "TGZ")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME
|
||||
"${CMAKE_PROJECT_NAME}-${OPENEXR_VERSION}"
|
||||
)
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
"/.git*;/.cvs*;${CPACK_SOURCE_IGNORE_FILES}")
|
||||
INCLUDE ( CPack )
|
||||
|
||||
|
||||
|
||||
# Allow the developer to select if Dynamic or Static libraries are built
|
||||
OPTION (OPENEXR_BUILD_SHARED_LIBS "Build Shared Libraries" ON)
|
||||
OPTION (OPENEXR_USE_ZLIB_WINAPI "Use ZLib Win API" OFF)
|
||||
OPTION (OPENEXR_NAMESPACE_VERSIONING "Use Namespace Versioning" ON)
|
||||
|
||||
# Setup osx rpathing
|
||||
SET (CMAKE_MACOSX_RPATH 1)
|
||||
SET (BUILD_WITH_INSTALL_RPATH 1)
|
||||
|
||||
ADD_DEFINITIONS ( -DHAVE_CONFIG_H -DILM_IMF_TEST_IMAGEDIR="${CMAKE_SOURCE_DIR}/IlmImfTest/" )
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config
|
||||
IlmImf
|
||||
IlmImfUtil
|
||||
exrmaketiled
|
||||
exrenvmap
|
||||
exrmakepreview
|
||||
exrmultiview
|
||||
IlmImfFuzzTest
|
||||
)
|
||||
|
||||
if (NOT WIN32)
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
endif()
|
||||
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
|
||||
|
||||
IF (NOT WIN32)
|
||||
SET ( PTHREAD_LIB pthread )
|
||||
ENDIF()
|
||||
|
||||
if (DEFINED ILMBASE_PACKAGE_PREFIX)
|
||||
INCLUDE_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/include/OpenEXR )
|
||||
LINK_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/lib )
|
||||
MESSAGE ( "ILMBASE_PACKAGE_PREFIX = " ${ILMBASE_PACKAGE_PREFIX})
|
||||
endif()
|
||||
|
||||
SET (LIB_TYPE STATIC)
|
||||
IF (OPENEXR_BUILD_SHARED_LIBS)
|
||||
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
|
||||
SET (LIB_TYPE SHARED)
|
||||
IF (WIN32)
|
||||
ADD_DEFINITIONS(-DOPENEXR_DLL)
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
IF (OPENEXR_USE_ZLIB_WINAPI)
|
||||
ADD_DEFINITIONS(-DZLIB_WINAPI)
|
||||
ENDIF ()
|
||||
|
||||
# Test for GCC-style inline asm support with AVX instructions
|
||||
INCLUDE (CheckCXXSourceCompiles)
|
||||
CHECK_CXX_SOURCE_COMPILES (
|
||||
"
|
||||
int main()
|
||||
{
|
||||
#if defined(__GNUC__) && defined(__SSE2__)
|
||||
int n = 0;
|
||||
int eax = 0;
|
||||
int edx = 0;
|
||||
__asm__(
|
||||
\"xgetbv ;\"
|
||||
\"vzeroupper \"
|
||||
: \"=a\"(eax), \"=d\"(edx) : \"c\"(n) : );
|
||||
#else
|
||||
#error No GCC style inline asm supported for AVX instructions
|
||||
#endif
|
||||
}
|
||||
" HAVE_GCC_INLINE_ASM_AVX)
|
||||
|
||||
# Check if sysconf(_SC_NPROCESSORS_ONLN) can be used for CPU count
|
||||
CHECK_CXX_SOURCE_COMPILES (
|
||||
"
|
||||
#include <unistd.h>
|
||||
int main()
|
||||
{
|
||||
sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
" HAVE_SYSCONF_NPROCESSORS_ONLN)
|
||||
|
||||
|
||||
##########################
|
||||
# OpenEXRConfig.h generation
|
||||
##########################
|
||||
IF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h)
|
||||
IF (WIN32)
|
||||
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
|
||||
ELSEIF (APPLE)
|
||||
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_DARWIN 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#include <string.h>\n" )
|
||||
ELSE ()
|
||||
# Linux
|
||||
FILE ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LINUX_PROCFS 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_LARGE_STACK 1\n" )
|
||||
ENDIF()
|
||||
|
||||
IF (OPENEXR_NAMESPACE_VERSIONING)
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 1\n")
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf_${OPENEXR_VERSION_API}\n\n" )
|
||||
ELSE ()
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE_CUSTOM 0\n")
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_NAMESPACE Imf\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_INTERNAL_NAMESPACE Imf\n\n" )
|
||||
ENDIF ()
|
||||
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_VERSION_STRING \"${OPENEXR_VERSION}\"\n" )
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_PACKAGE_STRING \"OpenEXR ${OPENEXR_VERSION}\"\n" )
|
||||
|
||||
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
|
||||
#define OPENEXR_VERSION_MAJOR ${OPENEXR_VERSION_MAJOR}
|
||||
#define OPENEXR_VERSION_MINOR ${OPENEXR_VERSION_MINOR}
|
||||
#define OPENEXR_VERSION_PATCH ${OPENEXR_VERSION_PATCH}
|
||||
")
|
||||
|
||||
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "
|
||||
// Version as a single hex number, e.g. 0x01000300 == 1.0.3
|
||||
#define OPENEXR_VERSION_HEX ((OPENEXR_VERSION_MAJOR << 24) | \\
|
||||
(OPENEXR_VERSION_MINOR << 16) | \\
|
||||
(OPENEXR_VERSION_PATCH << 8))\n
|
||||
")
|
||||
|
||||
IF (HAVE_GCC_INLINE_ASM_AVX)
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX 1\n" )
|
||||
ENDIF()
|
||||
|
||||
IF (HAVE_SYSCONF_NPROCESSORS_ONLN)
|
||||
FILE ( APPEND ${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h "#define OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN 1\n" )
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET (OPENEXR_LIBSUFFIX "")
|
||||
SET (ILMBASE_LIBSUFFIX "")
|
||||
IF (OPENEXR_NAMESPACE_VERSIONING)
|
||||
SET ( OPENEXR_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
|
||||
# assume same NAMESPACE_VERSION setting for IlmBase for now
|
||||
SET ( ILMBASE_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
|
||||
ENDIF ()
|
||||
|
||||
##########################
|
||||
# IlmImf library
|
||||
##########################
|
||||
ADD_SUBDIRECTORY ( IlmImf )
|
||||
|
||||
SET_TARGET_PROPERTIES ( IlmImf
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "IlmImf${OPENEXR_LIBSUFFIX}"
|
||||
)
|
||||
|
||||
##########################
|
||||
# IlmImfUtil library
|
||||
##########################
|
||||
if (OPENEXR_BUILD_UTILS)
|
||||
ADD_SUBDIRECTORY ( IlmImfUtil )
|
||||
|
||||
SET_TARGET_PROPERTIES ( IlmImfUtil
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "IlmImfUtil${OPENEXR_LIBSUFFIX}"
|
||||
)
|
||||
endif()
|
||||
|
||||
##########################
|
||||
# Example Code
|
||||
##########################
|
||||
if (OPENEXR_BUILD_EXAMPLES)
|
||||
ADD_SUBDIRECTORY ( IlmImfExamples )
|
||||
endif()
|
||||
|
||||
|
||||
##########################
|
||||
# Tests
|
||||
##########################
|
||||
if (OPENEXR_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY ( IlmImfTest )
|
||||
ADD_SUBDIRECTORY ( IlmImfUtilTest )
|
||||
ADD_SUBDIRECTORY ( IlmImfFuzzTest )
|
||||
endif()
|
||||
|
||||
|
||||
##########################
|
||||
# Binaries / Utilities
|
||||
##########################
|
||||
if (OPENEXR_BUILD_UTILS)
|
||||
ADD_SUBDIRECTORY ( exrheader )
|
||||
ADD_SUBDIRECTORY ( exrmaketiled )
|
||||
ADD_SUBDIRECTORY ( exrstdattr )
|
||||
ADD_SUBDIRECTORY ( exrmakepreview )
|
||||
ADD_SUBDIRECTORY ( exrenvmap )
|
||||
ADD_SUBDIRECTORY ( exrmultiview )
|
||||
ADD_SUBDIRECTORY ( exrmultipart )
|
||||
endif()
|
||||
|
||||
|
||||
##########################
|
||||
# Installation
|
||||
##########################
|
||||
|
||||
INSTALL ( FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config/OpenEXRConfig.h
|
||||
DESTINATION
|
||||
${OPENEXR_INSTALL_HEADER_DEST}
|
||||
)
|
||||
|
||||
# Documentation
|
||||
if (OPENEXR_INSTALL_DOCS)
|
||||
INSTALL ( FILES
|
||||
doc/TechnicalIntroduction.pdf
|
||||
doc/ReadingAndWritingImageFiles.pdf
|
||||
doc/OpenEXRFileLayout.pdf
|
||||
doc/MultiViewOpenEXR.pdf
|
||||
doc/InterpretingDeepPixels.pdf
|
||||
doc/TheoryDeepPixels.pdf
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Examples
|
||||
if (OPENEXR_INSTALL_EXAMPLES)
|
||||
INSTALL ( FILES
|
||||
IlmImfExamples/main.cpp
|
||||
IlmImfExamples/drawImage.cpp
|
||||
IlmImfExamples/rgbaInterfaceExamples.cpp
|
||||
IlmImfExamples/rgbaInterfaceTiledExamples.cpp
|
||||
IlmImfExamples/generalInterfaceExamples.cpp
|
||||
IlmImfExamples/lowLevelIoExamples.cpp
|
||||
IlmImfExamples/previewImageExamples.cpp
|
||||
IlmImfExamples/generalInterfaceTiledExamples.cpp
|
||||
IlmImfExamples/generalInterfaceTiledExamples.h
|
||||
IlmImfExamples/drawImage.h
|
||||
IlmImfExamples/rgbaInterfaceExamples.h
|
||||
IlmImfExamples/generalInterfaceExamples.h
|
||||
IlmImfExamples/rgbaInterfaceTiledExamples.h
|
||||
IlmImfExamples/lowLevelIoExamples.h
|
||||
IlmImfExamples/previewImageExamples.h
|
||||
IlmImfExamples/namespaceAlias.h
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}/examples
|
||||
)
|
||||
endif()
|
||||
34
cs440-acg/ext/openexr/OpenEXR/COPYING
Normal file
34
cs440-acg/ext/openexr/OpenEXR/COPYING
Normal file
@@ -0,0 +1,34 @@
|
||||
Copyright (c) 2006, Industrial Light & Magic, a division of Lucasfilm
|
||||
Entertainment Company Ltd. Portions contributed and copyright held by
|
||||
others as indicated. 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
|
||||
any other contributors to this software 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.
|
||||
|
||||
704
cs440-acg/ext/openexr/OpenEXR/ChangeLog
Normal file
704
cs440-acg/ext/openexr/OpenEXR/ChangeLog
Normal file
@@ -0,0 +1,704 @@
|
||||
Version 2.0.1
|
||||
* Temporarily turning off optimisation code path
|
||||
(Piotr Stanczyk)
|
||||
* Added additional tests for future optimisation refactoring
|
||||
(Piotr Stanczyk / Peter Hillman)
|
||||
* Fixes for StringVectors
|
||||
(Peter Hillman)
|
||||
* Additional checks for type mismatches
|
||||
(Peter Hillman)
|
||||
* Fix for Composite Deep Scanline
|
||||
(Brendan Bolles)
|
||||
|
||||
Version 2.0.0
|
||||
* Updated Documentation
|
||||
(Peter Hillman)
|
||||
* Updated Namespacing mechanism
|
||||
(Piotr Stanczyk)
|
||||
* Fixes for succd & predd
|
||||
(Peter Hillman)
|
||||
* Fixes for FPE control registers
|
||||
(Piotr Stanczyk)
|
||||
* Additional checks and tests on DeepImages, scanlines and tiles
|
||||
(Peter Hillman)
|
||||
* Folded in Autodesk read optimisations for RGB(A) files
|
||||
(Pascal Jette, Peter Hillman)
|
||||
* Updated the bootstrap scripts to use libtoolize if glibtoolize isn't available on darwin.
|
||||
(Nick Rasmussen)
|
||||
* Numerous minor fixes, missing includes etc
|
||||
|
||||
Version 2.0.0.beta.1:
|
||||
* Please read the separate file for v2 additions and changes.
|
||||
* Added git specific files
|
||||
(Piotr Stanczyk)
|
||||
* Updated the so verison to 20
|
||||
(Piotr Stanczyk)
|
||||
* Initial use of the CMake build system
|
||||
(Nicholas Yue)
|
||||
|
||||
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.
|
||||
2
cs440-acg/ext/openexr/OpenEXR/INSTALL
Normal file
2
cs440-acg/ext/openexr/OpenEXR/INSTALL
Normal file
@@ -0,0 +1,2 @@
|
||||
See the README file for instructions on how to build OpenEXR from
|
||||
source.
|
||||
16
cs440-acg/ext/openexr/OpenEXR/IlmImf/.cvsignore
Normal file
16
cs440-acg/ext/openexr/OpenEXR/IlmImf/.cvsignore
Normal file
@@ -0,0 +1,16 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
config.h.in
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
libtool
|
||||
stamp-h
|
||||
aclocal.m4
|
||||
OpenEXR.pc
|
||||
autom4te.cache
|
||||
ltmain.sh
|
||||
stamp-h.in
|
||||
depcomp
|
||||
.deps
|
||||
285
cs440-acg/ext/openexr/OpenEXR/IlmImf/CMakeLists.txt
Normal file
285
cs440-acg/ext/openexr/OpenEXR/IlmImf/CMakeLists.txt
Normal file
@@ -0,0 +1,285 @@
|
||||
# yue.nicholas@gmail.com
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
|
||||
|
||||
ADD_EXECUTABLE ( b44ExpLogTable
|
||||
b44ExpLogTable.cpp
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( b44ExpLogTable
|
||||
Half
|
||||
IlmThread
|
||||
Iex
|
||||
${PTHREAD_LIB}
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
ADD_CUSTOM_COMMAND (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
COMMAND ${CMAKE_COMMAND} -E env "PATH=$<TARGET_FILE_DIR:Half>;$<TARGET_FILE_DIR:IlmThread>;$<TARGET_FILE_DIR:Iex>"
|
||||
$<TARGET_FILE:b44ExpLogTable> > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
DEPENDS b44ExpLogTable
|
||||
)
|
||||
else()
|
||||
ADD_CUSTOM_COMMAND (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/b44ExpLogTable > ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
DEPENDS b44ExpLogTable
|
||||
)
|
||||
endif()
|
||||
|
||||
ADD_EXECUTABLE ( dwaLookups
|
||||
dwaLookups.cpp
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( dwaLookups
|
||||
Half
|
||||
IlmThread
|
||||
Iex
|
||||
${PTHREAD_LIB}
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
ADD_CUSTOM_COMMAND (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
COMMAND ${CMAKE_COMMAND} -E env "PATH=$<TARGET_FILE_DIR:Half>;$<TARGET_FILE_DIR:IlmThread>;$<TARGET_FILE_DIR:Iex>"
|
||||
$<TARGET_FILE:dwaLookups> > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
DEPENDS dwaLookups
|
||||
)
|
||||
else()
|
||||
ADD_CUSTOM_COMMAND (
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/dwaLookups > ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
DEPENDS dwaLookups
|
||||
)
|
||||
endif()
|
||||
|
||||
SET ( ILMIMF_SRCS
|
||||
ImfAttribute.cpp
|
||||
ImfBoxAttribute.cpp
|
||||
ImfCRgbaFile.cpp
|
||||
ImfChannelList.cpp
|
||||
ImfChannelListAttribute.cpp
|
||||
ImfFloatAttribute.cpp
|
||||
ImfFrameBuffer.cpp
|
||||
ImfHeader.cpp
|
||||
ImfIO.cpp
|
||||
ImfInputFile.cpp
|
||||
ImfIntAttribute.cpp
|
||||
ImfLineOrderAttribute.cpp
|
||||
ImfMatrixAttribute.cpp
|
||||
ImfOpaqueAttribute.cpp
|
||||
ImfOutputFile.cpp
|
||||
ImfRgbaFile.cpp
|
||||
ImfStringAttribute.cpp
|
||||
ImfVecAttribute.cpp
|
||||
ImfHuf.cpp
|
||||
ImfThreading.cpp
|
||||
ImfWav.cpp
|
||||
ImfLut.cpp
|
||||
ImfCompressor.cpp
|
||||
ImfRleCompressor.cpp
|
||||
ImfZipCompressor.cpp
|
||||
ImfPizCompressor.cpp
|
||||
ImfMisc.cpp
|
||||
ImfCompressionAttribute.cpp
|
||||
ImfDoubleAttribute.cpp
|
||||
ImfConvert.cpp
|
||||
ImfPreviewImage.cpp
|
||||
ImfPreviewImageAttribute.cpp
|
||||
ImfVersion.cpp
|
||||
ImfChromaticities.cpp
|
||||
ImfChromaticitiesAttribute.cpp
|
||||
ImfKeyCode.cpp
|
||||
ImfKeyCodeAttribute.cpp
|
||||
ImfTimeCode.cpp
|
||||
ImfTimeCodeAttribute.cpp
|
||||
ImfRational.cpp
|
||||
ImfRationalAttribute.cpp
|
||||
ImfFramesPerSecond.cpp
|
||||
ImfStandardAttributes.cpp
|
||||
ImfStdIO.cpp
|
||||
ImfEnvmap.cpp
|
||||
ImfEnvmapAttribute.cpp
|
||||
ImfScanLineInputFile.cpp
|
||||
ImfTiledInputFile.cpp
|
||||
ImfTiledMisc.cpp
|
||||
ImfTiledOutputFile.cpp
|
||||
ImfTiledRgbaFile.cpp
|
||||
ImfTileDescriptionAttribute.cpp
|
||||
ImfTileOffsets.cpp
|
||||
ImfRgbaYca.cpp
|
||||
ImfPxr24Compressor.cpp
|
||||
ImfTestFile.cpp
|
||||
ImfStringVectorAttribute.cpp
|
||||
ImfMultiView.cpp
|
||||
ImfAcesFile.cpp
|
||||
ImfMultiPartOutputFile.cpp
|
||||
ImfGenericOutputFile.cpp
|
||||
ImfOutputPartData.cpp
|
||||
ImfMultiPartInputFile.cpp
|
||||
ImfGenericInputFile.cpp
|
||||
ImfPartType.cpp
|
||||
ImfInputPartData.cpp
|
||||
ImfOutputPart.cpp
|
||||
ImfTiledOutputPart.cpp
|
||||
ImfInputPart.cpp
|
||||
ImfTiledInputPart.cpp
|
||||
ImfDeepScanLineInputPart.cpp
|
||||
ImfDeepScanLineOutputPart.cpp
|
||||
ImfDeepScanLineInputFile.cpp
|
||||
ImfDeepScanLineOutputFile.cpp
|
||||
ImfDeepTiledInputPart.cpp
|
||||
ImfDeepTiledOutputPart.cpp
|
||||
ImfDeepTiledInputFile.cpp
|
||||
ImfDeepTiledOutputFile.cpp
|
||||
ImfDeepFrameBuffer.cpp
|
||||
ImfDeepCompositing.cpp
|
||||
ImfCompositeDeepScanLine.cpp
|
||||
ImfDeepImageStateAttribute.cpp
|
||||
ImfFastHuf.cpp
|
||||
ImfFloatVectorAttribute.cpp
|
||||
ImfRle.cpp
|
||||
ImfSystemSpecific.cpp
|
||||
ImfZip.cpp
|
||||
)
|
||||
|
||||
IF (OPENEXR_BUILD_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DILMIMF_EXPORTS)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY ( IlmImf ${LIB_TYPE}
|
||||
ImfB44Compressor.cpp
|
||||
ImfDwaCompressor.cpp
|
||||
${ILMIMF_SRCS}
|
||||
)
|
||||
|
||||
if (${LIB_TYPE} MATCHES "SHARED")
|
||||
set_property(TARGET IlmImf PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
TARGET_LINK_LIBRARIES ( IlmImf
|
||||
Half
|
||||
Iex
|
||||
Imath
|
||||
IlmThread
|
||||
${PTHREAD_LIB} ${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
ADD_DEPENDENCIES ( IlmImf b44ExpLogTable )
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES (
|
||||
ImfB44Compressor.cpp
|
||||
PROPERTIES
|
||||
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/b44ExpLogTable.h
|
||||
)
|
||||
|
||||
ADD_DEPENDENCIES ( IlmImf dwaLookups )
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES (
|
||||
ImfDwaCompressor.cpp
|
||||
PROPERTIES
|
||||
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dwaLookups.h
|
||||
)
|
||||
|
||||
# Libraries
|
||||
|
||||
INSTALL ( TARGETS
|
||||
IlmImf
|
||||
DESTINATION
|
||||
${OPENEXR_INSTALL_LIB_DEST}
|
||||
)
|
||||
|
||||
# Headers
|
||||
INSTALL ( FILES
|
||||
ImfForward.h
|
||||
ImfExport.h
|
||||
ImfAttribute.h
|
||||
ImfBoxAttribute.h
|
||||
ImfCRgbaFile.h
|
||||
ImfChannelList.h
|
||||
ImfChannelListAttribute.h
|
||||
ImfCompressionAttribute.h
|
||||
ImfDoubleAttribute.h
|
||||
ImfFloatAttribute.h
|
||||
ImfFrameBuffer.h
|
||||
ImfHeader.h
|
||||
ImfIO.h
|
||||
ImfInputFile.h
|
||||
ImfIntAttribute.h
|
||||
ImfLineOrderAttribute.h
|
||||
ImfMatrixAttribute.h
|
||||
ImfOpaqueAttribute.h
|
||||
ImfOutputFile.h
|
||||
ImfRgbaFile.h
|
||||
ImfStringAttribute.h
|
||||
ImfVecAttribute.h
|
||||
ImfHuf.h
|
||||
ImfWav.h
|
||||
ImfLut.h
|
||||
ImfArray.h
|
||||
ImfCompression.h
|
||||
ImfLineOrder.h
|
||||
ImfName.h
|
||||
ImfPixelType.h
|
||||
ImfVersion.h
|
||||
ImfXdr.h
|
||||
ImfConvert.h
|
||||
ImfPreviewImage.h
|
||||
ImfPreviewImageAttribute.h
|
||||
ImfChromaticities.h
|
||||
ImfChromaticitiesAttribute.h
|
||||
ImfKeyCode.h
|
||||
ImfKeyCodeAttribute.h
|
||||
ImfTimeCode.h
|
||||
ImfTimeCodeAttribute.h
|
||||
ImfRational.h
|
||||
ImfRationalAttribute.h
|
||||
ImfFramesPerSecond.h
|
||||
ImfStandardAttributes.h
|
||||
ImfEnvmap.h
|
||||
ImfEnvmapAttribute.h
|
||||
ImfInt64.h
|
||||
ImfRgba.h
|
||||
ImfTileDescription.h
|
||||
ImfTileDescriptionAttribute.h
|
||||
ImfTiledInputFile.h
|
||||
ImfTiledOutputFile.h
|
||||
ImfTiledRgbaFile.h
|
||||
ImfRgbaYca.h
|
||||
ImfTestFile.h
|
||||
ImfThreading.h
|
||||
ImfB44Compressor.h
|
||||
ImfStringVectorAttribute.h
|
||||
ImfMultiView.h
|
||||
ImfAcesFile.h
|
||||
ImfMultiPartOutputFile.h
|
||||
ImfGenericOutputFile.h
|
||||
ImfMultiPartInputFile.h
|
||||
ImfGenericInputFile.h
|
||||
ImfPartType.h
|
||||
ImfPartHelper.h
|
||||
ImfOutputPart.h
|
||||
ImfTiledOutputPart.h
|
||||
ImfInputPart.h
|
||||
ImfTiledInputPart.h
|
||||
ImfDeepScanLineOutputFile.h
|
||||
ImfDeepScanLineOutputPart.h
|
||||
ImfDeepScanLineInputFile.h
|
||||
ImfDeepScanLineInputPart.h
|
||||
ImfDeepTiledInputFile.h
|
||||
ImfDeepTiledInputPart.h
|
||||
ImfDeepTiledOutputFile.h
|
||||
ImfDeepTiledOutputPart.h
|
||||
ImfDeepFrameBuffer.h
|
||||
ImfDeepCompositing.h
|
||||
ImfCompositeDeepScanLine.h
|
||||
ImfNamespace.h
|
||||
ImfMisc.h
|
||||
ImfDeepImageState.h
|
||||
ImfDeepImageStateAttribute.h
|
||||
ImfFloatVectorAttribute.h
|
||||
DESTINATION
|
||||
${OPENEXR_INSTALL_HEADER_DEST}
|
||||
)
|
||||
633
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAcesFile.cpp
Normal file
633
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAcesFile.cpp
Normal file
@@ -0,0 +1,633 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
using namespace IEX_NAMESPACE;
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
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
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::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_NAMESPACE::Box2i &displayWindow,
|
||||
const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
RgbaChannels rgbaChannels,
|
||||
float pixelAspectRatio,
|
||||
const IMATH_NAMESPACE::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_NAMESPACE::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_NAMESPACE::Box2i &
|
||||
AcesOutputFile::displayWindow () const
|
||||
{
|
||||
return _data->rgbaFile->displayWindow();
|
||||
}
|
||||
|
||||
|
||||
const IMATH_NAMESPACE::Box2i &
|
||||
AcesOutputFile::dataWindow () const
|
||||
{
|
||||
return _data->rgbaFile->dataWindow();
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
AcesOutputFile::pixelAspectRatio () const
|
||||
{
|
||||
return _data->rgbaFile->pixelAspectRatio();
|
||||
}
|
||||
|
||||
|
||||
const IMATH_NAMESPACE::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_NAMESPACE::Box2i &
|
||||
AcesInputFile::displayWindow () const
|
||||
{
|
||||
return _data->rgbaFile->displayWindow();
|
||||
}
|
||||
|
||||
|
||||
const IMATH_NAMESPACE::Box2i &
|
||||
AcesInputFile::dataWindow () const
|
||||
{
|
||||
return _data->rgbaFile->dataWindow();
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
AcesInputFile::pixelAspectRatio () const
|
||||
{
|
||||
return _data->rgbaFile->pixelAspectRatio();
|
||||
}
|
||||
|
||||
|
||||
const IMATH_NAMESPACE::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();
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
324
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAcesFile.h
Normal file
324
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAcesFile.h
Normal file
@@ -0,0 +1,324 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfForward.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
//
|
||||
// ACES red, green, blue and white-point chromaticities.
|
||||
//
|
||||
|
||||
const Chromaticities & acesChromaticities ();
|
||||
|
||||
|
||||
//
|
||||
// ACES output file.
|
||||
//
|
||||
|
||||
class IMF_EXPORT 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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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_NAMESPACE::Box2i &displayWindow,
|
||||
const IMATH_NAMESPACE::Box2i &dataWindow = IMATH_NAMESPACE::Box2i(),
|
||||
RgbaChannels rgbaChannels = WRITE_RGBA,
|
||||
float pixelAspectRatio = 1,
|
||||
const IMATH_NAMESPACE::V2f screenWindowCenter = IMATH_NAMESPACE::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_NAMESPACE::V2f screenWindowCenter = IMATH_NAMESPACE::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_NAMESPACE::Box2i & displayWindow () const;
|
||||
const IMATH_NAMESPACE::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const IMATH_NAMESPACE::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 IMF_EXPORT 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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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_NAMESPACE::Box2i & displayWindow () const;
|
||||
const IMATH_NAMESPACE::Box2i & dataWindow () const;
|
||||
float pixelAspectRatio () const;
|
||||
const IMATH_NAMESPACE::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;
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
285
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfArray.h
Normal file
285
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfArray.h
Normal file
@@ -0,0 +1,285 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
#include "ImfForward.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;
|
||||
// }
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
template <class T>
|
||||
class Array
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------
|
||||
// Constructors and destructors
|
||||
//-----------------------------
|
||||
|
||||
Array () {_data = 0; _size = 0;}
|
||||
Array (long size) {_data = new T[size]; _size = 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);
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Return the size of this array.
|
||||
//-------------------------------
|
||||
|
||||
long size() const {return _size;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array (const Array &); // Copying and assignment
|
||||
Array & operator = (const Array &); // are not implemented
|
||||
|
||||
long _size;
|
||||
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);
|
||||
|
||||
|
||||
//-------------------------------
|
||||
// Return the size of this array.
|
||||
//-------------------------------
|
||||
|
||||
long height() const {return _sizeX;}
|
||||
long width() const {return _sizeY;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Array2D (const Array2D &); // Copying and assignment
|
||||
Array2D & operator = (const Array2D &); // are not implemented
|
||||
|
||||
long _sizeX;
|
||||
long _sizeY;
|
||||
T * _data;
|
||||
};
|
||||
|
||||
|
||||
//---------------
|
||||
// Implementation
|
||||
//---------------
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array<T>::resizeErase (long size)
|
||||
{
|
||||
T *tmp = new T[size];
|
||||
delete [] _data;
|
||||
_size = size;
|
||||
_data = tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array<T>::resizeEraseUnsafe (long size)
|
||||
{
|
||||
delete [] _data;
|
||||
_data = 0;
|
||||
_size = 0;
|
||||
_data = new T[size];
|
||||
_size = size;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::Array2D ():
|
||||
_sizeX(0), _sizeY (0), _data (0)
|
||||
{
|
||||
// emtpy
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
Array2D<T>::Array2D (long sizeX, long sizeY):
|
||||
_sizeX (sizeX), _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;
|
||||
_sizeX = sizeX;
|
||||
_sizeY = sizeY;
|
||||
_data = tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
Array2D<T>::resizeEraseUnsafe (long sizeX, long sizeY)
|
||||
{
|
||||
delete [] _data;
|
||||
_data = 0;
|
||||
_sizeX = 0;
|
||||
_sizeY = 0;
|
||||
_data = new T[sizeX * sizeY];
|
||||
_sizeX = sizeX;
|
||||
_sizeY = sizeY;
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
158
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAttribute.cpp
Normal file
158
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAttribute.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
using ILMTHREAD_NAMESPACE::Mutex;
|
||||
using ILMTHREAD_NAMESPACE::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_NAMESPACE::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_NAMESPACE::ArgExc, "Cannot create image file attribute of "
|
||||
"unknown type \"" << typeName << "\".");
|
||||
|
||||
return (i->second)();
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
407
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAttribute.h
Normal file
407
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAttribute.h
Normal file
@@ -0,0 +1,407 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT 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 (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
|
||||
int version) const = 0;
|
||||
|
||||
virtual void readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::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 (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
|
||||
int version) const;
|
||||
|
||||
virtual void readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::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 (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
|
||||
int /* version */) const
|
||||
{
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, _value);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedAttribute<T>::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is,
|
||||
int /* size */,
|
||||
int /* version */)
|
||||
{
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::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_NAMESPACE::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_NAMESPACE::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());
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
95
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAutoArray.h
Normal file
95
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfAutoArray.h
Normal file
@@ -0,0 +1,95 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfNamespace.h"
|
||||
#include <string.h>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
#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
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
1072
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfB44Compressor.cpp
Normal file
1072
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfB44Compressor.cpp
Normal file
File diff suppressed because it is too large
Load Diff
118
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfB44Compressor.h
Normal file
118
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfB44Compressor.h
Normal file
@@ -0,0 +1,118 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfForward.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT 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_NAMESPACE::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_NAMESPACE::Box2i range,
|
||||
const char *&outPtr);
|
||||
private:
|
||||
|
||||
struct ChannelData;
|
||||
|
||||
int compress (const char *inPtr,
|
||||
int inSize,
|
||||
IMATH_NAMESPACE::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
int uncompress (const char *inPtr,
|
||||
int inSize,
|
||||
IMATH_NAMESPACE::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;
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
111
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfBoxAttribute.cpp
Normal file
111
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfBoxAttribute.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
template <>
|
||||
const char *
|
||||
Box2iAttribute::staticTypeName ()
|
||||
{
|
||||
return "box2i";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
Box2iAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
87
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfBoxAttribute.h
Normal file
87
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfBoxAttribute.h
Normal file
@@ -0,0 +1,87 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfAttribute.h"
|
||||
#include "ImathBox.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<IMATH_NAMESPACE::Box2i> Box2iAttribute;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
const char *Box2iAttribute::staticTypeName ();
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void Box2iAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &,
|
||||
int) const;
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void Box2iAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &,
|
||||
int, int);
|
||||
|
||||
|
||||
typedef TypedAttribute<IMATH_NAMESPACE::Box2f> Box2fAttribute;
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
const char *Box2fAttribute::staticTypeName ();
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void Box2fAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &,
|
||||
int) const;
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void Box2fAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &,
|
||||
int, int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
1438
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCRgbaFile.cpp
Normal file
1438
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCRgbaFile.cpp
Normal file
File diff suppressed because it is too large
Load Diff
555
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCRgbaFile.h
Normal file
555
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCRgbaFile.h
Normal file
@@ -0,0 +1,555 @@
|
||||
/*
|
||||
|
||||
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 "ImfExport.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Interpreting unsigned shorts as 16-bit floating point numbers
|
||||
*/
|
||||
|
||||
typedef unsigned short ImfHalf;
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfFloatToHalf (float f,
|
||||
ImfHalf *h);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfFloatToHalfArray (int n,
|
||||
const float f[/*n*/],
|
||||
ImfHalf h[/*n*/]);
|
||||
|
||||
IMF_EXPORT
|
||||
float ImfHalfToFloat (ImfHalf h);
|
||||
|
||||
IMF_EXPORT
|
||||
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_RANDOM_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;
|
||||
|
||||
IMF_EXPORT
|
||||
ImfHeader * ImfNewHeader (void);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfDeleteHeader (ImfHeader *hdr);
|
||||
|
||||
IMF_EXPORT
|
||||
ImfHeader * ImfCopyHeader (const ImfHeader *hdr);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetDisplayWindow (ImfHeader *hdr,
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderDisplayWindow (const ImfHeader *hdr,
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetDataWindow (ImfHeader *hdr,
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderDataWindow (const ImfHeader *hdr,
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetPixelAspectRatio (ImfHeader *hdr,
|
||||
float pixelAspectRatio);
|
||||
|
||||
IMF_EXPORT
|
||||
float ImfHeaderPixelAspectRatio (const ImfHeader *hdr);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetScreenWindowCenter (ImfHeader *hdr,
|
||||
float x, float y);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderScreenWindowCenter (const ImfHeader *hdr,
|
||||
float *x, float *y);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetScreenWindowWidth (ImfHeader *hdr,
|
||||
float width);
|
||||
|
||||
IMF_EXPORT
|
||||
float ImfHeaderScreenWindowWidth (const ImfHeader *hdr);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetLineOrder (ImfHeader *hdr,
|
||||
int lineOrder);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderLineOrder (const ImfHeader *hdr);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfHeaderSetCompression (ImfHeader *hdr,
|
||||
int compression);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderCompression (const ImfHeader *hdr);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetIntAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderIntAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetFloatAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetDoubleAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
double value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderFloatAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderDoubleAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
double *value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetStringAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const char value[]);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderStringAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
const char **value);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetBox2iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int xMin, int yMin,
|
||||
int xMax, int yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderBox2iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *xMin, int *yMin,
|
||||
int *xMax, int *yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetBox2fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float xMin, float yMin,
|
||||
float xMax, float yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderBox2fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *xMin, float *yMin,
|
||||
float *xMax, float *yMax);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetV2iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int x, int y);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderV2iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *x, int *y);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetV2fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float x, float y);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderV2fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *x, float *y);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetV3iAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
int x, int y, int z);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderV3iAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
int *x, int *y, int *z);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetV3fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
float x, float y, float z);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderV3fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float *x, float *y, float *z);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetM33fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const float m[3][3]);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderM33fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float m[3][3]);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderSetM44fAttribute (ImfHeader *hdr,
|
||||
const char name[],
|
||||
const float m[4][4]);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfHeaderM44fAttribute (const ImfHeader *hdr,
|
||||
const char name[],
|
||||
float m[4][4]);
|
||||
|
||||
/*
|
||||
** RGBA output file
|
||||
*/
|
||||
|
||||
struct ImfOutputFile;
|
||||
typedef struct ImfOutputFile ImfOutputFile;
|
||||
|
||||
IMF_EXPORT
|
||||
ImfOutputFile * ImfOpenOutputFile (const char name[],
|
||||
const ImfHeader *hdr,
|
||||
int channels);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfCloseOutputFile (ImfOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfOutputSetFrameBuffer (ImfOutputFile *out,
|
||||
const ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfOutputWritePixels (ImfOutputFile *out,
|
||||
int numScanLines);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfOutputCurrentScanLine (const ImfOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
const ImfHeader * ImfOutputHeader (const ImfOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfOutputChannels (const ImfOutputFile *out);
|
||||
|
||||
|
||||
/*
|
||||
** Tiled RGBA output file
|
||||
*/
|
||||
|
||||
struct ImfTiledOutputFile;
|
||||
typedef struct ImfTiledOutputFile ImfTiledOutputFile;
|
||||
|
||||
IMF_EXPORT
|
||||
ImfTiledOutputFile * ImfOpenTiledOutputFile (const char name[],
|
||||
const ImfHeader *hdr,
|
||||
int channels,
|
||||
int xSize, int ySize,
|
||||
int mode, int rmode);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfCloseTiledOutputFile (ImfTiledOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputSetFrameBuffer (ImfTiledOutputFile *out,
|
||||
const ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputWriteTile (ImfTiledOutputFile *out,
|
||||
int dx, int dy,
|
||||
int lx, int ly);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputWriteTiles (ImfTiledOutputFile *out,
|
||||
int dxMin, int dxMax,
|
||||
int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
IMF_EXPORT
|
||||
const ImfHeader * ImfTiledOutputHeader (const ImfTiledOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputChannels (const ImfTiledOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputTileXSize (const ImfTiledOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputTileYSize (const ImfTiledOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputLevelMode (const ImfTiledOutputFile *out);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledOutputLevelRoundingMode
|
||||
(const ImfTiledOutputFile *out);
|
||||
|
||||
|
||||
/*
|
||||
** RGBA input file
|
||||
*/
|
||||
|
||||
struct ImfInputFile;
|
||||
typedef struct ImfInputFile ImfInputFile;
|
||||
|
||||
ImfInputFile * ImfOpenInputFile (const char name[]);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfCloseInputFile (ImfInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfInputSetFrameBuffer (ImfInputFile *in,
|
||||
ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfInputReadPixels (ImfInputFile *in,
|
||||
int scanLine1,
|
||||
int scanLine2);
|
||||
|
||||
IMF_EXPORT
|
||||
const ImfHeader * ImfInputHeader (const ImfInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfInputChannels (const ImfInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
const char * ImfInputFileName (const ImfInputFile *in);
|
||||
|
||||
|
||||
/*
|
||||
** Tiled RGBA input file
|
||||
*/
|
||||
|
||||
struct ImfTiledInputFile;
|
||||
typedef struct ImfTiledInputFile ImfTiledInputFile;
|
||||
|
||||
IMF_EXPORT
|
||||
ImfTiledInputFile * ImfOpenTiledInputFile (const char name[]);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfCloseTiledInputFile (ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputSetFrameBuffer (ImfTiledInputFile *in,
|
||||
ImfRgba *base,
|
||||
size_t xStride,
|
||||
size_t yStride);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputReadTile (ImfTiledInputFile *in,
|
||||
int dx, int dy,
|
||||
int lx, int ly);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputReadTiles (ImfTiledInputFile *in,
|
||||
int dxMin, int dxMax,
|
||||
int dyMin, int dyMax,
|
||||
int lx, int ly);
|
||||
|
||||
IMF_EXPORT
|
||||
const ImfHeader * ImfTiledInputHeader (const ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputChannels (const ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
const char * ImfTiledInputFileName (const ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputTileXSize (const ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputTileYSize (const ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputLevelMode (const ImfTiledInputFile *in);
|
||||
|
||||
IMF_EXPORT
|
||||
int ImfTiledInputLevelRoundingMode
|
||||
(const ImfTiledInputFile *in);
|
||||
|
||||
/*
|
||||
** Lookup tables
|
||||
*/
|
||||
|
||||
struct ImfLut;
|
||||
typedef struct ImfLut ImfLut;
|
||||
|
||||
IMF_EXPORT
|
||||
ImfLut * ImfNewRound12logLut (int channels);
|
||||
|
||||
IMF_EXPORT
|
||||
ImfLut * ImfNewRoundNBitLut (unsigned int n, int channels);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfDeleteLut (ImfLut *lut);
|
||||
|
||||
IMF_EXPORT
|
||||
void ImfApplyLut (ImfLut *lut,
|
||||
ImfRgba *data,
|
||||
int nData,
|
||||
int stride);
|
||||
/*
|
||||
** Most recent error message
|
||||
*/
|
||||
|
||||
IMF_EXPORT
|
||||
const char * ImfErrorMessage (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
322
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChannelList.cpp
Normal file
322
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChannelList.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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;
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
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_NAMESPACE::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_NAMESPACE::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_NAMESPACE::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);
|
||||
size_t n = int(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);
|
||||
size_t 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();
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
436
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChannelList.h
Normal file
436
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChannelList.h
Normal file
@@ -0,0 +1,436 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
struct IMF_EXPORT 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 IMF_EXPORT 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_NAMESPACE::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);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
150
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChannelListAttribute.cpp
Normal file
150
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChannelListAttribute.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
namespace {
|
||||
|
||||
template <size_t N>
|
||||
void checkIsNullTerminated (const char (&str)[N], const char *what)
|
||||
{
|
||||
for (size_t 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_NAMESPACE::InputExc(s);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
ChannelListAttribute::staticTypeName ()
|
||||
{
|
||||
return "chlist";
|
||||
}
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
@@ -0,0 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::ChannelList> ChannelListAttribute;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
const char *ChannelListAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void ChannelListAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &,
|
||||
int) const;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void ChannelListAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &,
|
||||
int, int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
163
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCheckedArithmetic.h
Normal file
163
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCheckedArithmetic.h
Normal file
@@ -0,0 +1,163 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
template <bool b> struct StaticAssertionFailed;
|
||||
template <> struct StaticAssertionFailed <true> {};
|
||||
|
||||
#define IMF_STATIC_ASSERT(x) \
|
||||
do {StaticAssertionFailed <x> staticAssertionFailed; ((void) 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_NAMESPACE::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_NAMESPACE::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_NAMESPACE::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_NAMESPACE::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_NAMESPACE::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_NAMESPACE::OverflowExc ("Integer multiplication overflow.");
|
||||
|
||||
return size_t (n);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
151
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChromaticities.cpp
Normal file
151
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChromaticities.cpp
Normal file
@@ -0,0 +1,151 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
#include "ImfNamespace.h"
|
||||
#include <string.h>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
Chromaticities::Chromaticities (const IMATH_NAMESPACE::V2f &red,
|
||||
const IMATH_NAMESPACE::V2f &green,
|
||||
const IMATH_NAMESPACE::V2f &blue,
|
||||
const IMATH_NAMESPACE::V2f &white)
|
||||
:
|
||||
red (red),
|
||||
green (green),
|
||||
blue (blue),
|
||||
white (white)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Chromaticities::operator == (const Chromaticities & c) const
|
||||
{
|
||||
return red == c.red && green == c.green && blue == c.blue;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Chromaticities::operator != (const Chromaticities & c) const
|
||||
{
|
||||
return red != c.red || green != c.green || blue != c.blue;
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::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_NAMESPACE::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_NAMESPACE::M44f
|
||||
XYZtoRGB (const Chromaticities chroma, float Y)
|
||||
{
|
||||
return RGBtoXYZ (chroma, Y).inverse();
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
131
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChromaticities.h
Normal file
131
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfChromaticities.h
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_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"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
struct IMF_EXPORT 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_NAMESPACE::V2f red;
|
||||
IMATH_NAMESPACE::V2f green;
|
||||
IMATH_NAMESPACE::V2f blue;
|
||||
IMATH_NAMESPACE::V2f white;
|
||||
|
||||
//--------------------------------------------
|
||||
// Default constructor produces chromaticities
|
||||
// according to Rec. ITU-R BT.709-3
|
||||
//--------------------------------------------
|
||||
|
||||
Chromaticities (const IMATH_NAMESPACE::V2f &red = IMATH_NAMESPACE::V2f (0.6400f, 0.3300f),
|
||||
const IMATH_NAMESPACE::V2f &green = IMATH_NAMESPACE::V2f (0.3000f, 0.6000f),
|
||||
const IMATH_NAMESPACE::V2f &blue = IMATH_NAMESPACE::V2f (0.1500f, 0.0600f),
|
||||
const IMATH_NAMESPACE::V2f &white = IMATH_NAMESPACE::V2f (0.3127f, 0.3290f));
|
||||
|
||||
|
||||
//---------
|
||||
// Equality
|
||||
//---------
|
||||
|
||||
bool operator == (const Chromaticities &v) const;
|
||||
bool operator != (const Chromaticities &v) const;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// 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().
|
||||
//
|
||||
|
||||
IMF_EXPORT IMATH_NAMESPACE::M44f RGBtoXYZ (const Chromaticities chroma, float Y);
|
||||
IMF_EXPORT IMATH_NAMESPACE::M44f XYZtoRGB (const Chromaticities chroma, float Y);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
template <>
|
||||
const char *
|
||||
ChromaticitiesAttribute::staticTypeName ()
|
||||
{
|
||||
return "chromaticities";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
ChromaticitiesAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
@@ -0,0 +1,73 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::Chromaticities> ChromaticitiesAttribute;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
const char *ChromaticitiesAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void ChromaticitiesAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &,
|
||||
int) const;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void ChromaticitiesAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &,
|
||||
int,
|
||||
int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,591 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "ImfCompositeDeepScanLine.h"
|
||||
#include "ImfDeepScanLineInputPart.h"
|
||||
#include "ImfDeepScanLineInputFile.h"
|
||||
#include "ImfChannelList.h"
|
||||
#include "ImfFrameBuffer.h"
|
||||
#include "ImfDeepFrameBuffer.h"
|
||||
#include "ImfDeepCompositing.h"
|
||||
#include "ImfPixelType.h"
|
||||
#include "IlmThreadPool.h"
|
||||
|
||||
#include <Iex.h>
|
||||
#include <vector>
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using IMATH_NAMESPACE::Box2i;
|
||||
using ILMTHREAD_NAMESPACE::Task;
|
||||
using ILMTHREAD_NAMESPACE::TaskGroup;
|
||||
using ILMTHREAD_NAMESPACE::ThreadPool;
|
||||
|
||||
|
||||
|
||||
struct CompositeDeepScanLine::Data{
|
||||
public :
|
||||
vector<DeepScanLineInputFile *> _file; // array of files
|
||||
vector<DeepScanLineInputPart *> _part; // array of parts
|
||||
FrameBuffer _outputFrameBuffer; // output frame buffer provided
|
||||
bool _zback; // true if we are using zback (otherwise channel 1 = channel 0)
|
||||
vector< vector<float> > _channeldata; // pixel values, read from the input, one array per channel
|
||||
vector< int > _sampleCounts; // total per-pixel sample counts,
|
||||
Box2i _dataWindow; // data window of combined inputs
|
||||
DeepCompositing * _comp; // user-provided compositor
|
||||
vector<string> _channels; // names of channels that will be composited
|
||||
vector<int> _bufferMap; // entry _outputFrameBuffer[n].name() == _channels[ _bufferMap[n] ].name()
|
||||
|
||||
void check_valid(const Header & header); // check newly added part/file is OK; on first good call, set _zback/_dataWindow
|
||||
|
||||
//
|
||||
// set up the given deep frame buffer to contain the required channels
|
||||
// resize counts and pointers to the width of _dataWindow
|
||||
// zero-out all counts, since the datawindow may be smaller than/not include this part
|
||||
//
|
||||
|
||||
void handleDeepFrameBuffer (DeepFrameBuffer & buf,
|
||||
vector<unsigned int> & counts, //per-pixel counts
|
||||
vector< vector<float *> > & pointers, //per-channel-per-pixel pointers to data
|
||||
const Header & header,
|
||||
int start,
|
||||
int end);
|
||||
|
||||
Data();
|
||||
};
|
||||
|
||||
CompositeDeepScanLine::Data::Data() : _zback(false) , _comp(NULL) {}
|
||||
|
||||
CompositeDeepScanLine::CompositeDeepScanLine() : _Data(new Data) {}
|
||||
|
||||
CompositeDeepScanLine::~CompositeDeepScanLine()
|
||||
{
|
||||
delete _Data;
|
||||
}
|
||||
|
||||
void
|
||||
CompositeDeepScanLine::addSource(DeepScanLineInputPart* part)
|
||||
{
|
||||
_Data->check_valid(part->header());
|
||||
_Data->_part.push_back(part);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeDeepScanLine::addSource(DeepScanLineInputFile* file)
|
||||
{
|
||||
_Data->check_valid(file->header());
|
||||
_Data->_file.push_back(file);
|
||||
}
|
||||
|
||||
int
|
||||
CompositeDeepScanLine::sources() const
|
||||
{
|
||||
return int(_Data->_part.size())+int(_Data->_file.size());
|
||||
}
|
||||
|
||||
void
|
||||
CompositeDeepScanLine::Data::check_valid(const Header & header)
|
||||
{
|
||||
|
||||
bool has_z=false;
|
||||
bool has_alpha=false;
|
||||
// check good channel names
|
||||
for( ChannelList::ConstIterator i=header.channels().begin();i!=header.channels().end();++i)
|
||||
{
|
||||
std::string n(i.name());
|
||||
if(n=="ZBack")
|
||||
{
|
||||
_zback=true;
|
||||
}
|
||||
else if(n=="Z")
|
||||
{
|
||||
has_z=true;
|
||||
}
|
||||
else if(n=="A")
|
||||
{
|
||||
has_alpha=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!has_z)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc("Deep data provided to CompositeDeepScanLine is missing a Z channel");
|
||||
}
|
||||
|
||||
if(!has_alpha)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc("Deep data provided to CompositeDeepScanLine is missing an alpha channel");
|
||||
}
|
||||
|
||||
|
||||
if(_part.size()==0 && _file.size()==0)
|
||||
{
|
||||
// first in - update and return
|
||||
|
||||
_dataWindow = header.dataWindow();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const Header * const match_header = _part.size()>0 ? &_part[0]->header() : &_file[0]->header();
|
||||
|
||||
// check the sizes match
|
||||
if(match_header->displayWindow() != header.displayWindow())
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc("Deep data provided to CompositeDeepScanLine has a different displayWindow to previously provided data");
|
||||
}
|
||||
|
||||
_dataWindow.extendBy(header.dataWindow());
|
||||
|
||||
}
|
||||
void
|
||||
CompositeDeepScanLine::Data::handleDeepFrameBuffer (DeepFrameBuffer& buf,
|
||||
std::vector< unsigned int > & counts,
|
||||
vector< std::vector< float* > > & pointers,
|
||||
const Header& header,
|
||||
int start,
|
||||
int end)
|
||||
{
|
||||
int width=_dataWindow.size().x+1;
|
||||
size_t pixelcount = width * (end-start+1);
|
||||
pointers.resize(_channels.size());
|
||||
counts.resize(pixelcount);
|
||||
buf.insertSampleCountSlice (Slice (OPENEXR_IMF_INTERNAL_NAMESPACE::UINT,
|
||||
(char *) (&counts[0]-_dataWindow.min.x-start*width),
|
||||
sizeof(unsigned int),
|
||||
sizeof(unsigned int)*width));
|
||||
|
||||
pointers[0].resize(pixelcount);
|
||||
buf.insert ("Z", DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT,
|
||||
(char *)(&pointers[0][0]-_dataWindow.min.x-start*width),
|
||||
sizeof(float *),
|
||||
sizeof(float *)*width,
|
||||
sizeof(float) ));
|
||||
|
||||
if(_zback)
|
||||
{
|
||||
pointers[1].resize(pixelcount);
|
||||
buf.insert ("ZBack", DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT,
|
||||
(char *)(&pointers[1][0]-_dataWindow.min.x-start*width),
|
||||
sizeof(float *),
|
||||
sizeof(float *)*width,
|
||||
sizeof(float) ));
|
||||
}
|
||||
|
||||
pointers[2].resize(pixelcount);
|
||||
buf.insert ("A", DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT,
|
||||
(char *)(&pointers[2][0]-_dataWindow.min.x-start*width),
|
||||
sizeof(float *),
|
||||
sizeof(float *)*width,
|
||||
sizeof(float) ));
|
||||
|
||||
|
||||
size_t i =0;
|
||||
for(FrameBuffer::ConstIterator qt = _outputFrameBuffer.begin();
|
||||
qt != _outputFrameBuffer.end();
|
||||
qt++)
|
||||
{
|
||||
int channel_in_source = _bufferMap[i];
|
||||
if(channel_in_source>2)
|
||||
{
|
||||
// not dealt with yet (0,1,2 previously inserted)
|
||||
pointers[channel_in_source].resize(pixelcount);
|
||||
buf.insert (qt.name(),
|
||||
DeepSlice (OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT,
|
||||
(char *)(&pointers[channel_in_source][0]-_dataWindow.min.x-start*width),
|
||||
sizeof(float *),
|
||||
sizeof(float *)*width,
|
||||
sizeof(float) ));
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CompositeDeepScanLine::setCompositing(DeepCompositing* c)
|
||||
{
|
||||
_Data->_comp=c;
|
||||
}
|
||||
|
||||
const IMATH_NAMESPACE::Box2i& CompositeDeepScanLine::dataWindow() const
|
||||
{
|
||||
return _Data->_dataWindow;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CompositeDeepScanLine::setFrameBuffer(const FrameBuffer& fr)
|
||||
{
|
||||
|
||||
//
|
||||
// count channels; build map between channels in frame buffer
|
||||
// and channels in internal buffers
|
||||
//
|
||||
|
||||
_Data->_channels.resize(3);
|
||||
_Data->_channels[0]="Z";
|
||||
_Data->_channels[1]=_Data->_zback ? "ZBack" : "Z";
|
||||
_Data->_channels[2]="A";
|
||||
_Data->_bufferMap.resize(0);
|
||||
|
||||
for(FrameBuffer::ConstIterator q=fr.begin();q!=fr.end();q++)
|
||||
{
|
||||
string name(q.name());
|
||||
if(name=="ZBack")
|
||||
{
|
||||
_Data->_bufferMap.push_back(1);
|
||||
}else if(name=="Z")
|
||||
{
|
||||
_Data->_bufferMap.push_back(0);
|
||||
}else if(name=="A")
|
||||
{
|
||||
_Data->_bufferMap.push_back(2);
|
||||
}else{
|
||||
_Data->_bufferMap.push_back(_Data->_channels.size());
|
||||
_Data->_channels.push_back(name);
|
||||
}
|
||||
}
|
||||
|
||||
_Data->_outputFrameBuffer=fr;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class LineCompositeTask : public Task
|
||||
{
|
||||
public:
|
||||
|
||||
LineCompositeTask ( TaskGroup* group ,
|
||||
CompositeDeepScanLine::Data * data,
|
||||
int y,
|
||||
int start,
|
||||
vector<const char*>* names,
|
||||
vector<vector< vector<float *> > >* pointers,
|
||||
vector<unsigned int>* total_sizes,
|
||||
vector<unsigned int>* num_sources
|
||||
) : Task(group) ,
|
||||
_Data(data),
|
||||
_y(y),
|
||||
_start(start),
|
||||
_names(names),
|
||||
_pointers(pointers),
|
||||
_total_sizes(total_sizes),
|
||||
_num_sources(num_sources)
|
||||
{}
|
||||
|
||||
virtual ~LineCompositeTask () {}
|
||||
|
||||
virtual void execute ();
|
||||
CompositeDeepScanLine::Data* _Data;
|
||||
int _y;
|
||||
int _start;
|
||||
vector<const char *>* _names;
|
||||
vector<vector< vector<float *> > >* _pointers;
|
||||
vector<unsigned int>* _total_sizes;
|
||||
vector<unsigned int>* _num_sources;
|
||||
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
composite_line(int y,
|
||||
int start,
|
||||
CompositeDeepScanLine::Data * _Data,
|
||||
vector<const char *> & names,
|
||||
const vector<vector< vector<float *> > > & pointers,
|
||||
const vector<unsigned int> & total_sizes,
|
||||
const vector<unsigned int> & num_sources
|
||||
)
|
||||
{
|
||||
vector<float> output_pixel(names.size()); //the pixel we'll output to
|
||||
vector<const float *> inputs(names.size());
|
||||
DeepCompositing d; // fallback compositing engine
|
||||
DeepCompositing * comp= _Data->_comp ? _Data->_comp : &d;
|
||||
|
||||
int pixel = (y-start)*(_Data->_dataWindow.max.x+1-_Data->_dataWindow.min.x);
|
||||
|
||||
for(int x=_Data->_dataWindow.min.x;x<=_Data->_dataWindow.max.x;x++)
|
||||
{
|
||||
// set inputs[] to point to the first sample of the first part of each channel
|
||||
// if there's a zback, set all channel independently...
|
||||
|
||||
if(_Data->_zback)
|
||||
{
|
||||
|
||||
for(size_t channel=0;channel<names.size();channel++)
|
||||
{
|
||||
inputs[channel]=pointers[0][channel][pixel];
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
// otherwise, set 0 and 1 to point to Z
|
||||
|
||||
|
||||
inputs[0]=pointers[0][0][pixel];
|
||||
inputs[1]=pointers[0][0][pixel];
|
||||
for(size_t channel=2;channel<names.size();channel++)
|
||||
{
|
||||
inputs[channel]=pointers[0][channel][pixel];
|
||||
}
|
||||
|
||||
}
|
||||
comp->composite_pixel(&output_pixel[0],
|
||||
&inputs[0],
|
||||
&names[0],
|
||||
names.size(),
|
||||
total_sizes[pixel],
|
||||
num_sources[pixel]
|
||||
);
|
||||
|
||||
|
||||
size_t channel_number=0;
|
||||
|
||||
|
||||
//
|
||||
// write out composited value into internal frame buffer
|
||||
//
|
||||
for(FrameBuffer::Iterator it = _Data->_outputFrameBuffer.begin();it !=_Data->_outputFrameBuffer.end();it++)
|
||||
{
|
||||
|
||||
float value = output_pixel[ _Data->_bufferMap[channel_number] ]; // value to write
|
||||
|
||||
|
||||
// cast to half float if necessary
|
||||
if(it.slice().type==OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT)
|
||||
{
|
||||
* (float *)(it.slice().base + y*it.slice().yStride + x*it.slice().xStride) = value;
|
||||
}
|
||||
else if(it.slice().type==HALF)
|
||||
{
|
||||
* (half *)(it.slice().base + y*it.slice().yStride + x*it.slice().xStride) = half(value);
|
||||
}
|
||||
|
||||
channel_number++;
|
||||
|
||||
}
|
||||
|
||||
pixel++;
|
||||
|
||||
}// next pixel on row
|
||||
}
|
||||
|
||||
void LineCompositeTask::execute()
|
||||
{
|
||||
composite_line(_y,_start,_Data,*_names,*_pointers,*_total_sizes,*_num_sources);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CompositeDeepScanLine::readPixels(int start, int end)
|
||||
{
|
||||
size_t parts = _Data->_file.size() + _Data->_part.size(); // total of files+parts
|
||||
|
||||
vector<DeepFrameBuffer> framebuffers(parts);
|
||||
vector< vector<unsigned int> > counts(parts);
|
||||
|
||||
//
|
||||
// for each part, a pointer to an array of channels
|
||||
//
|
||||
vector<vector< vector<float *> > > pointers(parts);
|
||||
vector<const Header *> headers(parts);
|
||||
|
||||
{
|
||||
size_t i;
|
||||
for(i=0;i<_Data->_file.size();i++)
|
||||
{
|
||||
headers[i] = &_Data->_file[i]->header();
|
||||
}
|
||||
|
||||
for(size_t j=0;j<_Data->_part.size();j++)
|
||||
{
|
||||
headers[i+j] = &_Data->_part[j]->header();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(size_t i=0;i<parts;i++)
|
||||
{
|
||||
_Data->handleDeepFrameBuffer(framebuffers[i],counts[i],pointers[i],*headers[i],start,end);
|
||||
}
|
||||
|
||||
//
|
||||
// set frame buffers and read scanlines from all parts
|
||||
// TODO what happens if SCANLINE not in data window?
|
||||
//
|
||||
|
||||
{
|
||||
size_t i=0;
|
||||
for(i=0;i<_Data->_file.size();i++)
|
||||
{
|
||||
_Data->_file[i]->setFrameBuffer(framebuffers[i]);
|
||||
_Data->_file[i]->readPixelSampleCounts(start,end);
|
||||
}
|
||||
for(size_t j=0;j<_Data->_part.size();j++)
|
||||
{
|
||||
_Data->_part[j]->setFrameBuffer(framebuffers[i+j]);
|
||||
_Data->_part[j]->readPixelSampleCounts(start,end);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// total width
|
||||
//
|
||||
|
||||
size_t total_width = _Data->_dataWindow.size().x+1;
|
||||
size_t total_pixels = total_width*(end-start+1);
|
||||
vector<unsigned int> total_sizes(total_pixels);
|
||||
vector<unsigned int> num_sources(total_pixels); //number of parts with non-zero sample count
|
||||
|
||||
size_t overall_sample_count=0; // sum of all samples in all images between start and end
|
||||
|
||||
|
||||
//
|
||||
// accumulate pixel counts
|
||||
//
|
||||
for(size_t ptr=0;ptr<total_pixels;ptr++)
|
||||
{
|
||||
total_sizes[ptr]=0;
|
||||
num_sources[ptr]=0;
|
||||
for(size_t j=0;j<parts;j++)
|
||||
{
|
||||
total_sizes[ptr]+=counts[j][ptr];
|
||||
if(counts[j][ptr]>0) num_sources[ptr]++;
|
||||
}
|
||||
overall_sample_count+=total_sizes[ptr];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// allocate arrays for pixel data
|
||||
// samples array accessed as in pixels[channel][sample]
|
||||
//
|
||||
|
||||
vector<vector<float> > samples( _Data->_channels.size() );
|
||||
|
||||
for(size_t channel=0;channel<_Data->_channels.size();channel++)
|
||||
{
|
||||
if( channel!=1 || _Data->_zback)
|
||||
{
|
||||
samples[channel].resize(overall_sample_count);
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t channel=0;channel<samples.size();channel++)
|
||||
{
|
||||
|
||||
if( channel!=1 || _Data->_zback)
|
||||
{
|
||||
|
||||
samples[channel].resize(overall_sample_count);
|
||||
|
||||
|
||||
//
|
||||
// allocate pointers for channel data
|
||||
//
|
||||
|
||||
size_t offset=0;
|
||||
|
||||
for(size_t pixel=0;pixel<total_pixels;pixel++)
|
||||
{
|
||||
for(size_t part=0 ; part<parts && offset<overall_sample_count ; part++ )
|
||||
{
|
||||
pointers[part][channel][pixel]=&samples[channel][offset];
|
||||
offset+=counts[part][pixel];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// read data
|
||||
//
|
||||
|
||||
for(size_t i=0;i<_Data->_file.size();i++)
|
||||
{
|
||||
_Data->_file[i]->readPixels(start,end);
|
||||
}
|
||||
for(size_t j=0;j<_Data->_part.size();j++)
|
||||
{
|
||||
_Data->_part[j]->readPixels(start,end);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// composite pixels and write back to framebuffer
|
||||
//
|
||||
|
||||
|
||||
// turn vector of strings into array of char *
|
||||
// and make sure 'ZBack' channel is correct
|
||||
vector<const char *> names(_Data->_channels.size());
|
||||
for(size_t i=0;i<names.size();i++)
|
||||
{
|
||||
names[i]=_Data->_channels[i].c_str();
|
||||
}
|
||||
|
||||
if(!_Data->_zback) names[1]=names[0]; // no zback channel, so make it point to z
|
||||
|
||||
|
||||
|
||||
TaskGroup g;
|
||||
for(int y=start;y<=end;y++)
|
||||
{
|
||||
ThreadPool::addGlobalTask(new LineCompositeTask(&g,_Data,y,start,&names,&pointers,&total_sizes,&num_sources));
|
||||
}//next row
|
||||
}
|
||||
|
||||
const FrameBuffer&
|
||||
CompositeDeepScanLine::frameBuffer() const
|
||||
{
|
||||
return _Data->_outputFrameBuffer;
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
142
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompositeDeepScanLine.h
Normal file
142
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompositeDeepScanLine.h
Normal file
@@ -0,0 +1,142 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, 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_COMPOSITEDEEPSCANLINE_H
|
||||
#define INCLUDED_IMF_COMPOSITEDEEPSCANLINE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Class to composite deep samples into a frame buffer
|
||||
// Initialise with a deep input part or deep inputfile
|
||||
// (also supports multiple files and parts, and will
|
||||
// composite them together, as long as their sizes and channelmaps agree)
|
||||
//
|
||||
// Then call setFrameBuffer, and readPixels, exactly as for reading
|
||||
// regular scanline images.
|
||||
//
|
||||
// Restrictions - source file(s) must contain at least Z and alpha channels
|
||||
// - if multiple files/parts are provided, sizes must match
|
||||
// - all requested channels will be composited as premultiplied
|
||||
// - only half and float channels can be requested
|
||||
//
|
||||
// This object should not be considered threadsafe
|
||||
//
|
||||
// The default compositing engine will give spurious results with overlapping
|
||||
// volumetric samples - you may derive from DeepCompositing class, override the
|
||||
// sort_pixel() and composite_pixel() functions, and pass an instance to
|
||||
// setCompositing().
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfForward.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
#include <ImathBox.h>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT CompositeDeepScanLine
|
||||
{
|
||||
public:
|
||||
CompositeDeepScanLine();
|
||||
virtual ~CompositeDeepScanLine();
|
||||
|
||||
/// set the source data as a part
|
||||
///@note all parts must remain valid until after last interaction with DeepComp
|
||||
void addSource(DeepScanLineInputPart * part);
|
||||
|
||||
/// set the source data as a file
|
||||
///@note all file must remain valid until after last interaction with DeepComp
|
||||
void addSource(DeepScanLineInputFile * file);
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
//
|
||||
// set the frame buffer for output values
|
||||
// the buffers specified must be large enough
|
||||
// to handle the dataWindow()
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
void setFrameBuffer(const FrameBuffer & fr);
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
//
|
||||
// retrieve frameBuffer
|
||||
//
|
||||
////////////////////////////////////////
|
||||
const FrameBuffer & frameBuffer() const;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//
|
||||
// read scanlines start to end from the source(s)
|
||||
// storing the result in the frame buffer provided
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
void readPixels(int start,int end);
|
||||
|
||||
int sources() const; // return number of sources
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
// retrieve the datawindow
|
||||
// If multiple parts are specified, this will
|
||||
// be the union of the dataWindow of all parts
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
const IMATH_NAMESPACE::Box2i & dataWindow() const;
|
||||
|
||||
|
||||
//
|
||||
// override default sorting/compositing operation
|
||||
// (otherwise an instance of the base class will be used)
|
||||
//
|
||||
|
||||
void setCompositing(DeepCompositing *);
|
||||
|
||||
struct Data;
|
||||
private :
|
||||
struct Data *_Data;
|
||||
|
||||
CompositeDeepScanLine(const CompositeDeepScanLine &); // not implemented
|
||||
const CompositeDeepScanLine & operator=(const CompositeDeepScanLine &); // not implemented
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
84
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompression.h
Normal file
84
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompression.h
Normal file
@@ -0,0 +1,84 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
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
|
||||
|
||||
DWAA_COMPRESSION = 8, // lossy DCT based compression, in blocks
|
||||
// of 32 scanlines. More efficient for partial
|
||||
// buffer access.
|
||||
|
||||
DWAB_COMPRESSION = 9, // lossy DCT based compression, in blocks
|
||||
// of 256 scanlines. More efficient space
|
||||
// wise and faster to decode full frames
|
||||
// than DWAA_COMPRESSION.
|
||||
|
||||
NUM_COMPRESSION_METHODS // number of different compression methods
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
CompressionAttribute::staticTypeName ()
|
||||
{
|
||||
return "compression";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
CompressionAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const
|
||||
{
|
||||
unsigned char tmp = _value;
|
||||
Xdr::write <StreamIO> (os, tmp);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
CompressionAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version)
|
||||
{
|
||||
unsigned char tmp;
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value = Compression (tmp);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
@@ -0,0 +1,64 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::Compression> CompressionAttribute;
|
||||
template <> const char *CompressionAttribute::staticTypeName ();
|
||||
template <> void CompressionAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &,
|
||||
int) const;
|
||||
template <> void CompressionAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &,
|
||||
int,
|
||||
int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
226
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompressor.cpp
Normal file
226
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompressor.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfDwaCompressor.h"
|
||||
#include "ImfCheckedArithmetic.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using IMATH_NAMESPACE::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:
|
||||
case DWAA_COMPRESSION:
|
||||
case DWAB_COMPRESSION:
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isValidDeepCompression(Compression c)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case NO_COMPRESSION:
|
||||
case RLE_COMPRESSION:
|
||||
case ZIPS_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);
|
||||
|
||||
case DWAA_COMPRESSION:
|
||||
|
||||
return new DwaCompressor (hdr, maxScanLineSize, 32,
|
||||
DwaCompressor::STATIC_HUFFMAN);
|
||||
|
||||
case DWAB_COMPRESSION:
|
||||
|
||||
return new DwaCompressor (hdr, maxScanLineSize, 256,
|
||||
DwaCompressor::STATIC_HUFFMAN);
|
||||
|
||||
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);
|
||||
|
||||
case DWAA_COMPRESSION:
|
||||
case DWAB_COMPRESSION:
|
||||
|
||||
return new DwaCompressor (hdr, tileLineSize, numTileLines,
|
||||
DwaCompressor::DEFLATE);
|
||||
|
||||
default:
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
|
||||
265
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompressor.h
Normal file
265
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfCompressor.h
Normal file
@@ -0,0 +1,265 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfForward.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT 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_NAMESPACE::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_NAMESPACE::Box2i range,
|
||||
const char *&outPtr);
|
||||
|
||||
private:
|
||||
|
||||
const Header & _header;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------
|
||||
// Test if c is a valid compression type
|
||||
//--------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
bool isValidCompression (Compression c);
|
||||
|
||||
//--------------------------------------
|
||||
// Test if c is valid for deep data
|
||||
//--------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
bool isValidDeepCompression (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).
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
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).
|
||||
//
|
||||
//-----------------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
Compressor * newTileCompressor (Compression c,
|
||||
size_t tileLineSize,
|
||||
size_t numTileLines,
|
||||
const Header &hdr);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
143
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfConvert.cpp
Normal file
143
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfConvert.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfNamespace.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
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 > (float) UINT_MAX)
|
||||
return UINT_MAX;
|
||||
|
||||
return (unsigned int) f;
|
||||
}
|
||||
|
||||
|
||||
half
|
||||
uintToHalf (unsigned int ui)
|
||||
{
|
||||
if (ui > HALF_MAX)
|
||||
return half::posInf();
|
||||
|
||||
return half ((float) 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);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
107
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfConvert.h
Normal file
107
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfConvert.h
Normal file
@@ -0,0 +1,107 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// 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
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
IMF_EXPORT unsigned int halfToUint (half h);
|
||||
IMF_EXPORT 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
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
IMF_EXPORT half uintToHalf (unsigned int ui);
|
||||
IMF_EXPORT half floatToHalf (float f);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
110
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepCompositing.cpp
Normal file
110
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepCompositing.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ImfDeepCompositing.h"
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using std::sort;
|
||||
using std::vector;
|
||||
DeepCompositing::DeepCompositing()
|
||||
{
|
||||
}
|
||||
|
||||
DeepCompositing::~DeepCompositing()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DeepCompositing::composite_pixel (float outputs[],
|
||||
const float* inputs[],
|
||||
const char*channel_names[],
|
||||
int num_channels,
|
||||
int num_samples,
|
||||
int sources)
|
||||
{
|
||||
for(int i=0;i<num_channels;i++) outputs[i]=0.0;
|
||||
// no samples? do nothing
|
||||
if(num_samples==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vector<int> sort_order;
|
||||
if(sources>1)
|
||||
{
|
||||
sort_order.resize(num_samples);
|
||||
for(int i=0;i<num_samples;i++) sort_order[i]=i;
|
||||
sort(&sort_order[0],inputs,channel_names,num_channels,num_samples,sources);
|
||||
}
|
||||
|
||||
|
||||
for(int i=0;i<num_samples;i++)
|
||||
{
|
||||
int s=(sources>1) ? sort_order[i] : i;
|
||||
float alpha=outputs[2];
|
||||
if(alpha>=1.0) return;
|
||||
|
||||
for(int c=0;c<num_channels;c++)
|
||||
{
|
||||
outputs[c]+=(1.0-alpha)*inputs[c][s];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct sort_helper
|
||||
{
|
||||
const float ** inputs;
|
||||
bool operator() (int a,int b)
|
||||
{
|
||||
if(inputs[0][a] < inputs[0][b]) return true;
|
||||
if(inputs[0][a] > inputs[0][b]) return false;
|
||||
if(inputs[1][a] < inputs[1][b]) return true;
|
||||
if(inputs[1][a] > inputs[1][b]) return false;
|
||||
return a<b;
|
||||
}
|
||||
sort_helper(const float ** i) : inputs(i) {}
|
||||
};
|
||||
|
||||
void
|
||||
DeepCompositing::sort(int order[], const float* inputs[], const char* channel_names[], int num_channels, int num_samples, int sources)
|
||||
{
|
||||
std::sort(order+0,order+num_samples,sort_helper(inputs));
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
132
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepCompositing.h
Normal file
132
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepCompositing.h
Normal file
@@ -0,0 +1,132 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, 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_DEEPCOMPOSITING_H
|
||||
#define INCLUDED_IMF_DEEPCOMPOSITING_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Class to sort and composite deep samples into a frame buffer
|
||||
// You may derive from this class to change the way that CompositeDeepScanLine
|
||||
// and CompositeDeepTile combine samples together - pass an instance of your derived
|
||||
// class to the compositing engine
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfForward.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT DeepCompositing
|
||||
{
|
||||
public:
|
||||
DeepCompositing();
|
||||
virtual ~DeepCompositing();
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
///
|
||||
/// composite together the given channels
|
||||
///
|
||||
/// @param outputs - return array of pixel values -
|
||||
/// @param inputs - arrays of input sample
|
||||
/// @param channel_names - array of channel names for corresponding channels
|
||||
/// @param num_channels - number of active channels (3 or greater)
|
||||
/// @param num_samples - number of values in all input arrays
|
||||
/// @param sources - number of different sources
|
||||
///
|
||||
/// each array input has num_channels entries: outputs[n] should be the composited
|
||||
/// values in array inputs[n], whose name will be given by channel_names[n]
|
||||
///
|
||||
/// The channel ordering shall be as follows:
|
||||
/// Position Channel
|
||||
/// 0 Z
|
||||
/// 1 ZBack (if no ZBack, then inputs[1]==inputs[0] and channel_names[1]==channel_names[0])
|
||||
/// 2 A (alpha channel)
|
||||
/// 3-n other channels - only channels in the frame buffer will appear here
|
||||
///
|
||||
/// since a Z and Alpha channel is required, and channel[1] is ZBack or another copy of Z
|
||||
/// there will always be 3 or more channels.
|
||||
///
|
||||
/// The default implementation calls sort() if and only if more than one source is active,
|
||||
/// composites all samples together using the Over operator from front to back,
|
||||
/// stopping as soon as a sample with alpha=1 is found
|
||||
/// It also blanks all outputs if num_samples==0
|
||||
///
|
||||
/// note - multiple threads may call composite_pixel simultaneously for different pixels
|
||||
///
|
||||
///
|
||||
//////////////////////////////////////////////
|
||||
virtual void composite_pixel(float outputs[],
|
||||
const float * inputs[],
|
||||
const char * channel_names[],
|
||||
int num_channels,
|
||||
int num_samples,
|
||||
int sources
|
||||
);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
///
|
||||
/// find the depth order for samples with given channel values
|
||||
/// does not sort the values in-place. Instead it populates
|
||||
/// array 'order' with the desired sorting order
|
||||
///
|
||||
/// the default operation sorts samples from front to back according to their Z channel
|
||||
///
|
||||
/// @param order - required output order. order[n] shall be the nth closest sample
|
||||
/// @param inputs - arrays of input samples, one array per channel_name
|
||||
/// @param channel_names - array of channel names for corresponding channels
|
||||
/// @param num_channels - number of channels (3 or greater)
|
||||
/// @param num_samples - number of samples in each array
|
||||
/// @param sources - number of different sources the data arises from
|
||||
///
|
||||
/// the channel layout is identical to composite_pixel()
|
||||
///
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void sort(int order[],
|
||||
const float * inputs[],
|
||||
const char * channel_names[],
|
||||
int num_channels,
|
||||
int num_samples,
|
||||
int sources);
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
230
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepFrameBuffer.cpp
Normal file
230
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepFrameBuffer.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfDeepFrameBuffer.h"
|
||||
#include "Iex.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
DeepSlice::DeepSlice (PixelType t,
|
||||
char *b,
|
||||
size_t xst,
|
||||
size_t yst,
|
||||
size_t spst,
|
||||
int xsm,
|
||||
int ysm,
|
||||
double fv,
|
||||
bool xtc,
|
||||
bool ytc)
|
||||
:
|
||||
Slice (t, b, xst, yst, xsm, ysm, fv, xtc, ytc),
|
||||
sampleStride (spst)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepFrameBuffer::insert (const char name[], const DeepSlice &slice)
|
||||
{
|
||||
if (name[0] == 0)
|
||||
{
|
||||
THROW (IEX_NAMESPACE::ArgExc,
|
||||
"Frame buffer slice name cannot be an empty string.");
|
||||
}
|
||||
|
||||
_map[name] = slice;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepFrameBuffer::insert (const string &name, const DeepSlice &slice)
|
||||
{
|
||||
insert (name.c_str(), slice);
|
||||
}
|
||||
|
||||
|
||||
DeepSlice &
|
||||
DeepFrameBuffer::operator [] (const char name[])
|
||||
{
|
||||
SliceMap::iterator i = _map.find (name);
|
||||
|
||||
if (i == _map.end())
|
||||
{
|
||||
THROW (IEX_NAMESPACE::ArgExc,
|
||||
"Cannot find frame buffer slice \"" << name << "\".");
|
||||
}
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
const DeepSlice &
|
||||
DeepFrameBuffer::operator [] (const char name[]) const
|
||||
{
|
||||
SliceMap::const_iterator i = _map.find (name);
|
||||
|
||||
if (i == _map.end())
|
||||
{
|
||||
THROW (IEX_NAMESPACE::ArgExc,
|
||||
"Cannot find frame buffer slice \"" << name << "\".");
|
||||
}
|
||||
|
||||
return i->second;
|
||||
}
|
||||
|
||||
|
||||
DeepSlice &
|
||||
DeepFrameBuffer::operator [] (const string &name)
|
||||
{
|
||||
return this->operator[] (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const DeepSlice &
|
||||
DeepFrameBuffer::operator [] (const string &name) const
|
||||
{
|
||||
return this->operator[] (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
DeepSlice *
|
||||
DeepFrameBuffer::findSlice (const char name[])
|
||||
{
|
||||
SliceMap::iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: &i->second;
|
||||
}
|
||||
|
||||
|
||||
const DeepSlice *
|
||||
DeepFrameBuffer::findSlice (const char name[]) const
|
||||
{
|
||||
SliceMap::const_iterator i = _map.find (name);
|
||||
return (i == _map.end())? 0: &i->second;
|
||||
}
|
||||
|
||||
|
||||
DeepSlice *
|
||||
DeepFrameBuffer::findSlice (const string &name)
|
||||
{
|
||||
return findSlice (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
const DeepSlice *
|
||||
DeepFrameBuffer::findSlice (const string &name) const
|
||||
{
|
||||
return findSlice (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::Iterator
|
||||
DeepFrameBuffer::begin ()
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::ConstIterator
|
||||
DeepFrameBuffer::begin () const
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::Iterator
|
||||
DeepFrameBuffer::end ()
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::ConstIterator
|
||||
DeepFrameBuffer::end () const
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::Iterator
|
||||
DeepFrameBuffer::find (const char name[])
|
||||
{
|
||||
return _map.find (name);
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::ConstIterator
|
||||
DeepFrameBuffer::find (const char name[]) const
|
||||
{
|
||||
return _map.find (name);
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::Iterator
|
||||
DeepFrameBuffer::find (const string &name)
|
||||
{
|
||||
return find (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
DeepFrameBuffer::ConstIterator
|
||||
DeepFrameBuffer::find (const string &name) const
|
||||
{
|
||||
return find (name.c_str());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepFrameBuffer::insertSampleCountSlice(const Slice & slice)
|
||||
{
|
||||
if (slice.type != UINT)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc("The type of sample count slice should be UINT.");
|
||||
}
|
||||
|
||||
_sampleCounts = slice;
|
||||
}
|
||||
|
||||
|
||||
const Slice &
|
||||
DeepFrameBuffer::getSampleCountSlice() const
|
||||
{
|
||||
return _sampleCounts;
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
339
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepFrameBuffer.h
Normal file
339
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepFrameBuffer.h
Normal file
@@ -0,0 +1,339 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFDEEPFRAMEBUFFER_H_
|
||||
#define IMFDEEPFRAMEBUFFER_H_
|
||||
|
||||
#include "ImfFrameBuffer.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Description of a single deep slice of the frame buffer:
|
||||
//--------------------------------------------------------
|
||||
|
||||
struct IMF_EXPORT DeepSlice : public Slice
|
||||
{
|
||||
//---------------------------------------------------------------------
|
||||
// The stride for each sample in this slice.
|
||||
//
|
||||
// Memory layout: The address of sample i in pixel (x, y) is
|
||||
//
|
||||
// base + (xp / xSampling) * xStride + (yp / ySampling) * yStride
|
||||
// + i * sampleStride
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
int sampleStride;
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
DeepSlice (PixelType type = HALF,
|
||||
char * base = 0,
|
||||
size_t xStride = 0,
|
||||
size_t yStride = 0,
|
||||
size_t sampleStride = 0,
|
||||
int xSampling = 1,
|
||||
int ySampling = 1,
|
||||
double fillValue = 0.0,
|
||||
bool xTileCoords = false,
|
||||
bool yTileCoords = false);
|
||||
};
|
||||
|
||||
//-----------------
|
||||
// DeepFrameBuffer.
|
||||
//-----------------
|
||||
|
||||
class IMF_EXPORT DeepFrameBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
//------------
|
||||
// Add a slice
|
||||
//------------
|
||||
|
||||
void insert (const char name[],
|
||||
const DeepSlice &slice);
|
||||
|
||||
void insert (const std::string &name,
|
||||
const DeepSlice &slice);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Access to existing slices:
|
||||
//
|
||||
// [n] Returns a reference to the slice with name n.
|
||||
// If no slice with name n exists, an IEX_NAMESPACE::ArgExc
|
||||
// is thrown.
|
||||
//
|
||||
// findSlice(n) Returns a pointer to the slice with name n,
|
||||
// or 0 if no slice with name n exists.
|
||||
//
|
||||
//----------------------------------------------------------------
|
||||
|
||||
DeepSlice & operator [] (const char name[]);
|
||||
const DeepSlice & operator [] (const char name[]) const;
|
||||
|
||||
DeepSlice & operator [] (const std::string &name);
|
||||
const DeepSlice & operator [] (const std::string &name) const;
|
||||
|
||||
DeepSlice * findSlice (const char name[]);
|
||||
const DeepSlice * findSlice (const char name[]) const;
|
||||
|
||||
DeepSlice * findSlice (const std::string &name);
|
||||
const DeepSlice * findSlice (const std::string &name) const;
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Iterator-style access to existing slices
|
||||
//-----------------------------------------
|
||||
|
||||
typedef std::map <Name, DeepSlice> 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;
|
||||
|
||||
//----------------------------------------------------
|
||||
// Public function for accessing a sample count slice.
|
||||
//----------------------------------------------------
|
||||
|
||||
void insertSampleCountSlice(const Slice & slice);
|
||||
const Slice & getSampleCountSlice() const;
|
||||
|
||||
private:
|
||||
|
||||
SliceMap _map;
|
||||
Slice _sampleCounts;
|
||||
};
|
||||
|
||||
//----------
|
||||
// Iterators
|
||||
//----------
|
||||
|
||||
class DeepFrameBuffer::Iterator
|
||||
{
|
||||
public:
|
||||
|
||||
Iterator ();
|
||||
Iterator (const DeepFrameBuffer::SliceMap::iterator &i);
|
||||
|
||||
Iterator & operator ++ ();
|
||||
Iterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
DeepSlice & slice () const;
|
||||
|
||||
private:
|
||||
|
||||
friend class DeepFrameBuffer::ConstIterator;
|
||||
|
||||
DeepFrameBuffer::SliceMap::iterator _i;
|
||||
};
|
||||
|
||||
|
||||
class DeepFrameBuffer::ConstIterator
|
||||
{
|
||||
public:
|
||||
|
||||
ConstIterator ();
|
||||
ConstIterator (const DeepFrameBuffer::SliceMap::const_iterator &i);
|
||||
ConstIterator (const DeepFrameBuffer::Iterator &other);
|
||||
|
||||
ConstIterator & operator ++ ();
|
||||
ConstIterator operator ++ (int);
|
||||
|
||||
const char * name () const;
|
||||
const DeepSlice & slice () const;
|
||||
|
||||
private:
|
||||
|
||||
friend bool operator == (const ConstIterator &, const ConstIterator &);
|
||||
friend bool operator != (const ConstIterator &, const ConstIterator &);
|
||||
|
||||
DeepFrameBuffer::SliceMap::const_iterator _i;
|
||||
};
|
||||
|
||||
|
||||
//-----------------
|
||||
// Inline Functions
|
||||
//-----------------
|
||||
|
||||
inline
|
||||
DeepFrameBuffer::Iterator::Iterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
DeepFrameBuffer::Iterator::Iterator (const DeepFrameBuffer::SliceMap::iterator &i):
|
||||
_i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline DeepFrameBuffer::Iterator &
|
||||
DeepFrameBuffer::Iterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline DeepFrameBuffer::Iterator
|
||||
DeepFrameBuffer::Iterator::operator ++ (int)
|
||||
{
|
||||
Iterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
DeepFrameBuffer::Iterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
|
||||
inline DeepSlice &
|
||||
DeepFrameBuffer::Iterator::slice () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
DeepFrameBuffer::ConstIterator::ConstIterator (): _i()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline
|
||||
DeepFrameBuffer::ConstIterator::ConstIterator
|
||||
(const DeepFrameBuffer::SliceMap::const_iterator &i): _i (i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
DeepFrameBuffer::ConstIterator::ConstIterator (const DeepFrameBuffer::Iterator &other):
|
||||
_i (other._i)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
inline DeepFrameBuffer::ConstIterator &
|
||||
DeepFrameBuffer::ConstIterator::operator ++ ()
|
||||
{
|
||||
++_i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline DeepFrameBuffer::ConstIterator
|
||||
DeepFrameBuffer::ConstIterator::operator ++ (int)
|
||||
{
|
||||
ConstIterator tmp = *this;
|
||||
++_i;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
inline const char *
|
||||
DeepFrameBuffer::ConstIterator::name () const
|
||||
{
|
||||
return *_i->first;
|
||||
}
|
||||
|
||||
inline const DeepSlice &
|
||||
DeepFrameBuffer::ConstIterator::slice () const
|
||||
{
|
||||
return _i->second;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator == (const DeepFrameBuffer::ConstIterator &x,
|
||||
const DeepFrameBuffer::ConstIterator &y)
|
||||
{
|
||||
return x._i == y._i;
|
||||
}
|
||||
|
||||
|
||||
inline bool
|
||||
operator != (const DeepFrameBuffer::ConstIterator &x,
|
||||
const DeepFrameBuffer::ConstIterator &y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IMFDEEPFRAMEBUFFER_H_ */
|
||||
96
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepImageState.h
Normal file
96
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepImageState.h
Normal file
@@ -0,0 +1,96 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2013, 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_DEEPIMAGESTATE_H
|
||||
#define INCLUDED_IMF_DEEPIMAGESTATE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// enum DeepImageState -- describes how orderly the pixel data
|
||||
// in a deep image are
|
||||
//
|
||||
// The samples in a deep image pixel may be sorted according to
|
||||
// depth, and the sample depths or depth ranges may or may not
|
||||
// overlap each other. A pixel is
|
||||
//
|
||||
// - SORTED if for every i and j with i < j
|
||||
//
|
||||
// (Z[i] < Z[j]) || (Z[i] == Z[j] && ZBack[i] < ZBack[j]),
|
||||
//
|
||||
// - NON_OVERLAPPING if for every i and j with i != j
|
||||
//
|
||||
// (Z[i] < Z[j] && ZBack[i] <= Z[j]) ||
|
||||
// (Z[j] < Z[i] && ZBack[j] <= Z[i]) ||
|
||||
// (Z[i] == Z[j] && ZBack[i] <= Z[i] & ZBack[j] > Z[j]) ||
|
||||
// (Z[i] == Z[j] && ZBack[j] <= Z[j] & ZBack[i] > Z[i]),
|
||||
//
|
||||
// - TIDY if it is SORTED and NON_OVERLAPPING,
|
||||
//
|
||||
// - MESSY if it is neither SORTED nor NON_OVERLAPPING.
|
||||
//
|
||||
// A deep image is
|
||||
//
|
||||
// - MESSY if at least one of its pixels is MESSY,
|
||||
// - SORTED if all of its pixels are SORTED,
|
||||
// - NON_OVERLAPPING if all of its pixels are NON_OVERLAPPING,
|
||||
// - TIDY if all of its pixels are TIDY.
|
||||
//
|
||||
// Note: the rather complicated definition of NON_OVERLAPPING prohibits
|
||||
// overlapping volume samples, coincident point samples and point samples
|
||||
// in the middle of a volume sample, but it does allow point samples at
|
||||
// the front or back of a volume sample.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
enum DeepImageState
|
||||
{
|
||||
DIS_MESSY = 0,
|
||||
DIS_SORTED = 1,
|
||||
DIS_NON_OVERLAPPING = 2,
|
||||
DIS_TIDY = 3,
|
||||
|
||||
DIS_NUMSTATES // Number of different image states
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2013, 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 DeepImageStateAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfDeepImageStateAttribute.h>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
template <>
|
||||
const char *
|
||||
DeepImageStateAttribute::staticTypeName ()
|
||||
{
|
||||
return "deepImageState";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
DeepImageStateAttribute::writeValueTo
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const
|
||||
{
|
||||
unsigned char tmp = _value;
|
||||
Xdr::write <StreamIO> (os, tmp);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
DeepImageStateAttribute::readValueFrom
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version)
|
||||
{
|
||||
unsigned char tmp;
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value = DeepImageState (tmp);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
@@ -0,0 +1,68 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2013, 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_DEEPIMAGESTATE_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_DEEPIMAGESTATE_ATTRIBUTE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DeepImageStateAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfAttribute.h"
|
||||
#include "ImfDeepImageState.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::DeepImageState>
|
||||
DeepImageStateAttribute;
|
||||
|
||||
template <> IMF_EXPORT const char *DeepImageStateAttribute::staticTypeName ();
|
||||
|
||||
template <> IMF_EXPORT
|
||||
void DeepImageStateAttribute::writeValueTo
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &, int) const;
|
||||
|
||||
template <> IMF_EXPORT
|
||||
void DeepImageStateAttribute::readValueFrom
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &, int, int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
2025
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Normal file
2025
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp
Normal file
File diff suppressed because it is too large
Load Diff
276
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineInputFile.h
Normal file
276
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineInputFile.h
Normal file
@@ -0,0 +1,276 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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_DEEP_SCAN_LINE_INPUT_FILE_H
|
||||
#define INCLUDED_IMF_DEEP_SCAN_LINE_INPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DeepScanLineInputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfThreading.h"
|
||||
#include "ImfGenericInputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
#include "ImfDeepScanLineOutputFile.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT DeepScanLineInputFile : public GenericInputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
DeepScanLineInputFile (const char fileName[],
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
DeepScanLineInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is,
|
||||
int version, /*version field from file*/
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Destructor -- deallocates internal data
|
||||
// structures, but does not close the file.
|
||||
//-----------------------------------------
|
||||
|
||||
virtual ~DeepScanLineInputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// 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 DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & 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).
|
||||
//
|
||||
// If threading is enabled, readPixels (s1, s2) tries to perform
|
||||
// decopmression of multiple scanlines in parallel.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Extract pixel data from pre-read block
|
||||
//
|
||||
// readPixels(rawPixelData,frameBuffer,s1,s2) reads all scan lines with y coordinates
|
||||
// in the interval [min (s1, s2), max (s1, s2)] from the data provided and
|
||||
// stores them in the provided frameBuffer.
|
||||
// the data can be obtained from a call to rawPixelData()
|
||||
//
|
||||
//
|
||||
// Both s1 and s2 must be within the data specified
|
||||
//
|
||||
// you must provide a frameBuffer with a samplecountslice, which must have been read
|
||||
// and the data valid - readPixels uses your sample count buffer to compute
|
||||
// offsets to the data it needs
|
||||
//
|
||||
// This call does not block, and is thread safe for clients with an existing
|
||||
// threading model. The InputFile's frameBuffer is not used in this call.
|
||||
//
|
||||
// This call is only provided for clients which have an existing threading model in place
|
||||
// and unpredictable access patterns to the data.
|
||||
// The fastest way to read an entire image is to enable threading,use setFrameBuffer then
|
||||
// readPixels(header().dataWindow().min.y, header.dataWindow().max.y)
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void readPixels (const char * rawPixelData,
|
||||
const DeepFrameBuffer & frameBuffer,
|
||||
int scanLine1,
|
||||
int scanLine2) const;
|
||||
|
||||
//----------------------------------------------
|
||||
// Read a block of raw pixel data from the file,
|
||||
// without uncompressing it (this function is
|
||||
// used to implement OutputFile::copyPixels()).
|
||||
// note: returns the entire payload of the relevant chunk of data, not including part number
|
||||
// including compressed and uncompressed sizes
|
||||
// on entry, if pixelDataSize is insufficiently large, no bytes are read (pixelData can safely be NULL)
|
||||
// on exit, pixelDataSize is the number of bytes required to read the chunk
|
||||
//
|
||||
//----------------------------------------------
|
||||
|
||||
void rawPixelData (int firstScanLine,
|
||||
char * pixelData,
|
||||
Int64 &pixelDataSize);
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// firstScanLineInChunk() returns the row number of the first row that's stored in the
|
||||
// same chunk as scanline y. Depending on the compression mode, this may not be the same as y
|
||||
//
|
||||
// lastScanLineInChunk() returns the row number of the last row that's stored in the same
|
||||
// chunk as scanline y. Depending on the compression mode, this may not be the same as y.
|
||||
// The last chunk in the file may be smaller than all the others
|
||||
//
|
||||
//------------------------------------------------
|
||||
int firstScanLineInChunk(int y) const;
|
||||
int lastScanLineInChunk (int y) const;
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Read pixel sample counts into a slice in the frame buffer.
|
||||
//
|
||||
// readPixelSampleCounts(s1, s2) reads all the counts of
|
||||
// pixel samples with y coordinates in the interval
|
||||
// [min (s1, s2), max (s1, s2)] from the file, and stores
|
||||
// them in the slice naming "sample count".
|
||||
//
|
||||
// Both s1 and s2 must be within the interval
|
||||
// [header().dataWindow().min.y, header.dataWindow().max.y]
|
||||
//
|
||||
// readPixelSampleCounts(s) calls readPixelSampleCounts(s,s).
|
||||
//
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void readPixelSampleCounts (int scanline1,
|
||||
int scanline2);
|
||||
void readPixelSampleCounts (int scanline);
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Read pixel sample counts into the provided frameBuffer
|
||||
// using a block read of data read by rawPixelData
|
||||
// for multi-scanline compression schemes, you must decode the entire block
|
||||
// so scanline1=firstScanLineInChunk(y) and scanline2=lastScanLineInChunk(y)
|
||||
//
|
||||
// This call does not block, and is thread safe for clients with an existing
|
||||
// threading model. The InputFile's frameBuffer is not used in this call.
|
||||
//
|
||||
// The fastest way to read an entire image is to enable threading in OpenEXR, use setFrameBuffer then
|
||||
// readPixelSampleCounts(header().dataWindow().min.y, header.dataWindow().max.y)
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
void readPixelSampleCounts (const char * rawdata ,
|
||||
const DeepFrameBuffer & frameBuffer,
|
||||
int scanLine1 ,
|
||||
int scanLine2) const;
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
Data * _data;
|
||||
|
||||
DeepScanLineInputFile (InputPartData* part);
|
||||
|
||||
void initialize(const Header& header);
|
||||
void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream & is);
|
||||
void multiPartInitialize(InputPartData* part);
|
||||
|
||||
friend class InputFile;
|
||||
friend class MultiPartInputFile;
|
||||
friend void DeepScanLineOutputFile::copyPixels(DeepScanLineInputFile &);
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,149 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "ImfDeepScanLineInputPart.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
DeepScanLineInputPart::DeepScanLineInputPart(MultiPartInputFile& multiPartFile, int partNumber)
|
||||
{
|
||||
file = multiPartFile.getInputPart<DeepScanLineInputFile>(partNumber);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
DeepScanLineInputPart::fileName () const
|
||||
{
|
||||
return file->fileName();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
DeepScanLineInputPart::header () const
|
||||
{
|
||||
return file->header();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepScanLineInputPart::version () const
|
||||
{
|
||||
return file->version();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer)
|
||||
{
|
||||
file->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
|
||||
|
||||
const DeepFrameBuffer &
|
||||
DeepScanLineInputPart::frameBuffer () const
|
||||
{
|
||||
return file->frameBuffer();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DeepScanLineInputPart::isComplete () const
|
||||
{
|
||||
return file->isComplete();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::readPixels (int scanLine1, int scanLine2)
|
||||
{
|
||||
file->readPixels(scanLine1, scanLine2);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::readPixels (int scanLine)
|
||||
{
|
||||
file->readPixels(scanLine);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::rawPixelData (int firstScanLine,
|
||||
char *pixelData,
|
||||
Int64 &pixelDataSize)
|
||||
{
|
||||
file->rawPixelData(firstScanLine, pixelData, pixelDataSize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::readPixelSampleCounts(int scanline1,
|
||||
int scanline2)
|
||||
{
|
||||
file->readPixelSampleCounts(scanline1, scanline2);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::readPixelSampleCounts(int scanline)
|
||||
{
|
||||
file->readPixelSampleCounts(scanline);
|
||||
}
|
||||
|
||||
int
|
||||
DeepScanLineInputPart::firstScanLineInChunk(int y) const
|
||||
{
|
||||
return file->firstScanLineInChunk(y);
|
||||
}
|
||||
|
||||
int
|
||||
DeepScanLineInputPart::lastScanLineInChunk(int y) const
|
||||
{
|
||||
return file->lastScanLineInChunk(y);
|
||||
}
|
||||
|
||||
void
|
||||
DeepScanLineInputPart::readPixels(const char* rawPixelData, const DeepFrameBuffer& frameBuffer, int scanLine1, int scanLine2) const
|
||||
{
|
||||
return file->readPixels(rawPixelData,frameBuffer,scanLine1,scanLine2);
|
||||
}
|
||||
void
|
||||
DeepScanLineInputPart::readPixelSampleCounts(const char* rawdata, const DeepFrameBuffer& frameBuffer, int scanLine1, int scanLine2) const
|
||||
{
|
||||
return file->readPixelSampleCounts(rawdata,frameBuffer,scanLine1,scanLine2);
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
181
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineInputPart.h
Normal file
181
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineInputPart.h
Normal file
@@ -0,0 +1,181 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFDEEPSCANLINEINPUTPART_H_
|
||||
#define IMFDEEPSCANLINEINPUTPART_H_
|
||||
|
||||
#include "ImfMultiPartInputFile.h"
|
||||
#include "ImfDeepScanLineInputFile.h"
|
||||
#include "ImfDeepScanLineOutputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT DeepScanLineInputPart
|
||||
{
|
||||
public:
|
||||
|
||||
DeepScanLineInputPart(MultiPartInputFile& file, int partNumber);
|
||||
|
||||
//------------------------
|
||||
// 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 DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & 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).
|
||||
//
|
||||
// If threading is enabled, readPixels (s1, s2) tries to perform
|
||||
// decopmression of multiple scanlines in parallel.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
void readPixels (const char * rawPixelData,const DeepFrameBuffer & frameBuffer,
|
||||
int scanLine1,int scanLine2) const;
|
||||
|
||||
//----------------------------------------------
|
||||
// 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,
|
||||
char * pixelData,
|
||||
Int64 &pixelDataSize);
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Read pixel sample counts into a slice in the frame buffer.
|
||||
//
|
||||
// readPixelSampleCounts(s1, s2) reads all the counts of
|
||||
// pixel samples with y coordinates in the interval
|
||||
// [min (s1, s2), max (s1, s2)] from the file, and stores
|
||||
// them in the slice naming "sample count".
|
||||
//
|
||||
// Both s1 and s2 must be within the interval
|
||||
// [header().dataWindow().min.y, header.dataWindow().max.y]
|
||||
//
|
||||
// readPixelSampleCounts(s) calls readPixelSampleCounts(s,s).
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void readPixelSampleCounts(int scanline1,
|
||||
int scanline2);
|
||||
void readPixelSampleCounts(int scanline);
|
||||
|
||||
void readPixelSampleCounts( const char * rawdata , const DeepFrameBuffer & frameBuffer,
|
||||
int scanLine1 , int scanLine2) const;
|
||||
|
||||
int firstScanLineInChunk(int y) const;
|
||||
int lastScanLineInChunk (int y) const;
|
||||
private:
|
||||
DeepScanLineInputFile *file;
|
||||
|
||||
// needed for copyPixels
|
||||
friend void DeepScanLineOutputFile::copyPixels(DeepScanLineInputPart &);
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IMFDEEPSCANLINEINPUTPART_H_ */
|
||||
1552
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp
Normal file
1552
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp
Normal file
File diff suppressed because it is too large
Load Diff
244
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.h
Normal file
244
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.h
Normal file
@@ -0,0 +1,244 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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_DEEP_SCAN_LINE_OUTPUT_FILE_H
|
||||
#define INCLUDED_IMF_DEEP_SCAN_LINE_OUTPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DeepScanLineOutputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfHeader.h"
|
||||
#include "ImfFrameBuffer.h"
|
||||
#include "ImfThreading.h"
|
||||
#include "ImfGenericOutputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
struct PreviewRgba;
|
||||
|
||||
class IMF_EXPORT DeepScanLineOutputFile : public GenericOutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Constructor -- opens the file and writes the file header.
|
||||
// The file header is also copied into the DeepScanLineOutputFile
|
||||
// object, and can later be accessed via the header() method.
|
||||
// Destroying this DeepScanLineOutputFile object automatically closes
|
||||
// the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to write the file (see ImfThreading.h).
|
||||
//-----------------------------------------------------------
|
||||
|
||||
DeepScanLineOutputFile (const char fileName[], const Header &header,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Constructor -- attaches the new DeepScanLineOutputFile object
|
||||
// to a file that has already been opened, and writes the file header.
|
||||
// The file header is also copied into the DeepScanLineOutputFile
|
||||
// object, and can later be accessed via the header() method.
|
||||
// Destroying this DeepScanLineOutputFile object does not automatically
|
||||
// close the file.
|
||||
//
|
||||
// numThreads determines the number of threads that will be
|
||||
// used to write the file (see ImfThreading.h).
|
||||
//------------------------------------------------------------
|
||||
|
||||
DeepScanLineOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, const Header &header,
|
||||
int numThreads = globalThreadCount());
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Destroying the DeepScanLineOutputFile object
|
||||
// before writing all scan lines within the data
|
||||
// window results in an incomplete file.
|
||||
//-------------------------------------------------
|
||||
|
||||
virtual ~DeepScanLineOutputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// 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 DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & 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 (DeepScanLineInputFile &in);
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Shortcut to copy pixels from a given part of a multipart file
|
||||
// --------------------------------------------------------------
|
||||
void copyPixels (DeepScanLineInputPart &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_NAMESPACE::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[]);
|
||||
|
||||
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Constructor -- attaches the OutputStreamMutex to the
|
||||
// given one from MultiPartOutputFile. Set the previewPosition
|
||||
// and lineOffsetsPosition which have been acquired from
|
||||
// the constructor of MultiPartOutputFile as well.
|
||||
//------------------------------------------------------------
|
||||
DeepScanLineOutputFile (const OutputPartData* part);
|
||||
|
||||
DeepScanLineOutputFile (const DeepScanLineOutputFile &); // not implemented
|
||||
DeepScanLineOutputFile & operator = (const DeepScanLineOutputFile &); // not implemented
|
||||
|
||||
void initialize (const Header &header);
|
||||
void initializeLineBuffer();
|
||||
|
||||
Data * _data;
|
||||
|
||||
|
||||
|
||||
friend class MultiPartOutputFile;
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,107 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfDeepScanLineOutputPart.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
DeepScanLineOutputPart::DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber)
|
||||
{
|
||||
file = multiPartFile.getOutputPart<DeepScanLineOutputFile>(partNumber);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
DeepScanLineOutputPart::fileName () const
|
||||
{
|
||||
return file->fileName();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
DeepScanLineOutputPart::header () const
|
||||
{
|
||||
return file->header();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineOutputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer)
|
||||
{
|
||||
file->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
|
||||
|
||||
const DeepFrameBuffer &
|
||||
DeepScanLineOutputPart::frameBuffer () const
|
||||
{
|
||||
return file->frameBuffer();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineOutputPart::writePixels (int numScanLines)
|
||||
{
|
||||
file->writePixels(numScanLines);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepScanLineOutputPart::currentScanLine () const
|
||||
{
|
||||
return file->currentScanLine();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepScanLineOutputPart::copyPixels (DeepScanLineInputFile &in)
|
||||
{
|
||||
file->copyPixels(in);
|
||||
}
|
||||
|
||||
void
|
||||
DeepScanLineOutputPart::copyPixels (DeepScanLineInputPart &in)
|
||||
{
|
||||
file->copyPixels(in);
|
||||
}
|
||||
|
||||
void
|
||||
DeepScanLineOutputPart::updatePreviewImage (const PreviewRgba newPixels[])
|
||||
{
|
||||
file->updatePreviewImage(newPixels);
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
|
||||
168
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineOutputPart.h
Normal file
168
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepScanLineOutputPart.h
Normal file
@@ -0,0 +1,168 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFDEEPSCANLINEOUTPUTPART_H_
|
||||
#define IMFDEEPSCANLINEOUTPUTPART_H_
|
||||
|
||||
#include "ImfDeepScanLineOutputFile.h"
|
||||
#include "ImfMultiPartOutputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT DeepScanLineOutputPart
|
||||
{
|
||||
public:
|
||||
|
||||
DeepScanLineOutputPart(MultiPartOutputFile& multiPartFile, int partNumber);
|
||||
|
||||
//------------------------
|
||||
// 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 DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & 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 (DeepScanLineInputFile &in);
|
||||
void copyPixels (DeepScanLineInputPart &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_NAMESPACE::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[]);
|
||||
|
||||
private:
|
||||
DeepScanLineOutputFile* file;
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IMFDEEPSCANLINEOUTPUTPART_H_ */
|
||||
1979
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp
Normal file
1979
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp
Normal file
File diff suppressed because it is too large
Load Diff
437
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputFile.h
Normal file
437
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputFile.h
Normal file
@@ -0,0 +1,437 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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_DEEP_TILED_INPUT_FILE_H
|
||||
#define INCLUDED_IMF_DEEP_TILED_INPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DeepTiledInputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfHeader.h"
|
||||
#include "ImfFrameBuffer.h"
|
||||
#include "ImathBox.h"
|
||||
#include "ImfTileDescription.h"
|
||||
#include "ImfThreading.h"
|
||||
#include "ImfGenericInputFile.h"
|
||||
#include "ImfDeepFrameBuffer.h"
|
||||
#include "ImfDeepTiledOutputFile.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT DeepTiledInputFile : public GenericInputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// A constructor that opens the file with the specified name, and
|
||||
// reads the file header. The constructor throws an IEX_NAMESPACE::ArgExc
|
||||
// exception if the file is not tiled.
|
||||
// The numThreads parameter specifies how many worker threads this
|
||||
// file will try to keep busy when decompressing individual tiles.
|
||||
// Destroying TiledInputFile objects constructed with this constructor
|
||||
// automatically closes the corresponding files.
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
DeepTiledInputFile (const char fileName[],
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// A constructor that attaches the new TiledInputFile object
|
||||
// to a file that has already been opened.
|
||||
// Destroying TiledInputFile objects constructed with this
|
||||
// constructor does not automatically close the corresponding
|
||||
// files.
|
||||
// ----------------------------------------------------------
|
||||
|
||||
DeepTiledInputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-----------
|
||||
// Destructor
|
||||
//-----------
|
||||
|
||||
virtual ~DeepTiledInputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// 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 TiledInputFile 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 readTile() is called.
|
||||
// The current frame buffer can be changed after each call
|
||||
// to readTile().
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Check if the file is complete:
|
||||
//
|
||||
// isComplete() returns true if all pixels in the data window
|
||||
// (in all levels) 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;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Utility functions:
|
||||
//--------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Multiresolution mode and tile size:
|
||||
// The following functions return the xSize, ySize and mode
|
||||
// fields of the file header's TileDescriptionAttribute.
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Number of levels:
|
||||
//
|
||||
// numXLevels() returns the file's number of levels in x direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL:
|
||||
// return value is: 1
|
||||
//
|
||||
// if levelMode() == MIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (w) / log (2)) + 1
|
||||
//
|
||||
// where
|
||||
// w is the width of the image's data window, max.x - min.x + 1,
|
||||
// y is the height of the image's data window, max.y - min.y + 1,
|
||||
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||
//
|
||||
// numYLevels() returns the file's number of levels in y direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (h) / log (2)) + 1
|
||||
//
|
||||
//
|
||||
// numLevels() is a convenience function for use with
|
||||
// MIPMAP_LEVELS files.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||
//
|
||||
// isValidLevel(lx, ly) returns true if the file contains
|
||||
// a level with level number (lx, ly), false if not.
|
||||
//
|
||||
// totalTiles() returns the total number of tiles in the image
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
size_t totalTiles() const;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Dimensions of a level:
|
||||
//
|
||||
// levelWidth(lx) returns the width of a level with level
|
||||
// number (lx, *), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (w / pow (2, lx)))
|
||||
//
|
||||
//
|
||||
// levelHeight(ly) returns the height of a level with level
|
||||
// number (*, ly), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (h / pow (2, ly)))
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Number of tiles:
|
||||
//
|
||||
// numXTiles(lx) returns the number of tiles in x direction
|
||||
// that cover a level with level number (lx, *), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//
|
||||
// numYTiles(ly) returns the number of tiles in y direction
|
||||
// that cover a level with level number (*, ly), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Level pixel ranges:
|
||||
//
|
||||
// dataWindowForLevel(lx, ly) returns a 2-dimensional region of
|
||||
// valid pixel coordinates for a level with level number (lx, ly)
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x, dataWindow.min.y)
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||
//
|
||||
// dataWindowForLevel(level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForLevel(level, level).
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const;
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tile pixel ranges:
|
||||
//
|
||||
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a tile with tile coordinates
|
||||
// (dx,dy) and level number (lx, ly).
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x + dx * tileXSize(),
|
||||
// dataWindow.min.y + dy * tileYSize())
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||
//
|
||||
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForTile(dx, dy, level, level).
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, int l = 0) const;
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Read pixel data:
|
||||
//
|
||||
// readTile(dx, dy, lx, ly) reads the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly),
|
||||
// and stores it in the current frame buffer.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// readTile(dx, dy, level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It calls
|
||||
// readTile(dx, dy, level, level).
|
||||
//
|
||||
// The two readTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// reading multiple tiles at once. If multi-threading is used
|
||||
// the multiple tiles are read concurrently.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the
|
||||
// tile's level, are never accessed by readTile().
|
||||
//
|
||||
// Attempting to access a tile that is not present in the file
|
||||
// throws an InputExc exception.
|
||||
//
|
||||
//------------------------------------------------------------
|
||||
|
||||
void readTile (int dx, int dy, int l = 0);
|
||||
void readTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// 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,
|
||||
char *pixelData,
|
||||
Int64 &dataSize) const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Read pixel sample counts into a slice in the frame buffer.
|
||||
//
|
||||
// readPixelSampleCount(dx, dy, lx, ly) reads the sample counts
|
||||
// for tile (dx, dy) in level (lx, ly).
|
||||
//
|
||||
// readPixelSampleCount(dx, dy, l) calls
|
||||
// readPixelSampleCount(dx, dy, lx = l, ly = l)
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx, ly) reads all
|
||||
// the sample counts for tiles within range
|
||||
// [(min(dx1, dx2), min(dy1, dy2))...(max(dx1, dx2), max(dy1, dy2)],
|
||||
// and on level (lx, ly)
|
||||
//
|
||||
// readPixelSampleCounts(dx1, dx2, dy1, dy2, l) calls
|
||||
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx = l, ly = l).
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void readPixelSampleCount (int dx, int dy, int l = 0);
|
||||
void readPixelSampleCount (int dx, int dy, int lx, int ly);
|
||||
|
||||
void readPixelSampleCounts (int dx1, int dx2,
|
||||
int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void readPixelSampleCounts (int dx1, int dx2,
|
||||
int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
struct Data;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
friend class InputFile;
|
||||
friend class MultiPartInputFile;
|
||||
|
||||
DeepTiledInputFile (InputPartData* part);
|
||||
|
||||
DeepTiledInputFile (const DeepTiledInputFile &); // not implemented
|
||||
DeepTiledInputFile & operator = (const DeepTiledInputFile &); // not implemented
|
||||
|
||||
DeepTiledInputFile (const Header &header, OPENEXR_IMF_INTERNAL_NAMESPACE::IStream *is, int version,
|
||||
int numThreads);
|
||||
|
||||
void initialize ();
|
||||
void multiPartInitialize(InputPartData* part);
|
||||
void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is);
|
||||
|
||||
bool isValidTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
size_t bytesPerLineForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
|
||||
void getTileOrder(int dx[],int dy[],int lx[],int ly[]) const;
|
||||
|
||||
|
||||
Data * _data;
|
||||
|
||||
|
||||
// needed for copyPixels
|
||||
friend void DeepTiledOutputFile::copyPixels(DeepTiledInputFile &);
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
273
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputPart.cpp
Normal file
273
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputPart.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfDeepTiledInputPart.h"
|
||||
#include "ImfMultiPartInputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
DeepTiledInputPart::DeepTiledInputPart(MultiPartInputFile& multiPartFile, int partNumber)
|
||||
{
|
||||
file = multiPartFile.getInputPart<DeepTiledInputFile>(partNumber);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
DeepTiledInputPart::fileName () const
|
||||
{
|
||||
return file->fileName();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
DeepTiledInputPart::header () const
|
||||
{
|
||||
return file->header();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::version () const
|
||||
{
|
||||
return file->version();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer)
|
||||
{
|
||||
file->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
|
||||
|
||||
const DeepFrameBuffer &
|
||||
DeepTiledInputPart::frameBuffer () const
|
||||
{
|
||||
return file->frameBuffer();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DeepTiledInputPart::isComplete () const
|
||||
{
|
||||
return file->isComplete();
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
DeepTiledInputPart::tileXSize () const
|
||||
{
|
||||
return file->tileXSize();
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
DeepTiledInputPart::tileYSize () const
|
||||
{
|
||||
return file->tileYSize();
|
||||
}
|
||||
|
||||
|
||||
LevelMode
|
||||
DeepTiledInputPart::levelMode () const
|
||||
{
|
||||
return file->levelMode();
|
||||
}
|
||||
|
||||
|
||||
LevelRoundingMode
|
||||
DeepTiledInputPart::levelRoundingMode () const
|
||||
{
|
||||
return file->levelRoundingMode();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::numLevels () const
|
||||
{
|
||||
return file->numLevels();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::numXLevels () const
|
||||
{
|
||||
return file->numXLevels();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::numYLevels () const
|
||||
{
|
||||
return file->numYLevels();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DeepTiledInputPart::isValidLevel (int lx, int ly) const
|
||||
{
|
||||
return file->isValidLevel(lx, ly);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::levelWidth (int lx) const
|
||||
{
|
||||
return file->levelWidth(lx);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::levelHeight (int ly) const
|
||||
{
|
||||
return file->levelHeight(ly);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::numXTiles (int lx) const
|
||||
{
|
||||
return file->numXTiles(lx);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledInputPart::numYTiles (int ly) const
|
||||
{
|
||||
return file->numYTiles(ly);
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledInputPart::dataWindowForLevel (int l) const
|
||||
{
|
||||
return file->dataWindowForLevel(l);
|
||||
}
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledInputPart::dataWindowForLevel (int lx, int ly) const
|
||||
{
|
||||
return file->dataWindowForLevel(lx, ly);
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledInputPart::dataWindowForTile (int dx, int dy, int l) const
|
||||
{
|
||||
return file->dataWindowForTile(dx, dy, l);
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledInputPart::dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const
|
||||
{
|
||||
return file->dataWindowForTile(dx, dy, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readTile (int dx, int dy, int l)
|
||||
{
|
||||
file->readTile(dx, dy, l);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readTile (int dx, int dy, int lx, int ly)
|
||||
{
|
||||
file->readTile(dx, dy, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly)
|
||||
{
|
||||
file->readTiles(dx1, dx2, dy1, dy2, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l)
|
||||
{
|
||||
file->readTiles(dx1, dx2, dy1, dy2, l);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::rawTileData (int &dx, int &dy,
|
||||
int &lx, int &ly,
|
||||
char * pixelData,
|
||||
Int64 & dataSize) const
|
||||
{
|
||||
file->rawTileData(dx, dy, lx, ly, pixelData, dataSize );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readPixelSampleCount (int dx, int dy, int l)
|
||||
{
|
||||
file->readPixelSampleCount(dx, dy, l);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readPixelSampleCount (int dx, int dy, int lx, int ly)
|
||||
{
|
||||
file->readPixelSampleCount(dx, dy, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readPixelSampleCounts (int dx1, int dx2,
|
||||
int dy1, int dy2,
|
||||
int lx, int ly)
|
||||
{
|
||||
file->readPixelSampleCounts(dx1, dx2, dy1, dy2, lx, ly);
|
||||
}
|
||||
|
||||
void
|
||||
DeepTiledInputPart::readPixelSampleCounts (int dx1, int dx2,
|
||||
int dy1, int dy2,
|
||||
int l)
|
||||
{
|
||||
file->readPixelSampleCounts(dx1, dx2, dy1, dy2, l);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
362
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputPart.h
Normal file
362
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledInputPart.h
Normal file
@@ -0,0 +1,362 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFDEEPTILEDINPUTPART_H_
|
||||
#define IMFDEEPTILEDINPUTPART_H_
|
||||
|
||||
#include "ImfDeepTiledInputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT DeepTiledInputPart
|
||||
{
|
||||
public:
|
||||
|
||||
DeepTiledInputPart(MultiPartInputFile& multiPartFile, int partNumber);
|
||||
|
||||
//------------------------
|
||||
// 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 TiledInputFile 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 readTile() is called.
|
||||
// The current frame buffer can be changed after each call
|
||||
// to readTile().
|
||||
//-----------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Check if the file is complete:
|
||||
//
|
||||
// isComplete() returns true if all pixels in the data window
|
||||
// (in all levels) 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;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Utility functions:
|
||||
//--------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Multiresolution mode and tile size:
|
||||
// The following functions return the xSize, ySize and mode
|
||||
// fields of the file header's TileDescriptionAttribute.
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Number of levels:
|
||||
//
|
||||
// numXLevels() returns the file's number of levels in x direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL:
|
||||
// return value is: 1
|
||||
//
|
||||
// if levelMode() == MIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (w) / log (2)) + 1
|
||||
//
|
||||
// where
|
||||
// w is the width of the image's data window, max.x - min.x + 1,
|
||||
// y is the height of the image's data window, max.y - min.y + 1,
|
||||
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||
//
|
||||
// numYLevels() returns the file's number of levels in y direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (h) / log (2)) + 1
|
||||
//
|
||||
//
|
||||
// numLevels() is a convenience function for use with
|
||||
// MIPMAP_LEVELS files.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||
//
|
||||
// isValidLevel(lx, ly) returns true if the file contains
|
||||
// a level with level number (lx, ly), false if not.
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Dimensions of a level:
|
||||
//
|
||||
// levelWidth(lx) returns the width of a level with level
|
||||
// number (lx, *), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (w / pow (2, lx)))
|
||||
//
|
||||
//
|
||||
// levelHeight(ly) returns the height of a level with level
|
||||
// number (*, ly), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (h / pow (2, ly)))
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Number of tiles:
|
||||
//
|
||||
// numXTiles(lx) returns the number of tiles in x direction
|
||||
// that cover a level with level number (lx, *), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//
|
||||
// numYTiles(ly) returns the number of tiles in y direction
|
||||
// that cover a level with level number (*, ly), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Level pixel ranges:
|
||||
//
|
||||
// dataWindowForLevel(lx, ly) returns a 2-dimensional region of
|
||||
// valid pixel coordinates for a level with level number (lx, ly)
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x, dataWindow.min.y)
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||
//
|
||||
// dataWindowForLevel(level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForLevel(level, level).
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const;
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tile pixel ranges:
|
||||
//
|
||||
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a tile with tile coordinates
|
||||
// (dx,dy) and level number (lx, ly).
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x + dx * tileXSize(),
|
||||
// dataWindow.min.y + dy * tileYSize())
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||
//
|
||||
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForTile(dx, dy, level, level).
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy, int l = 0) const;
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------
|
||||
// Read pixel data:
|
||||
//
|
||||
// readTile(dx, dy, lx, ly) reads the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly),
|
||||
// and stores it in the current frame buffer.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// readTile(dx, dy, level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It calls
|
||||
// readTile(dx, dy, level, level).
|
||||
//
|
||||
// The two readTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// reading multiple tiles at once. If multi-threading is used
|
||||
// the multiple tiles are read concurrently.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the
|
||||
// tile's level, are never accessed by readTile().
|
||||
//
|
||||
// Attempting to access a tile that is not present in the file
|
||||
// throws an InputExc exception.
|
||||
//
|
||||
//------------------------------------------------------------
|
||||
|
||||
void readTile (int dx, int dy, int l = 0);
|
||||
void readTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void readTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// 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,
|
||||
char *data,
|
||||
Int64 &dataSize
|
||||
) const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Read pixel sample counts into a slice in the frame buffer.
|
||||
//
|
||||
// readPixelSampleCount(dx, dy, lx, ly) reads the sample counts
|
||||
// for tile (dx, dy) in level (lx, ly).
|
||||
//
|
||||
// readPixelSampleCount(dx, dy, l) calls
|
||||
// readPixelSampleCount(dx, dy, lx = l, ly = l)
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx)-1]
|
||||
// dy must lie in the interval [0, numYTiles(ly)-1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels()-1]
|
||||
// ly must lie in the inverval [0, numYLevels()-1]
|
||||
//
|
||||
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx, ly) reads all
|
||||
// the sample counts for tiles within range
|
||||
// [(min(dx1, dx2), min(dy1, dy2))...(max(dx1, dx2), max(dy1, dy2)],
|
||||
// and on level (lx, ly)
|
||||
//
|
||||
// readPixelSampleCounts(dx1, dx2, dy1, dy2, l) calls
|
||||
// readPixelSampleCounts(dx1, dx2, dy1, dy2, lx = l, ly = l).
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void readPixelSampleCount (int dx, int dy, int l = 0);
|
||||
void readPixelSampleCount (int dx, int dy, int lx, int ly);
|
||||
|
||||
void readPixelSampleCounts (int dx1, int dx2,
|
||||
int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void readPixelSampleCounts (int dx1, int dx2,
|
||||
int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
private:
|
||||
DeepTiledInputFile* file;
|
||||
|
||||
friend void DeepTiledOutputFile::copyPixels(DeepTiledInputPart &);
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif /* IMFDEEPTILEDINPUTPART_H_ */
|
||||
2055
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp
Normal file
2055
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp
Normal file
File diff suppressed because it is too large
Load Diff
475
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputFile.h
Normal file
475
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputFile.h
Normal file
@@ -0,0 +1,475 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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_DEEP_TILED_OUTPUT_FILE_H
|
||||
#define INCLUDED_IMF_DEEP_TILED_OUTPUT_FILE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class DeepTiledOutputFile
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfHeader.h"
|
||||
#include "ImfFrameBuffer.h"
|
||||
#include "ImathBox.h"
|
||||
#include "ImfThreading.h"
|
||||
#include "ImfGenericOutputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT DeepTiledOutputFile : public GenericOutputFile
|
||||
{
|
||||
public:
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// A constructor that opens the file with the specified name, and
|
||||
// writes the file header. The file header is also copied into the
|
||||
// TiledOutputFile object, and can later be accessed via the header()
|
||||
// method.
|
||||
//
|
||||
// Destroying TiledOutputFile constructed with this constructor
|
||||
// automatically closes the corresponding files.
|
||||
//
|
||||
// The header must contain a TileDescriptionAttribute called "tiles".
|
||||
//
|
||||
// The x and y subsampling factors for all image channels must be 1;
|
||||
// subsampling is not supported.
|
||||
//
|
||||
// Tiles can be written to the file in arbitrary order. The line
|
||||
// order attribute can be used to cause the tiles to be sorted in
|
||||
// the file. When the file is read later, reading the tiles in the
|
||||
// same order as they are in the file tends to be significantly
|
||||
// faster than reading the tiles in random order (see writeTile,
|
||||
// below).
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
DeepTiledOutputFile (const char fileName[],
|
||||
const Header &header,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// A constructor that attaches the new TiledOutputFile object to
|
||||
// a file that has already been opened. Destroying TiledOutputFile
|
||||
// objects constructed with this constructor does not automatically
|
||||
// close the corresponding files.
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
DeepTiledOutputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
|
||||
const Header &header,
|
||||
int numThreads = globalThreadCount ());
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Destroying a TiledOutputFile object before all tiles
|
||||
// have been written results in an incomplete file.
|
||||
//-----------------------------------------------------
|
||||
|
||||
virtual ~DeepTiledOutputFile ();
|
||||
|
||||
|
||||
//------------------------
|
||||
// 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 TiledOutputFile 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 writeTile() is
|
||||
// called. The current frame buffer can be changed
|
||||
// after each call to writeTile().
|
||||
//-------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//-------------------
|
||||
// Utility functions:
|
||||
//-------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Multiresolution mode and tile size:
|
||||
// The following functions return the xSize, ySize and mode
|
||||
// fields of the file header's TileDescriptionAttribute.
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Number of levels:
|
||||
//
|
||||
// numXLevels() returns the file's number of levels in x direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL:
|
||||
// return value is: 1
|
||||
//
|
||||
// if levelMode() == MIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (w) / log (2)) + 1
|
||||
//
|
||||
// where
|
||||
// w is the width of the image's data window, max.x - min.x + 1,
|
||||
// y is the height of the image's data window, max.y - min.y + 1,
|
||||
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||
//
|
||||
// numYLevels() returns the file's number of levels in y direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (h) / log (2)) + 1
|
||||
//
|
||||
//
|
||||
// numLevels() is a convenience function for use with MIPMAP_LEVELS
|
||||
// files.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||
//
|
||||
// isValidLevel(lx, ly) returns true if the file contains
|
||||
// a level with level number (lx, ly), false if not.
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Dimensions of a level:
|
||||
//
|
||||
// levelWidth(lx) returns the width of a level with level
|
||||
// number (lx, *), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (w / pow (2, lx)))
|
||||
//
|
||||
//
|
||||
// levelHeight(ly) returns the height of a level with level
|
||||
// number (*, ly), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (h / pow (2, ly)))
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Number of tiles:
|
||||
//
|
||||
// numXTiles(lx) returns the number of tiles in x direction
|
||||
// that cover a level with level number (lx, *), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//
|
||||
// numYTiles(ly) returns the number of tiles in y direction
|
||||
// that cover a level with level number (*, ly), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Level pixel ranges:
|
||||
//
|
||||
// dataWindowForLevel(lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a level with
|
||||
// level number (lx, ly)
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x, dataWindow.min.y)
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||
//
|
||||
// dataWindowForLevel(level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForLevel(level, level).
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const;
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tile pixel ranges:
|
||||
//
|
||||
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a tile with tile coordinates
|
||||
// (dx,dy) and level number (lx, ly).
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x + dx * tileXSize(),
|
||||
// dataWindow.min.y + dy * tileYSize())
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||
//
|
||||
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForTile(dx, dy, level, level).
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy,
|
||||
int l = 0) const;
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Write pixel data:
|
||||
//
|
||||
// writeTile(dx, dy, lx, ly) writes the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly) to
|
||||
// the file.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx) - 1]
|
||||
// dy must lie in the interval [0, numYTiles(ly) - 1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels() - 1]
|
||||
// ly must lie in the inverval [0, numYLevels() - 1]
|
||||
//
|
||||
// writeTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVEL files. It calls
|
||||
// writeTile(dx, dy, level, level).
|
||||
//
|
||||
// The two writeTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// writing multiple tiles at once. If multi-threading is used
|
||||
// multiple tiles are written concurrently. The tile coordinates,
|
||||
// dx1, dx2 and dy1, dy2, specify inclusive ranges of tile
|
||||
// coordinates. It is valid for dx1 < dx2 or dy1 < dy2; the
|
||||
// tiles are always written in the order specified by the line
|
||||
// order attribute. Hence, it is not possible to specify an
|
||||
// "invalid" or empty tile range.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the tile's
|
||||
// level, are never accessed by writeTile().
|
||||
//
|
||||
// Each tile in the file must be written exactly once.
|
||||
//
|
||||
// The file's line order attribute determines the order of the tiles
|
||||
// in the file:
|
||||
//
|
||||
// INCREASING_Y In the file, the tiles for each level are stored
|
||||
// in a contiguous block. The levels are ordered
|
||||
// like this:
|
||||
//
|
||||
// (0, 0) (1, 0) ... (nx-1, 0)
|
||||
// (0, 1) (1, 1) ... (nx-1, 1)
|
||||
// ...
|
||||
// (0,ny-1) (1,ny-1) ... (nx-1,ny-1)
|
||||
//
|
||||
// where nx = numXLevels(), and ny = numYLevels().
|
||||
// In an individual level, (lx, ly), the tiles
|
||||
// are stored in the following order:
|
||||
//
|
||||
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||
// ...
|
||||
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||
//
|
||||
// where tx = numXTiles(lx),
|
||||
// and ty = numYTiles(ly).
|
||||
//
|
||||
// DECREASING_Y As for INCREASING_Y, the tiles for each level
|
||||
// are stored in a contiguous block. The levels
|
||||
// are ordered the same way as for INCREASING_Y,
|
||||
// but within an individual level, the tiles
|
||||
// are stored in this order:
|
||||
//
|
||||
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||
// ...
|
||||
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||
//
|
||||
//
|
||||
// RANDOM_Y The order of the calls to writeTile() determines
|
||||
// the order of the tiles in the file.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void writeTile (int dx, int dy, int l = 0);
|
||||
void writeTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Shortcut to copy all pixels from a TiledInputFile into this file,
|
||||
// without uncompressing and then recompressing the pixel data.
|
||||
// This file's header must be compatible with the TiledInputFile's
|
||||
// header: The two header's "dataWindow", "compression",
|
||||
// "lineOrder", "channels", and "tiles" attributes must be the same.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void copyPixels (DeepTiledInputFile &in);
|
||||
void copyPixels (DeepTiledInputPart &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_NAMESPACE::LogicExc.
|
||||
//
|
||||
// Note: updatePreviewImage() is necessary because images are
|
||||
// often stored in a file incrementally, a few tiles 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 tile of the main image.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba newPixels[]);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Break a tile -- for testing and debugging only:
|
||||
//
|
||||
// breakTile(dx,dy,lx,ly,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 tile with tile coordinates
|
||||
// (dx, dy) and level number (lx, ly).
|
||||
//
|
||||
// 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 breakTile (int dx, int dy,
|
||||
int lx, int ly,
|
||||
int offset,
|
||||
int length,
|
||||
char c);
|
||||
struct Data;
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// A constructor attaches the OutputStreamMutex to the
|
||||
// given one from MultiPartOutputFile. Set the previewPosition
|
||||
// and lineOffsetsPosition which have been acquired from
|
||||
// the constructor of MultiPartOutputFile as well.
|
||||
// ----------------------------------------------------------------
|
||||
DeepTiledOutputFile (const OutputPartData* part);
|
||||
|
||||
DeepTiledOutputFile (const DeepTiledOutputFile &); // not implemented
|
||||
DeepTiledOutputFile & operator = (const DeepTiledOutputFile &); // not implemented
|
||||
|
||||
void initialize (const Header &header);
|
||||
|
||||
bool isValidTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
size_t bytesPerLineForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
Data * _data;
|
||||
|
||||
|
||||
friend class MultiPartOutputFile;
|
||||
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
250
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputPart.cpp
Normal file
250
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputPart.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfDeepTiledOutputPart.h"
|
||||
#include "ImfMultiPartOutputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
DeepTiledOutputPart::DeepTiledOutputPart(MultiPartOutputFile& multiPartFile, int partNumber)
|
||||
{
|
||||
file = multiPartFile.getOutputPart<DeepTiledOutputFile>(partNumber);
|
||||
}
|
||||
|
||||
const char *
|
||||
DeepTiledOutputPart::fileName () const
|
||||
{
|
||||
return file->fileName();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
DeepTiledOutputPart::header () const
|
||||
{
|
||||
return file->header();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::setFrameBuffer (const DeepFrameBuffer &frameBuffer)
|
||||
{
|
||||
file->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
|
||||
|
||||
const DeepFrameBuffer &
|
||||
DeepTiledOutputPart::frameBuffer () const
|
||||
{
|
||||
return file->frameBuffer();
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
DeepTiledOutputPart::tileXSize () const
|
||||
{
|
||||
return file->tileXSize();
|
||||
}
|
||||
|
||||
|
||||
unsigned int
|
||||
DeepTiledOutputPart::tileYSize () const
|
||||
{
|
||||
return file->tileYSize();
|
||||
}
|
||||
|
||||
|
||||
LevelMode
|
||||
DeepTiledOutputPart::levelMode () const
|
||||
{
|
||||
return file->levelMode();
|
||||
}
|
||||
|
||||
|
||||
LevelRoundingMode
|
||||
DeepTiledOutputPart::levelRoundingMode () const
|
||||
{
|
||||
return file->levelRoundingMode();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::numLevels () const
|
||||
{
|
||||
return file->numLevels();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::numXLevels () const
|
||||
{
|
||||
return file->numXLevels();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::numYLevels () const
|
||||
{
|
||||
return file->numYLevels();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
DeepTiledOutputPart::isValidLevel (int lx, int ly) const
|
||||
{
|
||||
return file->isValidLevel(lx, ly);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::levelWidth (int lx) const
|
||||
{
|
||||
return file->levelWidth(lx);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::levelHeight (int ly) const
|
||||
{
|
||||
return file->levelHeight(ly);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::numXTiles (int lx) const
|
||||
{
|
||||
return file->numXTiles(lx);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
DeepTiledOutputPart::numYTiles (int ly) const
|
||||
{
|
||||
return file->numYTiles(ly);
|
||||
}
|
||||
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledOutputPart::dataWindowForLevel (int l) const
|
||||
{
|
||||
return file->dataWindowForLevel(l);
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledOutputPart::dataWindowForLevel (int lx, int ly) const
|
||||
{
|
||||
return file->dataWindowForLevel(lx, ly);
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledOutputPart::dataWindowForTile (int dx, int dy,
|
||||
int l) const
|
||||
{
|
||||
return file->dataWindowForTile(dx, dy, l);
|
||||
}
|
||||
|
||||
|
||||
IMATH_NAMESPACE::Box2i
|
||||
DeepTiledOutputPart::dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const
|
||||
{
|
||||
return file->dataWindowForTile(dx, dy, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::writeTile (int dx, int dy, int l)
|
||||
{
|
||||
file->writeTile(dx, dy, l);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::writeTile (int dx, int dy, int lx, int ly)
|
||||
{
|
||||
file->writeTile(dx, dy, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly)
|
||||
{
|
||||
file->writeTiles(dx1, dx2, dy1, dy2, lx, ly);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l)
|
||||
{
|
||||
file->writeTiles(dx1, dx2, dy1, dy2, l);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::copyPixels (DeepTiledInputFile &in)
|
||||
{
|
||||
file->copyPixels(in);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::copyPixels (DeepTiledInputPart &in)
|
||||
{
|
||||
file->copyPixels(in);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::updatePreviewImage (const PreviewRgba newPixels[])
|
||||
{
|
||||
file->updatePreviewImage(newPixels);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeepTiledOutputPart::breakTile (int dx, int dy,
|
||||
int lx, int ly,
|
||||
int offset,
|
||||
int length,
|
||||
char c)
|
||||
{
|
||||
file->breakTile(dx, dy, lx, ly, offset, length, c);
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
394
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputPart.h
Normal file
394
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDeepTiledOutputPart.h
Normal file
@@ -0,0 +1,394 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFDEEPTILEDOUTPUTPART_H_
|
||||
#define IMFDEEPTILEDOUTPUTPART_H_
|
||||
|
||||
#include "ImfForward.h"
|
||||
#include "ImfDeepTiledInputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT DeepTiledOutputPart
|
||||
{
|
||||
public:
|
||||
|
||||
DeepTiledOutputPart(MultiPartOutputFile& multiPartFile, int partNumber);
|
||||
|
||||
//------------------------
|
||||
// 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 TiledOutputFile 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 writeTile() is
|
||||
// called. The current frame buffer can be changed
|
||||
// after each call to writeTile().
|
||||
//-------------------------------------------------------
|
||||
|
||||
void setFrameBuffer (const DeepFrameBuffer &frameBuffer);
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// Access to the current frame buffer
|
||||
//-----------------------------------
|
||||
|
||||
const DeepFrameBuffer & frameBuffer () const;
|
||||
|
||||
|
||||
//-------------------
|
||||
// Utility functions:
|
||||
//-------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Multiresolution mode and tile size:
|
||||
// The following functions return the xSize, ySize and mode
|
||||
// fields of the file header's TileDescriptionAttribute.
|
||||
//---------------------------------------------------------
|
||||
|
||||
unsigned int tileXSize () const;
|
||||
unsigned int tileYSize () const;
|
||||
LevelMode levelMode () const;
|
||||
LevelRoundingMode levelRoundingMode () const;
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Number of levels:
|
||||
//
|
||||
// numXLevels() returns the file's number of levels in x direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL:
|
||||
// return value is: 1
|
||||
//
|
||||
// if levelMode() == MIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (max (w, h)) / log (2)) + 1
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (w) / log (2)) + 1
|
||||
//
|
||||
// where
|
||||
// w is the width of the image's data window, max.x - min.x + 1,
|
||||
// y is the height of the image's data window, max.y - min.y + 1,
|
||||
// and rfunc(x) is either floor(x), or ceil(x), depending on
|
||||
// whether levelRoundingMode() returns ROUND_DOWN or ROUND_UP.
|
||||
//
|
||||
// numYLevels() returns the file's number of levels in y direction.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// return value is: rfunc (log (h) / log (2)) + 1
|
||||
//
|
||||
//
|
||||
// numLevels() is a convenience function for use with MIPMAP_LEVELS
|
||||
// files.
|
||||
//
|
||||
// if levelMode() == ONE_LEVEL or levelMode() == MIPMAP_LEVELS:
|
||||
// return value is the same as for numXLevels()
|
||||
//
|
||||
// if levelMode() == RIPMAP_LEVELS:
|
||||
// an IEX_NAMESPACE::LogicExc exception is thrown
|
||||
//
|
||||
// isValidLevel(lx, ly) returns true if the file contains
|
||||
// a level with level number (lx, ly), false if not.
|
||||
//
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
int numLevels () const;
|
||||
int numXLevels () const;
|
||||
int numYLevels () const;
|
||||
bool isValidLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Dimensions of a level:
|
||||
//
|
||||
// levelWidth(lx) returns the width of a level with level
|
||||
// number (lx, *), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (w / pow (2, lx)))
|
||||
//
|
||||
//
|
||||
// levelHeight(ly) returns the height of a level with level
|
||||
// number (*, ly), where * is any number.
|
||||
//
|
||||
// return value is:
|
||||
// max (1, rfunc (h / pow (2, ly)))
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
int levelWidth (int lx) const;
|
||||
int levelHeight (int ly) const;
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Number of tiles:
|
||||
//
|
||||
// numXTiles(lx) returns the number of tiles in x direction
|
||||
// that cover a level with level number (lx, *), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelWidth(lx) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//
|
||||
// numYTiles(ly) returns the number of tiles in y direction
|
||||
// that cover a level with level number (*, ly), where * is
|
||||
// any number.
|
||||
//
|
||||
// return value is:
|
||||
// (levelHeight(ly) + tileXSize() - 1) / tileXSize()
|
||||
//
|
||||
//----------------------------------------------------------
|
||||
|
||||
int numXTiles (int lx = 0) const;
|
||||
int numYTiles (int ly = 0) const;
|
||||
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Level pixel ranges:
|
||||
//
|
||||
// dataWindowForLevel(lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a level with
|
||||
// level number (lx, ly)
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x, dataWindow.min.y)
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + levelWidth(lx) - 1,
|
||||
// dataWindow.min.y + levelHeight(ly) - 1)
|
||||
//
|
||||
// dataWindowForLevel(level) is a convenience function used
|
||||
// for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForLevel(level, level).
|
||||
//
|
||||
//---------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int l = 0) const;
|
||||
IMATH_NAMESPACE::Box2i dataWindowForLevel (int lx, int ly) const;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Tile pixel ranges:
|
||||
//
|
||||
// dataWindowForTile(dx, dy, lx, ly) returns a 2-dimensional
|
||||
// region of valid pixel coordinates for a tile with tile coordinates
|
||||
// (dx,dy) and level number (lx, ly).
|
||||
//
|
||||
// return value is a Box2i with min value:
|
||||
// (dataWindow.min.x + dx * tileXSize(),
|
||||
// dataWindow.min.y + dy * tileYSize())
|
||||
//
|
||||
// and max value:
|
||||
// (dataWindow.min.x + (dx + 1) * tileXSize() - 1,
|
||||
// dataWindow.min.y + (dy + 1) * tileYSize() - 1)
|
||||
//
|
||||
// dataWindowForTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVELS files. It returns
|
||||
// dataWindowForTile(dx, dy, level, level).
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy,
|
||||
int l = 0) const;
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindowForTile (int dx, int dy,
|
||||
int lx, int ly) const;
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Write pixel data:
|
||||
//
|
||||
// writeTile(dx, dy, lx, ly) writes the tile with tile
|
||||
// coordinates (dx, dy), and level number (lx, ly) to
|
||||
// the file.
|
||||
//
|
||||
// dx must lie in the interval [0, numXTiles(lx) - 1]
|
||||
// dy must lie in the interval [0, numYTiles(ly) - 1]
|
||||
//
|
||||
// lx must lie in the interval [0, numXLevels() - 1]
|
||||
// ly must lie in the inverval [0, numYLevels() - 1]
|
||||
//
|
||||
// writeTile(dx, dy, level) is a convenience function
|
||||
// used for ONE_LEVEL and MIPMAP_LEVEL files. It calls
|
||||
// writeTile(dx, dy, level, level).
|
||||
//
|
||||
// The two writeTiles(dx1, dx2, dy1, dy2, ...) functions allow
|
||||
// writing multiple tiles at once. If multi-threading is used
|
||||
// multiple tiles are written concurrently. The tile coordinates,
|
||||
// dx1, dx2 and dy1, dy2, specify inclusive ranges of tile
|
||||
// coordinates. It is valid for dx1 < dx2 or dy1 < dy2; the
|
||||
// tiles are always written in the order specified by the line
|
||||
// order attribute. Hence, it is not possible to specify an
|
||||
// "invalid" or empty tile range.
|
||||
//
|
||||
// Pixels that are outside the pixel coordinate range for the tile's
|
||||
// level, are never accessed by writeTile().
|
||||
//
|
||||
// Each tile in the file must be written exactly once.
|
||||
//
|
||||
// The file's line order attribute determines the order of the tiles
|
||||
// in the file:
|
||||
//
|
||||
// INCREASING_Y In the file, the tiles for each level are stored
|
||||
// in a contiguous block. The levels are ordered
|
||||
// like this:
|
||||
//
|
||||
// (0, 0) (1, 0) ... (nx-1, 0)
|
||||
// (0, 1) (1, 1) ... (nx-1, 1)
|
||||
// ...
|
||||
// (0,ny-1) (1,ny-1) ... (nx-1,ny-1)
|
||||
//
|
||||
// where nx = numXLevels(), and ny = numYLevels().
|
||||
// In an individual level, (lx, ly), the tiles
|
||||
// are stored in the following order:
|
||||
//
|
||||
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||
// ...
|
||||
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||
//
|
||||
// where tx = numXTiles(lx),
|
||||
// and ty = numYTiles(ly).
|
||||
//
|
||||
// DECREASING_Y As for INCREASING_Y, the tiles for each level
|
||||
// are stored in a contiguous block. The levels
|
||||
// are ordered the same way as for INCREASING_Y,
|
||||
// but within an individual level, the tiles
|
||||
// are stored in this order:
|
||||
//
|
||||
// (0,ty-1) (1,ty-1) ... (tx-1,ty-1)
|
||||
// ...
|
||||
// (0, 1) (1, 1) ... (tx-1, 1)
|
||||
// (0, 0) (1, 0) ... (tx-1, 0)
|
||||
//
|
||||
//
|
||||
// RANDOM_Y The order of the calls to writeTile() determines
|
||||
// the order of the tiles in the file.
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void writeTile (int dx, int dy, int l = 0);
|
||||
void writeTile (int dx, int dy, int lx, int ly);
|
||||
|
||||
void writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int lx, int ly);
|
||||
|
||||
void writeTiles (int dx1, int dx2, int dy1, int dy2,
|
||||
int l = 0);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Shortcut to copy all pixels from a TiledInputFile into this file,
|
||||
// without uncompressing and then recompressing the pixel data.
|
||||
// This file's header must be compatible with the TiledInputFile's
|
||||
// header: The two header's "dataWindow", "compression",
|
||||
// "lineOrder", "channels", and "tiles" attributes must be the same.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
void copyPixels (DeepTiledInputFile &in);
|
||||
void copyPixels (DeepTiledInputPart &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_NAMESPACE::LogicExc.
|
||||
//
|
||||
// Note: updatePreviewImage() is necessary because images are
|
||||
// often stored in a file incrementally, a few tiles 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 tile of the main image.
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
void updatePreviewImage (const PreviewRgba newPixels[]);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Break a tile -- for testing and debugging only:
|
||||
//
|
||||
// breakTile(dx,dy,lx,ly,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 tile with tile coordinates
|
||||
// (dx, dy) and level number (lx, ly).
|
||||
//
|
||||
// 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 breakTile (int dx, int dy,
|
||||
int lx, int ly,
|
||||
int offset,
|
||||
int length,
|
||||
char c);
|
||||
|
||||
private:
|
||||
DeepTiledOutputFile* file;
|
||||
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif /* IMFDEEPTILEDOUTPUTPART_H_ */
|
||||
57
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDoubleAttribute.cpp
Normal file
57
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDoubleAttribute.cpp
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>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
DoubleAttribute::staticTypeName ()
|
||||
{
|
||||
return "double";
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
59
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDoubleAttribute.h
Normal file
59
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDoubleAttribute.h
Normal file
@@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<double> DoubleAttribute;
|
||||
template <> IMF_EXPORT const char *DoubleAttribute::staticTypeName ();
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
3434
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDwaCompressor.cpp
Normal file
3434
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDwaCompressor.cpp
Normal file
File diff suppressed because it is too large
Load Diff
210
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDwaCompressor.h
Normal file
210
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDwaCompressor.h
Normal file
@@ -0,0 +1,210 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2009-2014 DreamWorks Animation 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 DreamWorks Animation 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_DWA_COMRESSOR_H
|
||||
#define INCLUDED_IMF_DWA_COMRESSOR_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// class DwaCompressor -- Store lossy RGB data by quantizing DCT components.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <vector>
|
||||
#include <half.h>
|
||||
|
||||
#include "ImfInt64.h"
|
||||
#include "ImfZip.h"
|
||||
#include "ImfChannelList.h"
|
||||
#include "ImfCompressor.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class DwaCompressor: public Compressor
|
||||
{
|
||||
public:
|
||||
|
||||
enum AcCompression
|
||||
{
|
||||
STATIC_HUFFMAN,
|
||||
DEFLATE,
|
||||
};
|
||||
|
||||
|
||||
DwaCompressor (const Header &hdr,
|
||||
int maxScanLineSize,
|
||||
int numScanLines, // ideally is a multiple of 8
|
||||
AcCompression acCompression);
|
||||
|
||||
virtual ~DwaCompressor ();
|
||||
|
||||
virtual int numScanLines () const;
|
||||
|
||||
virtual Imf::Compressor::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);
|
||||
|
||||
static void initializeFuncs ();
|
||||
|
||||
private:
|
||||
|
||||
struct ChannelData;
|
||||
struct CscChannelSet;
|
||||
struct Classifier;
|
||||
|
||||
class LossyDctDecoderBase;
|
||||
class LossyDctDecoder;
|
||||
class LossyDctDecoderCsc;
|
||||
|
||||
class LossyDctEncoderBase;
|
||||
class LossyDctEncoder;
|
||||
class LossyDctEncoderCsc;
|
||||
|
||||
enum CompressorScheme
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
LOSSY_DCT,
|
||||
RLE,
|
||||
|
||||
NUM_COMPRESSOR_SCHEMES
|
||||
};
|
||||
|
||||
//
|
||||
// Per-chunk compressed data sizes, one value per chunk
|
||||
//
|
||||
|
||||
enum DataSizesSingle
|
||||
{
|
||||
VERSION = 0, // Version number:
|
||||
// 0: classic
|
||||
// 1: adds "end of block" to the AC RLE
|
||||
|
||||
UNKNOWN_UNCOMPRESSED_SIZE, // Size of leftover data, uncompressed.
|
||||
UNKNOWN_COMPRESSED_SIZE, // Size of leftover data, zlib compressed.
|
||||
|
||||
AC_COMPRESSED_SIZE, // AC RLE + Huffman size
|
||||
DC_COMPRESSED_SIZE, // DC + Deflate size
|
||||
RLE_COMPRESSED_SIZE, // RLE + Deflate data size
|
||||
RLE_UNCOMPRESSED_SIZE, // RLE'd data size
|
||||
RLE_RAW_SIZE, // Un-RLE'd data size
|
||||
|
||||
AC_UNCOMPRESSED_COUNT, // AC RLE number of elements
|
||||
DC_UNCOMPRESSED_COUNT, // DC number of elements
|
||||
|
||||
AC_COMPRESSION, // AC compression strategy
|
||||
NUM_SIZES_SINGLE
|
||||
};
|
||||
|
||||
AcCompression _acCompression;
|
||||
|
||||
int _maxScanLineSize;
|
||||
int _numScanLines;
|
||||
int _min[2], _max[2];
|
||||
|
||||
ChannelList _channels;
|
||||
std::vector<ChannelData> _channelData;
|
||||
std::vector<CscChannelSet> _cscSets;
|
||||
std::vector<Classifier> _channelRules;
|
||||
|
||||
char *_packedAcBuffer;
|
||||
size_t _packedAcBufferSize;
|
||||
char *_packedDcBuffer;
|
||||
size_t _packedDcBufferSize;
|
||||
char *_rleBuffer;
|
||||
size_t _rleBufferSize;
|
||||
char *_outBuffer;
|
||||
size_t _outBufferSize;
|
||||
char *_planarUncBuffer[NUM_COMPRESSOR_SCHEMES];
|
||||
size_t _planarUncBufferSize[NUM_COMPRESSOR_SCHEMES];
|
||||
|
||||
Zip *_zip;
|
||||
float _dwaCompressionLevel;
|
||||
|
||||
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);
|
||||
|
||||
void initializeBuffers (size_t&);
|
||||
void initializeDefaultChannelRules ();
|
||||
void initializeLegacyChannelRules ();
|
||||
|
||||
void relevantChannelRules( std::vector<Classifier> &) const;
|
||||
|
||||
//
|
||||
// Populate our cached version of the channel data with
|
||||
// data from the real channel list. We want to
|
||||
// copy over attributes, determine compression schemes
|
||||
// releveant for the channel type, and find sets of
|
||||
// channels to be compressed from Y'CbCr data instead
|
||||
// of R'G'B'.
|
||||
//
|
||||
|
||||
void classifyChannels (ChannelList channels,
|
||||
std::vector<ChannelData> &chanData,
|
||||
std::vector<CscChannelSet> &cscData);
|
||||
|
||||
//
|
||||
// Compute various buffer pointers for each channel
|
||||
//
|
||||
|
||||
void setupChannelData (int minX, int minY, int maxX, int maxY);
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
2150
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDwaCompressorSimd.h
Normal file
2150
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfDwaCompressorSimd.h
Normal file
File diff suppressed because it is too large
Load Diff
335
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmap.cpp
Normal file
335
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmap.cpp
Normal file
@@ -0,0 +1,335 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfNamespace.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
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 = -1 * float(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 * float(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 * float(M_PI)) + 0.5f;
|
||||
float y = latLong.x / (-1 * float(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
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
336
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmap.h
Normal file
336
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmap.h
Normal file
@@ -0,0 +1,336 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
//--------------------------------
|
||||
// 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.
|
||||
//----------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V2f latLong (const IMATH_NAMESPACE::V3f &direction);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Convert the position of a pixel to a 2D vector whose
|
||||
// x and y components represent the corresponding latitude
|
||||
// and longitude.
|
||||
//--------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V2f latLong (const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
const IMATH_NAMESPACE::V2f &pixelPosition);
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Convert a 2D vector, whose x and y components represent
|
||||
// longitude and latitude, into a corresponding pixel position.
|
||||
//-------------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V2f pixelPosition (const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
const IMATH_NAMESPACE::V2f &latLong);
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Convert a 3D direction vector into a corresponding
|
||||
// pixel position. pixelPosition(dw,dir) is equivalent
|
||||
// to pixelPosition(dw,latLong(dw,dir)).
|
||||
//-----------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V2f pixelPosition (const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
const IMATH_NAMESPACE::V3f &direction);
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Convert the position of a pixel in a latitude-longitude
|
||||
// map into a corresponding 3D direction.
|
||||
//--------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V3f direction (const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
const IMATH_NAMESPACE::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
|
||||
//---------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
int sizeOfFace (const IMATH_NAMESPACE::Box2i &dataWindow);
|
||||
|
||||
|
||||
//------------------------------------------
|
||||
// Compute the region in the environment map
|
||||
// that is covered by the specified face.
|
||||
//------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::Box2i dataWindowForFace (CubeMapFace face,
|
||||
const IMATH_NAMESPACE::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.
|
||||
//----------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V2f pixelPosition (CubeMapFace face,
|
||||
const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
IMATH_NAMESPACE::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);
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
void faceAndPixelPosition (const IMATH_NAMESPACE::V3f &direction,
|
||||
const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
CubeMapFace &face,
|
||||
IMATH_NAMESPACE::V2f &positionInFace);
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// Given a cube face and a pixel position within that face,
|
||||
// compute the corresponding 3D direction.
|
||||
// --------------------------------------------------------
|
||||
|
||||
IMF_EXPORT
|
||||
IMATH_NAMESPACE::V3f direction (CubeMapFace face,
|
||||
const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
const IMATH_NAMESPACE::V2f &positionInFace);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
76
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmapAttribute.cpp
Normal file
76
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmapAttribute.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
template <>
|
||||
const char *
|
||||
EnvmapAttribute::staticTypeName ()
|
||||
{
|
||||
return "envmap";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
EnvmapAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const
|
||||
{
|
||||
unsigned char tmp = _value;
|
||||
Xdr::write <StreamIO> (os, tmp);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
EnvmapAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version)
|
||||
{
|
||||
unsigned char tmp;
|
||||
Xdr::read <StreamIO> (is, tmp);
|
||||
_value = Envmap (tmp);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
68
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmapAttribute.h
Normal file
68
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfEnvmapAttribute.h
Normal file
@@ -0,0 +1,68 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::Envmap> EnvmapAttribute;
|
||||
|
||||
template <> IMF_EXPORT const char *EnvmapAttribute::staticTypeName ();
|
||||
|
||||
template <> IMF_EXPORT
|
||||
void EnvmapAttribute::writeValueTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &,
|
||||
int) const;
|
||||
|
||||
template <> IMF_EXPORT
|
||||
void EnvmapAttribute::readValueFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &,
|
||||
int,
|
||||
int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
46
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfExport.h
Normal file
46
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfExport.h
Normal file
@@ -0,0 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(OPENEXR_DLL)
|
||||
#if defined(ILMIMF_EXPORTS)
|
||||
#define IMF_EXPORT __declspec(dllexport)
|
||||
#define IMF_EXPORT_CONST extern __declspec(dllexport)
|
||||
#else
|
||||
#define IMF_EXPORT __declspec(dllimport)
|
||||
#define IMF_EXPORT_CONST extern __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define IMF_EXPORT
|
||||
#define IMF_EXPORT_CONST extern const
|
||||
#endif
|
||||
768
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFastHuf.cpp
Normal file
768
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFastHuf.cpp
Normal file
@@ -0,0 +1,768 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2009-2014 DreamWorks Animation 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 DreamWorks Animation 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 "ImfFastHuf.h"
|
||||
#include <Iex.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
//
|
||||
// Adapted from hufUnpackEncTable -
|
||||
// We don't need to reconstruct the code book, just the encoded
|
||||
// lengths for each symbol. From the lengths, we can build the
|
||||
// base + offset tables. This should be a bit more efficient
|
||||
// for sparse code books.
|
||||
//
|
||||
// table - ptr to the start of the code length data. Will be
|
||||
// updated as we decode data
|
||||
//
|
||||
// numBytes - size of the encoded table (I think)?
|
||||
//
|
||||
// minSymbol - smallest symbol in the code book
|
||||
//
|
||||
// maxSymbol - largest symbol in the code book.
|
||||
//
|
||||
// rleSymbol - the symbol to trigger RLE in the encoded bitstream
|
||||
//
|
||||
|
||||
FastHufDecoder::FastHufDecoder
|
||||
(const char *&table,
|
||||
int numBytes,
|
||||
int minSymbol,
|
||||
int maxSymbol,
|
||||
int rleSymbol)
|
||||
:
|
||||
_rleSymbol (rleSymbol),
|
||||
_numSymbols (0),
|
||||
_minCodeLength (255),
|
||||
_maxCodeLength (0),
|
||||
_idToSymbol (0)
|
||||
{
|
||||
//
|
||||
// List of symbols that we find with non-zero code lengths
|
||||
// (listed in the order we find them). Store these in the
|
||||
// same format as the code book stores codes + lengths -
|
||||
// low 6 bits are the length, everything above that is
|
||||
// the symbol.
|
||||
//
|
||||
|
||||
std::vector<Int64> symbols;
|
||||
|
||||
//
|
||||
// The 'base' table is the minimum code at each code length. base[i]
|
||||
// is the smallest code (numerically) of length i.
|
||||
//
|
||||
|
||||
Int64 base[MAX_CODE_LEN + 1];
|
||||
|
||||
//
|
||||
// The 'offset' table is the position (in sorted order) of the first id
|
||||
// of a given code lenght. Array is indexed by code length, like base.
|
||||
//
|
||||
|
||||
Int64 offset[MAX_CODE_LEN + 1];
|
||||
|
||||
//
|
||||
// Count of how many codes at each length there are. Array is
|
||||
// indexed by code length, like base and offset.
|
||||
//
|
||||
|
||||
size_t codeCount[MAX_CODE_LEN + 1];
|
||||
|
||||
for (int i = 0; i <= MAX_CODE_LEN; ++i)
|
||||
{
|
||||
codeCount[i] = 0;
|
||||
base[i] = 0xffffffffffffffffULL;
|
||||
offset[i] = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Count the number of codes, the min/max code lengths, the number of
|
||||
// codes with each length, and record symbols with non-zero code
|
||||
// length as we find them.
|
||||
//
|
||||
|
||||
const char *currByte = table;
|
||||
Int64 currBits = 0;
|
||||
int currBitCount = 0;
|
||||
|
||||
const int SHORT_ZEROCODE_RUN = 59;
|
||||
const int LONG_ZEROCODE_RUN = 63;
|
||||
const int SHORTEST_LONG_RUN = 2 + LONG_ZEROCODE_RUN - SHORT_ZEROCODE_RUN;
|
||||
|
||||
for (Int64 symbol = minSymbol; symbol <= maxSymbol; symbol++)
|
||||
{
|
||||
if (currByte - table > numBytes)
|
||||
{
|
||||
throw Iex::InputExc ("Error decoding Huffman table "
|
||||
"(Truncated table data).");
|
||||
}
|
||||
|
||||
//
|
||||
// Next code length - either:
|
||||
// 0-58 (literal code length)
|
||||
// 59-62 (various lengths runs of 0)
|
||||
// 63 (run of n 0's, with n is the next 8 bits)
|
||||
//
|
||||
|
||||
Int64 codeLen = readBits (6, currBits, currBitCount, currByte);
|
||||
|
||||
if (codeLen == (Int64) LONG_ZEROCODE_RUN)
|
||||
{
|
||||
if (currByte - table > numBytes)
|
||||
{
|
||||
throw Iex::InputExc ("Error decoding Huffman table "
|
||||
"(Truncated table data).");
|
||||
}
|
||||
|
||||
int runLen = readBits (8, currBits, currBitCount, currByte) +
|
||||
SHORTEST_LONG_RUN;
|
||||
|
||||
if (symbol + runLen > maxSymbol + 1)
|
||||
{
|
||||
throw Iex::InputExc ("Error decoding Huffman table "
|
||||
"(Run beyond end of table).");
|
||||
}
|
||||
|
||||
symbol += runLen - 1;
|
||||
|
||||
}
|
||||
else if (codeLen >= (Int64) SHORT_ZEROCODE_RUN)
|
||||
{
|
||||
int runLen = codeLen - SHORT_ZEROCODE_RUN + 2;
|
||||
|
||||
if (symbol + runLen > maxSymbol + 1)
|
||||
{
|
||||
throw Iex::InputExc ("Error decoding Huffman table "
|
||||
"(Run beyond end of table).");
|
||||
}
|
||||
|
||||
symbol += runLen - 1;
|
||||
|
||||
}
|
||||
else if (codeLen != 0)
|
||||
{
|
||||
symbols.push_back ((symbol << 6) | (codeLen & 63));
|
||||
|
||||
if (codeLen < _minCodeLength)
|
||||
_minCodeLength = codeLen;
|
||||
|
||||
if (codeLen > _maxCodeLength)
|
||||
_maxCodeLength = codeLen;
|
||||
|
||||
codeCount[codeLen]++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_CODE_LEN; ++i)
|
||||
_numSymbols += codeCount[i];
|
||||
|
||||
table = currByte;
|
||||
|
||||
//
|
||||
// Compute base - once we have the code length counts, there
|
||||
// is a closed form solution for this
|
||||
//
|
||||
|
||||
{
|
||||
double* countTmp = new double[_maxCodeLength+1];
|
||||
|
||||
for (int l = _minCodeLength; l <= _maxCodeLength; ++l)
|
||||
{
|
||||
countTmp[l] = (double)codeCount[l] *
|
||||
(double)(2 << (_maxCodeLength-l));
|
||||
}
|
||||
|
||||
for (int l = _minCodeLength; l <= _maxCodeLength; ++l)
|
||||
{
|
||||
double tmp = 0;
|
||||
|
||||
for (int k =l + 1; k <= _maxCodeLength; ++k)
|
||||
tmp += countTmp[k];
|
||||
|
||||
tmp /= (double)(2 << (_maxCodeLength - l));
|
||||
|
||||
base[l] = (Int64)ceil (tmp);
|
||||
}
|
||||
|
||||
delete [] countTmp;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute offset - these are the positions of the first
|
||||
// id (not symbol) that has length [i]
|
||||
//
|
||||
|
||||
offset[_maxCodeLength] = 0;
|
||||
|
||||
for (int i= _maxCodeLength - 1; i >= _minCodeLength; i--)
|
||||
offset[i] = offset[i + 1] + codeCount[i + 1];
|
||||
|
||||
//
|
||||
// Allocate and fill the symbol-to-id mapping. Smaller Ids should be
|
||||
// mapped to less-frequent symbols (which have longer codes). Use
|
||||
// the offset table to tell us where the id's for a given code
|
||||
// length start off.
|
||||
//
|
||||
|
||||
_idToSymbol = new int[_numSymbols];
|
||||
|
||||
Int64 mapping[MAX_CODE_LEN + 1];
|
||||
for (int i = 0; i < MAX_CODE_LEN + 1; ++i)
|
||||
mapping[i] = -1;
|
||||
for (int i = _minCodeLength; i <= _maxCodeLength; ++i)
|
||||
mapping[i] = offset[i];
|
||||
|
||||
for (std::vector<Int64>::const_iterator i = symbols.begin();
|
||||
i != symbols.end();
|
||||
++i)
|
||||
{
|
||||
int codeLen = *i & 63;
|
||||
int symbol = *i >> 6;
|
||||
|
||||
if (mapping[codeLen] >= _numSymbols)
|
||||
throw Iex::InputExc ("Huffman decode error "
|
||||
"(Invalid symbol in header).");
|
||||
|
||||
_idToSymbol[mapping[codeLen]] = symbol;
|
||||
mapping[codeLen]++;
|
||||
}
|
||||
|
||||
buildTables(base, offset);
|
||||
}
|
||||
|
||||
|
||||
FastHufDecoder::~FastHufDecoder()
|
||||
{
|
||||
delete[] _idToSymbol;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Static check if the decoder is enabled.
|
||||
//
|
||||
// ATM, I only have access to little endian hardware for testing,
|
||||
// so I'm not entirely sure that we are reading fom the bit stream
|
||||
// properly on BE.
|
||||
//
|
||||
// If you happen to have more obscure hardware, check that the
|
||||
// byte swapping in refill() is happening sensable, add an endian
|
||||
// check if needed, and fix the preprocessor magic here.
|
||||
//
|
||||
|
||||
#define READ64(c) \
|
||||
((Int64)(c)[0] << 56) | ((Int64)(c)[1] << 48) | ((Int64)(c)[2] << 40) | \
|
||||
((Int64)(c)[3] << 32) | ((Int64)(c)[4] << 24) | ((Int64)(c)[5] << 16) | \
|
||||
((Int64)(c)[6] << 8) | ((Int64)(c)[7] )
|
||||
|
||||
#ifdef __INTEL_COMPILER // ICC built-in swap for LE hosts
|
||||
#if defined (__i386__) || defined(__x86_64__)
|
||||
#undef READ64
|
||||
#define READ64(c) _bswap64 (*(const Int64*)(c))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
FastHufDecoder::enabled()
|
||||
{
|
||||
#if defined(__INTEL_COMPILER) || defined(__GNUC__)
|
||||
|
||||
//
|
||||
// Enabled for ICC, GCC:
|
||||
// __i386__ -> x86
|
||||
// __x86_64__ -> 64-bit x86
|
||||
//
|
||||
|
||||
#if defined (__i386__) || defined(__x86_64__)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#elif defined (_MSC_VER)
|
||||
|
||||
//
|
||||
// Enabled for Visual Studio:
|
||||
// _M_IX86 -> x86
|
||||
// _M_X64 -> 64bit x86
|
||||
|
||||
#if defined (_M_IX86) || defined(_M_X64)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Unknown compiler - Be safe and disable.
|
||||
//
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Built the acceleration tables for lookups on the upper bits
|
||||
// as well as the 'LJ' tables.
|
||||
//
|
||||
|
||||
void
|
||||
FastHufDecoder::buildTables (Int64 *base, Int64 *offset)
|
||||
{
|
||||
//
|
||||
// Build the 'left justified' base table, by shifting base left..
|
||||
//
|
||||
|
||||
for (int i = 0; i <= MAX_CODE_LEN; ++i)
|
||||
{
|
||||
if (base[i] != 0xffffffffffffffffULL)
|
||||
{
|
||||
_ljBase[i] = base[i] << (64 - i);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Unused code length - insert dummy values
|
||||
//
|
||||
|
||||
_ljBase[i] = 0xffffffffffffffffULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Combine some terms into a big fat constant, which for
|
||||
// lack of a better term we'll call the 'left justified'
|
||||
// offset table (because it serves the same function
|
||||
// as 'offset', when using the left justified base table.
|
||||
//
|
||||
|
||||
for (int i = 0; i <= MAX_CODE_LEN; ++i)
|
||||
_ljOffset[i] = offset[i] - (_ljBase[i] >> (64 - i));
|
||||
|
||||
//
|
||||
// Build the acceleration tables for the lookups of
|
||||
// short codes ( <= TABLE_LOOKUP_BITS long)
|
||||
//
|
||||
|
||||
for (Int64 i = 0; i < 1 << TABLE_LOOKUP_BITS; ++i)
|
||||
{
|
||||
Int64 value = i << (64 - TABLE_LOOKUP_BITS);
|
||||
|
||||
_tableSymbol[i] = 0xffff;
|
||||
_tableCodeLen[i] = 0;
|
||||
|
||||
for (int codeLen = _minCodeLength; codeLen <= _maxCodeLength; ++codeLen)
|
||||
{
|
||||
if (_ljBase[codeLen] <= value)
|
||||
{
|
||||
_tableCodeLen[i] = codeLen;
|
||||
|
||||
Int64 id = _ljOffset[codeLen] + (value >> (64 - codeLen));
|
||||
if (id < _numSymbols)
|
||||
{
|
||||
_tableSymbol[i] = _idToSymbol[id];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Iex::InputExc ("Huffman decode error "
|
||||
"(Overrun).");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Store the smallest value in the table that points to real data.
|
||||
// This should be the entry for the largest length that has
|
||||
// valid data (in our case, non-dummy _ljBase)
|
||||
//
|
||||
|
||||
int minIdx = TABLE_LOOKUP_BITS;
|
||||
|
||||
while (minIdx > 0 && _ljBase[minIdx] == 0xffffffffffffffffULL)
|
||||
minIdx--;
|
||||
|
||||
if (minIdx < 0)
|
||||
{
|
||||
//
|
||||
// Error, no codes with lengths 0-TABLE_LOOKUP_BITS used.
|
||||
// Set the min value such that the table is never tested.
|
||||
//
|
||||
|
||||
_tableMin = 0xffffffffffffffffULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
_tableMin = _ljBase[minIdx];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// For decoding, we're holding onto 2 Int64's.
|
||||
//
|
||||
// The first (buffer), holds the next bits from the bitstream to be
|
||||
// decoded. For certain paths in the decoder, we only need TABLE_LOOKUP_BITS
|
||||
// valid bits to decode the next symbol. For other paths, we need a full
|
||||
// 64-bits to decode a symbol.
|
||||
//
|
||||
// When we need to refill 'buffer', we could pull bits straight from
|
||||
// the bitstream. But this is very slow and requires lots of book keeping
|
||||
// (what's the next bit in the next byte?). Instead, we keep another Int64
|
||||
// around that we use to refill from. While this doesn't cut down on the
|
||||
// book keeping (still need to know how many valid bits), it does cut
|
||||
// down on some of the bit shifting crazy and byte access.
|
||||
//
|
||||
// The refill Int64 (bufferBack) gets left-shifted after we've pulled
|
||||
// off bits. If we run out of bits in the input bit stream, we just
|
||||
// shift in 0's to bufferBack.
|
||||
//
|
||||
// The refill act takes numBits from the top of bufferBack and sticks
|
||||
// them in the bottom of buffer. If there arn't enough bits in bufferBack,
|
||||
// it gets refilled (to 64-bits) from the input bitstream.
|
||||
//
|
||||
|
||||
inline void
|
||||
FastHufDecoder::refill
|
||||
(Int64 &buffer,
|
||||
int numBits, // number of bits to refill
|
||||
Int64 &bufferBack, // the next 64-bits, to refill from
|
||||
int &bufferBackNumBits, // number of bits left in bufferBack
|
||||
const unsigned char *&currByte, // current byte in the bitstream
|
||||
int &currBitsLeft) // number of bits left in the bitsream
|
||||
{
|
||||
//
|
||||
// Refill bits into the bottom of buffer, from the top of bufferBack.
|
||||
// Always top up buffer to be completely full.
|
||||
//
|
||||
|
||||
buffer |= bufferBack >> (64 - numBits);
|
||||
|
||||
if (bufferBackNumBits < numBits)
|
||||
{
|
||||
numBits -= bufferBackNumBits;
|
||||
|
||||
//
|
||||
// Refill all of bufferBack from the bitstream. Either grab
|
||||
// a full 64-bit chunk, or whatever bytes are left. If we
|
||||
// don't have 64-bits left, pad with 0's.
|
||||
//
|
||||
|
||||
if (currBitsLeft >= 64)
|
||||
{
|
||||
bufferBack = READ64 (currByte);
|
||||
bufferBackNumBits = 64;
|
||||
currByte += sizeof (Int64);
|
||||
currBitsLeft -= 8 * sizeof (Int64);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferBack = 0;
|
||||
bufferBackNumBits = 64;
|
||||
|
||||
Int64 shift = 56;
|
||||
|
||||
while (currBitsLeft > 0)
|
||||
{
|
||||
bufferBack |= ((Int64)(*currByte)) << shift;
|
||||
|
||||
currByte++;
|
||||
shift -= 8;
|
||||
currBitsLeft -= 8;
|
||||
}
|
||||
|
||||
//
|
||||
// At this point, currBitsLeft might be negative, just because
|
||||
// we're subtracting whole bytes. To keep anyone from freaking
|
||||
// out, zero the counter.
|
||||
//
|
||||
|
||||
if (currBitsLeft < 0)
|
||||
currBitsLeft = 0;
|
||||
}
|
||||
|
||||
buffer |= bufferBack >> (64 - numBits);
|
||||
}
|
||||
|
||||
bufferBack = bufferBack << numBits;
|
||||
bufferBackNumBits -= numBits;
|
||||
|
||||
//
|
||||
// We can have cases where the previous shift of bufferBack is << 64 -
|
||||
// in which case no shift occurs. The bit count math still works though,
|
||||
// so if we don't have any bits left, zero out bufferBack.
|
||||
//
|
||||
|
||||
if (bufferBackNumBits == 0)
|
||||
bufferBack = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Read the next few bits out of a bitstream. Will be given a backing buffer
|
||||
// (buffer) that may still have data left over from previous reads
|
||||
// (bufferNumBits). Bitstream pointer (currByte) will be advanced when needed.
|
||||
//
|
||||
|
||||
inline Int64
|
||||
FastHufDecoder::readBits
|
||||
(int numBits,
|
||||
Int64 &buffer, // c
|
||||
int &bufferNumBits, // lc
|
||||
const char *&currByte) // in
|
||||
{
|
||||
while (bufferNumBits < numBits)
|
||||
{
|
||||
buffer = (buffer << 8) | *(unsigned char*)(currByte++);
|
||||
bufferNumBits += 8;
|
||||
}
|
||||
|
||||
bufferNumBits -= numBits;
|
||||
return (buffer >> bufferNumBits) & ((1 << numBits) - 1);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Decode using a the 'One-Shift' strategy for decoding, with a
|
||||
// small-ish table to accelerate decoding of short codes.
|
||||
//
|
||||
// If possible, try looking up codes into the acceleration table.
|
||||
// This has a few benifits - there's no search involved; We don't
|
||||
// need an additional lookup to map id to symbol; we don't need
|
||||
// a full 64-bits (so less refilling).
|
||||
//
|
||||
|
||||
void
|
||||
FastHufDecoder::decode
|
||||
(const unsigned char *src,
|
||||
int numSrcBits,
|
||||
unsigned short *dst,
|
||||
int numDstElems)
|
||||
{
|
||||
if (numSrcBits < 128)
|
||||
throw Iex::InputExc ("Error choosing Huffman decoder implementation "
|
||||
"(insufficient number of bits).");
|
||||
|
||||
//
|
||||
// Current position (byte/bit) in the src data stream
|
||||
// (after the first buffer fill)
|
||||
//
|
||||
|
||||
const unsigned char *currByte = src + 2 * sizeof (Int64);
|
||||
|
||||
numSrcBits -= 8 * 2 * sizeof (Int64);
|
||||
|
||||
//
|
||||
// 64-bit buffer holding the current bits in the stream
|
||||
//
|
||||
|
||||
Int64 buffer = READ64 (src);
|
||||
int bufferNumBits = 64;
|
||||
|
||||
//
|
||||
// 64-bit buffer holding the next bits in the stream
|
||||
//
|
||||
|
||||
Int64 bufferBack = READ64 ((src + sizeof (Int64)));
|
||||
int bufferBackNumBits = 64;
|
||||
|
||||
int dstIdx = 0;
|
||||
|
||||
while (dstIdx < numDstElems)
|
||||
{
|
||||
int codeLen;
|
||||
int symbol;
|
||||
|
||||
//
|
||||
// Test if we can be table accelerated. If so, directly
|
||||
// lookup the output symbol. Otherwise, we need to fall
|
||||
// back to searching for the code.
|
||||
//
|
||||
// If we're doing table lookups, we don't really need
|
||||
// a re-filled buffer, so long as we have TABLE_LOOKUP_BITS
|
||||
// left. But for a search, we do need a refilled table.
|
||||
//
|
||||
|
||||
if (_tableMin <= buffer)
|
||||
{
|
||||
int tableIdx = buffer >> (64 - TABLE_LOOKUP_BITS);
|
||||
|
||||
//
|
||||
// For invalid codes, _tableCodeLen[] should return 0. This
|
||||
// will cause the decoder to get stuck in the current spot
|
||||
// until we run out of elements, then barf that the codestream
|
||||
// is bad. So we don't need to stick a condition like
|
||||
// if (codeLen > _maxCodeLength) in this inner.
|
||||
//
|
||||
|
||||
codeLen = _tableCodeLen[tableIdx];
|
||||
symbol = _tableSymbol[tableIdx];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bufferNumBits < 64)
|
||||
{
|
||||
refill (buffer,
|
||||
64 - bufferNumBits,
|
||||
bufferBack,
|
||||
bufferBackNumBits,
|
||||
currByte,
|
||||
numSrcBits);
|
||||
|
||||
bufferNumBits = 64;
|
||||
}
|
||||
|
||||
//
|
||||
// Brute force search:
|
||||
// Find the smallest length where _ljBase[length] <= buffer
|
||||
//
|
||||
|
||||
codeLen = TABLE_LOOKUP_BITS + 1;
|
||||
|
||||
while (_ljBase[codeLen] > buffer && codeLen <= _maxCodeLength)
|
||||
codeLen++;
|
||||
|
||||
if (codeLen > _maxCodeLength)
|
||||
{
|
||||
throw Iex::InputExc ("Huffman decode error "
|
||||
"(Decoded an invalid symbol).");
|
||||
}
|
||||
|
||||
Int64 id = _ljOffset[codeLen] + (buffer >> (64 - codeLen));
|
||||
if (id < _numSymbols)
|
||||
{
|
||||
symbol = _idToSymbol[id];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw Iex::InputExc ("Huffman decode error "
|
||||
"(Decoded an invalid symbol).");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Shift over bit stream, and update the bit count in the buffer
|
||||
//
|
||||
|
||||
buffer = buffer << codeLen;
|
||||
bufferNumBits -= codeLen;
|
||||
|
||||
//
|
||||
// If we recieved a RLE symbol (_rleSymbol), then we need
|
||||
// to read ahead 8 bits to know how many times to repeat
|
||||
// the previous symbol. Need to ensure we at least have
|
||||
// 8 bits of data in the buffer
|
||||
//
|
||||
|
||||
if (symbol == _rleSymbol)
|
||||
{
|
||||
if (bufferNumBits < 8)
|
||||
{
|
||||
refill (buffer,
|
||||
64 - bufferNumBits,
|
||||
bufferBack,
|
||||
bufferBackNumBits,
|
||||
currByte,
|
||||
numSrcBits);
|
||||
|
||||
bufferNumBits = 64;
|
||||
}
|
||||
|
||||
int rleCount = buffer >> 56;
|
||||
|
||||
if (dstIdx < 1)
|
||||
{
|
||||
throw Iex::InputExc ("Huffman decode error (RLE code "
|
||||
"with no previous symbol).");
|
||||
}
|
||||
|
||||
if (dstIdx + rleCount > numDstElems)
|
||||
{
|
||||
throw Iex::InputExc ("Huffman decode error (Symbol run "
|
||||
"beyond expected output buffer length).");
|
||||
}
|
||||
|
||||
if (rleCount <= 0)
|
||||
{
|
||||
throw Iex::InputExc("Huffman decode error"
|
||||
" (Invalid RLE length)");
|
||||
}
|
||||
|
||||
for (int i = 0; i < rleCount; ++i)
|
||||
dst[dstIdx + i] = dst[dstIdx - 1];
|
||||
|
||||
dstIdx += rleCount;
|
||||
|
||||
buffer = buffer << 8;
|
||||
bufferNumBits -= 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst[dstIdx] = symbol;
|
||||
dstIdx++;
|
||||
}
|
||||
|
||||
//
|
||||
// refill bit stream buffer if we're below the number of
|
||||
// bits needed for a table lookup
|
||||
//
|
||||
|
||||
if (bufferNumBits < TABLE_LOOKUP_BITS)
|
||||
{
|
||||
refill (buffer,
|
||||
64 - bufferNumBits,
|
||||
bufferBack,
|
||||
bufferBackNumBits,
|
||||
currByte,
|
||||
numSrcBits);
|
||||
|
||||
bufferNumBits = 64;
|
||||
}
|
||||
}
|
||||
|
||||
if (numSrcBits != 0)
|
||||
{
|
||||
throw Iex::InputExc ("Huffman decode error (Compressed data remains "
|
||||
"after filling expected output buffer).");
|
||||
}
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
148
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFastHuf.h
Normal file
148
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFastHuf.h
Normal file
@@ -0,0 +1,148 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2009-2014 DreamWorks Animation 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 DreamWorks Animation 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_FAST_HUF_H
|
||||
#define INCLUDED_IMF_FAST_HUF_H
|
||||
|
||||
#include "ImfInt64.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
//
|
||||
// Alternative Canonical Huffman decoder:
|
||||
//
|
||||
// Canonical Huffman decoder based on 'On the Implementation of Minimum
|
||||
// Redundancy Prefix Codes' by Moffat and Turpin - highly recommended
|
||||
// reading as a good description of the problem space, as well as
|
||||
// a fast decoding algorithm.
|
||||
//
|
||||
// The premise is that instead of working directly with the coded
|
||||
// symbols, we create a new ordering based on the frequency of symbols.
|
||||
// Less frequent symbols (and thus longer codes) are ordered earler.
|
||||
// We're calling the values in this ordering 'Ids', as oppsed to
|
||||
// 'Symbols' - which are the short values we eventually want decoded.
|
||||
//
|
||||
// With this new ordering, a few small tables can be derived ('base'
|
||||
// and 'offset') which drive the decoding. To cut down on the
|
||||
// linear scanning of these tables, you can add a small table
|
||||
// to directly look up short codes (as you might in a traditional
|
||||
// lookup-table driven decoder).
|
||||
//
|
||||
// The decoder is meant to be compatible with the encoder (and decoder)
|
||||
// in ImfHuf.cpp, just faster. For ease of implementation, this decoder
|
||||
// should only be used on compressed bitstreams >= 128 bits long.
|
||||
//
|
||||
|
||||
class FastHufDecoder
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// Longest compressed code length that ImfHuf supports (58 bits)
|
||||
//
|
||||
|
||||
static const int MAX_CODE_LEN = 58;
|
||||
|
||||
//
|
||||
// Number of bits in our acceleration table. Should match all
|
||||
// codes up to TABLE_LOOKUP_BITS in length.
|
||||
//
|
||||
|
||||
static const int TABLE_LOOKUP_BITS = 12;
|
||||
|
||||
FastHufDecoder (const char*& table,
|
||||
int numBytes,
|
||||
int minSymbol,
|
||||
int maxSymbol,
|
||||
int rleSymbol);
|
||||
|
||||
~FastHufDecoder ();
|
||||
|
||||
static bool enabled ();
|
||||
|
||||
void decode (const unsigned char *src,
|
||||
int numSrcBits,
|
||||
unsigned short *dst,
|
||||
int numDstElems);
|
||||
|
||||
private:
|
||||
|
||||
void buildTables (Int64*, Int64*);
|
||||
void refill (Int64&, int, Int64&, int&, const unsigned char *&, int&);
|
||||
Int64 readBits (int, Int64&, int&, const char *&);
|
||||
|
||||
int _rleSymbol; // RLE symbol written by the encoder.
|
||||
// This could be 65536, so beware
|
||||
// when you use shorts to hold things.
|
||||
|
||||
int _numSymbols; // Number of symbols in the codebook.
|
||||
|
||||
unsigned char _minCodeLength; // Minimum code length, in bits.
|
||||
unsigned char _maxCodeLength; // Maximum code length, in bits.
|
||||
|
||||
int *_idToSymbol; // Maps Ids to symbols. Ids are a symbol
|
||||
// ordering sorted first in terms of
|
||||
// code length, and by code within
|
||||
// the same length. Ids run from 0
|
||||
// to mNumSymbols-1.
|
||||
|
||||
Int64 _ljBase[MAX_CODE_LEN + 1]; // the 'left justified base' table.
|
||||
// Takes base[i] (i = code length)
|
||||
// and 'left justifies' it into an Int64
|
||||
|
||||
Int64 _ljOffset[MAX_CODE_LEN +1 ]; // There are some other terms that can
|
||||
// be folded into constants when taking
|
||||
// the 'left justified' decode path. This
|
||||
// holds those constants, indexed by
|
||||
// code length
|
||||
|
||||
//
|
||||
// We can accelerate the 'left justified' processing by running the
|
||||
// top TABLE_LOOKUP_BITS through a LUT, to find the symbol and code
|
||||
// length. These are those acceleration tables.
|
||||
//
|
||||
// Even though our evental 'symbols' are ushort's, the encoder adds
|
||||
// a symbol to indicate RLE. So with a dense code book, we could
|
||||
// have 2^16+1 codes, so both mIdToSymbol and mTableSymbol need
|
||||
// to be bigger than 16 bits.
|
||||
//
|
||||
|
||||
int _tableSymbol[1 << TABLE_LOOKUP_BITS];
|
||||
unsigned char _tableCodeLen[1 << TABLE_LOOKUP_BITS];
|
||||
Int64 _tableMin;
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
57
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFloatAttribute.cpp
Normal file
57
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFloatAttribute.cpp
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>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
FloatAttribute::staticTypeName ()
|
||||
{
|
||||
return "float";
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
58
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFloatAttribute.h
Normal file
58
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFloatAttribute.h
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_IMF_FLOAT_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_FLOAT_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class FloatAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfAttribute.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
typedef TypedAttribute<float> FloatAttribute;
|
||||
template <> IMF_EXPORT const char *FloatAttribute::staticTypeName ();
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2013, 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 FloatVectorAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfFloatVectorAttribute.h>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
using namespace OPENEXR_IMF_INTERNAL_NAMESPACE;
|
||||
|
||||
|
||||
template <>
|
||||
const char *
|
||||
FloatVectorAttribute::staticTypeName ()
|
||||
{
|
||||
return "floatvector";
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
FloatVectorAttribute::writeValueTo
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os, int version) const
|
||||
{
|
||||
int n = _value.size();
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
Xdr::write <StreamIO> (os, _value[i]);
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
void
|
||||
FloatVectorAttribute::readValueFrom
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int size, int version)
|
||||
{
|
||||
int n = size / Xdr::size<float>();
|
||||
_value.resize (n);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
Xdr::read <StreamIO> (is, _value[i]);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
@@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_FLOATVECTOR_ATTRIBUTE_H
|
||||
#define INCLUDED_IMF_FLOATVECTOR_ATTRIBUTE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class FloatVectorAttribute
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfAttribute.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
typedef std::vector<float>
|
||||
FloatVector;
|
||||
|
||||
typedef TypedAttribute<OPENEXR_IMF_INTERNAL_NAMESPACE::FloatVector>
|
||||
FloatVectorAttribute;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
const char *FloatVectorAttribute::staticTypeName ();
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void FloatVectorAttribute::writeValueTo
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &, int) const;
|
||||
|
||||
template <>
|
||||
IMF_EXPORT
|
||||
void FloatVectorAttribute::readValueFrom
|
||||
(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &, int, int);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
127
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfForward.h
Normal file
127
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfForward.h
Normal file
@@ -0,0 +1,127 @@
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// Portions (c) 2012 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 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_FORWARD_H
|
||||
#define INCLUDED_IMF_FORWARD_H
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Forward declarations for OpenEXR - correctly declares namespace
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
// classes for basic types;
|
||||
template<class T> class Array;
|
||||
template<class T> class Array2D;
|
||||
struct Channel;
|
||||
class ChannelList;
|
||||
struct Chromaticities;
|
||||
|
||||
// attributes used in headers are TypedAttributes
|
||||
class Attribute;
|
||||
|
||||
class Header;
|
||||
|
||||
// file handling classes
|
||||
class OutputFile;
|
||||
class TiledInputFile;
|
||||
class ScanLineInputFile;
|
||||
class InputFile;
|
||||
class TiledOutputFile;
|
||||
class DeepScanLineInputFile;
|
||||
class DeepScanLineOutputFile;
|
||||
class DeepTiledInputFile;
|
||||
class DeepTiledOutputFile;
|
||||
class AcesInputFile;
|
||||
class AcesOutputFile;
|
||||
class TiledInputPart;
|
||||
class TiledInputFile;
|
||||
class TileOffsets;
|
||||
|
||||
// multipart file handling
|
||||
class GenericInputFile;
|
||||
class GenericOutputFile;
|
||||
class MultiPartInputFile;
|
||||
class MultiPartOutputFile;
|
||||
|
||||
class InputPart;
|
||||
class TiledInputPart;
|
||||
class DeepScanLineInputPart;
|
||||
class DeepTiledInputPart;
|
||||
|
||||
class OutputPart;
|
||||
class ScanLineOutputPart;
|
||||
class TiledOutputPart;
|
||||
class DeepScanLineOutputPart;
|
||||
class DeepTiledOutputPart;
|
||||
|
||||
|
||||
// internal use only
|
||||
struct InputPartData;
|
||||
struct OutputStreamMutex;
|
||||
struct OutputPartData;
|
||||
struct InputStreamMutex;
|
||||
|
||||
// frame buffers
|
||||
|
||||
class FrameBuffer;
|
||||
class DeepFrameBuffer;
|
||||
struct DeepSlice;
|
||||
|
||||
// compositing
|
||||
class DeepCompositing;
|
||||
class CompositeDeepScanLine;
|
||||
|
||||
// preview image
|
||||
class PreviewImage;
|
||||
struct PreviewRgba;
|
||||
|
||||
// streams
|
||||
class OStream;
|
||||
class IStream;
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif // include guard
|
||||
228
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFrameBuffer.cpp
Normal file
228
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFrameBuffer.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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;
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
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_NAMESPACE::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_NAMESPACE::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_NAMESPACE::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());
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
386
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFrameBuffer.h
Normal file
386
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFrameBuffer.h
Normal file
@@ -0,0 +1,386 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfExport.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
//-------------------------------------------------------
|
||||
// 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 IMF_EXPORT 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 IMF_EXPORT 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_NAMESPACE::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);
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
76
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFramesPerSecond.cpp
Normal file
76
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFramesPerSecond.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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;
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
94
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFramesPerSecond.h
Normal file
94
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfFramesPerSecond.h
Normal file
@@ -0,0 +1,94 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
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);}
|
||||
|
||||
IMF_EXPORT Rational guessExactFps (double fps);
|
||||
IMF_EXPORT Rational guessExactFps (const Rational &fps);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif
|
||||
76
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericInputFile.cpp
Normal file
76
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericInputFile.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfGenericInputFile.h"
|
||||
|
||||
#include <ImfVersion.h>
|
||||
#include <ImfXdr.h>
|
||||
#include <Iex.h>
|
||||
#include <OpenEXRConfig.h>
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
void GenericInputFile::readMagicNumberAndVersionField(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int& version)
|
||||
{
|
||||
//
|
||||
// Read the magic number and the file format version number.
|
||||
// Then check if we can read the rest of this file.
|
||||
//
|
||||
|
||||
int magic;
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, magic);
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, version);
|
||||
|
||||
if (magic != MAGIC)
|
||||
{
|
||||
throw IEX_NAMESPACE::InputExc ("File is not an image file.");
|
||||
}
|
||||
|
||||
if (getVersion (version) != EXR_VERSION)
|
||||
{
|
||||
THROW (IEX_NAMESPACE::InputExc, "Cannot read "
|
||||
"version " << getVersion (version) << " "
|
||||
"image files. Current file format version "
|
||||
"is " << EXR_VERSION << ".");
|
||||
}
|
||||
|
||||
if (!supportsFlags (getFlags (version)))
|
||||
{
|
||||
THROW (IEX_NAMESPACE::InputExc, "The file format version number's flag field "
|
||||
"contains unrecognized flags.");
|
||||
}
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
58
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericInputFile.h
Normal file
58
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericInputFile.h
Normal file
@@ -0,0 +1,58 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFGENERICINPUTFILE_H_
|
||||
#define IMFGENERICINPUTFILE_H_
|
||||
|
||||
#include "ImfIO.h"
|
||||
#include "ImfHeader.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
class IMF_EXPORT GenericInputFile
|
||||
{
|
||||
public:
|
||||
virtual ~GenericInputFile() {}
|
||||
|
||||
protected:
|
||||
GenericInputFile() {}
|
||||
void readMagicNumberAndVersionField(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int& version);
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
#endif /* IMFGENERICINPUTFILE_H_ */
|
||||
112
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericOutputFile.cpp
Normal file
112
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericOutputFile.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfGenericOutputFile.h"
|
||||
|
||||
#include <ImfBoxAttribute.h>
|
||||
#include <ImfFloatAttribute.h>
|
||||
#include <ImfTimeCodeAttribute.h>
|
||||
#include <ImfChromaticitiesAttribute.h>
|
||||
|
||||
#include <ImfMisc.h>
|
||||
#include <ImfPartType.h>
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
void
|
||||
GenericOutputFile::writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os,
|
||||
const Header& header)
|
||||
{
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC);
|
||||
|
||||
int version = EXR_VERSION;
|
||||
|
||||
if (header.hasType() && isDeepData(header.type()))
|
||||
{
|
||||
version |= NON_IMAGE_FLAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
// (TODO) we may want to check something else in function signature
|
||||
// instead of hasTileDescription()?
|
||||
if (header.hasTileDescription())
|
||||
version |= TILED_FLAG;
|
||||
}
|
||||
|
||||
if (usesLongNames (header))
|
||||
version |= LONG_NAMES_FLAG;
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version);
|
||||
}
|
||||
|
||||
void
|
||||
GenericOutputFile::writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os,
|
||||
const Header * headers,
|
||||
int parts)
|
||||
{
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, MAGIC);
|
||||
|
||||
int version = EXR_VERSION;
|
||||
|
||||
if (parts == 1)
|
||||
{
|
||||
if (headers[0].type() == TILEDIMAGE)
|
||||
version |= TILED_FLAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
version |= MULTI_PART_FILE_FLAG;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parts; i++)
|
||||
{
|
||||
if (usesLongNames (headers[i]))
|
||||
version |= LONG_NAMES_FLAG;
|
||||
|
||||
if (headers[i].hasType() && isImage(headers[i].type()) == false)
|
||||
version |= NON_IMAGE_FLAG;
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::write <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (os, version);
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
62
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericOutputFile.h
Normal file
62
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfGenericOutputFile.h
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFGENERICOUTPUTFILE_H_
|
||||
#define IMFGENERICOUTPUTFILE_H_
|
||||
|
||||
#include "ImfVersion.h"
|
||||
#include "ImfIO.h"
|
||||
#include "ImfXdr.h"
|
||||
#include "ImfHeader.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT GenericOutputFile
|
||||
{
|
||||
public:
|
||||
virtual ~GenericOutputFile() {}
|
||||
|
||||
protected:
|
||||
GenericOutputFile() {}
|
||||
void writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, const Header& header);
|
||||
void writeMagicNumberAndVersionField (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, const Header * headers, int parts);
|
||||
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif /* GENERICOUTPUTFILE_H_ */
|
||||
1283
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHeader.cpp
Normal file
1283
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHeader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
699
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHeader.h
Normal file
699
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHeader.h
Normal file
@@ -0,0 +1,699 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfForward.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
class IMF_EXPORT 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_NAMESPACE::V2f &screenWindowCenter = IMATH_NAMESPACE::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_NAMESPACE::Box2i &dataWindow,
|
||||
float pixelAspectRatio = 1,
|
||||
const IMATH_NAMESPACE::V2f &screenWindowCenter = IMATH_NAMESPACE::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_NAMESPACE::Box2i &displayWindow,
|
||||
const IMATH_NAMESPACE::Box2i &dataWindow,
|
||||
float pixelAspectRatio = 1,
|
||||
const IMATH_NAMESPACE::V2f &screenWindowCenter = IMATH_NAMESPACE::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_NAMESPACE::TypeExc
|
||||
// is thrown.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void insert (const char name[],
|
||||
const Attribute &attribute);
|
||||
|
||||
void insert (const std::string &name,
|
||||
const Attribute &attribute);
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Remove an attribute:
|
||||
//
|
||||
// remove(n) If an attribute with name n exists, then it
|
||||
// is removed from the map of present attributes.
|
||||
//
|
||||
// If no attribute with name n exists, then this
|
||||
// functions becomes a 'no-op'
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
void erase (const char name[]);
|
||||
void erase (const std::string &name);
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Access to existing attributes:
|
||||
//
|
||||
// [n] Returns a reference to the attribute
|
||||
// with name n. If no attribute with
|
||||
// name n exists, an IEX_NAMESPACE::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_NAMESPACE::ArgExc is
|
||||
// thrown. If an attribute with name n
|
||||
// exists, but its type is not T, an
|
||||
// IEX_NAMESPACE::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_NAMESPACE::Box2i & displayWindow ();
|
||||
const IMATH_NAMESPACE::Box2i & displayWindow () const;
|
||||
|
||||
IMATH_NAMESPACE::Box2i & dataWindow ();
|
||||
const IMATH_NAMESPACE::Box2i & dataWindow () const;
|
||||
|
||||
float & pixelAspectRatio ();
|
||||
const float & pixelAspectRatio () const;
|
||||
|
||||
IMATH_NAMESPACE::V2f & screenWindowCenter ();
|
||||
const IMATH_NAMESPACE::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;
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// Access to required attributes for multipart files
|
||||
// They are optional to non-multipart files and mandatory
|
||||
// for multipart files.
|
||||
//-----------------------------------------------------
|
||||
void setName (const string& name);
|
||||
|
||||
string& name();
|
||||
const string& name() const;
|
||||
|
||||
bool hasName() const;
|
||||
|
||||
void setType (const string& Type);
|
||||
|
||||
string& type();
|
||||
const string& type() const;
|
||||
|
||||
bool hasType() const;
|
||||
|
||||
void setVersion (const int version);
|
||||
|
||||
int& version();
|
||||
const int& version() const;
|
||||
|
||||
bool hasVersion() const;
|
||||
|
||||
//
|
||||
// the chunkCount attribute is set automatically when a file is written.
|
||||
// There is no need to set it manually
|
||||
//
|
||||
void setChunkCount(int chunks);
|
||||
bool hasChunkCount() const;
|
||||
const int & chunkCount() const;
|
||||
int & chunkCount();
|
||||
|
||||
|
||||
//
|
||||
// for multipart files, return whether the file has a view string attribute
|
||||
// (for the deprecated single part multiview format EXR, see ImfMultiView.h)
|
||||
//
|
||||
void setView(const string & view);
|
||||
bool hasView() const;
|
||||
string & view();
|
||||
const string & view() 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,
|
||||
bool isMultipartFile = 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);
|
||||
|
||||
//
|
||||
// Check if the header reads nothing.
|
||||
//
|
||||
bool readsNothing();
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// 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 (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
|
||||
bool isTiled = false) const;
|
||||
|
||||
void readFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is,
|
||||
int &version);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
AttributeMap _map;
|
||||
|
||||
bool _readsNothing;
|
||||
};
|
||||
|
||||
|
||||
//----------
|
||||
// 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.
|
||||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
IMF_EXPORT 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_NAMESPACE::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_NAMESPACE::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());
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
1114
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHuf.cpp
Normal file
1114
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHuf.cpp
Normal file
File diff suppressed because it is too large
Load Diff
82
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHuf.h
Normal file
82
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfHuf.h
Normal file
@@ -0,0 +1,82 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
#include "ImfExport.h"
|
||||
#include "ImfNamespace.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).
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
IMF_EXPORT
|
||||
int
|
||||
hufCompress (const unsigned short raw[/*nRaw*/],
|
||||
int nRaw,
|
||||
char compressed[/*2 * nRaw + 65536*/]);
|
||||
|
||||
IMF_EXPORT
|
||||
void
|
||||
hufUncompress (const char compressed[/*nCompressed*/],
|
||||
int nCompressed,
|
||||
unsigned short raw[/*nRaw*/],
|
||||
int nRaw);
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
110
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfIO.cpp
Normal file
110
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfIO.cpp
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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Low-level file input and output for OpenEXR.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfIO.h>
|
||||
#include "Iex.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
IStream::IStream (const char fileName[]): _fileName (fileName)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
IStream::~IStream ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
IStream::isMemoryMapped () const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
IStream::readMemoryMapped (int n)
|
||||
{
|
||||
throw IEX_NAMESPACE::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();
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
255
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfIO.h
Normal file
255
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfIO.h
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_IO_H
|
||||
#define INCLUDED_IMF_IO_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Low-level file input and output for OpenEXR.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImfInt64.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// class IStream -- an abstract base class for input streams.
|
||||
//-----------------------------------------------------------
|
||||
|
||||
class IMF_EXPORT 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 IMF_EXPORT 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;
|
||||
}
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
928
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputFile.cpp
Normal file
928
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputFile.cpp
Normal file
@@ -0,0 +1,928 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfPartType.h"
|
||||
#include "ImfInputPartData.h"
|
||||
#include "ImfMultiPartInputFile.h"
|
||||
|
||||
#include <ImfCompositeDeepScanLine.h>
|
||||
#include <ImfDeepScanLineInputFile.h>
|
||||
|
||||
#include "ImathFun.h"
|
||||
#include "IlmThreadMutex.h"
|
||||
#include "Iex.h"
|
||||
#include "half.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
|
||||
using IMATH_NAMESPACE::Box2i;
|
||||
using IMATH_NAMESPACE::divp;
|
||||
using IMATH_NAMESPACE::modp;
|
||||
using ILMTHREAD_NAMESPACE::Mutex;
|
||||
using ILMTHREAD_NAMESPACE::Lock;
|
||||
|
||||
|
||||
//
|
||||
// Struct InputFile::Data stores things that will be
|
||||
// needed between calls to readPixels
|
||||
//
|
||||
|
||||
struct InputFile::Data : public Mutex
|
||||
{
|
||||
Header header;
|
||||
int version;
|
||||
bool isTiled;
|
||||
|
||||
TiledInputFile * tFile;
|
||||
ScanLineInputFile * sFile;
|
||||
DeepScanLineInputFile * dsFile;
|
||||
|
||||
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;
|
||||
CompositeDeepScanLine * compositor; // for loading deep files
|
||||
|
||||
int cachedTileY;
|
||||
int offset;
|
||||
|
||||
int numThreads;
|
||||
|
||||
int partNumber;
|
||||
InputPartData* part;
|
||||
|
||||
bool multiPartBackwardSupport;
|
||||
MultiPartInputFile* multiPartFile;
|
||||
InputStreamMutex * _streamData;
|
||||
bool _deleteStream;
|
||||
|
||||
Data (int numThreads);
|
||||
~Data ();
|
||||
|
||||
void deleteCachedBuffer();
|
||||
};
|
||||
|
||||
|
||||
InputFile::Data::Data (int numThreads):
|
||||
isTiled (false),
|
||||
tFile (0),
|
||||
sFile (0),
|
||||
dsFile(0),
|
||||
cachedBuffer (0),
|
||||
compositor(0),
|
||||
cachedTileY (-1),
|
||||
numThreads (numThreads),
|
||||
partNumber (-1),
|
||||
part(NULL),
|
||||
multiPartBackwardSupport (false),
|
||||
multiPartFile (0),
|
||||
_streamData(0),
|
||||
_deleteStream(false)
|
||||
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
InputFile::Data::~Data ()
|
||||
{
|
||||
if (tFile)
|
||||
delete tFile;
|
||||
if (sFile)
|
||||
delete sFile;
|
||||
if (dsFile)
|
||||
delete dsFile;
|
||||
if (compositor)
|
||||
delete compositor;
|
||||
|
||||
deleteCachedBuffer();
|
||||
|
||||
if (multiPartBackwardSupport && multiPartFile)
|
||||
delete multiPartFile;
|
||||
}
|
||||
|
||||
|
||||
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 OPENEXR_IMF_INTERNAL_NAMESPACE::UINT:
|
||||
|
||||
delete [] (((unsigned int *)s.base) + offset);
|
||||
break;
|
||||
|
||||
case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF:
|
||||
|
||||
delete [] ((half *)s.base + offset);
|
||||
break;
|
||||
|
||||
case OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT:
|
||||
|
||||
delete [] (((float *)s.base) + offset);
|
||||
break;
|
||||
case NUM_PIXELTYPES :
|
||||
throw(IEX_NAMESPACE::ArgExc("Invalid pixel type"));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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_NAMESPACE::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 (int 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 (numThreads))
|
||||
{
|
||||
_data->_streamData = NULL;
|
||||
_data->_deleteStream=true;
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::IStream* is = 0;
|
||||
try
|
||||
{
|
||||
is = new StdIFStream (fileName);
|
||||
readMagicNumberAndVersionField(*is, _data->version);
|
||||
|
||||
//
|
||||
// compatibility to read multipart file.
|
||||
//
|
||||
if (isMultiPart(_data->version))
|
||||
{
|
||||
compatibilityInitialize(*is);
|
||||
}
|
||||
else
|
||||
{
|
||||
_data->_streamData = new InputStreamMutex();
|
||||
_data->_streamData->is = is;
|
||||
_data->header.readFrom (*_data->_streamData->is, _data->version);
|
||||
|
||||
// fix type attribute in single part regular image types
|
||||
// (may be wrong if an old version of OpenEXR converts
|
||||
// a tiled image to scanline or vice versa)
|
||||
if(!isNonImage(_data->version) &&
|
||||
!isMultiPart(_data->version) &&
|
||||
_data->header.hasType())
|
||||
{
|
||||
_data->header.setType(isTiled(_data->version) ? TILEDIMAGE : SCANLINEIMAGE);
|
||||
}
|
||||
|
||||
_data->header.sanityCheck (isTiled (_data->version));
|
||||
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
catch (IEX_NAMESPACE::BaseExc &e)
|
||||
{
|
||||
if (is) delete is;
|
||||
|
||||
if ( _data && !_data->multiPartBackwardSupport && _data->_streamData)
|
||||
{
|
||||
delete _data->_streamData;
|
||||
_data->_streamData=NULL;
|
||||
}
|
||||
|
||||
if (_data) delete _data;
|
||||
_data=NULL;
|
||||
|
||||
REPLACE_EXC (e, "Cannot read image file "
|
||||
"\"" << fileName << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (is) delete is;
|
||||
if (_data && !_data->multiPartBackwardSupport && _data->_streamData)
|
||||
{
|
||||
delete _data->_streamData;
|
||||
}
|
||||
if (_data) delete _data;
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InputFile::InputFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, int numThreads):
|
||||
_data (new Data (numThreads))
|
||||
{
|
||||
_data->_streamData=NULL;
|
||||
_data->_deleteStream=false;
|
||||
try
|
||||
{
|
||||
readMagicNumberAndVersionField(is, _data->version);
|
||||
|
||||
//
|
||||
// Backward compatibility to read multpart file.
|
||||
//
|
||||
if (isMultiPart(_data->version))
|
||||
{
|
||||
compatibilityInitialize(is);
|
||||
}
|
||||
else
|
||||
{
|
||||
_data->_streamData = new InputStreamMutex();
|
||||
_data->_streamData->is = &is;
|
||||
_data->header.readFrom (*_data->_streamData->is, _data->version);
|
||||
|
||||
// fix type attribute in single part regular image types
|
||||
// (may be wrong if an old version of OpenEXR converts
|
||||
// a tiled image to scanline or vice versa)
|
||||
if(!isNonImage(_data->version) &&
|
||||
!isMultiPart(_data->version) &&
|
||||
_data->header.hasType())
|
||||
{
|
||||
_data->header.setType(isTiled(_data->version) ? TILEDIMAGE : SCANLINEIMAGE);
|
||||
}
|
||||
|
||||
_data->header.sanityCheck (isTiled (_data->version));
|
||||
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
catch (IEX_NAMESPACE::BaseExc &e)
|
||||
{
|
||||
if (_data && !_data->multiPartBackwardSupport && _data->_streamData) delete _data->_streamData;
|
||||
if (_data) delete _data;
|
||||
_data=NULL;
|
||||
|
||||
REPLACE_EXC (e, "Cannot read image file "
|
||||
"\"" << is.fileName() << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (_data && !_data->multiPartBackwardSupport && _data->_streamData) delete _data->_streamData;
|
||||
if (_data) delete _data;
|
||||
_data=NULL;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InputFile::InputFile (InputPartData* part) :
|
||||
_data (new Data (part->numThreads))
|
||||
{
|
||||
_data->_deleteStream=false;
|
||||
multiPartInitialize (part);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::compatibilityInitialize (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is)
|
||||
{
|
||||
is.seekg(0);
|
||||
|
||||
//
|
||||
// Construct a MultiPartInputFile, initialize InputFile
|
||||
// with the part 0 data.
|
||||
// (TODO) may want to have a way to set the reconstruction flag.
|
||||
//
|
||||
_data->multiPartBackwardSupport = true;
|
||||
_data->multiPartFile = new MultiPartInputFile(is, _data->numThreads);
|
||||
InputPartData* part = _data->multiPartFile->getPart(0);
|
||||
|
||||
multiPartInitialize (part);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::multiPartInitialize (InputPartData* part)
|
||||
{
|
||||
_data->_streamData = part->mutex;
|
||||
_data->version = part->version;
|
||||
_data->header = part->header;
|
||||
_data->partNumber = part->partNumber;
|
||||
_data->part = part;
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::initialize ()
|
||||
{
|
||||
if (!_data->part)
|
||||
{
|
||||
if(_data->header.hasType() && _data->header.type()==DEEPSCANLINE)
|
||||
{
|
||||
_data->isTiled=false;
|
||||
const Box2i &dataWindow = _data->header.dataWindow();
|
||||
_data->minY = dataWindow.min.y;
|
||||
_data->maxY = dataWindow.max.y;
|
||||
|
||||
_data->dsFile = new DeepScanLineInputFile (_data->header,
|
||||
_data->_streamData->is,
|
||||
_data->version,
|
||||
_data->numThreads);
|
||||
_data->compositor = new CompositeDeepScanLine;
|
||||
_data->compositor->addSource(_data->dsFile);
|
||||
}
|
||||
|
||||
else if (isTiled (_data->version))
|
||||
{
|
||||
_data->isTiled = true;
|
||||
_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->_streamData->is,
|
||||
_data->version,
|
||||
_data->numThreads);
|
||||
}
|
||||
|
||||
else if(!_data->header.hasType() || _data->header.type()==SCANLINEIMAGE)
|
||||
{
|
||||
_data->sFile = new ScanLineInputFile (_data->header,
|
||||
_data->_streamData->is,
|
||||
_data->numThreads);
|
||||
}else{
|
||||
// type set but not recognised
|
||||
|
||||
THROW(IEX_NAMESPACE::ArgExc, "InputFile cannot handle parts of type " << _data->header.type());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_data->header.hasType() && _data->header.type()==DEEPSCANLINE)
|
||||
{
|
||||
_data->isTiled=false;
|
||||
const Box2i &dataWindow = _data->header.dataWindow();
|
||||
_data->minY = dataWindow.min.y;
|
||||
_data->maxY = dataWindow.max.y;
|
||||
|
||||
_data->dsFile = new DeepScanLineInputFile (_data->part);
|
||||
_data->compositor = new CompositeDeepScanLine;
|
||||
_data->compositor->addSource(_data->dsFile);
|
||||
}
|
||||
else if (isTiled (_data->header.type()))
|
||||
{
|
||||
_data->isTiled = true;
|
||||
_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->part);
|
||||
}
|
||||
else if(!_data->header.hasType() || _data->header.type()==SCANLINEIMAGE)
|
||||
{
|
||||
_data->sFile = new ScanLineInputFile (_data->part);
|
||||
}else{
|
||||
THROW(IEX_NAMESPACE::ArgExc, "InputFile cannot handle parts of type " << _data->header.type());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
InputFile::~InputFile ()
|
||||
{
|
||||
if (_data->_deleteStream)
|
||||
delete _data->_streamData->is;
|
||||
|
||||
// unless this file was opened via the multipart API,
|
||||
// delete the streamData object too
|
||||
if (_data->partNumber==-1 && _data->_streamData)
|
||||
delete _data->_streamData;
|
||||
|
||||
if (_data) delete _data;
|
||||
}
|
||||
|
||||
const char *
|
||||
InputFile::fileName () const
|
||||
{
|
||||
return _data->_streamData->is->fileName();
|
||||
}
|
||||
|
||||
|
||||
const Header &
|
||||
InputFile::header () const
|
||||
{
|
||||
return _data->header;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
InputFile::version () const
|
||||
{
|
||||
return _data->version;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
|
||||
{
|
||||
if (_data->isTiled)
|
||||
{
|
||||
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 OPENEXR_IMF_INTERNAL_NAMESPACE::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 OPENEXR_IMF_INTERNAL_NAMESPACE::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 OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT:
|
||||
|
||||
_data->cachedBuffer->insert
|
||||
(k.name(),
|
||||
Slice (OPENEXR_IMF_INTERNAL_NAMESPACE::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_NAMESPACE::ArgExc ("Unknown pixel data type.");
|
||||
}
|
||||
}
|
||||
|
||||
_data->tFile->setFrameBuffer (*_data->cachedBuffer);
|
||||
}
|
||||
|
||||
_data->tFileBuffer = frameBuffer;
|
||||
}
|
||||
else if(_data->compositor)
|
||||
{
|
||||
_data->compositor->setFrameBuffer(frameBuffer);
|
||||
}else {
|
||||
_data->sFile->setFrameBuffer(frameBuffer);
|
||||
_data->tFileBuffer = frameBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const FrameBuffer &
|
||||
InputFile::frameBuffer () const
|
||||
{
|
||||
if(_data->compositor)
|
||||
{
|
||||
return _data->compositor->frameBuffer();
|
||||
}
|
||||
else if(_data->isTiled)
|
||||
{
|
||||
Lock lock (*_data);
|
||||
return _data->tFileBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _data->sFile->frameBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
InputFile::isComplete () const
|
||||
{
|
||||
if (_data->dsFile)
|
||||
return _data->dsFile->isComplete();
|
||||
else if (_data->isTiled)
|
||||
return _data->tFile->isComplete();
|
||||
else
|
||||
return _data->sFile->isComplete();
|
||||
}
|
||||
|
||||
bool
|
||||
InputFile::isOptimizationEnabled() const
|
||||
{
|
||||
if(_data->sFile)
|
||||
{
|
||||
return _data->sFile->isOptimizationEnabled();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputFile::readPixels (int scanLine1, int scanLine2)
|
||||
{
|
||||
if (_data->compositor)
|
||||
{
|
||||
_data->compositor->readPixels(scanLine1,scanLine2);
|
||||
}
|
||||
else if (_data->isTiled)
|
||||
{
|
||||
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 (_data->dsFile)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc ("Tried to read a raw scanline "
|
||||
"from a deep image.");
|
||||
}
|
||||
|
||||
else if (_data->isTiled)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc ("Tried to read a raw scanline "
|
||||
"from a tiled image.");
|
||||
}
|
||||
|
||||
_data->sFile->rawPixelData (firstScanLine, pixelData, pixelDataSize);
|
||||
}
|
||||
catch (IEX_NAMESPACE::BaseExc &e)
|
||||
{
|
||||
REPLACE_EXC (e, "Error reading pixel data from image "
|
||||
"file \"" << fileName() << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
InputFile::rawPixelDataToBuffer (int scanLine,
|
||||
char *pixelData,
|
||||
int &pixelDataSize) const
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_data->dsFile)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc ("Tried to read a raw scanline "
|
||||
"from a deep image.");
|
||||
}
|
||||
|
||||
else if (_data->isTiled)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc ("Tried to read a raw scanline "
|
||||
"from a tiled image.");
|
||||
}
|
||||
|
||||
_data->sFile->rawPixelDataToBuffer(scanLine, pixelData, pixelDataSize);
|
||||
}
|
||||
catch (IEX_NAMESPACE::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 (!_data->isTiled)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc ("Tried to read a raw tile "
|
||||
"from a scanline-based image.");
|
||||
}
|
||||
|
||||
_data->tFile->rawTileData (dx, dy, lx, ly, pixelData, pixelDataSize);
|
||||
}
|
||||
catch (IEX_NAMESPACE::BaseExc &e)
|
||||
{
|
||||
REPLACE_EXC (e, "Error reading tile data from image "
|
||||
"file \"" << fileName() << "\". " << e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiledInputFile*
|
||||
InputFile::tFile()
|
||||
{
|
||||
if (!_data->isTiled)
|
||||
{
|
||||
throw IEX_NAMESPACE::ArgExc ("Cannot get a TiledInputFile pointer "
|
||||
"from an InputFile that is not tiled.");
|
||||
}
|
||||
|
||||
return _data->tFile;
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
263
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputFile.h
Normal file
263
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputFile.h
Normal file
@@ -0,0 +1,263 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "ImfThreading.h"
|
||||
#include "ImfGenericInputFile.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
class IMF_EXPORT InputFile : public GenericInputFile
|
||||
{
|
||||
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 (OPENEXR_IMF_INTERNAL_NAMESPACE::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;
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Check if SSE optimization is enabled
|
||||
//
|
||||
// Call after setFrameBuffer() to query whether optimized file decoding
|
||||
// is available - decode times will be faster if returns true
|
||||
//
|
||||
// Optimization depends on:
|
||||
// the file type (only scanline data is supported),
|
||||
// the framebuffer channels (RGB/RGBA mono or stereo)
|
||||
// the framebuffer channel types (all channels half-float format only)
|
||||
// the file channels (RGB/RGBA mono or stereo)
|
||||
// the file channel types (all channel half-float format only)
|
||||
// whether SSE2 instruction support was detected at compile time
|
||||
//
|
||||
// Calling isOptimizationEnabled before setFrameBuffer will throw an exception
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
bool isOptimizationEnabled () 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 scanline's worth of raw pixel data
|
||||
// from the file, without uncompressing it, and
|
||||
// store in an external buffer, pixelData.
|
||||
// pixelData should be pre-allocated with space
|
||||
// for pixelDataSize chars.
|
||||
//
|
||||
// This function can be used to separate the
|
||||
// reading of a raw scan line from the
|
||||
// decompression of that scan line, for
|
||||
// example to allow multiple scan lines to be
|
||||
// decompressed in parallel by an application's
|
||||
// own threads, where it is not convenient to
|
||||
// use the threading within the library.
|
||||
//----------------------------------------------
|
||||
|
||||
void rawPixelDataToBuffer (int scanLine,
|
||||
char *pixelData,
|
||||
int &pixelDataSize) const;
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// 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 (InputPartData* part);
|
||||
InputFile (const InputFile &); // not implemented
|
||||
InputFile & operator = (const InputFile &); // not implemented
|
||||
|
||||
void initialize ();
|
||||
void multiPartInitialize(InputPartData* part);
|
||||
void compatibilityInitialize(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is);
|
||||
TiledInputFile * tFile ();
|
||||
|
||||
friend void TiledOutputFile::copyPixels (InputFile &);
|
||||
|
||||
Data * _data;
|
||||
|
||||
|
||||
friend class MultiPartInputFile;
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif
|
||||
122
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPart.cpp
Normal file
122
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPart.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfInputPart.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
#include "ImfMultiPartInputFile.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
InputPart::InputPart(MultiPartInputFile& multiPartFile, int partNumber)
|
||||
{
|
||||
file = multiPartFile.getInputPart<InputFile>(partNumber);
|
||||
}
|
||||
|
||||
const char *
|
||||
InputPart::fileName () const
|
||||
{
|
||||
return file->fileName();
|
||||
}
|
||||
|
||||
const Header &
|
||||
InputPart::header () const
|
||||
{
|
||||
return file->header();
|
||||
}
|
||||
|
||||
int
|
||||
InputPart::version () const
|
||||
{
|
||||
return file->version();
|
||||
}
|
||||
|
||||
void
|
||||
InputPart::setFrameBuffer (const FrameBuffer &frameBuffer)
|
||||
{
|
||||
file->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
|
||||
const FrameBuffer &
|
||||
InputPart::frameBuffer () const
|
||||
{
|
||||
return file->frameBuffer();
|
||||
}
|
||||
|
||||
bool
|
||||
InputPart::isComplete () const
|
||||
{
|
||||
return file->isComplete();
|
||||
}
|
||||
|
||||
bool
|
||||
InputPart::isOptimizationEnabled() const
|
||||
{
|
||||
return file->isOptimizationEnabled();
|
||||
}
|
||||
|
||||
void
|
||||
InputPart::readPixels (int scanLine1, int scanLine2)
|
||||
{
|
||||
file->readPixels(scanLine1, scanLine2);
|
||||
}
|
||||
|
||||
void
|
||||
InputPart::readPixels (int scanLine)
|
||||
{
|
||||
file->readPixels(scanLine);
|
||||
}
|
||||
|
||||
void
|
||||
InputPart::rawPixelData (int firstScanLine, const char *&pixelData, int &pixelDataSize)
|
||||
{
|
||||
file->rawPixelData(firstScanLine, pixelData, pixelDataSize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputPart::rawPixelDataToBuffer (int scanLine, char *pixelData, int &pixelDataSize) const
|
||||
{
|
||||
file->rawPixelDataToBuffer(scanLine, pixelData, pixelDataSize);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InputPart::rawTileData (int &dx, int &dy, int &lx, int &ly,
|
||||
const char *&pixelData, int &pixelDataSize)
|
||||
{
|
||||
file->rawTileData(dx, dy, lx, ly, pixelData, pixelDataSize);
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
91
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPart.h
Normal file
91
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPart.h
Normal file
@@ -0,0 +1,91 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFINPUTPART_H_
|
||||
#define IMFINPUTPART_H_
|
||||
|
||||
#include "ImfInputFile.h"
|
||||
#include "ImfOutputPart.h"
|
||||
#include "ImfForward.h"
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImfExport.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// class InputPart:
|
||||
//
|
||||
// Same interface as InputFile. Please refer to InputFile.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
class IMF_EXPORT InputPart
|
||||
{
|
||||
public:
|
||||
InputPart(MultiPartInputFile& multiPartFile, int partNumber);
|
||||
|
||||
const char * fileName () const;
|
||||
const Header & header () const;
|
||||
int version () const;
|
||||
void setFrameBuffer (const FrameBuffer &frameBuffer);
|
||||
const FrameBuffer & frameBuffer () const;
|
||||
bool isComplete () const;
|
||||
bool isOptimizationEnabled () const;
|
||||
void readPixels (int scanLine1, int scanLine2);
|
||||
void readPixels (int scanLine);
|
||||
void rawPixelData (int firstScanLine,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
|
||||
void rawPixelDataToBuffer (int scanLine,
|
||||
char *pixelData,
|
||||
int &pixelDataSize) const;
|
||||
|
||||
|
||||
void rawTileData (int &dx, int &dy,
|
||||
int &lx, int &ly,
|
||||
const char *&pixelData,
|
||||
int &pixelDataSize);
|
||||
|
||||
private:
|
||||
InputFile* file;
|
||||
// for internal use - give OutputFile and TiledOutputFile access to file for copyPixels
|
||||
friend void OutputFile::copyPixels(InputPart&);
|
||||
friend void TiledOutputFile::copyPixels(InputPart&);
|
||||
|
||||
};
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
#endif /* IMFINPUTPART_H_ */
|
||||
51
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPartData.cpp
Normal file
51
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPartData.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 "ImfInputPartData.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
|
||||
|
||||
InputPartData::InputPartData(InputStreamMutex* mutex, const Header &header,
|
||||
int partNumber, int numThreads, int version):
|
||||
header(header),
|
||||
numThreads(numThreads),
|
||||
partNumber(partNumber),
|
||||
version(version),
|
||||
mutex(mutex),
|
||||
completed(false)
|
||||
{
|
||||
}
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT
|
||||
69
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPartData.h
Normal file
69
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputPartData.h
Normal file
@@ -0,0 +1,69 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFINPUTPARTDATA_H_
|
||||
#define IMFINPUTPARTDATA_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ImfInputStreamMutex.h"
|
||||
#include "ImfHeader.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
|
||||
struct InputPartData
|
||||
{
|
||||
Header header;
|
||||
int numThreads;
|
||||
int partNumber;
|
||||
int version;
|
||||
InputStreamMutex* mutex;
|
||||
std::vector<Int64> chunkOffsets;
|
||||
bool completed;
|
||||
|
||||
InputPartData(InputStreamMutex* mutex, const Header &header,
|
||||
int partNumber, int numThreads, int version);
|
||||
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IMFINPUTPARTDATA_H_ */
|
||||
68
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputStreamMutex.h
Normal file
68
cs440-acg/ext/openexr/OpenEXR/IlmImf/ImfInputStreamMutex.h
Normal file
@@ -0,0 +1,68 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2011, 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 IMFINPUTSTREAMMUTEX_H_
|
||||
#define IMFINPUTSTREAMMUTEX_H_
|
||||
|
||||
#include "ImfIO.h"
|
||||
#include "IlmThreadMutex.h"
|
||||
#include "ImfNamespace.h"
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
|
||||
|
||||
using ILMTHREAD_NAMESPACE::Mutex;
|
||||
|
||||
//
|
||||
// Used to wrap OPENEXR_IMF_INTERNAL_NAMESPACE::IStream as a Mutex.
|
||||
//
|
||||
struct InputStreamMutex : public Mutex
|
||||
{
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::IStream* is;
|
||||
Int64 currentPosition;
|
||||
|
||||
InputStreamMutex()
|
||||
{
|
||||
is = 0;
|
||||
currentPosition = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* IMFINPUTSTREAMMUTEX_H_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user