Disabled external gits
This commit is contained in:
16
cs440-acg/ext/openexr/OpenEXR_Viewers/.cvsignore
Normal file
16
cs440-acg/ext/openexr/OpenEXR_Viewers/.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
|
||||
12
cs440-acg/ext/openexr/OpenEXR_Viewers/AUTHORS
Normal file
12
cs440-acg/ext/openexr/OpenEXR_Viewers/AUTHORS
Normal file
@@ -0,0 +1,12 @@
|
||||
Developers:
|
||||
-----------
|
||||
|
||||
Florian Kainz <kainz@ilm.com>
|
||||
Drew Hess <dhess@ilm.com>
|
||||
|
||||
|
||||
Win32 build system:
|
||||
-------------------
|
||||
|
||||
Kimball Thurston
|
||||
|
||||
75
cs440-acg/ext/openexr/OpenEXR_Viewers/CMakeLists.txt
Normal file
75
cs440-acg/ext/openexr/OpenEXR_Viewers/CMakeLists.txt
Normal file
@@ -0,0 +1,75 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
PROJECT (openexr_viewers)
|
||||
|
||||
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})
|
||||
|
||||
|
||||
# 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 )
|
||||
|
||||
OPTION (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 )
|
||||
|
||||
SET (FLTK_SKIP_FLUID 1)
|
||||
FIND_PACKAGE (OpenGL REQUIRED)
|
||||
FIND_PACKAGE (FLTK)
|
||||
FIND_PACKAGE (GLUT)
|
||||
FIND_PACKAGE (Cg)
|
||||
|
||||
IF (NOT WIN32)
|
||||
SET ( PTHREAD_LIB pthread )
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES ( ${OPENEXR_PACKAGE_PREFIX}/include/OpenEXR )
|
||||
LINK_DIRECTORIES ( ${OPENEXR_PACKAGE_PREFIX}/lib )
|
||||
MESSAGE ( "OPENEXR_PACKAGE_PREFIX = " ${OPENEXR_PACKAGE_PREFIX})
|
||||
|
||||
SET (OPENEXR_LIBSUFFIX "")
|
||||
SET (ILMBASE_LIBSUFFIX "")
|
||||
IF (NAMESPACE_VERSIONING)
|
||||
SET ( OPENEXR_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
|
||||
# assume same NAMESPACE_VERSION setting for IlmBase for now
|
||||
SET ( ILMBASE_LIBSUFFIX "-${OPENEXR_VERSION_API}" )
|
||||
ENDIF ()
|
||||
|
||||
##########################
|
||||
IF (FLTK_FOUND)
|
||||
ADD_SUBDIRECTORY ( exrdisplay )
|
||||
ENDIF ()
|
||||
|
||||
IF (CG_FOUND AND GLUT_FOUND)
|
||||
ADD_SUBDIRECTORY ( playexr )
|
||||
INCLUDE_DIRECTORIES ( playexr )
|
||||
ENDIF ()
|
||||
|
||||
##########################
|
||||
# Installation
|
||||
##########################
|
||||
|
||||
# Documentation
|
||||
INSTALL ( FILES
|
||||
doc/OpenEXRViewers.pdf
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/share/doc/OpenEXR-${OPENEXR_VERSION}
|
||||
)
|
||||
|
||||
34
cs440-acg/ext/openexr/OpenEXR_Viewers/COPYING
Normal file
34
cs440-acg/ext/openexr/OpenEXR_Viewers/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.
|
||||
|
||||
37
cs440-acg/ext/openexr/OpenEXR_Viewers/ChangeLog
Normal file
37
cs440-acg/ext/openexr/OpenEXR_Viewers/ChangeLog
Normal file
@@ -0,0 +1,37 @@
|
||||
Version 2.0.1
|
||||
* Bumped version to track OpenEXR
|
||||
(Piotr Stanczyk)
|
||||
|
||||
Version 1.0.2:
|
||||
* Added a new -L command-line flag to exrdisplay. The flag
|
||||
specifies which layer in a multi-layer or multi-view image
|
||||
should be displayed on the screen.
|
||||
(Florian Kainz)
|
||||
|
||||
Version 1.0.1:
|
||||
* Removed Windows .suo files from distribution.
|
||||
(Eric Wimmer)
|
||||
|
||||
Version 1.0.0:
|
||||
* Moved some .ctl files from the OpenEXR_Viewers to the
|
||||
OpenEXR_CTL package, changed naming conventions for
|
||||
image channels to match upcoming paper.
|
||||
(Florian Kainz)
|
||||
* Added "look modification transform" support to playexr, exrdisplay.
|
||||
(Florian Kainz)
|
||||
* Installation Tuning:
|
||||
- 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 0.9.0:
|
||||
* Initial release of this code as a separate package.
|
||||
Previously the exrdisplay contained in this package
|
||||
was part of version 1.4.0 of OpenEXR. The playexr
|
||||
program is new.
|
||||
* New build scripts for Linux/Unix
|
||||
(Andrew Kunz)
|
||||
* New Windows project files and build scripts
|
||||
(Kimball Thurston)
|
||||
2
cs440-acg/ext/openexr/OpenEXR_Viewers/INSTALL
Normal file
2
cs440-acg/ext/openexr/OpenEXR_Viewers/INSTALL
Normal file
@@ -0,0 +1,2 @@
|
||||
See the README file for instructions on how to build OpenEXR_Viewers from
|
||||
source.
|
||||
34
cs440-acg/ext/openexr/OpenEXR_Viewers/LICENSE
Normal file
34
cs440-acg/ext/openexr/OpenEXR_Viewers/LICENSE
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.
|
||||
|
||||
14
cs440-acg/ext/openexr/OpenEXR_Viewers/Makefile.am
Normal file
14
cs440-acg/ext/openexr/OpenEXR_Viewers/Makefile.am
Normal file
@@ -0,0 +1,14 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
SUBDIRS = playexr exrdisplay doc config
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
$(SUBDIRS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
AUTHORS COPYING ChangeLog INSTALL LICENSE NEWS \
|
||||
README README.CVS README.OSX README.win32 bootstrap
|
||||
|
||||
|
||||
2
cs440-acg/ext/openexr/OpenEXR_Viewers/NEWS
Normal file
2
cs440-acg/ext/openexr/OpenEXR_Viewers/NEWS
Normal file
@@ -0,0 +1,2 @@
|
||||
Version 0.9.0
|
||||
- initial release
|
||||
11
cs440-acg/ext/openexr/OpenEXR_Viewers/OpenEXR_Viewers.pc.in
Normal file
11
cs440-acg/ext/openexr/OpenEXR_Viewers/OpenEXR_Viewers.pc.in
Normal file
@@ -0,0 +1,11 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
OpenEXR_includedir=@includedir@/OpenEXR
|
||||
|
||||
Name: OpenEXR_Viewers
|
||||
Description: OpenEXR Viewers
|
||||
Version: @OPENEXR_VIEWERS_VERSION@
|
||||
Libs: -L${libdir} @OPENEXR_CTL_LDFLAGS@ @OPENEXR_CTL_LIBS@
|
||||
Cflags: @OPENEXR_CTL_CXXFLAGS@
|
||||
95
cs440-acg/ext/openexr/OpenEXR_Viewers/README
Normal file
95
cs440-acg/ext/openexr/OpenEXR_Viewers/README
Normal file
@@ -0,0 +1,95 @@
|
||||
ABOUT THE OPENEXR_VIEWERS LIBRARIES
|
||||
----------------------------
|
||||
|
||||
exrdisplay:
|
||||
|
||||
exrdisplay is a simple still image viewer that optionally applies color
|
||||
transforms to OpenEXR images, using ctl as explained in this document:
|
||||
|
||||
doc/OpenEXRViewers.pdf
|
||||
|
||||
exrdisplay requires FLTK 1.1 or greater and OpenGL.
|
||||
|
||||
playexr:
|
||||
|
||||
playexr is a program that plays back OpenEXR image sequences, optionally
|
||||
with CTL support, applying rendering and display transforms in line with
|
||||
the current discussions at the AMPAS Image Interchange Framework committee
|
||||
(September 2006).
|
||||
|
||||
The playexr directory contains the source code for the playback program,
|
||||
and two sample CTL transforms (one rendering and one display transform).
|
||||
|
||||
playexr requires OpenGL, GLUT and the Cg hardware shading language.
|
||||
|
||||
|
||||
If you have installed the OpenEXR_CTL package, exrdisplay and playexr
|
||||
will automatically be built with CTL support. If you don't have
|
||||
OpenEXR_CTL, the programs will still work, but CTL support will be
|
||||
disabled.
|
||||
|
||||
If you have questions about using the OpenEXR_Viewers package, you
|
||||
may want to join our developer mailing list. See http://www.openexr.com
|
||||
for details.
|
||||
|
||||
|
||||
LICENSE
|
||||
-------
|
||||
|
||||
The OpenEXR_Viewers source code distribution is free software. See the file
|
||||
named COPYING (included in this distribution) for details.
|
||||
|
||||
|
||||
BUILDING OPENEXR_VIEWERS
|
||||
----------------
|
||||
|
||||
Building OpenEXR_Viewers requires the OpenEXR library. CTL support in
|
||||
OpenEXR_Viewers requires the OpenEXR_CTL library.
|
||||
|
||||
If you want to build the 'exrdisplay' image viewer, you'll need FLTK
|
||||
1.1 or higher.
|
||||
|
||||
If you want to buyild the playexr image viewer, you'll need GLUT
|
||||
and the Cg hardware shading language.
|
||||
|
||||
Your OS distribution may already include these libraries, or supply
|
||||
packages for them. That is the preferred way to obtain them for use
|
||||
with OpenEXR. If not, you can obtain the source code for FLTK from:
|
||||
|
||||
http://www.fltk.org
|
||||
|
||||
and you can download the NVIDIA Cg SDK from
|
||||
http://developer.nvidia.com.
|
||||
|
||||
If you're building OpenEXR_VIEWERS on a Windows platform, see README.win32
|
||||
for instructions. The remainder of this file applies only to GNU/Linux or
|
||||
other UNIX-like systems.
|
||||
|
||||
After installing the required libraries, to build OpenEXR_Viewers on
|
||||
GNU/Linux or other UNIX-like systems, do this:
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
unless you obtained OpenEXR_Viewers directly from CVS, in which case you
|
||||
should first read README.CVS.
|
||||
|
||||
If you have the Nvidia Cg SDK and you want to build support for
|
||||
fragment shaders into exrdisplay, specify the path to the SDK using
|
||||
the "--with-cg-prefix" flag. There are some additional compile-time
|
||||
configuration options available; type `./configure --help` for more
|
||||
information.
|
||||
|
||||
See README.OSX for details on building OpenEXR in MacOS X.
|
||||
|
||||
Do `make check` to run the OpenEXR confidence tests. They should all
|
||||
pass; if you find a test that does not pass on your system, please let
|
||||
us know.
|
||||
|
||||
Other UNIX variants haven't been tested, but should be easy to build.
|
||||
Let us know if you're having problems porting OpenEXR to a particular
|
||||
platform.
|
||||
|
||||
All include files needed to use the OpenEXR libraries are installed in the
|
||||
OpenEXR subdirectory of the install prefix, e.g. /usr/local/include/OpenEXR.
|
||||
16
cs440-acg/ext/openexr/OpenEXR_Viewers/README.CVS
Normal file
16
cs440-acg/ext/openexr/OpenEXR_Viewers/README.CVS
Normal file
@@ -0,0 +1,16 @@
|
||||
If you're using OpenEXR_Viewers from CVS, you should run the bootstrap script
|
||||
to create the auto* files. It's a good idea to run this whenever you
|
||||
update OpenEXR from CVS.
|
||||
|
||||
Then run './configure' and make.
|
||||
|
||||
Note that the configure.ac file requires a fairly new version of
|
||||
automake. If you get this error message:
|
||||
|
||||
running aclocal ...
|
||||
aclocal: configure.ac: 142: macro `AM_CFLAGS' not found in library
|
||||
aclocal: configure.ac: 143: macro `AM_CXXFLAGS' not found in library
|
||||
failed!
|
||||
|
||||
you should upgrade your automake to version 1.6 or better.
|
||||
|
||||
18
cs440-acg/ext/openexr/OpenEXR_Viewers/README.OSX
Normal file
18
cs440-acg/ext/openexr/OpenEXR_Viewers/README.OSX
Normal file
@@ -0,0 +1,18 @@
|
||||
OpenEXR_Viewers on MacOS X
|
||||
------------------
|
||||
|
||||
Building OpenEXR_Viewers on MacOS X is just like building it on GNU/Linux.
|
||||
Follow the instructions in the README file under BUILDLING OPENEXR_VIEWERS,
|
||||
but see below re: shared libraries.
|
||||
|
||||
On OS X 10.4, you can build universal binaries by passing
|
||||
'--enable-osx-universal-binaries --disable-dependency-tracking' to the
|
||||
configure script. The default is *not* to build universal binaries.
|
||||
|
||||
|
||||
Known bugs
|
||||
----------
|
||||
|
||||
None.
|
||||
|
||||
|
||||
196
cs440-acg/ext/openexr/OpenEXR_Viewers/README.win32
Normal file
196
cs440-acg/ext/openexr/OpenEXR_Viewers/README.win32
Normal file
@@ -0,0 +1,196 @@
|
||||
OpenEXR_Viewers is one of five software packages that were designed to
|
||||
work together: IlmBase, OpenEXR, OpenEXR_Viewers, CTL and OpenEXR_CTL.
|
||||
OpenEXR_Viewers contains two OpenEXR image viewing programs that can
|
||||
be built with or without support for color rendering via CTL.
|
||||
|
||||
What follows are instructions for building OpenEXR_Viewers with CTL
|
||||
support. To build without CTL support, skip steps 3 and 4.
|
||||
|
||||
A couple of notes before getting started:
|
||||
|
||||
- This is not the only way to do this. This document describes a path
|
||||
that doesn't involve installing libraries into default system paths,
|
||||
but rather, creates a standalone universe.
|
||||
- Some of these steps may be a bit redundant, and will be optimized in
|
||||
the future.
|
||||
- The Debug versions of the libraries and tools are not required if
|
||||
you are not going to be doing any debugging, and can be optionally
|
||||
built.
|
||||
|
||||
The source will build under both Visual Studio versions 7 and 8, and
|
||||
there are separate directories for the corresponding build files. The
|
||||
tag <vc7|8> is used in this document to describe the appropriate folder
|
||||
in the path that corresponds to your the version of Visual Studio.
|
||||
|
||||
The Visual Studio project files assume, and help build out, a directory
|
||||
called "Deploy". In the end, this directory will contain the objects
|
||||
that might then be moved away from the source for general running of the
|
||||
compiled programs. The directory structure at the end of compiling all
|
||||
the related tools looks like this:
|
||||
|
||||
Deploy
|
||||
include
|
||||
lib
|
||||
Debug
|
||||
Release
|
||||
bin
|
||||
Debug
|
||||
Release
|
||||
openexr-cvs (name as desired)
|
||||
IlmBase
|
||||
OpenEXR
|
||||
OpenEXR_Viewers
|
||||
ctl-cvs (name as desired)
|
||||
CTL
|
||||
OpenEXR_CTL
|
||||
fltk
|
||||
FL
|
||||
GL
|
||||
lib
|
||||
nvidia
|
||||
include
|
||||
GL
|
||||
glh
|
||||
lib
|
||||
|
||||
If OpenEXR_Viewers is not being compiled, then fltk and nvidia will
|
||||
not be needed, but that will be covered later.
|
||||
|
||||
Step 1. Compile IlmBase
|
||||
|
||||
a. Point Visual Studio at the .sln file in vc\<vc7|8>\IlmBase in the
|
||||
IlmBase subdirectory
|
||||
|
||||
b. Select the Release configuration and hit Build Solution. This
|
||||
will create the Deploy directory, and copy the relevant parts to it.
|
||||
|
||||
c. If the debug versions are desired, select the Debug configuration
|
||||
and hit Build Solution. This will add the Debug directories to Deploy.
|
||||
|
||||
Step 2. Compile OpenEXR support
|
||||
|
||||
a. Retrieve the zlib binaries. The project files are set up to link
|
||||
against the dll version of zlib, but can easily be changed to link
|
||||
against a static version, or a self-built version if desired.
|
||||
|
||||
1. Go to http://www.zlib.net and download the precompiled DLL
|
||||
version of zlib (as of writing, zlib123-dll.zip)
|
||||
|
||||
2. If you don't wish to put the files into your MS visual studio
|
||||
directories and install the dll into windows\system32:
|
||||
|
||||
a. Put a copy of zlib1.dll into Deploy\bin\Release and
|
||||
Deploy\bin\Debug
|
||||
|
||||
b. Copy the header files into Deploy\include
|
||||
|
||||
c. Copy zdll.lib and zdll.exp into Deploy\lib\Release and
|
||||
Deploy\lib\Debug
|
||||
|
||||
b. Open the Visual Studio project in OpenEXR\vc\<vc7|8>\OpenEXR.
|
||||
|
||||
c. Select the Release configuration and build. The IlmImfTest
|
||||
program runs a confidence test of your build to make sure
|
||||
it is able to work, and may take some time to complete.
|
||||
|
||||
d. Optionally select the Debug configuration and build.
|
||||
|
||||
Step 3. Compile CTL support
|
||||
|
||||
a. Open the Visual Studio project in CTL\vc\<vc7|8>\CTL.
|
||||
|
||||
b. Select the Release configuration and build. The IlmCtlTest
|
||||
program runs a confidence test of your build to make sure it is
|
||||
able to work, and may take some time to complete.
|
||||
|
||||
c. Optionally select the Debug configuration and build.
|
||||
|
||||
Step 4. Compile OpenEXR_CTL support
|
||||
|
||||
a. Open the Visual Studio project in OpenEXR_CTL\vc\<vc7|8>\OpenEXR_CTL.
|
||||
|
||||
b. Select the Release configuration and build.
|
||||
|
||||
c. Optionally select the Debug configuration and build.
|
||||
|
||||
Step 5. Compile OpenEXR_Viewers
|
||||
|
||||
a. Open the appropriate Visual Studio project in
|
||||
OpenEXR_Viewers\vc\<vc7|8>\OpenEXR_Viewers depending on whether or not
|
||||
you want CTL support.
|
||||
|
||||
b. exrdisplay requires fltk to work.
|
||||
|
||||
1. Go to http://www.fltk.org and download fltk 1.1.7
|
||||
|
||||
2. Open its project files and compile using the instructions they
|
||||
provide.
|
||||
|
||||
3. Create the fltk directory at the top level of your directory
|
||||
structure as presented above and copy the FL, GL, and lib folders
|
||||
into the fltk directory
|
||||
|
||||
4. exrdisplay links fltk statically, so no dll is needed.
|
||||
|
||||
c. playexr requires the nvidia cg library as well as glut and glew.
|
||||
|
||||
1. Setup the cg toolkit
|
||||
|
||||
a. Go to http://developer.nvidia.com, the developer section and
|
||||
download the cg toolkit, version 1.5, and install it. The path
|
||||
where you choose to install Cg is referred to by the
|
||||
<Cg install location> tag in the steps below.
|
||||
|
||||
b. During the installation, if the integrate with visual studio
|
||||
option is selected, the header files will be automatically found.
|
||||
Otherwise, copy the directory <Cg install location>\Cg\include\Cg
|
||||
to Deploy\include\Cg
|
||||
|
||||
b. Copy the cg.dll and cgGL.dll from the <Cg install location>\Cg\bin
|
||||
into Deploy\bin\Release and Deploy\bin\Debug, or otherwise make
|
||||
them available (put them in system32, add to path, etc.)
|
||||
|
||||
c. Copy the cg.lib and cgGL.lib from <Cg install location>\Cg\lib
|
||||
into Deploy\lib\Release and Deploy\lib\Debug
|
||||
|
||||
2. Make glut available. This can be done via several mechanisms.
|
||||
See step 4 below.
|
||||
|
||||
3. Make glew available. This can be done via several mechanisms.
|
||||
http://glew.sourceforge.net is the master site for this
|
||||
library. See step 4 below.
|
||||
|
||||
4. nVidia makes both glut and glew available in their SDK package,
|
||||
which is a fairly large download, but provides a wealth of other
|
||||
information on programming for the GPU, and is generally a useful
|
||||
package, so that is the path chosen for this set up.
|
||||
|
||||
a. Go to http://developer.nvidia.com and download version 10 of the
|
||||
SDK and install it. It will prompt you to install the Cg toolkit,
|
||||
but this is not necessary as it was handled in step 1. The path
|
||||
where you choose to install the SDK is referred to by the
|
||||
<SDK install location> tag in the steps below.
|
||||
|
||||
b. Make an nvidia folder at the top level, with an include and
|
||||
lib folder inside it. Inside the lib folder, make Debug and
|
||||
Release folders.
|
||||
|
||||
c. Copy the <SDK install location>\external\include\GL directory into
|
||||
nvidia\include the GL and glh folders into nvidia\include.
|
||||
|
||||
d. Copy the glew headers in <SDK install location>\common\GLEW\include\GL
|
||||
into nvidia\include\GL.
|
||||
|
||||
e. Copy <SDK install location>\common\GLEW\lib\glew32.lib and
|
||||
<SDK install location>\external\lib\glut32.lib into Deploy\bin\Release.
|
||||
|
||||
f. Copy bin\glut32.dll and bin\glew32.dll into Deploy\bin\Release.
|
||||
|
||||
d. Build the Release configuration of the OpenEXR_Viewers.
|
||||
|
||||
e. Build the Debug configuration if desired.
|
||||
|
||||
At this point, the Deploy folder should be fully built out and ready
|
||||
to be used. Both exrdisplay and playexr are meant to be launched from
|
||||
the command line, as they originated as unix commands, so open a command
|
||||
prompt, cd to the Deploy\bin\Release folder and enjoy.
|
||||
61
cs440-acg/ext/openexr/OpenEXR_Viewers/bootstrap
Executable file
61
cs440-acg/ext/openexr/OpenEXR_Viewers/bootstrap
Executable file
@@ -0,0 +1,61 @@
|
||||
#! /bin/sh
|
||||
# If we're on OS X, use glibtoolize instead of toolize when available
|
||||
HOSTTYPE=`uname`
|
||||
if [ "$HOSTTYPE" == "Darwin" ] && $(which glibtoolize > /dev/null 2>&1) ; then
|
||||
LIBTOOLIZE=glibtoolize
|
||||
else
|
||||
LIBTOOLIZE=libtoolize
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
# Check Autoconf version
|
||||
if [ -x `which autoconf` ]; then
|
||||
AC_VER=`autoconf --version | head -n 1 | sed 's/^[^0-9]*//'`
|
||||
AC_VER_MAJOR=`echo $AC_VER | cut -f1 -d'.'`
|
||||
AC_VER_MINOR=`echo $AC_VER | cut -f2 -d'.' | sed 's/[^0-9]*$//'`
|
||||
|
||||
if [ "$AC_VER_MAJOR" -lt "2" ]; then
|
||||
echo "Autoconf 2.13 or greater needed to build configure."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$AC_VER_MINOR" -lt "13" ]; then
|
||||
echo "Autoconf 2.13 or greater needed to build configure."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$AC_VER_MINOR" -lt "50" ]; then
|
||||
if [ ! -e configure.in ]; then
|
||||
ln -s configure.ac configure.in
|
||||
fi
|
||||
echo "If you see some warnings about cross-compiling, don't worry; this is normal."
|
||||
else
|
||||
rm -f configure.in
|
||||
fi
|
||||
else
|
||||
echo autoconf not found. OpenEXR CVS requires autoconf to bootstrap itself.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_cmd() {
|
||||
echo running $* ...
|
||||
if ! $*; then
|
||||
echo failed!
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if /usr/local/share/aclocal exists
|
||||
if [ -d /usr/local/share/aclocal ]; then
|
||||
ACLOCAL_INCLUDE="$ACLOCAL_INCLUDE -I /usr/local/share/aclocal"
|
||||
fi
|
||||
|
||||
run_cmd aclocal -I m4 $ACLOCAL_INCLUDE
|
||||
run_cmd $LIBTOOLIZE --automake --copy
|
||||
run_cmd automake --add-missing --copy
|
||||
run_cmd autoconf
|
||||
echo
|
||||
echo "Now type './configure' to configure OpenEXR_Viewers."
|
||||
echo
|
||||
7
cs440-acg/ext/openexr/OpenEXR_Viewers/config/Makefile.am
Normal file
7
cs440-acg/ext/openexr/OpenEXR_Viewers/config/Makefile.am
Normal file
@@ -0,0 +1,7 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
configincludedir = $(includedir)/OpenEXR
|
||||
|
||||
configinclude_HEADERS = OpenEXR_ViewersConfig.h
|
||||
|
||||
EXTRA_DIST = OpenEXR_ViewersConfig.h.in
|
||||
@@ -0,0 +1,7 @@
|
||||
//
|
||||
// Define and set to 1 if the target system includes the NVIDIA Cg
|
||||
// runtime. The exrdisplay program will use a fragment shader to
|
||||
// accelerate the display of OpenEXR images.
|
||||
//
|
||||
|
||||
#undef HAVE_FRAGMENT_SHADERS
|
||||
291
cs440-acg/ext/openexr/OpenEXR_Viewers/configure.ac
Normal file
291
cs440-acg/ext/openexr/OpenEXR_Viewers/configure.ac
Normal file
@@ -0,0 +1,291 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(OpenEXR_Viewers, 2.2.0)
|
||||
AC_SUBST(OPENEXR_VIEWERS_VERSION, 2.2.0)
|
||||
AC_CANONICAL_HOST
|
||||
AC_CONFIG_SRCDIR(playexr/main.cpp)
|
||||
AM_CONFIG_HEADER(config/OpenEXR_ViewersConfig.h)
|
||||
AM_INIT_AUTOMAKE(1.6.3) dnl Require automake 1.6.3 or better
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
|
||||
LIBTOOL_CURRENT=6
|
||||
LIBTOOL_REVISION=1
|
||||
LIBTOOL_AGE=0
|
||||
LIBTOOL_VERSION=$LIBTOOL_CURRENT:$LIBTOOL_REVISION:$LIBTOOL_AGE
|
||||
AC_SUBST(LIBTOOL_VERSION)
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_CC
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
dnl
|
||||
dnl PKGCONFIG preparations
|
||||
dnl
|
||||
|
||||
if test -z "${PKG_CONFIG_PATH}"; then
|
||||
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
|
||||
fi
|
||||
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
LIB64_IF_EXISTS=""
|
||||
if [[ -e /usr/lib64 ]]; then
|
||||
LIB64_IF_EXISTS="-L/usr/lib64"
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT([LIB64_IF_EXISTS ... $LIB64_IF_EXISTS])
|
||||
|
||||
|
||||
dnl
|
||||
dnl get ccflags and libs from openexr and ctl packages
|
||||
dnl
|
||||
|
||||
dnl
|
||||
dnl get ccflags and libs from other packages in use and check
|
||||
dnl whether test programs compile.
|
||||
dnl OpenEXR is required. If OpenEXR_CTL is optional. If it is present,
|
||||
dnl the viewer will use ctl. The compile flag HAVE_CTL_INTERPRETER is set
|
||||
dnl to 1 if ctl is in use.
|
||||
|
||||
dnl
|
||||
dnl check openexr
|
||||
dnl
|
||||
AM_PATH_PKGCONFIG(
|
||||
[OPENEXR_CXXFLAGS],
|
||||
[OPENEXR_LDFLAGS],
|
||||
[OPENEXR_LIBS],
|
||||
[OpenEXR],
|
||||
[OpenEXR],
|
||||
[$LIB64_IF_EXISTS -L/usr/local/lib],
|
||||
[-lIlmImf -lImath -lIex -lHalf -lz -lpthread],
|
||||
[openexr-prefix])
|
||||
|
||||
dnl
|
||||
dnl check optional OpenexrCTL (see comment above)
|
||||
dnl
|
||||
AM_PATH_PKGCONFIG(
|
||||
[OPENEXR_CTL_CXXFLAGS],
|
||||
[OPENEXR_CTL_LDFLAGS],
|
||||
[OPENEXR_CTL_LIBS],
|
||||
[OpenEXR_CTL],
|
||||
[OpenEXR CTL],
|
||||
[$LIB64_IF_EXISTS -L/usr/local/lib],
|
||||
[-lIlmImfCtl -lIlmImf -lz -lImath -lHalf -lIex -lIlmThread -lpthread -lIlmCtlSimd -lIlmCtlMath -lIlmCtl],
|
||||
[openexrctl-prefix])
|
||||
|
||||
|
||||
dnl --enable-threading
|
||||
AC_ARG_ENABLE(threading,
|
||||
AC_HELP_STRING([--enable-threading],
|
||||
[enable multi-threading [[default=yes]]]),
|
||||
[multithread="${enableval}"], [multithread=yes])
|
||||
|
||||
if test x$PKG_CONFIG == xno && test "x${multithread}" != xno ; then
|
||||
ACX_PTHREAD(
|
||||
[
|
||||
AC_DEFINE(HAVE_PTHREAD)
|
||||
OPENEXR_LIBS="$PTHREAD_LIBS $OPENEXR_LIBS"
|
||||
OPENEXR_CXXFLAGS="$OPENEXR_CXXFLAGS $PTHREAD_CFLAGS"
|
||||
OPENEXR_CTL_LIBS="$PTHREAD_LIBS $OPENEXR_CTL_LIBS"
|
||||
OPENEXR_CTL_CXXFLAGS="$OPENEXR_CTL_CXXFLAGS $PTHREAD_CFLAGS"
|
||||
CC="$PTHREAD_CC"
|
||||
|
||||
AM_POSIX_SEM()
|
||||
],
|
||||
[AC_MSG_ERROR([POSIX thread support required])])
|
||||
AC_MSG_NOTICE([multithread true, LIBS = $LIBS, CC = $CC, CXXFLAGS = $CXXFLAGS])
|
||||
fi
|
||||
|
||||
|
||||
AM_COMPILELINKRUN(
|
||||
[OpenEXR],
|
||||
[openexrtest],
|
||||
[$OPENEXR_CXXFLAGS],
|
||||
[$OPENEXR_LDFLAGS],
|
||||
[$OPENEXR_LIBS],[[
|
||||
#include <stdlib.h>
|
||||
#include <ImfTestFile.h>
|
||||
#include <ImfNamespace.h>
|
||||
]],
|
||||
[[OPENEXR_IMF_NAMESPACE::isOpenExrFile("notExist");]],
|
||||
AC_MSG_RESULT([Compiled and ran OpenEXR test program.]),
|
||||
AC_MSG_ERROR([Could not compile OpenEXR test program.]))
|
||||
|
||||
|
||||
|
||||
AM_COMPILELINKRUN(
|
||||
[OpenEXR_CTL],
|
||||
[openexrctltest],
|
||||
[$OPENEXR_CTL_CXXFLAGS],
|
||||
[$OPENEXR_CTL_LDFLAGS],
|
||||
[$OPENEXR_CTL_LIBS],[[
|
||||
#include <ImfCtlApplyTransforms.h>
|
||||
#include <CtlSimdInterpreter.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImathBox.h>
|
||||
#include <ImfNamespace.h>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
using namespace Ctl;
|
||||
using namespace OPENEXR_IMF_NAMESPACE;
|
||||
using namespace Imath;
|
||||
]],
|
||||
[[
|
||||
SimdInterpreter interpreter;
|
||||
std::vector<std::string> transformNames;
|
||||
Box2i transformWindow (V2i (0, 0), V2i (0, 0));
|
||||
Header envHeader;
|
||||
Header inHeader;
|
||||
Header outHeader;
|
||||
FrameBuffer inFb;
|
||||
FrameBuffer outFb;
|
||||
|
||||
ImfCtl::applyTransforms (interpreter, transformNames, transformWindow,
|
||||
envHeader, inHeader, inFb, outHeader, outFb);
|
||||
]],
|
||||
AC_MSG_RESULT([Compiled and ran OpenEXR_CTL test program.]); have_ctl=yes,
|
||||
AC_MSG_RESULT([The OpenEXR_CTL package could not be found. Will build and install playexr and exrdisplay without ctl support. ]); have_ctl=no)
|
||||
|
||||
|
||||
|
||||
dnl
|
||||
dnl if some autoconf expert knows how to get the actual prefix used, please
|
||||
dnl tell us. Until then...
|
||||
dnl
|
||||
if test "x$prefix" != "xNONE"; then
|
||||
ACTUAL_PREFIX=$prefix
|
||||
else
|
||||
ACTUAL_PREFIX=/usr/local
|
||||
fi
|
||||
|
||||
|
||||
|
||||
[if (test "${have_ctl}" = yes) ; then
|
||||
OPENEXR_CTL_CXXFLAGS="$OPENEXR_CTL_CXXFLAGS -DHAVE_CTL_INTERPRETER=1 -DCTL_MODULE_BASE_PATH=\\\"$ACTUAL_PREFIX/lib/CTL\\\""
|
||||
else
|
||||
OPENEXR_CTL_CXXFLAGS="-DHAVE_CTL_INTERPRETER=0 $OPENEXR_CXXFLAGS"
|
||||
OPENEXR_CTL_LIBS="-DHAVE_CTL_INTERPRETER=0 $OPENEXR_LIBS"
|
||||
OPENEXR_CTL_LDFLAGS="-DHAVE_CTL_INTERPRETER=0 $OPENEXR_LDFLAGS"
|
||||
fi]
|
||||
|
||||
dnl
|
||||
dnl These are already shared by AM_PATH_PKGCONFIG... now we update them
|
||||
dnl with the latest changes
|
||||
AC_SUBST(OPENEXR_CTL_CXXFLAGS)
|
||||
AC_SUBST(OPENEXR_CTL_LDFLAGS)
|
||||
AC_SUBST(OPENEXR_CTL_LIBS)
|
||||
|
||||
|
||||
dnl
|
||||
dnl check for alternate OpenGL headers
|
||||
dnl
|
||||
AM_PATH_GL(,)
|
||||
|
||||
dnl
|
||||
dnl check for FLTK
|
||||
dnl
|
||||
AM_PATH_FLTK(have_fltk=yes, have_fltk=no)
|
||||
|
||||
dnl
|
||||
dnl check for Cg
|
||||
dnl
|
||||
if test "${have_fltk}" = yes; then
|
||||
AM_PATH_CG(have_cg=yes, have_cg=no)
|
||||
if test "${have_cg}" = yes; then
|
||||
AC_DEFINE(HAVE_FRAGMENT_SHADERS)
|
||||
fi
|
||||
else have_cg=no
|
||||
fi
|
||||
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(limits.h unistd.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_C_INLINE
|
||||
AC_TYPE_SIZE_T
|
||||
|
||||
dnl gcc optimization
|
||||
AC_MSG_CHECKING(for gcc optimization flags)
|
||||
old_cflags=$CFLAGS
|
||||
CFLAGS="$CFLAGS -pipe"
|
||||
AC_TRY_COMPILE([#include <stdio.h>],
|
||||
[ printf ("hello, world"); ],
|
||||
[ EXTRA_OPT_CFLAGS="-pipe"],[ EXTRA_OPT_CFLAGS=""])
|
||||
CFLAGS=$old_cflags
|
||||
AC_MSG_RESULT([$EXTRA_OPT_CFLAGS])
|
||||
|
||||
dnl Platform-specific stuff
|
||||
case "$host" in
|
||||
*darwin*)
|
||||
AC_DEFINE(HAVE_DARWIN)
|
||||
|
||||
dnl OS X universal binary support, requires --disable-dependency-tracking
|
||||
AC_ARG_ENABLE(osx-universal-binaries,
|
||||
AC_HELP_STRING([--enable-osx-universal-binaries],
|
||||
[build universal binaries on OS X [[default=no]]]),
|
||||
[build_osxuniversal="${enableval}"], [build_osxuniversal=no])
|
||||
|
||||
if test "${build_osxuniversal}" != no ; then
|
||||
if test "$enable_dependency_tracking" != no ; then
|
||||
AC_MSG_ERROR([--enable-osx-universal-binary requires --disable-dependency-tracking.
|
||||
Please re-run configure with these options:
|
||||
--disable-dependency-tracking --enable-osx-universal-binary
|
||||
])
|
||||
fi
|
||||
CXXFLAGS="$CXXFLAGS -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386"
|
||||
dnl LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386"
|
||||
fi
|
||||
|
||||
CXXFLAGS="$CXXFLAGS"
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CFLAGS="$EXTRA_OPT_CFLAGS"
|
||||
AM_CXXFLAGS="$EXTRA_OPT_CFLAGS"
|
||||
|
||||
AC_SUBST(AM_CFLAGS)
|
||||
AC_SUBST(AM_CXXFLAGS)
|
||||
|
||||
AM_CONDITIONAL(HAVE_FLTK, test "x$have_fltk" = xyes)
|
||||
AM_CONDITIONAL(HAVE_CG, test "x$have_cg" = xyes)
|
||||
AM_CONDITIONAL(HAVE_CTL, test "x$have_ctl" = xyes)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
config/Makefile
|
||||
exrdisplay/Makefile
|
||||
playexr/Makefile
|
||||
doc/Makefile
|
||||
])
|
||||
|
||||
if test "x$build_osxuniversal" = xyes; then
|
||||
AC_MSG_RESULT([
|
||||
---------------------------------------------
|
||||
Summary for OpenEXR features:
|
||||
|
||||
build exrdisplay FLTK application $have_fltk
|
||||
with fragment shader support $have_cg
|
||||
ctl support $have_ctl
|
||||
build OS X universal binaries $build_osxuniversal
|
||||
---------------------------------------------
|
||||
])
|
||||
else
|
||||
AC_MSG_RESULT([
|
||||
---------------------------------------------
|
||||
Summary for OpenEXR features:
|
||||
|
||||
build exrdisplay FLTK application $have_fltk
|
||||
with fragment shader support $have_cg
|
||||
ctl support $have_ctl
|
||||
---------------------------------------------
|
||||
])
|
||||
fi
|
||||
|
||||
16
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/.cvsignore
Normal file
16
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/.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
|
||||
5
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/Makefile.am
Normal file
5
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/Makefile.am
Normal file
@@ -0,0 +1,5 @@
|
||||
EXTRA_DIST = OpenEXRViewers.odt OpenEXRViewers.pdf
|
||||
|
||||
docdir=$(datadir)/doc/OpenEXR_Viewers-@OPENEXR_VIEWERS_VERSION@
|
||||
doc_DATA = $(EXTRA_DIST)
|
||||
|
||||
BIN
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/OpenEXRViewers.odt
Normal file
BIN
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/OpenEXRViewers.odt
Normal file
Binary file not shown.
BIN
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/OpenEXRViewers.pdf
Normal file
BIN
cs440-acg/ext/openexr/OpenEXR_Viewers/doc/OpenEXRViewers.pdf
Normal file
Binary file not shown.
17
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/.cvsignore
Normal file
17
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/.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
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
ADD_EXECUTABLE ( exrdisplay
|
||||
main.cpp
|
||||
ImageView.cpp
|
||||
ImageView.h
|
||||
loadImage.cpp
|
||||
loadImage.h
|
||||
scaleImage.cpp
|
||||
scaleImage.h
|
||||
applyCtl.cpp
|
||||
applyCtl.h
|
||||
GlWindow3d.h
|
||||
GlWindow3d.cpp
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
${FLTK_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( exrdisplay
|
||||
IlmImf${OPENEXR_LIBSUFFIX}
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
Half
|
||||
${FLTK_LIBRARIES}
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
|
||||
INSTALL ( TARGETS
|
||||
exrdisplay
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/bin
|
||||
)
|
||||
400
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/GlWindow3d.cpp
Normal file
400
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/GlWindow3d.cpp
Normal file
@@ -0,0 +1,400 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// class GlWindow3d -- reconstructs deep image in a 3D OpenGl window
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "GlWindow3d.h"
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
using std::max;
|
||||
using std::min;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::cerr;
|
||||
|
||||
GlWindow::GlWindow (int x,int y,
|
||||
int w,int h,
|
||||
const char *l,
|
||||
const IMF::Rgba pixels[],
|
||||
float* dataZ[],
|
||||
unsigned int sampleCount[],
|
||||
int dx, int dy,
|
||||
float zmax, float zmin,
|
||||
float farPlane)
|
||||
:
|
||||
Fl_Gl_Window (x,y,w,h,l),
|
||||
_rawPixels (pixels),
|
||||
_dataZ (dataZ),
|
||||
_sampleCount (sampleCount),
|
||||
_dx (dx),
|
||||
_dy (dy),
|
||||
_zmax (zmax),
|
||||
_zmin (zmin),
|
||||
_farPlane (farPlane)
|
||||
{
|
||||
Fl::add_timeout (FPS, Timer_CallBack, (void*)this); // 24fps timer
|
||||
|
||||
// check zmax and zmin
|
||||
if (zmax < zmin)
|
||||
{
|
||||
cerr << "z max: "<< zmax << ", z min: " << zmin << endl;
|
||||
cerr << "z value bound error" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
_fitTran = -(_zmax + _zmin) / 2.0;
|
||||
_fitScale = 1.0;
|
||||
|
||||
if (_zmax != _zmin)
|
||||
_fitScale = 1.0 / (_zmax - _zmin);
|
||||
}
|
||||
|
||||
GlWindow::~GlWindow ()
|
||||
{
|
||||
for (int y = 0; y < _dy; y++)
|
||||
{
|
||||
for (int x = 0; x < _dx; x++)
|
||||
{
|
||||
delete _dataZ[y * _dx + x];
|
||||
}
|
||||
}
|
||||
|
||||
delete [] _sampleCount;
|
||||
delete [] _rawPixels;
|
||||
}
|
||||
|
||||
void
|
||||
GlWindow::Perspective (GLdouble focal, GLdouble aspect,
|
||||
GLdouble zNear, GLdouble zFar)
|
||||
{
|
||||
GLdouble xmin, xmax, ymin, ymax;
|
||||
ymax = zNear * tan (focal * M_PI / 360.0);
|
||||
ymin = -ymax;
|
||||
xmin = ymin * aspect;
|
||||
xmax = ymax * aspect;
|
||||
glFrustum (xmin, xmax, ymin, ymax, zNear, zFar);
|
||||
}
|
||||
|
||||
void
|
||||
GlWindow::ReshapeViewport()
|
||||
{
|
||||
glViewport (0, 0, w(), h());
|
||||
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
GLfloat ratio = w() / h();
|
||||
Perspective(min (max (30.0 + _zoom, 1.0), 179.0),
|
||||
1.0 * ratio, 1.0, _farPlane);
|
||||
glTranslatef(0.0, 0.0, -8.0);
|
||||
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
void
|
||||
GlWindow::GlInit()
|
||||
{
|
||||
glShadeModel (GL_FLAT);
|
||||
|
||||
_zoom = 0;
|
||||
_translateX = 0;
|
||||
_translateY = 0;
|
||||
_scaleZ = 1.0;
|
||||
_elevation = 0;
|
||||
_azimuth = 0;
|
||||
_inverted = 0;
|
||||
_displayFactor = 1;
|
||||
}
|
||||
|
||||
void
|
||||
drawRefPlan()
|
||||
{
|
||||
glBegin (GL_LINES);
|
||||
glColor3f (0.6, 0.6, 0.6);
|
||||
for (int i = 0; i <= 10; i++)
|
||||
{
|
||||
glVertex3f (1.0 - 0.2 * i, 0.0, 1.0);
|
||||
glVertex3f (1.0 - 0.2 * i, 0.0, -1.0);
|
||||
glVertex3f (1.0, 0.0, 1.0 - 0.2 * i);
|
||||
glVertex3f (-1.0, 0.0, 1.0 - 0.2 * i);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glBegin (GL_LINES);
|
||||
glColor3f (0.3, 0.3, 0.3);
|
||||
glVertex3f (0.0, 0.0, 1.0);
|
||||
glVertex3f (0.0, 0.0, -1.0);
|
||||
glVertex3f (1.0, 0.0, 0.0);
|
||||
glVertex3f (-1.0, 0.0, 0.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void
|
||||
drawCoord()
|
||||
{
|
||||
glBegin (GL_LINES);
|
||||
glColor3f (0.0, 0.0, 1.0);
|
||||
glVertex3f (-1.0, 0.0, 1.0);
|
||||
glVertex3f (-1.0, 0.0, 0.8);
|
||||
|
||||
glColor3f (1.0, 0.0, 0.0);
|
||||
glVertex3f (-1.0, 0.0, 1.0);
|
||||
glVertex3f (-0.8, 0.0, 1.0);
|
||||
|
||||
glColor3f (0.0, 1.0, 0.0);
|
||||
glVertex3f (-1.0, 0.0, 1.0);
|
||||
glVertex3f (-1.0, 0.2, 1.0);
|
||||
glEnd();
|
||||
|
||||
glPointSize(6);
|
||||
glBegin (GL_POINTS);
|
||||
glColor3f (1.0, 1.0, 0.0);
|
||||
glVertex3f (-1.0, 0.0, 1.0);
|
||||
|
||||
glColor3f (0.0, 0.0, 1.0);
|
||||
glVertex3f (-1.0, 0.0, 0.8);
|
||||
|
||||
glColor3f (1.0, 0.0, 0.0);
|
||||
glVertex3f (-0.8, 0.0, 1.0);
|
||||
|
||||
glColor3f (0.0, 1.0, 0.0);
|
||||
glVertex3f (-1.0, 0.2, 1.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void
|
||||
drawOutLine(float dx, float dy, float z)
|
||||
{
|
||||
glBegin (GL_LINE_LOOP);
|
||||
glColor3f (0.6, 0.0, 0.6);
|
||||
glVertex3f (0, 0, z);
|
||||
glVertex3f (0, dy, z);
|
||||
glVertex3f (dx, dy, z);
|
||||
glVertex3f (dx, 0, z);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void
|
||||
GlWindow::draw()
|
||||
{
|
||||
if ( !valid() )
|
||||
{
|
||||
valid (1);
|
||||
GlInit();
|
||||
}
|
||||
ReshapeViewport();
|
||||
glClearColor (.5,.5,.5, 0.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
|
||||
glTranslatef (_translateX, 0.0, 0.0);
|
||||
glTranslatef (0.0, -_translateY, 0.0);
|
||||
|
||||
glRotatef (_elevation, 1.0, 0.0, 0.0);
|
||||
glRotatef (_azimuth, 0.0, 1.0, 0.0);
|
||||
|
||||
// draw the reference plane
|
||||
drawRefPlan();
|
||||
|
||||
// draw the coordinate
|
||||
drawCoord();
|
||||
|
||||
// scale z value
|
||||
glScalef (1.0, 1.0, _scaleZ);
|
||||
|
||||
// display the objects
|
||||
// move the objects to the center of display
|
||||
glScalef (1.0 / _dx, 1.0 / _dx, 1.0 / 2.0);
|
||||
glTranslatef (-_dx / 2.0, -_dy / 2.0, 0.0);
|
||||
|
||||
glScalef (1.0, 1.0, _fitScale);
|
||||
glTranslatef (0.0, 0.0, -_fitTran);
|
||||
|
||||
// loop dataZ to draw points
|
||||
glPointSize (2);
|
||||
|
||||
glBegin (GL_POINTS);
|
||||
glColor3f (0.0, 1.0, 1.0);
|
||||
|
||||
for (int y = 0; y < _dy; y++)
|
||||
{
|
||||
for (int x = 0; x < _dx; x++)
|
||||
{
|
||||
if( x % (10 * _displayFactor) == 0 && y % (10 * _displayFactor) == 0)
|
||||
{
|
||||
float* z = _dataZ[y * _dx + x];
|
||||
unsigned int count = _sampleCount[y * _dx + x];
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
float val = z[i];
|
||||
glVertex3f (float(x), _dy - float(y) -1, -val);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
// draw the display window OutLine
|
||||
drawOutLine (_dx, _dy, -(_zmax + _zmin) / 2.0);
|
||||
|
||||
// Check gl errors
|
||||
GLenum err = glGetError();
|
||||
if ( err != GL_NO_ERROR )
|
||||
{
|
||||
cerr << "GLGETERROR = " << (int)err << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
GlWindow::handle (int event)
|
||||
{
|
||||
if (Fl::event_button() == FL_LEFT_MOUSE)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case FL_PUSH:
|
||||
_mouseStartX = Fl::event_x();
|
||||
_mouseStartY = Fl::event_y();
|
||||
|
||||
if (fabs(_elevation) > 90.0)
|
||||
{
|
||||
_inverted = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_inverted = 0;
|
||||
}
|
||||
break;
|
||||
case FL_DRAG:
|
||||
case FL_RELEASE:
|
||||
{
|
||||
int x = Fl::event_x();
|
||||
int y = Fl::event_y();
|
||||
|
||||
if (_inverted)
|
||||
{
|
||||
_azimuth -= (double)(x - _mouseStartX) * 0.2;
|
||||
}
|
||||
else
|
||||
{
|
||||
_azimuth += (double)(x - _mouseStartX) * 0.2;
|
||||
}
|
||||
_elevation += (double)(y - _mouseStartY) * 0.2;
|
||||
|
||||
while (_elevation < -180.0)
|
||||
_elevation += 360.0;
|
||||
while (_elevation > 180.0)
|
||||
_elevation -= 360.0;
|
||||
|
||||
_mouseStartX = x;
|
||||
_mouseStartY = y;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Fl::event_button() == FL_MIDDLE_MOUSE )
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case FL_PUSH:
|
||||
fl_cursor (FL_CURSOR_MOVE);
|
||||
break;
|
||||
case FL_RELEASE:
|
||||
fl_cursor (FL_CURSOR_DEFAULT);
|
||||
break;
|
||||
case FL_DRAG:
|
||||
int x = Fl::event_x();
|
||||
int y = Fl::event_y();
|
||||
_translateX += (x - _mouseX) * 0.01;
|
||||
_translateY += (y - _mouseY) * 0.01;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( event == FL_DRAG && Fl::event_button() == FL_RIGHT_MOUSE )
|
||||
{
|
||||
int x = Fl::event_x();
|
||||
int dx = x - _mouseX;
|
||||
int delta = -dx;
|
||||
_zoom += delta * 0.2;
|
||||
}
|
||||
|
||||
_mouseX = Fl::event_x();
|
||||
_mouseY = Fl::event_y();
|
||||
|
||||
if (event == FL_KEYUP)
|
||||
{
|
||||
const char* text = Fl::event_text();
|
||||
if (!strcmp (text, "A")) //scale up
|
||||
{
|
||||
_scaleZ *= 1.2;
|
||||
}
|
||||
if (!strcmp (text, "S")) //scale down
|
||||
{
|
||||
_scaleZ /= 1.2;
|
||||
}
|
||||
if (!strcmp (text, "F")) //fit
|
||||
{
|
||||
GlInit();
|
||||
}
|
||||
if (!strcmp (text, "D")) //decrease pixel samples
|
||||
{
|
||||
_displayFactor *= 2;
|
||||
if (_displayFactor > (_dx/10) || _displayFactor > (_dy/10) )
|
||||
_displayFactor /= 2;
|
||||
}
|
||||
if (!strcmp (text, "C")) //increase pixel samples
|
||||
{
|
||||
_displayFactor /= 2;
|
||||
if (_displayFactor < 1)
|
||||
_displayFactor = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Fl_Gl_Window::handle (event);
|
||||
}
|
||||
119
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/GlWindow3d.h
Normal file
119
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/GlWindow3d.h
Normal file
@@ -0,0 +1,119 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDED_GLWINDOW3D_H
|
||||
#define INCLUDED_GLWINDOW3D_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// class GlWindow3d -- reconstructs deep image in a 3D OpenGl window
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Gl_Window.H>
|
||||
#include <FL/gl.h>
|
||||
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfArray.h>
|
||||
#include <ImfNamespace.h>
|
||||
|
||||
#define FPS (1.0/24.0) // frames per second
|
||||
|
||||
class GlWindow : public Fl_Gl_Window
|
||||
{
|
||||
public:
|
||||
|
||||
GlWindow (int x,int y,
|
||||
int w,int h,
|
||||
const char *l,
|
||||
const IMF::Rgba pixels[],
|
||||
float* dataZ[],
|
||||
unsigned int sampleCount[],
|
||||
int dx, int dy, // data window
|
||||
float zmax, float zmin,
|
||||
float farPlane // zfar plane in Deep 3D window
|
||||
);
|
||||
~GlWindow ();
|
||||
|
||||
void Perspective (GLdouble focal, GLdouble aspect,
|
||||
GLdouble zNear, GLdouble zFar);
|
||||
void ReshapeViewport();
|
||||
void GlInit();
|
||||
void draw();
|
||||
int handle (int event);
|
||||
|
||||
protected:
|
||||
const IMF::Rgba * _rawPixels;
|
||||
float** _dataZ;
|
||||
unsigned int * _sampleCount;
|
||||
int _dx;
|
||||
int _dy;
|
||||
float _zmax;
|
||||
float _zmin;
|
||||
float _farPlane;
|
||||
|
||||
private:
|
||||
double _zoom;
|
||||
double _translateX;
|
||||
double _translateY;
|
||||
double _scaleZ;
|
||||
double _fitTran;
|
||||
double _fitScale;
|
||||
double _elevation; // for rotation
|
||||
double _azimuth; // for rotation
|
||||
int _mouseX;
|
||||
int _mouseY;
|
||||
int _mouseStartX;
|
||||
int _mouseStartY;
|
||||
int _inverted; // for rotation
|
||||
int _displayFactor; // for display pixel samples
|
||||
|
||||
// TIMER CALLBACK
|
||||
// Handles rotation of the object
|
||||
//
|
||||
static void Timer_CallBack (void *data)
|
||||
{
|
||||
GlWindow *glwin = (GlWindow*)data;
|
||||
glwin->redraw();
|
||||
Fl::repeat_timeout(FPS, Timer_CallBack, data);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
718
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/ImageView.cpp
Normal file
718
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/ImageView.cpp
Normal file
@@ -0,0 +1,718 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// class ImageView
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "ImageView.h"
|
||||
|
||||
#include <ImathMath.h>
|
||||
#include <ImathFun.h>
|
||||
#include <ImathLimits.h>
|
||||
#include <halfFunction.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined PLATFORM_WINDOWS || defined _WIN32
|
||||
#include <windows.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <GL/gl.h>
|
||||
#elif defined __APPLE__
|
||||
#include <FL/Fl.H>
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <FL/Fl.H>
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::cerr;
|
||||
using namespace IMATH;
|
||||
|
||||
ImageView::ImageView (int x, int y,
|
||||
int w, int h,
|
||||
const char label[],
|
||||
const IMF::Rgba pixels[],
|
||||
float* dataZ[],
|
||||
unsigned int sampleCount[],
|
||||
int zsize,
|
||||
int dw, int dh,
|
||||
int dx, int dy,
|
||||
Fl_Box *rgbaBox,
|
||||
float farPlane,
|
||||
float gamma,
|
||||
float exposure,
|
||||
float defog,
|
||||
float kneeLow,
|
||||
float kneeHigh)
|
||||
:
|
||||
Fl_Gl_Window (x, y, w, h, label),
|
||||
_gamma (gamma),
|
||||
_exposure (exposure),
|
||||
_defog (defog),
|
||||
_kneeLow (kneeLow),
|
||||
_kneeHigh (kneeHigh),
|
||||
_rawPixels (pixels),
|
||||
_dataZ (dataZ),
|
||||
_sampleCount (sampleCount),
|
||||
_fogR (0),
|
||||
_fogG (0),
|
||||
_fogB (0),
|
||||
_farPlane (farPlane),
|
||||
_dw (dw),
|
||||
_dh (dh),
|
||||
_dx (dx),
|
||||
_dy (dy),
|
||||
_zsize (zsize),
|
||||
_rgbaBox (rgbaBox),
|
||||
_screenPixels (dw * dh * 3)
|
||||
{
|
||||
computeFogColor();
|
||||
updateScreenPixels();
|
||||
|
||||
//
|
||||
// initialize z value chart
|
||||
//
|
||||
_chartwin = new Fl_Window (600, 300);
|
||||
_chartwin->label("Deep Pixel Display");
|
||||
|
||||
_chart = new Fl_Chart (20, 20,
|
||||
_chartwin->w()-40,
|
||||
_chartwin->h()-40,
|
||||
"Sample #");
|
||||
_chartMax = new Fl_Chart (20, 20,
|
||||
_chartwin->w()-40,
|
||||
_chartwin->h()-40,
|
||||
"");
|
||||
_chartMin = new Fl_Chart (20, 20,
|
||||
_chartwin->w()-40,
|
||||
_chartwin->h()-40,
|
||||
"");
|
||||
|
||||
findZbound();
|
||||
|
||||
//
|
||||
// initialize Deep 3d window
|
||||
//
|
||||
_gl3d = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::setExposure (float exposure)
|
||||
{
|
||||
_exposure = exposure;
|
||||
updateScreenPixels();
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageView::setDefog (float defog)
|
||||
{
|
||||
_defog = defog;
|
||||
updateScreenPixels();
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageView::setKneeLow (float kneeLow)
|
||||
{
|
||||
_kneeLow = kneeLow;
|
||||
updateScreenPixels();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::findZbound()
|
||||
{
|
||||
//
|
||||
// find zmax and zmin values of deep data to set bound
|
||||
//
|
||||
float zmax = limits<float>::min();
|
||||
float zmin = limits<float>::max();
|
||||
_maxCount = 0;
|
||||
|
||||
for (int k = 0; k < _zsize; k++)
|
||||
{
|
||||
float* z = _dataZ[k];
|
||||
unsigned int count = _sampleCount[k];
|
||||
|
||||
if (_maxCount < count)
|
||||
_maxCount = count;
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
double val = double(z[i]);
|
||||
if (val > zmax && val < _farPlane)
|
||||
zmax = val;
|
||||
if (val < zmin)
|
||||
zmin = val;
|
||||
}
|
||||
}
|
||||
|
||||
if ( zmax > zmin)
|
||||
{
|
||||
cout << "z max: "<< zmax << ", z min: " << zmin << endl;
|
||||
_chart->bounds (zmin, zmax);
|
||||
}
|
||||
|
||||
_zmax = zmax;
|
||||
_zmin = zmin;
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::setPixels(const IMF::Rgba pixels[/* w*h */],
|
||||
float* dataZ[/* w*h */],
|
||||
unsigned int sampleCount[/* w*h */],
|
||||
int zsize,
|
||||
int dw, int dh, int dx, int dy)
|
||||
{
|
||||
//
|
||||
// update data of imageview
|
||||
//
|
||||
_rawPixels = pixels;
|
||||
_dw = dw;
|
||||
_dh = dh;
|
||||
_dx = dx;
|
||||
_dy = dy;
|
||||
_dataZ = dataZ;
|
||||
_sampleCount = sampleCount;
|
||||
_zsize = zsize;
|
||||
|
||||
_screenPixels.resizeErase(dw*dh*3);
|
||||
|
||||
findZbound();
|
||||
|
||||
//
|
||||
// update Deep 3d window
|
||||
//
|
||||
GlWindow* temp;
|
||||
temp = _gl3d;
|
||||
_gl3d = NULL;
|
||||
|
||||
if (_gl3d != NULL){
|
||||
delete temp;
|
||||
}
|
||||
|
||||
updateScreenPixels();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::clearDataDisplay()
|
||||
{
|
||||
_chart->clear();
|
||||
|
||||
if (_gl3d != NULL)
|
||||
_gl3d->hide();
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::setKneeHigh (float kneeHigh)
|
||||
{
|
||||
_kneeHigh = kneeHigh;
|
||||
updateScreenPixels();
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageView::draw()
|
||||
{
|
||||
if (!valid())
|
||||
{
|
||||
glLoadIdentity();
|
||||
glViewport (0, 0, w(), h());
|
||||
glOrtho(0, w(), h(), 0, -1, 1);
|
||||
}
|
||||
|
||||
glClearColor (0.3, 0.3, 0.3, 1.0);
|
||||
glClear (GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if (_dx + _dw <= 0 || _dx >= w())
|
||||
return;
|
||||
|
||||
for (int y = 0; y < _dh; ++y)
|
||||
{
|
||||
if (y + _dy < 0 || y + _dy >= h())
|
||||
continue;
|
||||
|
||||
glRasterPos2i (max (0, _dx), y + _dy + 1);
|
||||
|
||||
glDrawPixels (_dw + min (0, _dx), // width
|
||||
1, // height
|
||||
GL_RGB, // format
|
||||
GL_UNSIGNED_BYTE, // type
|
||||
_screenPixels + // pixels
|
||||
static_cast <ptrdiff_t> ((y * _dw - min (0, _dx)) * 3));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageView::computeFogColor ()
|
||||
{
|
||||
_fogR = 0;
|
||||
_fogG = 0;
|
||||
_fogB = 0;
|
||||
|
||||
for (int j = 0; j < _dw * _dh; ++j)
|
||||
{
|
||||
const IMF::Rgba &rp = _rawPixels[j];
|
||||
|
||||
if (rp.r.isFinite())
|
||||
_fogR += rp.r;
|
||||
|
||||
if (rp.g.isFinite())
|
||||
_fogG += rp.g;
|
||||
|
||||
if (rp.b.isFinite())
|
||||
_fogB += rp.b;
|
||||
}
|
||||
|
||||
_fogR /= _dw * _dh;
|
||||
_fogG /= _dw * _dh;
|
||||
_fogB /= _dw * _dh;
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::drawChart (int x, int y, bool initChart)
|
||||
{
|
||||
if (x >= 0 && x < w() && y >= 0 && y < h())
|
||||
{
|
||||
int px = x - _dx;
|
||||
int py = y - _dy;
|
||||
|
||||
if (px >= 0 && px < _dw && py >= 0 && py < _dh)
|
||||
{
|
||||
float* z = _dataZ[py * _dw + px];
|
||||
unsigned int count = _sampleCount[py * _dw + px];
|
||||
|
||||
cout << "\nsample Count: " << count << endl;
|
||||
cout << "x: " << px << ", y: " << py << endl;
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
printf ("pixel Z value %d: %.3f\n", i, float(z[i]));
|
||||
}
|
||||
|
||||
const IMF::Rgba &p = _rawPixels[py * _dw + px];
|
||||
|
||||
cout << "R = " << p.r << ", G = " << p.g << ","
|
||||
" B = " << p.b <<endl;
|
||||
|
||||
//
|
||||
// draw the chart
|
||||
//
|
||||
drawChartRef();
|
||||
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
double val = double(z[i]);
|
||||
if (val < _farPlane)
|
||||
{
|
||||
static char val_str[20];
|
||||
sprintf (val_str, "%.3lf", val);
|
||||
_chart->add (val, val_str, FL_BLUE);
|
||||
}
|
||||
}
|
||||
|
||||
redraw();
|
||||
|
||||
if (initChart)
|
||||
{
|
||||
_chartwin->resizable (_chartwin);
|
||||
_chartwin->set_non_modal(); // make chart on top
|
||||
|
||||
if (!_chartwin->shown())
|
||||
_chartwin->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ImageView::drawChartRef ()
|
||||
{
|
||||
_chart->clear();
|
||||
_chart->bounds(_zmin, _zmax);
|
||||
|
||||
_chart->type (FL_LINE_CHART);
|
||||
_chart->label("Sample #");
|
||||
|
||||
_chartMax->clear();
|
||||
_chartMax->type (FL_SPIKE_CHART);
|
||||
static char val_str[20];
|
||||
sprintf (val_str, "Zmax : %.3lf", _zmax);
|
||||
_chartMax->label(val_str);
|
||||
_chartMax->align(FL_ALIGN_TOP_LEFT);
|
||||
_chartMax->box(FL_NO_BOX);
|
||||
|
||||
_chartMin->clear();
|
||||
_chartMin->type (FL_SPIKE_CHART);
|
||||
static char val_str1[20];
|
||||
sprintf (val_str1, "Zmin : %.3lf", _zmin);
|
||||
_chartMin->label(val_str1);
|
||||
_chartMin->align(FL_ALIGN_BOTTOM_LEFT);
|
||||
_chartMin->box(FL_NO_BOX);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ImageView::handle (int event)
|
||||
{
|
||||
|
||||
if (event == FL_PUSH)
|
||||
{
|
||||
// We want to get the other associated events for this widget so
|
||||
// return a non-zero value here.
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (event == FL_MOVE)
|
||||
{
|
||||
//
|
||||
// Print the red, green and blue values of
|
||||
// the pixel at the current cursor location.
|
||||
//
|
||||
|
||||
int x = Fl::event_x();
|
||||
int y = Fl::event_y();
|
||||
|
||||
if (x >= 0 && x < w() && y >= 0 && y < h())
|
||||
{
|
||||
int px = x - _dx;
|
||||
int py = y - _dy;
|
||||
|
||||
if (px >= 0 && px < _dw && py >= 0 && py < _dh)
|
||||
{
|
||||
const IMF::Rgba &p = _rawPixels[py * _dw + px];
|
||||
|
||||
sprintf (_rgbaBoxLabel,
|
||||
"r = %.3g g = %.3g b = %.3g",
|
||||
float (p.r), float (p.g), float (p.b));
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (_rgbaBoxLabel, " ");
|
||||
}
|
||||
|
||||
_rgbaBox->label (_rgbaBoxLabel);
|
||||
|
||||
|
||||
if (_chartwin->shown() && _zsize > 0)
|
||||
{
|
||||
int x = Fl::event_x();
|
||||
int y = Fl::event_y();
|
||||
drawChart (x, y, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event == FL_RELEASE && Fl::event_button() == FL_LEFT_MOUSE)
|
||||
{
|
||||
//
|
||||
// Open a sample chart and print the z values of
|
||||
// the pixel at the current cursor location
|
||||
//
|
||||
|
||||
if(_zsize > 0)
|
||||
{
|
||||
int x = Fl::event_x();
|
||||
int y = Fl::event_y();
|
||||
|
||||
drawChart (x, y, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (event == FL_RELEASE && Fl::event_button() == FL_RIGHT_MOUSE)
|
||||
{
|
||||
if(_zsize > 0)
|
||||
{
|
||||
if (_gl3d == NULL)
|
||||
{
|
||||
//
|
||||
// initialize Deep 3d display
|
||||
//
|
||||
|
||||
_gl3d = new GlWindow(10, 10, 500, 500,
|
||||
"3D View", _rawPixels,
|
||||
_dataZ, _sampleCount,
|
||||
_dw, _dh, _zmax, _zmin,
|
||||
_farPlane);
|
||||
|
||||
_gl3d->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gl3d->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Fl_Gl_Window::handle (event);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
//
|
||||
// Conversion from raw pixel data to data for the OpenGL frame buffer:
|
||||
//
|
||||
// 1) Compensate for fogging by subtracting defog
|
||||
// from the raw pixel values.
|
||||
//
|
||||
// 2) Multiply the defogged pixel values by
|
||||
// 2^(exposure + 2.47393).
|
||||
//
|
||||
// 3) Values that are now 1.0 are called "middle gray".
|
||||
// If defog and exposure are both set to 0.0, then
|
||||
// middle gray corresponds to a raw pixel value of 0.18.
|
||||
// In step 6, middle gray values will be mapped to an
|
||||
// intensity 3.5 f-stops below the display's maximum
|
||||
// intensity.
|
||||
//
|
||||
// 4) Apply a knee function. The knee function has two
|
||||
// parameters, kneeLow and kneeHigh. Pixel values
|
||||
// below 2^kneeLow are not changed by the knee
|
||||
// function. Pixel values above kneeLow are lowered
|
||||
// according to a logarithmic curve, such that the
|
||||
// value 2^kneeHigh is mapped to 2^3.5. (In step 6,
|
||||
// this value will be mapped to the the display's
|
||||
// maximum intensity.)
|
||||
//
|
||||
// 5) Gamma-correct the pixel values, according to the
|
||||
// screen's gamma. (We assume that the gamma curve
|
||||
// is a simple power function.)
|
||||
//
|
||||
// 6) Scale the values such that middle gray pixels are
|
||||
// mapped to a frame buffer value that is 3.5 f-stops
|
||||
// below the display's maximum intensity. (84.65 if
|
||||
// the screen's gamma is 2.2)
|
||||
//
|
||||
// 7) Clamp the values to [0, 255].
|
||||
//
|
||||
|
||||
|
||||
float
|
||||
knee (double x, double f)
|
||||
{
|
||||
return float (IMATH::Math<double>::log (x * f + 1) / f);
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
findKneeF (float x, float y)
|
||||
{
|
||||
float f0 = 0;
|
||||
float f1 = 1;
|
||||
|
||||
while (knee (x, f1) > y)
|
||||
{
|
||||
f0 = f1;
|
||||
f1 = f1 * 2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 30; ++i)
|
||||
{
|
||||
float f2 = (f0 + f1) / 2;
|
||||
float y2 = knee (x, f2);
|
||||
|
||||
if (y2 < y)
|
||||
f1 = f2;
|
||||
else
|
||||
f0 = f2;
|
||||
}
|
||||
|
||||
return (f0 + f1) / 2;
|
||||
}
|
||||
|
||||
|
||||
struct Gamma
|
||||
{
|
||||
float g, m, d, kl, f, s;
|
||||
|
||||
Gamma (float gamma,
|
||||
float exposure,
|
||||
float defog,
|
||||
float kneeLow,
|
||||
float kneeHigh);
|
||||
|
||||
float operator () (half h);
|
||||
};
|
||||
|
||||
|
||||
Gamma::Gamma
|
||||
(float gamma,
|
||||
float exposure,
|
||||
float defog,
|
||||
float kneeLow,
|
||||
float kneeHigh)
|
||||
:
|
||||
g (gamma),
|
||||
m (IMATH::Math<float>::pow (2, exposure + 2.47393)),
|
||||
d (defog),
|
||||
kl (IMATH::Math<float>::pow (2, kneeLow)),
|
||||
f (findKneeF (IMATH::Math<float>::pow (2, kneeHigh) - kl,
|
||||
IMATH::Math<float>::pow (2, 3.5) - kl)),
|
||||
s (255.0 * IMATH::Math<float>::pow (2, -3.5 * g))
|
||||
{}
|
||||
|
||||
|
||||
float
|
||||
Gamma::operator () (half h)
|
||||
{
|
||||
//
|
||||
// Defog
|
||||
//
|
||||
|
||||
float x = max (0.f, (h - d));
|
||||
|
||||
//
|
||||
// Exposure
|
||||
//
|
||||
|
||||
x *= m;
|
||||
|
||||
//
|
||||
// Knee
|
||||
//
|
||||
|
||||
if (x > kl)
|
||||
x = kl + knee (x - kl, f);
|
||||
|
||||
//
|
||||
// Gamma
|
||||
//
|
||||
|
||||
x = IMATH::Math<float>::pow (x, g);
|
||||
|
||||
//
|
||||
// Scale and clamp
|
||||
//
|
||||
|
||||
return clamp (x * s, 0.f, 255.f);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Dithering: Reducing the raw 16-bit pixel data to 8 bits for the
|
||||
// OpenGL frame buffer can sometimes lead to contouring in smooth
|
||||
// color ramps. Dithering with a simple Bayer pattern eliminates
|
||||
// visible contouring.
|
||||
//
|
||||
|
||||
unsigned char
|
||||
dither (float v, int x, int y)
|
||||
{
|
||||
static const float d[4][4] =
|
||||
{
|
||||
{0.f / 16, 8.f / 16, 2.f / 16, 10.f / 16},
|
||||
{12.f / 16, 4.f / 16, 14.f / 16, 6.f / 16},
|
||||
{3.f / 16, 11.f / 16, 1.f / 16, 9.f / 16},
|
||||
{15.f / 16, 7.f / 16, 13.f / 16, 5.f / 16}
|
||||
};
|
||||
|
||||
return (unsigned char) (v + d[y & 3][x & 3]);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
float
|
||||
ImageView::findKnee (float x, float y)
|
||||
{
|
||||
return findKneeF (x, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ImageView::updateScreenPixels ()
|
||||
{
|
||||
halfFunction<float>
|
||||
rGamma (Gamma (_gamma,
|
||||
_exposure,
|
||||
_defog * _fogR,
|
||||
_kneeLow,
|
||||
_kneeHigh),
|
||||
-HALF_MAX, HALF_MAX,
|
||||
0.f, 255.f, 0.f, 0.f);
|
||||
|
||||
halfFunction<float>
|
||||
gGamma (Gamma (_gamma,
|
||||
_exposure,
|
||||
_defog * _fogG,
|
||||
_kneeLow,
|
||||
_kneeHigh),
|
||||
-HALF_MAX, HALF_MAX,
|
||||
0.f, 255.f, 0.f, 0.f);
|
||||
|
||||
halfFunction<float>
|
||||
bGamma (Gamma (_gamma,
|
||||
_exposure,
|
||||
_defog * _fogB,
|
||||
_kneeLow,
|
||||
_kneeHigh),
|
||||
-HALF_MAX, HALF_MAX,
|
||||
0.f, 255.f, 0.f, 0.f);
|
||||
|
||||
|
||||
for (int y = 0; y < _dh; ++y)
|
||||
{
|
||||
int i = y * _dw;
|
||||
|
||||
for (int x = 0; x < _dw; ++x)
|
||||
{
|
||||
int j = i + x;
|
||||
const IMF::Rgba &rp = _rawPixels[j];
|
||||
unsigned char *sp = _screenPixels + j * 3;
|
||||
sp[0] = dither (rGamma (rp.r), x, y);
|
||||
sp[1] = dither (gGamma (rp.g), x, y);
|
||||
sp[2] = dither (bGamma (rp.b), x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
133
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/ImageView.h
Normal file
133
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/ImageView.h
Normal file
@@ -0,0 +1,133 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef INCLUDED_IMAGE_VIEW_H
|
||||
#define INCLUDED_IMAGE_VIEW_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// class ImageView -- draws an Imf::Rgba image in an OpenGl window
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "namespaceAlias.h"
|
||||
#include "GlWindow3d.h"
|
||||
|
||||
#include <FL/Fl_Chart.H>
|
||||
#include <FL/Fl_Gl_Window.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfArray.h>
|
||||
|
||||
|
||||
|
||||
class ImageView: public Fl_Gl_Window
|
||||
{
|
||||
public:
|
||||
|
||||
ImageView (int x, int y,
|
||||
int w, int h, // display window width and height
|
||||
const char label[],
|
||||
const IMF::Rgba pixels[/* w*h */],
|
||||
float* dataZ[/* w*h */],
|
||||
unsigned int sampleCount[/* w*h */],
|
||||
int zsize,
|
||||
int dw, int dh, // data window width and height
|
||||
int dx, int dy, // data window offset
|
||||
Fl_Box *rgbaBox,
|
||||
float farPlane, // zfar plane in Deep 3D window
|
||||
float gamma,
|
||||
float exposure,
|
||||
float defog,
|
||||
float kneeLow,
|
||||
float kneeHigh);
|
||||
|
||||
virtual void setExposure (float exposure);
|
||||
virtual void setDefog (float defog);
|
||||
virtual void setKneeLow (float low);
|
||||
virtual void setKneeHigh (float high);
|
||||
virtual void setPixels(const IMF::Rgba pixels[],
|
||||
float* dataZ[/* w*h */],
|
||||
unsigned int sampleCount[/* w*h */],
|
||||
int zsize,
|
||||
int dw, int dh, int dx, int dy);
|
||||
|
||||
virtual void draw();
|
||||
virtual int handle (int event);
|
||||
void clearDataDisplay();
|
||||
|
||||
protected:
|
||||
|
||||
virtual void updateScreenPixels ();
|
||||
void computeFogColor ();
|
||||
void findZbound ();
|
||||
float findKnee (float x, float y);
|
||||
void drawChart (int x, int y, bool initChart);
|
||||
void drawChartRef ();
|
||||
|
||||
float _gamma;
|
||||
float _exposure;
|
||||
float _defog;
|
||||
float _kneeLow;
|
||||
float _kneeHigh;
|
||||
const IMF::Rgba * _rawPixels;
|
||||
float** _dataZ;
|
||||
unsigned int * _sampleCount;
|
||||
float _fogR;
|
||||
float _fogG;
|
||||
float _fogB;
|
||||
float _zmax;
|
||||
float _zmin;
|
||||
float _farPlane;
|
||||
int _dw;
|
||||
int _dh;
|
||||
int _dx;
|
||||
int _dy;
|
||||
int _zsize;
|
||||
unsigned int _maxCount;
|
||||
|
||||
private:
|
||||
|
||||
GlWindow* _gl3d;
|
||||
Fl_Window * _chartwin;
|
||||
Fl_Chart * _chart;
|
||||
Fl_Chart * _chartMax;
|
||||
Fl_Chart * _chartMin;
|
||||
Fl_Box * _rgbaBox;
|
||||
char _rgbaBoxLabel[200];
|
||||
IMF::Array<unsigned char> _screenPixels;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
52
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/Makefile.am
Normal file
52
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/Makefile.am
Normal file
@@ -0,0 +1,52 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
if HAVE_FLTK
|
||||
|
||||
bin_PROGRAMS = exrdisplay
|
||||
|
||||
INCLUDES = @OPENEXR_CXXFLAGS@ \
|
||||
@GL_CXXFLAGS@ @CG_CXXFLAGS@ @FLTK_CXXFLAGS@ -I$(top_builddir) \
|
||||
@OPENEXR_CTL_CXXFLAGS@
|
||||
|
||||
LDADD = @OPENEXR_LDFLAGS@ @OPENEXR_LIBS@ \
|
||||
@OPENEXR_CTL_LDFLAGS@ @OPENEXR_CTL_LIBS@ \
|
||||
@CG_LDFLAGS@ @FLTK_LDFLAGS@
|
||||
|
||||
all-local:
|
||||
@FLTK_CONFIG@ --post exrdisplay
|
||||
|
||||
install-exec-hook:
|
||||
@FLTK_CONFIG@ --post $(DESTDIR)$(bindir)/exrdisplay
|
||||
|
||||
else
|
||||
install-exec-hook:
|
||||
|
||||
endif
|
||||
|
||||
|
||||
exrdisplay_SOURCES = \
|
||||
main.cpp \
|
||||
ImageView.cpp \
|
||||
ImageView.h \
|
||||
loadImage.cpp \
|
||||
loadImage.h \
|
||||
scaleImage.cpp \
|
||||
scaleImage.h \
|
||||
applyCtl.cpp \
|
||||
applyCtl.h \
|
||||
GlWindow3d.h \
|
||||
GlWindow3d.cpp
|
||||
|
||||
noinst_HEADERS = \
|
||||
ImageView.h \
|
||||
loadImage.h \
|
||||
scaleImage.h \
|
||||
applyCtl.h \
|
||||
GlWindow3d.h \
|
||||
namespaceAlias.h
|
||||
|
||||
EXTRA_DIST = $(exrdisplay_SOURCES)
|
||||
|
||||
|
||||
|
||||
|
||||
436
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/applyCtl.cpp
Normal file
436
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/applyCtl.cpp
Normal file
@@ -0,0 +1,436 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Apply CTL transforms
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "applyCtl.h"
|
||||
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
|
||||
#include <ImfCtlApplyTransforms.h>
|
||||
#include <CtlSimdInterpreter.h>
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include<stdio.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Ctl;
|
||||
using namespace IMATH;
|
||||
|
||||
#else
|
||||
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace IMATH;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
using namespace IMF;
|
||||
|
||||
#define WARNING(message) (cerr << "Warning: " << message << endl)
|
||||
|
||||
|
||||
float
|
||||
displayVideoGamma ()
|
||||
{
|
||||
//
|
||||
// Get the display's video gamma from an environment variable.
|
||||
// If this fails, use a default value (1/2.2).
|
||||
//
|
||||
|
||||
const char gammaEnv[] = "EXR_DISPLAY_VIDEO_GAMMA";
|
||||
float g = 2.2f;
|
||||
|
||||
if (const char *gamma = getenv (gammaEnv))
|
||||
{
|
||||
float tmp;
|
||||
int n = sscanf (gamma, " %f", &tmp);
|
||||
|
||||
if (n != 1)
|
||||
WARNING ("Cannot parse environment variable " << gammaEnv << "; "
|
||||
"using default value (" << g << ").");
|
||||
else if (tmp < 1.f)
|
||||
WARNING ("Display video gamma, specified in environment "
|
||||
"variable " << gammaEnv << " is out of range; "
|
||||
"using default value (" << g << ").");
|
||||
else
|
||||
g = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << gammaEnv << " is not set; "
|
||||
"using default value (" << g << ").");
|
||||
}
|
||||
|
||||
return 1.f / g;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
Chromaticities
|
||||
displayChromaticities ()
|
||||
{
|
||||
//
|
||||
// Get the chromaticities of the display's primaries and
|
||||
// white point from an environment variable. If this fails,
|
||||
// assume chromaticities according to Rec. ITU-R BT.709.
|
||||
//
|
||||
|
||||
static const char chromaticitiesEnv[] = "CTL_DISPLAY_CHROMATICITIES";
|
||||
Chromaticities c; // default-initialized according to Rec. 709
|
||||
|
||||
if (const char *chromaticities = getenv (chromaticitiesEnv))
|
||||
{
|
||||
Chromaticities tmp;
|
||||
|
||||
int n = sscanf (chromaticities,
|
||||
" red %f %f green %f %f blue %f %f white %f %f",
|
||||
&tmp.red.x, &tmp.red.y,
|
||||
&tmp.green.x, &tmp.green.y,
|
||||
&tmp.blue.x, &tmp.blue.y,
|
||||
&tmp.white.x, &tmp.white.y);
|
||||
|
||||
if (n == 8)
|
||||
c = tmp;
|
||||
else
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
chromaticitiesEnv << "; using default value "
|
||||
"(chromaticities according to Rec. ITU-R BT.709).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << chromaticitiesEnv << " is "
|
||||
"not set; using default value (chromaticities according "
|
||||
"to Rec. ITU-R BT.709).");
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
initializeEnvHeader (Header &envHeader)
|
||||
{
|
||||
//
|
||||
// Initialize the "environment header" for the CTL
|
||||
// transforms by adding displayChromaticities,
|
||||
// displayWhiteLuminance and displaySurroundLuminance
|
||||
// attributes.
|
||||
//
|
||||
|
||||
Chromaticities c = displayChromaticities();
|
||||
envHeader.insert ("displayChromaticities", ChromaticitiesAttribute (c));
|
||||
|
||||
//
|
||||
// Get the display's white luminance from an environment variable.
|
||||
// If this fails, assume 120 candelas per square meter.
|
||||
// (Screen aim luminance according to SMPTE RP 166.)
|
||||
//
|
||||
|
||||
static const char whiteLuminanceEnv[] = "CTL_DISPLAY_WHITE_LUMINANCE";
|
||||
static const float whiteLuminanceDefault = 120.0;
|
||||
float wl = whiteLuminanceDefault;
|
||||
|
||||
if (const char *whiteLuminance = getenv (whiteLuminanceEnv))
|
||||
{
|
||||
int n = sscanf (whiteLuminance, " %f", &wl);
|
||||
|
||||
if (n != 1)
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
whiteLuminanceEnv << "; using default value "
|
||||
"(" << wl << " candelas per square meter).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << whiteLuminanceEnv << " is "
|
||||
"is not set; using default value (" << wl << " candelas "
|
||||
"per square meter).");
|
||||
}
|
||||
|
||||
envHeader.insert ("displayWhiteLuminance", FloatAttribute (wl));
|
||||
|
||||
//
|
||||
// Get the display's surround luminance from an environment variable.
|
||||
// If this fails, assume 10% of the display's white luminance.
|
||||
// (Recommended setup according to SMPTE RP 166.)
|
||||
//
|
||||
|
||||
static const char surroundLuminanceEnv[] = "CTL_DISPLAY_SURROUND_LUMINANCE";
|
||||
float sl = wl * 0.1f;
|
||||
|
||||
if (const char *surroundLuminance = getenv (surroundLuminanceEnv))
|
||||
{
|
||||
int n = sscanf (surroundLuminance, " %f", &sl);
|
||||
|
||||
if (n != 1)
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
surroundLuminanceEnv << "; using default value "
|
||||
"(" << sl << " candelas per square meter).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << surroundLuminanceEnv << " is "
|
||||
"is not set; using default value (" << sl << " candelas "
|
||||
"per square meter).");
|
||||
}
|
||||
|
||||
envHeader.insert ("displaySurroundLuminance", FloatAttribute (sl));
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
displayTransformName ()
|
||||
{
|
||||
//
|
||||
// Get the name of the display transform from an environment
|
||||
// variable. If this fails, use a default name.
|
||||
//
|
||||
|
||||
static const char displayTransformEnv[] = "CTL_DISPLAY_TRANSFORM";
|
||||
static const char displayTransformDefault[] = "transform_display_video";
|
||||
const char *displayTransform = getenv (displayTransformEnv);
|
||||
|
||||
if (!displayTransform)
|
||||
{
|
||||
displayTransform = displayTransformDefault;
|
||||
|
||||
WARNING ("Environment variable " << displayTransformEnv << " "
|
||||
"is not set; using default value "
|
||||
"(\"" << displayTransform << "\").");
|
||||
}
|
||||
|
||||
return displayTransform;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
initializeInFrameBuffer
|
||||
(int w,
|
||||
int h,
|
||||
const Array<Rgba> &pixels,
|
||||
FrameBuffer &fb)
|
||||
{
|
||||
fb.insert ("R", Slice (HALF, // type
|
||||
(char *)(&pixels[0].r), // base
|
||||
sizeof (pixels[0]), // xStride
|
||||
sizeof (pixels[0]) * w)); // yStride
|
||||
|
||||
fb.insert ("G", Slice (HALF, // type
|
||||
(char *)(&pixels[0].g), // base
|
||||
sizeof (pixels[0]), // xStride
|
||||
sizeof (pixels[0]) * w)); // yStride
|
||||
|
||||
fb.insert ("B", Slice (HALF, // type
|
||||
(char *)(&pixels[0].b), // base
|
||||
sizeof (pixels[0]), // xStride
|
||||
sizeof (pixels[0]) * w)); // yStride
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
initializeOutFrameBuffer
|
||||
(int w,
|
||||
int h,
|
||||
const Array<Rgba> &pixels,
|
||||
FrameBuffer &fb)
|
||||
{
|
||||
fb.insert ("R_display", Slice (HALF, // type
|
||||
(char *)(&pixels[0].r), // base
|
||||
sizeof (pixels[0]), // xStride
|
||||
sizeof (pixels[0]) * w)); // yStride
|
||||
|
||||
fb.insert ("G_display", Slice (HALF, // type
|
||||
(char *)(&pixels[0].g), // base
|
||||
sizeof (pixels[0]), // xStride
|
||||
sizeof (pixels[0]) * w)); // yStride
|
||||
|
||||
fb.insert ("B_display", Slice (HALF, // type
|
||||
(char *)(&pixels[0].b), // base
|
||||
sizeof (pixels[0]), // xStride
|
||||
sizeof (pixels[0]) * w)); // yStride
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void
|
||||
applyCtl (vector<string> transformNames,
|
||||
Header inHeader,
|
||||
const Array<Rgba> &inPixels,
|
||||
int w,
|
||||
int h,
|
||||
Array<Rgba> &outPixels)
|
||||
{
|
||||
//
|
||||
// If we do not have an explicit set of transform names
|
||||
// then find suitable look modification, rendering and
|
||||
// display transforms.
|
||||
//
|
||||
|
||||
if (transformNames.empty())
|
||||
{
|
||||
if (hasLookModTransform (inHeader))
|
||||
transformNames.push_back (lookModTransform (inHeader));
|
||||
|
||||
if (hasRenderingTransform (inHeader))
|
||||
transformNames.push_back (renderingTransform (inHeader));
|
||||
else
|
||||
transformNames.push_back ("transform_RRT");
|
||||
|
||||
transformNames.push_back (displayTransformName());
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize an input and an environment header:
|
||||
// Make sure that the headers contain information about the primaries
|
||||
// and the white point of the image files an the display, and about
|
||||
// the display's white luminance and surround luminance.
|
||||
//
|
||||
|
||||
if (!hasChromaticities (inHeader))
|
||||
addChromaticities (inHeader, Chromaticities());
|
||||
|
||||
if (!hasAdoptedNeutral (inHeader))
|
||||
addAdoptedNeutral (inHeader, chromaticities(inHeader).white);
|
||||
|
||||
Header envHeader;
|
||||
initializeEnvHeader (envHeader);
|
||||
|
||||
//
|
||||
// Set up input and output FrameBuffer objects for the transforms.
|
||||
//
|
||||
|
||||
FrameBuffer inFb;
|
||||
initializeInFrameBuffer (w, h, inPixels, inFb);
|
||||
|
||||
FrameBuffer outFb;
|
||||
initializeOutFrameBuffer (w, h, outPixels, outFb);
|
||||
|
||||
//
|
||||
// Run the CTL transforms
|
||||
//
|
||||
|
||||
Box2i transformWindow (V2i (0, 0), V2i (w - 1, h - 1));
|
||||
|
||||
SimdInterpreter interpreter;
|
||||
|
||||
#ifdef CTL_MODULE_BASE_PATH
|
||||
|
||||
//
|
||||
// The configuration scripts has defined a default
|
||||
// location for CTL modules. Include this location
|
||||
// in the CTL module search path.
|
||||
//
|
||||
|
||||
vector<string> paths = interpreter.modulePaths();
|
||||
paths.push_back (CTL_MODULE_BASE_PATH);
|
||||
interpreter.setModulePaths (paths);
|
||||
|
||||
#endif
|
||||
|
||||
Header outHeader;
|
||||
|
||||
ImfCtl::applyTransforms (interpreter,
|
||||
transformNames,
|
||||
transformWindow,
|
||||
envHeader,
|
||||
inHeader,
|
||||
inFb,
|
||||
outHeader,
|
||||
outFb);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
adjustChromaticities (const Header &header,
|
||||
const Array<Rgba> &inPixels,
|
||||
int w, int h,
|
||||
Array<Rgba> &outPixels)
|
||||
{
|
||||
Chromaticities fileChroma; // default-initialized according to Rec. 709
|
||||
|
||||
if (hasChromaticities (header))
|
||||
fileChroma = chromaticities (header);
|
||||
|
||||
Chromaticities displayChroma = displayChromaticities();
|
||||
|
||||
if (fileChroma.red == displayChroma.red &&
|
||||
fileChroma.green == displayChroma.green &&
|
||||
fileChroma.blue == displayChroma.blue &&
|
||||
fileChroma.white == displayChroma.white)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
M44f M = RGBtoXYZ (fileChroma, 1) * XYZtoRGB (displayChroma, 1);
|
||||
|
||||
size_t numPixels = w * h;
|
||||
|
||||
for (size_t i = 0; i < numPixels; ++i)
|
||||
{
|
||||
const Rgba &in = inPixels[i];
|
||||
Rgba &out = outPixels[i];
|
||||
|
||||
V3f rgb = V3f (in.r, in.g, in.b) * M;
|
||||
|
||||
out.r = rgb[0];
|
||||
out.g = rgb[1];
|
||||
out.b = rgb[2];
|
||||
}
|
||||
}
|
||||
123
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/applyCtl.h
Normal file
123
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/applyCtl.h
Normal file
@@ -0,0 +1,123 @@
|
||||
#ifndef INCLUDED_APPLY_CTL_H
|
||||
#define INCLUDED_APPLY_CTL_H
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2005, 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Apply CTL transforms
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfArray.h>
|
||||
#include <ImfHeader.h>
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
|
||||
//
|
||||
// Apply a series of CTL transforms to the raw pixel data from an image file
|
||||
// in order to generate pixel data that can be displayed on the screen.
|
||||
//
|
||||
// transformNames A list of the names of the CTL transforms that will
|
||||
// be applied to raw pixels. If this list is empty,
|
||||
// applyCtl() looks for a rendering transform and a
|
||||
// display transform:
|
||||
//
|
||||
// If inHeader contains a string attribute called
|
||||
// "renderingTransform" then the value of this attribute
|
||||
// is the name of the rendering transform.
|
||||
// If inHeader contains no such attribute, then the
|
||||
// name of the rendering transform is "transform_RRT".
|
||||
//
|
||||
// If the environment variable CTL_DISPLAY_TRANSFORM
|
||||
// is set, the value of the environment variable is
|
||||
// the name of the display transform.
|
||||
// If the environment variable is not set, then the name
|
||||
// of the display transform is "transform_display_video".
|
||||
//
|
||||
// inHeader The header of the image file.
|
||||
//
|
||||
// inPixels Raw pixels from the image file.
|
||||
//
|
||||
// w, h Width and height of the inPixels and outPixels
|
||||
// arrays. (The caller must set the size of the
|
||||
// arrays to w*h, before calling applyCtl().)
|
||||
//
|
||||
// outPixels Output -- pixels for display on the screen.
|
||||
// The data in outPixels represent relative
|
||||
// luminance values; an R, G or B value of 1.0
|
||||
// represents the maximum red, green or blue
|
||||
// luminance that the display can achieve.
|
||||
//
|
||||
|
||||
void applyCtl (std::vector<std::string> transformNames,
|
||||
IMF::Header inHeader,
|
||||
const IMF::Array<IMF::Rgba> &inPixels,
|
||||
int w,
|
||||
int h,
|
||||
IMF::Array<IMF::Rgba> &outPixels);
|
||||
|
||||
|
||||
//
|
||||
// If the chromaticities of the RGB pixel loaded from a file
|
||||
// are not the same as the chromaticities of the display,
|
||||
// then transform the pixels from the RGB coordinate system
|
||||
// of the file to the RGB coordinate system of the display.
|
||||
//
|
||||
|
||||
void adjustChromaticities (const IMF::Header &header,
|
||||
const IMF::Array<IMF::Rgba> &inPixels,
|
||||
int w,
|
||||
int h,
|
||||
IMF::Array<IMF::Rgba> &outPixels);
|
||||
|
||||
|
||||
//
|
||||
// Get the gamma factor that must be used in order to convert luminance
|
||||
// values output by applyCtl() into display frame buffer values.
|
||||
//
|
||||
|
||||
float displayVideoGamma ();
|
||||
|
||||
|
||||
#endif
|
||||
1000
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/loadImage.cpp
Normal file
1000
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/loadImage.cpp
Normal file
File diff suppressed because it is too large
Load Diff
99
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/loadImage.h
Normal file
99
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/loadImage.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef INCLUDED_LOAD_IMAGE_H
|
||||
#define INCLUDED_LOAD_IMAGE_H
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Load an OpenEXR image into a pixel array.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfArray.h>
|
||||
#include <ImfHeader.h>
|
||||
|
||||
|
||||
//
|
||||
// Load an OpenEXR image file:
|
||||
//
|
||||
// fileName The name of the file to be loaded.
|
||||
//
|
||||
// channel If channel is 0, load the R, G and B channels,
|
||||
// otherwise channel must point to the name of the
|
||||
// image channel to be loaded; the channel is copied
|
||||
// into the R, G and B components of the frame buffer.
|
||||
//
|
||||
// layer Used only if channel is 0: if layer is 0, load
|
||||
// the R, G and B channels, otherwise load layer.R,
|
||||
// layer.G and layer.B.
|
||||
//
|
||||
// preview If preview is true load the file's preview image,
|
||||
// otherwise load the main image.
|
||||
//
|
||||
// lx, ly If lx != 0 or ly != 0 then assume that the input
|
||||
// file is tiled and load level (0, 0).
|
||||
//
|
||||
// header Output -- the header of the input file, but with
|
||||
// the dataWindow, displayWindow and pixelAspectRatio
|
||||
// attributes adjusted to match what parts of the file
|
||||
// were actually loaded.
|
||||
//
|
||||
// pixels Output -- the pixels loaded from the file.
|
||||
// loadImage() resizes the pixels array to fit
|
||||
// the dataWindow attribute of the header.
|
||||
//
|
||||
|
||||
|
||||
void loadImage (const char fileName[],
|
||||
const char channel[],
|
||||
const char layer[],
|
||||
bool preview,
|
||||
int lx,
|
||||
int ly,
|
||||
int partnum,
|
||||
int &zsize,
|
||||
IMF::Header &header,
|
||||
IMF::Array<IMF::Rgba> &pixels,
|
||||
IMF::Array<float*> &zbuffer,
|
||||
IMF::Array<unsigned int> &sampleCount,
|
||||
bool deepComp);
|
||||
|
||||
#endif
|
||||
1063
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/main.cpp
Normal file
1063
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#ifndef NAMESPACEALIAS_H_
|
||||
#define NAMESPACEALIAS_H_
|
||||
|
||||
#include "ImfNamespace.h"
|
||||
#include "ImathNamespace.h"
|
||||
#include "IexNamespace.h"
|
||||
|
||||
namespace IMF = OPENEXR_IMF_NAMESPACE;
|
||||
namespace IMATH = IMATH_NAMESPACE;
|
||||
namespace IEX = IEX_NAMESPACE;
|
||||
|
||||
#endif /* NAMESPACEALIAS_H_ */
|
||||
276
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/scaleImage.cpp
Normal file
276
cs440-acg/ext/openexr/OpenEXR_Viewers/exrdisplay/scaleImage.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Image scaling and filtering functions.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "scaleImage.h"
|
||||
|
||||
#include <ImathLimits.h>
|
||||
#include <ImathFun.h>
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
using namespace IMF;
|
||||
using namespace IMATH;
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
|
||||
int
|
||||
scaleInt (float f, int i)
|
||||
{
|
||||
return int (f * i + 0.5);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scaleX (float f,
|
||||
int &w, int &h,
|
||||
int &dw, int &dh,
|
||||
int &dx, int &dy,
|
||||
Array<Rgba> &pixels)
|
||||
{
|
||||
int dw1 = scaleInt (f, dw);
|
||||
|
||||
if (dw1 <= dw)
|
||||
{
|
||||
//
|
||||
// Do nothing if the width of the data window
|
||||
// woudn't increase by at least one pixel.
|
||||
//
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
w = scaleInt (f, w);
|
||||
dx = scaleInt (f, dx);
|
||||
|
||||
//
|
||||
// Copy the pixels to a temporary array
|
||||
//
|
||||
|
||||
Array<Rgba> tmp (dw * dh);
|
||||
|
||||
for (int i = 0; i < dw * dh; ++i)
|
||||
tmp[i] = pixels[i];
|
||||
|
||||
//
|
||||
// Resize the original pixel array,
|
||||
// and copy the pixels back into the
|
||||
// resized array.
|
||||
//
|
||||
|
||||
pixels.resizeErase (dw1 * dh);
|
||||
|
||||
f = float (dw - 1) / float (dw1 - 1);
|
||||
|
||||
for (int x = 0; x < dw1; ++x)
|
||||
{
|
||||
float x1 = x * f;
|
||||
int xs = int (x1);
|
||||
int xt = min (xs + 1, dw - 1);
|
||||
float t = x1 - xs;
|
||||
float s = 1 - t;
|
||||
|
||||
for (int y = 0; y < dh; ++y)
|
||||
{
|
||||
const Rgba &ps = tmp [y * dw + xs];
|
||||
const Rgba &pt = tmp [y * dw + xt];
|
||||
Rgba &p = pixels[y * dw1 + x];
|
||||
|
||||
p.r = ps.r * s + pt.r * t;
|
||||
p.g = ps.g * s + pt.g * t;
|
||||
p.b = ps.b * s + pt.b * t;
|
||||
p.a = ps.a * s + pt.a * t;
|
||||
}
|
||||
}
|
||||
|
||||
dw = dw1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
scaleY (float f,
|
||||
int &w, int &h,
|
||||
int &dw, int &dh,
|
||||
int &dx, int &dy,
|
||||
Array<Rgba> &pixels)
|
||||
{
|
||||
int dh1 = scaleInt (f, dh);
|
||||
|
||||
if (dh1 <= dh)
|
||||
{
|
||||
//
|
||||
// Do nothing if the height of the data window
|
||||
// woudn't increase by at least one pixel.
|
||||
//
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
h = scaleInt (f, h);
|
||||
dy = scaleInt (f, dy);
|
||||
|
||||
//
|
||||
// Copy the pixels to a temporary array
|
||||
//
|
||||
|
||||
Array<Rgba> tmp (dw * dh);
|
||||
|
||||
for (int i = 0; i < dw * dh; ++i)
|
||||
tmp[i] = pixels[i];
|
||||
|
||||
//
|
||||
// Resize the original pixel array,
|
||||
// and copy the pixels back into the
|
||||
// resized array.
|
||||
//
|
||||
|
||||
pixels.resizeErase (dw * dh1);
|
||||
|
||||
f = float (dh - 1) / float (dh1 - 1);
|
||||
|
||||
for (int y = 0; y < dh1; ++y)
|
||||
{
|
||||
float y1 = y * f;
|
||||
int ys = int (y1);
|
||||
int yt = min (ys + 1, dh - 1);
|
||||
float t = y1 - ys;
|
||||
float s = 1 - t;
|
||||
|
||||
for (int x = 0; x < dw; ++x)
|
||||
{
|
||||
const Rgba &ps = tmp [ys * dw + x];
|
||||
const Rgba &pt = tmp [yt * dw + x];
|
||||
Rgba &p = pixels[y * dw + x];
|
||||
|
||||
p.r = ps.r * s + pt.r * t;
|
||||
p.g = ps.g * s + pt.g * t;
|
||||
p.b = ps.b * s + pt.b * t;
|
||||
p.a = ps.a * s + pt.a * t;
|
||||
}
|
||||
}
|
||||
|
||||
dh = dh1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
normalizePixels (int dw, int dh, Array<Rgba> &pixels)
|
||||
{
|
||||
float pMax = -IMATH::limits<float>::max ();
|
||||
float pMin = IMATH::limits<float>::max ();
|
||||
|
||||
for (int i = 0; i < dw * dh; ++i)
|
||||
{
|
||||
const Rgba &p = pixels[i];
|
||||
|
||||
if (p.r.isFinite())
|
||||
{
|
||||
pMax = max (float (p.r), pMax);
|
||||
pMin = min (float (p.r), pMin);
|
||||
}
|
||||
|
||||
if (p.g.isFinite())
|
||||
{
|
||||
pMax = max (float (p.g), pMax);
|
||||
pMin = min (float (p.g), pMin);
|
||||
}
|
||||
|
||||
if (p.b.isFinite())
|
||||
{
|
||||
pMax = max (float (p.b), pMax);
|
||||
pMin = min (float (p.b), pMin);
|
||||
}
|
||||
}
|
||||
|
||||
if (pMax <= pMin)
|
||||
pMax = pMin + 1;
|
||||
|
||||
for (int i = 0; i < dw * dh; ++i)
|
||||
{
|
||||
Rgba &p = pixels[i];
|
||||
|
||||
if (p.r.isFinite())
|
||||
p.r = (p.r - pMin) / (pMax - pMin);
|
||||
|
||||
if (p.g.isFinite())
|
||||
p.g = (p.g - pMin) / (pMax - pMin);
|
||||
|
||||
if (p.b.isFinite())
|
||||
p.b = (p.b - pMin) / (pMax - pMin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
swapPixels (int dw, int dh, Array<Rgba> &pixels)
|
||||
{
|
||||
Array<Rgba> tmp (max (dw, dh));
|
||||
|
||||
int dw2 = dw / 2;
|
||||
int dh2 = dh / 2;
|
||||
|
||||
//
|
||||
// Swap top and bottom half
|
||||
//
|
||||
|
||||
for (int x = 0; x < dw; ++x)
|
||||
{
|
||||
for (int y = 0; y < dh; ++y)
|
||||
tmp[(y + dh2) % dh] = pixels[dw * y + x];
|
||||
|
||||
for (int y = 0; y < dh; ++y)
|
||||
pixels[dw * y + x] = tmp[y];
|
||||
}
|
||||
|
||||
//
|
||||
// Swap left and right half
|
||||
//
|
||||
|
||||
for (int y = 0; y < dh; ++y)
|
||||
{
|
||||
for (int x = 0; x < dw; ++x)
|
||||
tmp[(x + dw2) % dw] = pixels[dw * y + x];
|
||||
|
||||
for (int x = 0; x < dw; ++x)
|
||||
pixels[dw * y + x] = tmp[x];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_SCALE_IMAGE_H
|
||||
#define INCLUDED_SCALE_IMAGE_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Image scaling and filtering functions.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
#include <ImfRgba.h>
|
||||
#include <ImfArray.h>
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Scale an image horizontally or vertically, by a factor of
|
||||
// approximately f (f is adjusted slightly so that the corners
|
||||
// of the display window and the data window fall on integer
|
||||
// pixel locations).
|
||||
//
|
||||
// f scale factor; must be >= 1.0
|
||||
//
|
||||
// w, h width and height of the display window
|
||||
//
|
||||
// dw, dh width and height of the data window
|
||||
//
|
||||
// dx, dy offset of the data window's upper left
|
||||
// corner from the display window's upper
|
||||
// left corner
|
||||
//
|
||||
// pixels the image's pixel array
|
||||
//
|
||||
|
||||
void scaleX (float f,
|
||||
int &w, int &h,
|
||||
int &dw, int &dh,
|
||||
int &dx, int &dy,
|
||||
IMF::Array<IMF::Rgba> &pixels);
|
||||
|
||||
void scaleY (float f,
|
||||
int &w, int &h,
|
||||
int &dw, int &dh,
|
||||
int &dx, int &dy,
|
||||
IMF::Array<IMF::Rgba> &pixels);
|
||||
|
||||
//
|
||||
// Normalize the pixel values in an image so that the smallest
|
||||
// value becomes 0.0 and the largest value becomes 1.0.
|
||||
//
|
||||
|
||||
void normalizePixels (int dw, int dh, IMF::Array<IMF::Rgba> &pixels);
|
||||
|
||||
|
||||
//
|
||||
// Swap the left and right half of and image; then swap the
|
||||
// top and bottom half, so that the four corners of the image
|
||||
// end up in the center.
|
||||
//
|
||||
|
||||
void swapPixels (int dw, int dh, IMF::Array<IMF::Rgba> &pixels);
|
||||
|
||||
|
||||
#endif
|
||||
171
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/compilelinkrun.m4
Normal file
171
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/compilelinkrun.m4
Normal file
@@ -0,0 +1,171 @@
|
||||
dnl
|
||||
dnl
|
||||
dnl compilelinkrun.m4 - used to check whether a required package is properly
|
||||
dnl installed. Compiles, links and runs a c++ test program that uses the
|
||||
dnl package to verify that the package is properly installed
|
||||
dnl
|
||||
dnl Expected arguments:
|
||||
dnl $1: the name of the package we are testing, e.g. "OpenEXR"
|
||||
dnl used for informational messages, warnings & errors
|
||||
dnl
|
||||
dnl $2: the argument passed to configure specifying how to disable this test
|
||||
dnl for example:
|
||||
dnl $3 = "openexrtest" and
|
||||
dnl "configure --disable-openexrtest" will skip the test
|
||||
dnl
|
||||
dnl $3: CXXFLAGS used by the test
|
||||
dnl
|
||||
dnl $4: LDFLAGS used by the test
|
||||
dnl
|
||||
dnl $5: include section of sourcecode for a c++ test program
|
||||
dnl $6: body section of sourcecode for a c++ test program
|
||||
dnl The test program should make use of a library that is supposed to
|
||||
dnl be tested.
|
||||
dnl
|
||||
dnl $7: the action to be perfomed if the test succeeds
|
||||
dnl (e.g. AC_MSG_RESULT("OpenEXR test program succeeded"))
|
||||
dnl
|
||||
dnl $8 the action to be perfomed if the test fails
|
||||
dnl (e.g. AC_MSG_ERROR("OpenEXR test program failed"))
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AM_COMPILELINKRUN],
|
||||
[
|
||||
|
||||
dnl create some local m4 "variables" so that we don't have to use numbers
|
||||
define([arg_pkg_name],$1)
|
||||
define([arg_disable],$2)
|
||||
define([arg_cxxflags],$3)
|
||||
define([arg_ldflags],$4)
|
||||
define([arg_libs],$5)
|
||||
define([arg_include_source],$6)
|
||||
define([arg_body_source],$7)
|
||||
define([arg_do_yes],$8)
|
||||
define([arg_do_no],$9)
|
||||
|
||||
|
||||
dnl check arguments
|
||||
AC_ARG_ENABLE(arg_disable, [ --disable-arg_disable Do not try to compile and run a test arg_pkg_name program],, enable_programtest=yes)
|
||||
|
||||
|
||||
dnl
|
||||
dnl if the test hasn't been disabled, then compile, link and run test program
|
||||
dnl
|
||||
if test "x$enable_programtest" = "xyes" ; then
|
||||
|
||||
dnl basic preliminary checks
|
||||
AC_MSG_CHECKING(for arg_pkg_name)
|
||||
test_runs="yes"
|
||||
|
||||
dnl save settings and setup c++ before we start
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
ac_save_LDFLAGS="$LDFLAGS"
|
||||
ac_save_LIBS="$LIBS"
|
||||
CXXFLAGS="$CXXFLAGS arg_cxxflags"
|
||||
LDFLAGS="$LDFLAGS arg_ldflags"
|
||||
LIBS="$LIBS arg_libs"
|
||||
AC_REQUIRE_CPP()
|
||||
AC_LANG_PUSH([C++])
|
||||
rm -f conf.testprogram
|
||||
|
||||
dnl
|
||||
dnl first try a complete test - compile, link run
|
||||
dnl
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(arg_include_source,
|
||||
arg_body_source; [[system("touch conf.testprogram"); ]])],
|
||||
test_runs=yes,
|
||||
test_runs=no,
|
||||
[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
||||
|
||||
if test "x$test_runs" = "xyes" || test -f conf.testprogram ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([arg_do_yes], , :, [arg_do_yes])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
echo "*** Could not run the arg_pkg_name test program, checking why..."
|
||||
|
||||
test_compiles="yes"
|
||||
test_links="yes"
|
||||
|
||||
dnl
|
||||
dnl if the program did not run, attempt to compile only
|
||||
dnl
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(arg_include_source,
|
||||
arg_body_source ; )],
|
||||
test_compiles=yes,
|
||||
test_compiles=no)
|
||||
|
||||
if test "x$test_compiles" = "xno" ; then
|
||||
echo "*** The test program could not be compiled. Is arg_pkg_name installed?"
|
||||
echo "*** Check that the cflags (below) includes the arg_pkg_name include directory"
|
||||
|
||||
else
|
||||
dnl
|
||||
dnl if the program did compile, try linking
|
||||
dnl
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM(arg_include_source,
|
||||
arg_body_source ; )],
|
||||
test_links=yes,
|
||||
test_links=no)
|
||||
|
||||
if test "x$test_links" = "xyes"; then
|
||||
echo "*** The test program compiled and staticly linked, but did not run. This "
|
||||
echo "*** usually means that the run-time linker is not finding arg_pkg_name or finding"
|
||||
echo "*** the wrong version of arg_pkg_name."
|
||||
echo "***"
|
||||
echo "*** If the linker is not finding arg_pkg_name, you'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system."
|
||||
else
|
||||
echo "*** The arg_pkg_name test program could be compiled, but could not be dynamically."
|
||||
echo "*** or statically linked."
|
||||
echo "***"
|
||||
echo "*** Make sure the LDFLAGS points to the location of the arg_pkg_name library."
|
||||
echo "*** (e.g. -L/usr/local/lib)."
|
||||
echo "*** If the run-time linker is not finding arg_pkg_name, you'll need to set your"
|
||||
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
|
||||
echo "*** to the installed location Also, make sure you have run ldconfig if that"
|
||||
echo "*** is required on your system."
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl The test failed for some reason. Print out more info,
|
||||
dnl unset flags and signal an error.
|
||||
dnl
|
||||
echo "***"
|
||||
echo "*** Flags used by the test:"
|
||||
echo "*** cflags: $CXXFLAGS "
|
||||
echo "*** ldflags: $LDFLAGS"
|
||||
echo "***"
|
||||
echo "*** You can also run configure with --disable-arg_disable to skip this test."
|
||||
|
||||
ifelse([arg_do_no], , :, [arg_do_no])
|
||||
fi
|
||||
|
||||
AC_LANG_POP([C++])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
|
||||
dnl
|
||||
dnl clean up
|
||||
dnl
|
||||
rm -f conf.testprogram
|
||||
fi
|
||||
|
||||
|
||||
dnl clean up local "variables"
|
||||
undefine([arg_pkg_name])
|
||||
undefine([arg_disable])
|
||||
undefine([arg_cxxflags])
|
||||
undefine([arg_ldflags])
|
||||
undefine([arg_libs])
|
||||
undefine([arg_include_source])
|
||||
undefine([arg_body_source])
|
||||
undefine([arg_do_yes])
|
||||
undefine([arg_do_no])
|
||||
|
||||
])
|
||||
89
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.cb.m4
Normal file
89
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.cb.m4
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
dnl
|
||||
dnl Cg support
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AM_PATH_CG],
|
||||
[dnl
|
||||
dnl Get the cflags
|
||||
dnl
|
||||
AC_ARG_WITH(cg-prefix,[ --with-cg-prefix=PFX Prefix where Cg is installed (optional)],
|
||||
cg_prefix="$withval", cg_prefix="")
|
||||
|
||||
if test x$cg_prefix != x ; then
|
||||
CG_CXXFLAGS="-I$cg_prefix/include"
|
||||
CG_LDFLAGS="-L$cg_prefix/lib -lGL -lCg -lCgGL -lGLU -lpthread -lglut"
|
||||
else
|
||||
case $host_os in
|
||||
darwin*)
|
||||
CG_CXXFLAGS=""
|
||||
CG_LDFLAGS="-framework Cg -framework AGL -framework OpenGL -framework GLUT"
|
||||
;;
|
||||
*)
|
||||
CG_CXXFLAGS=""
|
||||
CG_LDFLAGS="-lGL -lCg -lCgGL -lGLU -lpthread -lglut"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for Cg)
|
||||
no_cg=""
|
||||
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
ac_save_LDFLAGS="$LDFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $CG_CXXFLAGS"
|
||||
LDFLAGS="$CG_LDFLAGS"
|
||||
|
||||
case $host_os in
|
||||
darwin*)
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_LINK([
|
||||
#include <OpenGL/gl.h>
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>],
|
||||
[
|
||||
cgCreateContext ();
|
||||
],, no_cg=yes)
|
||||
;;
|
||||
*)
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_LINK([
|
||||
#include <GL/gl.h>
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>],
|
||||
[
|
||||
cgCreateContext ();
|
||||
],, no_cg=yes)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_LANG_RESTORE
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
|
||||
if test "x$no_cg" = "x" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$1], , :, [$1])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
echo "*** The Cg test program could not be compiled."
|
||||
echo "*** Possible reasons:"
|
||||
echo "*** - The Cg libraries and includes are not installed."
|
||||
echo "*** - configure cannot find Cg (use the"
|
||||
echo "*** --with-cg-prefix option to tell configure where"
|
||||
echo "*** to find it)."
|
||||
echo "*** - Your version of Cg is out of date. Please update it"
|
||||
echo "*** to the latest version."
|
||||
echo "***"
|
||||
echo "*** The exrdisplay program will not be built with fragment shader"
|
||||
echo "*** support because the fragment shader support depends on Cg."
|
||||
CG_CXXFLAGS=""
|
||||
CG_LDFLAGS=""
|
||||
ifelse([$2], , :, [$2])
|
||||
fi
|
||||
AC_SUBST(CG_CXXFLAGS)
|
||||
AC_SUBST(CG_LDFLAGS)
|
||||
])
|
||||
|
||||
81
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.fltk.m4
Normal file
81
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.fltk.m4
Normal file
@@ -0,0 +1,81 @@
|
||||
dnl
|
||||
dnl FLTK with GL support
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AM_PATH_FLTK],
|
||||
[dnl
|
||||
dnl Get the cflags and libraries
|
||||
dnl
|
||||
AC_ARG_VAR(FLTK_CONFIG, Path to fltk-config command)
|
||||
AC_PATH_PROG(FLTK_CONFIG, fltk-config, no, [$PATH:/usr/local/bin])
|
||||
AC_ARG_WITH(fltk-config,[ --with-fltk-config=PATH Specify which fltk-config to use (optional)], FLTK_CONFIG="$withval",)
|
||||
|
||||
if test x$FLTK_CONFIG != xno ; then
|
||||
FLTK_CXXFLAGS="`$FLTK_CONFIG --use-gl --cxxflags`"
|
||||
FLTK_LDFLAGS="`$FLTK_CONFIG --use-gl --ldflags`"
|
||||
else
|
||||
FLTK_CXXFLAGS=""
|
||||
FLTK_LDFLAGS=""
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for FLTK with GL support)
|
||||
no_fltk=""
|
||||
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
ac_save_LDFLAGS="$LDFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $FLTK_CXXFLAGS"
|
||||
LDFLAGS="$LDFLAGS $FLTK_LDFLAGS"
|
||||
|
||||
dnl
|
||||
dnl Now check if the installed FLTK has GL support
|
||||
dnl
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_LINK([
|
||||
#include <stdlib.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Gl_Window.H>],
|
||||
[
|
||||
Fl_Gl_Window foo ();
|
||||
],, no_fltk=yes)
|
||||
AC_LANG_RESTORE
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
|
||||
if test "x$no_fltk" = "x" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ifelse([$1], , :, [$1])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
echo "*** The fltk test program could not be compiled. Possible reasons:"
|
||||
echo "***"
|
||||
echo "*** - FLTK is not installed."
|
||||
echo "*** - Your version of FLTK does not support OpenGL."
|
||||
echo "*** - configure cannot find your 'fltk-config' program (use"
|
||||
echo "*** the --with-fltk-config option to tell configure where"
|
||||
echo "*** to find it)."
|
||||
echo "*** - Your version of FLTK is too old. The exrdisplay"
|
||||
echo "*** program requires FLTK 1.1 or higher."
|
||||
echo "*** - Your FLTK library was compiled with a different C++"
|
||||
echo "*** compiler than the one you're using to compile OpenEXR."
|
||||
echo "***"
|
||||
echo "*** The exrdisplay program will not be built because it depends on"
|
||||
echo "*** a working FLTK install with OpenGL support."
|
||||
FLTK_CXXFLAGS=""
|
||||
FLTK_LDFLAGS=""
|
||||
ifelse([$2], , :, [$2])
|
||||
fi
|
||||
AC_SUBST(FLTK_CXXFLAGS)
|
||||
AC_SUBST(FLTK_LDFLAGS)
|
||||
|
||||
AC_MSG_RESULT([
|
||||
---------------------------------------------
|
||||
Fltk setup:
|
||||
|
||||
FLTK_CXXFLAGS $FLTK_CXXFLAGS
|
||||
FLTK_LDFLAGS $FLTK_LDFLAGS
|
||||
---------------------------------------------
|
||||
])
|
||||
|
||||
|
||||
])
|
||||
18
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.gl.m4
Normal file
18
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.gl.m4
Normal file
@@ -0,0 +1,18 @@
|
||||
dnl
|
||||
dnl Alternate OpenGL headers (e.g. for Nvidia headers)
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AM_PATH_GL],
|
||||
[dnl
|
||||
dnl Get the cflags
|
||||
dnl
|
||||
AC_ARG_WITH(gl-includes,[ --with-gl-includes=PFX Specify which OpenGL headers to use],
|
||||
gl_includes="$withval", gl_includes="")
|
||||
if test x$gl_includes != x ; then
|
||||
GL_CXXFLAGS="-I$gl_includes"
|
||||
else
|
||||
GL_CXXFLAGS=""
|
||||
fi
|
||||
|
||||
AC_SUBST(GL_CXXFLAGS)
|
||||
])
|
||||
134
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.pkgconfig.m4
Normal file
134
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/path.pkgconfig.m4
Normal file
@@ -0,0 +1,134 @@
|
||||
AC_DEFUN([AM_PATH_PKGCONFIG],
|
||||
[
|
||||
|
||||
dnl sets cflags and ldflags
|
||||
dnl TEST_CXXFLAGS and TEST_LDFLAGS, by trying thes following
|
||||
dnl until something works:
|
||||
dnl
|
||||
dnl 1 - try the test_prefix
|
||||
dnl 2 - check whether pkgconfig can find values (unless --with-pkg-config=no)
|
||||
dnl 3 - use the prefix, if it is not the default
|
||||
dnl 4 - use defaults, /usr/local/include/OpenEXR and /usr/local/lib
|
||||
dnl
|
||||
dnl
|
||||
dnl Expected arguments
|
||||
dnl $1: arg_cxxflags - CXXFLAGS variable to set
|
||||
dnl
|
||||
dnl $2: arg-ldflags - LDFLAGS variable to set
|
||||
dnl
|
||||
dnl $3: package name (the package being checked), as requried by pkg-config
|
||||
dnl
|
||||
dnl $4: arg_include_subdir
|
||||
dnl the name of the subdirectory name that is tacked on to
|
||||
dnl the end of the include path e.g. "OpenEXR" in
|
||||
dnl /usr/local/include/OpenEXR
|
||||
dnl
|
||||
dnl $5: arg_default_libs - default libraries, used if pkgconfig doesnt work
|
||||
dnl
|
||||
dnl $6: arg_test_prefix
|
||||
dnl the argument passed to configure specifying a directory to
|
||||
dnl be used in the CXX and LD flags for example:
|
||||
dnl $2 = "openexr-prefix" and
|
||||
dnl "configure --openexr-prefix=/usr/lib"
|
||||
dnl leads to CXX including "-I/usr/lib/OpenEXR"
|
||||
dnl
|
||||
|
||||
dnl create some local m4 "variables" so that we don't have to use numbers
|
||||
define([arg_cxxflags],$1)
|
||||
define([arg_ldflags],$2)
|
||||
define([arg_libs],$3)
|
||||
define([arg_pkg_name],$4)
|
||||
define([arg_include_subdir],$5)
|
||||
define([arg_default_ldflags],$6)
|
||||
define([arg_default_libs],$7)
|
||||
define([arg_test_prefix],$8)
|
||||
|
||||
TEST_CXXFLAGS=""
|
||||
TEST_LDFLAGS=""
|
||||
TEST_LIBS=""
|
||||
|
||||
AC_ARG_WITH(arg_test_prefix,[ --with-arg_test_prefix=PFX Prefix where tested libraries are supposed to be installed (optional)], test_prefix="$withval", test_prefix="NONE")
|
||||
echo "test_prefix = $test_prefix"
|
||||
|
||||
AC_ARG_VAR(PKG_CONFIG, Path to pkg-config command)
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
AC_ARG_WITH(pkg-config,[ --with-pkg-config=PATH Specify which pkg-config to use (optional)], PKG_CONFIG="$withval",)
|
||||
|
||||
|
||||
if test "x$test_prefix" != "xNONE" ; then
|
||||
echo "using arg_test_prefix to set arg_cxxflags, arg_ldflags and arg_libs:"
|
||||
for inc_dir in arg_include_subdir
|
||||
do
|
||||
TEST_CXXFLAGS="$TEST_CXXFLAGS -I$test_prefix/include/$inc_dir"
|
||||
done
|
||||
TEST_LDFLAGS="-L$test_prefix/lib"
|
||||
TEST_LDFLAGS="$TEST_LDFLAGS arg_default_ldflags"
|
||||
TEST_LIBS="arg_default_libs"
|
||||
else
|
||||
dnl
|
||||
dnl Get the cflags and libraries from the arg_pkg_name package using
|
||||
dnl pkg-config
|
||||
dnl
|
||||
dnl Note: the TEST_LIBS contains both the -L and the -l flags. This means
|
||||
dnl the -L flags will appear twice on the command line, but we can not
|
||||
dnl limit it to --libs-only-l because it may include the "-pthread" flag.
|
||||
dnl
|
||||
if test x$PKG_CONFIG != xno ; then
|
||||
echo "using pkg-config to set arg_cxxflags and arg_ldflags:"
|
||||
TEST_CXXFLAGS="`$PKG_CONFIG --cflags arg_pkg_name`"
|
||||
TEST_LDFLAGS="`$PKG_CONFIG --libs-only-L arg_pkg_name`"
|
||||
TEST_LIBS="`$PKG_CONFIG --libs arg_pkg_name`"
|
||||
else
|
||||
echo "Not using pkg-config."
|
||||
TEST_CXXFLAGS=""
|
||||
TEST_LDFLAGS=""
|
||||
TEST_LIBS=""
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl if the flags are still not set, try a prefix and finally a default
|
||||
dnl
|
||||
if test -z "${TEST_CXXFLAGS}"; then
|
||||
TEST_CXXFLAGS=""
|
||||
if test "x$prefix" != "xNONE"; then
|
||||
echo "using prefix to set arg_cxxflags and arg_ldflags:"
|
||||
for inc_dir in arg_include_subdir
|
||||
do
|
||||
TEST_CXXFLAGS="$TEST_CXXFLAGS -I$prefix/include/$inc_dir"
|
||||
done
|
||||
TEST_LDFLAGS="-L$prefix/lib"
|
||||
else
|
||||
echo "using default as guess for arg_cxxflags and arg_ldflags:"
|
||||
for inc_dir in arg_include_subdir
|
||||
do
|
||||
TEST_CXXFLAGS="$TEST_CXXFLAGS -I/usr/local/include/$inc_dir"
|
||||
done
|
||||
TEST_LDFLAGS="arg_default_ldflags"
|
||||
fi
|
||||
TEST_LIBS="arg_default_libs"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo " arg_cxxflags = $TEST_CXXFLAGS"
|
||||
echo " arg_ldflags = $TEST_LDFLAGS"
|
||||
echo " arg_libs = $TEST_LIBS"
|
||||
|
||||
|
||||
AC_SUBST(arg_cxxflags, $TEST_CXXFLAGS)
|
||||
AC_SUBST(arg_ldflags, $TEST_LDFLAGS)
|
||||
AC_SUBST(arg_libs, $TEST_LIBS)
|
||||
|
||||
|
||||
dnl clean up local "variables"
|
||||
undefine([arg_cxxflags])
|
||||
undefine([arg_ldflags])
|
||||
undefine([arg_libs])
|
||||
undefine([arg_pkg_name])
|
||||
undefine([arg_include_subdir])
|
||||
undefine([arg_default_ldflags])
|
||||
undefine([arg_default_libs])
|
||||
undefine([arg_test_prefix])
|
||||
|
||||
])
|
||||
|
||||
|
||||
291
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/threads.m4
Normal file
291
cs440-acg/ext/openexr/OpenEXR_Viewers/m4/threads.m4
Normal file
@@ -0,0 +1,291 @@
|
||||
|
||||
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
dnl Modified by Wojciech Jarosz (2005) to include check for POSIX
|
||||
dnl semaphore usability. Defines HAVE_POSIX_SEMAPHORES if found.
|
||||
dnl
|
||||
dnl This macro figures out how to build C programs using POSIX threads.
|
||||
dnl It sets the PTHREAD_LIBS output variable to the threads library and
|
||||
dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
|
||||
dnl C compiler flags that are needed. (The user can also force certain
|
||||
dnl compiler flags/libs to be tested by setting these environment
|
||||
dnl variables.)
|
||||
dnl
|
||||
dnl Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||
dnl multi-threaded programs (defaults to the value of CC otherwise).
|
||||
dnl (This is necessary on AIX to use the special cc_r compiler alias.)
|
||||
dnl
|
||||
dnl NOTE: You are assumed to not only compile your program with these
|
||||
dnl flags, but also link it with them as well. e.g. you should link
|
||||
dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
|
||||
dnl $LIBS
|
||||
dnl
|
||||
dnl If you are only building threads programs, you may wish to use
|
||||
dnl these variables in your default LIBS, CFLAGS, and CC:
|
||||
dnl
|
||||
dnl LIBS="$PTHREAD_LIBS $LIBS"
|
||||
dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
dnl CC="$PTHREAD_CC"
|
||||
dnl
|
||||
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
|
||||
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
|
||||
dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
dnl
|
||||
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
|
||||
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
|
||||
dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
|
||||
dnl default action will define HAVE_PTHREAD.
|
||||
dnl
|
||||
dnl Please let the authors know if this macro fails on any platform, or
|
||||
dnl if you have any other suggestions or comments. This macro was based
|
||||
dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
|
||||
dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
|
||||
dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
|
||||
dnl We are also grateful for the helpful feedback of numerous users.
|
||||
dnl
|
||||
dnl @category InstalledPackages
|
||||
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
dnl @version 2005-01-14
|
||||
dnl @license GPLWithACException
|
||||
|
||||
AC_DEFUN([ACX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
acx_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all, and "pthread-config"
|
||||
# which is a program returning the flags for the Pth emulation library.
|
||||
|
||||
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthread or
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
for flag in $acx_pthread_flags; do
|
||||
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||
PTHREAD_CFLAGS="$flag"
|
||||
PTHREAD_LIBS="$flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
||||
if test x"$acx_pthread_config" = xno; then continue; fi
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[acx_pthread_ok=yes])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
attr_name=unknown
|
||||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr;],
|
||||
[attr_name=$attr; break])
|
||||
done
|
||||
AC_MSG_RESULT($attr_name)
|
||||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||
esac
|
||||
AC_MSG_RESULT(${flag})
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
# More AIX lossage: must compile with cc_r
|
||||
AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
|
||||
else
|
||||
PTHREAD_CC="$CC"
|
||||
fi
|
||||
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
AC_SUBST(PTHREAD_CC)
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$acx_pthread_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||
:
|
||||
else
|
||||
acx_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
|
||||
AC_LANG_RESTORE
|
||||
])dnl ACX_PTHREAD
|
||||
|
||||
|
||||
dnl
|
||||
dnl Posix Semaphore support
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AM_POSIX_SEM],
|
||||
[
|
||||
AC_ARG_ENABLE([posix-sem], AC_HELP_STRING([--disable-posix-sem],
|
||||
[do not attempt to use POSIX unnamed semaphores]))
|
||||
|
||||
am_posix_sem_ok=no
|
||||
if test "${enable_posix_sem:-yes}" != "no"; then
|
||||
AC_CHECK_HEADERS([semaphore.h], [
|
||||
AC_SEARCH_LIBS(sem_init, [posix4 pthread], [
|
||||
AC_MSG_CHECKING([whether to use POSIX unnamed semaphores])
|
||||
AC_RUN_IFELSE([
|
||||
AC_LANG_PROGRAM([#include <semaphore.h>], [
|
||||
sem_t mysem;
|
||||
if (sem_init (&mysem, 1, 1) == 0)
|
||||
{
|
||||
if (sem_wait (&mysem) == 0)
|
||||
{
|
||||
sem_post (&mysem);
|
||||
sem_destroy (&mysem);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([yes])
|
||||
am_posix_sem_ok=yes], [
|
||||
AC_MSG_RESULT([no (pshared not usable)])], [
|
||||
AC_MSG_RESULT([no (cannot check usability when cross compiling)])])
|
||||
])
|
||||
])
|
||||
fi
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$am_posix_sem_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_POSIX_SEMAPHORES),[$1])
|
||||
:
|
||||
else
|
||||
am_posix_sem_ok=no
|
||||
$2
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
17
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/.cvsignore
Normal file
17
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/.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
|
||||
40
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/CMakeLists.txt
Normal file
40
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
ADD_EXECUTABLE ( playexr
|
||||
main.cpp
|
||||
playExr.cpp
|
||||
playExr.h
|
||||
fileNameForFrame.cpp
|
||||
fileNameForFrame.h
|
||||
FileReadingThread.cpp
|
||||
FileReadingThread.h
|
||||
ImageBuffers.cpp
|
||||
ImageBuffers.h
|
||||
Timer.cpp
|
||||
Timer.h
|
||||
ctlToLut.cpp
|
||||
ctlToLut.h
|
||||
osDependent.cpp
|
||||
osDependent.h
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES (
|
||||
${CG_INCLUDE_PATH}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( playexr
|
||||
IlmImf${OPENEXR_LIBSUFFIX}
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
IlmThread${ILMBASE_LIBSUFFIX}
|
||||
Half
|
||||
${CG_LIBRARY}
|
||||
${CG_GL_LIBRARY}
|
||||
${OPENGL_LIBRARIES}
|
||||
${GLUT_LIBRARY}
|
||||
)
|
||||
|
||||
INSTALL ( TARGETS
|
||||
playexr
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/bin
|
||||
)
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class FileReadingThread
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "FileReadingThread.h"
|
||||
#include "fileNameForFrame.h"
|
||||
#include "ImageBuffers.h"
|
||||
#include <ImfInputFile.h>
|
||||
#include <Iex.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace OPENEXR_IMF_NAMESPACE;
|
||||
using namespace ILMTHREAD_NAMESPACE;
|
||||
using namespace IEX_NAMESPACE;
|
||||
using namespace std;
|
||||
|
||||
|
||||
FileReadingThread::FileReadingThread
|
||||
(const char fileNameTemplate[],
|
||||
int firstFrame,
|
||||
int lastFrame,
|
||||
ImageBuffers &imageBuffers)
|
||||
:
|
||||
Thread(),
|
||||
_fileNameTemplate (fileNameTemplate),
|
||||
_firstFrame (firstFrame),
|
||||
_lastFrame (lastFrame),
|
||||
_imageBuffers (imageBuffers)
|
||||
{
|
||||
start(); // start() calls run()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FileReadingThread::run ()
|
||||
{
|
||||
try
|
||||
{
|
||||
int i = 0; // index of the image buffer we will fill next
|
||||
int frame = _firstFrame;
|
||||
|
||||
while (true)
|
||||
{
|
||||
//
|
||||
// Check if the display thread wants us to exit.
|
||||
//
|
||||
|
||||
if (_imageBuffers.exitSemaphore1.tryWait())
|
||||
{
|
||||
_imageBuffers.exitSemaphore2.post();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Wait for an image buffer to become available.
|
||||
//
|
||||
|
||||
_imageBuffers.emptyBuffersSemaphore.wait();
|
||||
|
||||
//
|
||||
// Generate the file name for this frame
|
||||
// and open the corresponding OpenEXR file.
|
||||
//
|
||||
|
||||
string fileName = fileNameForFrame (_fileNameTemplate, frame);
|
||||
InputFile in (fileName.c_str());
|
||||
|
||||
//
|
||||
// Verify that this frame has the same data window
|
||||
// as all other frames. (We do not dynamically resize
|
||||
// our image buffers.)
|
||||
//
|
||||
|
||||
if (in.header().dataWindow() != _imageBuffers.dataWindow)
|
||||
THROW (ArgExc,
|
||||
"Data window of frame " << frame << " "
|
||||
"differs from data window of "
|
||||
"frame " << _firstFrame << ".");
|
||||
|
||||
//
|
||||
// Read the OpenEXR file, storing the pixels in
|
||||
// image buffer i.
|
||||
//
|
||||
|
||||
in.setFrameBuffer (_imageBuffers.frameBuffer (i));
|
||||
|
||||
in.readPixels (_imageBuffers.dataWindow.min.y,
|
||||
_imageBuffers.dataWindow.max.y);
|
||||
|
||||
//
|
||||
// Mark the image buffer as full; the display
|
||||
// thread can now display this frame.
|
||||
//
|
||||
|
||||
_imageBuffers.frameNumber (i) = frame;
|
||||
_imageBuffers.fullBuffersSemaphore.post();
|
||||
|
||||
//
|
||||
// Advance to the next frame
|
||||
//
|
||||
|
||||
if (_imageBuffers.forward)
|
||||
{
|
||||
if (frame >= _lastFrame)
|
||||
frame = _firstFrame;
|
||||
else
|
||||
frame += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (frame <= _firstFrame)
|
||||
frame = _lastFrame;
|
||||
else
|
||||
frame -= 1;
|
||||
}
|
||||
|
||||
i = (i + 1) % _imageBuffers.numBuffers();
|
||||
}
|
||||
}
|
||||
catch (const std::exception &exc)
|
||||
{
|
||||
//
|
||||
// If anything goes wrong, print an eror message and exit.
|
||||
//
|
||||
|
||||
cerr << exc.what() << endl;
|
||||
|
||||
_imageBuffers.exitSemaphore2.post();
|
||||
_imageBuffers.fullBuffersSemaphore.post();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_FILE_READING_THREAD_H
|
||||
#define INCLUDED_FILE_READING_THREAD_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class FileReadingThread
|
||||
//
|
||||
// The file reading thread for the playExr application; reads
|
||||
// image files and hands the pixels to the display thread.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <IlmThread.h>
|
||||
#include <string>
|
||||
|
||||
class ImageBuffers;
|
||||
|
||||
|
||||
class FileReadingThread: ILMTHREAD_NAMESPACE::Thread
|
||||
{
|
||||
public:
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Constructor - stores the arguments passed by the caller,
|
||||
// and starts the thread by calling run(), below. The caller
|
||||
// must not destroy the FileReadingThread object while the
|
||||
// thread is running.
|
||||
//
|
||||
// Arguments:
|
||||
//
|
||||
// fileNameTemplate The file name for frame f will
|
||||
// be generated by calling
|
||||
// fileNameForFrame (fileNameTemplate, f)
|
||||
//
|
||||
// firstFrame, lastFrame Range of frame numbers to be loaded.
|
||||
// after loading the last frame, the
|
||||
// file reading thread starts over with
|
||||
// the first frame.
|
||||
//
|
||||
// imageBuffers A ring buffer for the pixel data
|
||||
// loaded from the image files. The
|
||||
// ring buffer has enough space for
|
||||
// imageBuffers.numBuffers() images.
|
||||
// Two semaphores track the number of
|
||||
// empty and full image buffers.
|
||||
// The file reading thread fills the
|
||||
// buffers, and the display thread
|
||||
// empties them.
|
||||
//----------------------------------------------------------------
|
||||
|
||||
FileReadingThread
|
||||
(const char fileNameTemplate[],
|
||||
int firstFrame,
|
||||
int lastFrame,
|
||||
ImageBuffers &imageBuffers);
|
||||
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
|
||||
const std::string _fileNameTemplate;
|
||||
int _firstFrame;
|
||||
int _lastFrame;
|
||||
ImageBuffers & _imageBuffers;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ImageBuffers
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "ImageBuffers.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
using namespace OPENEXR_IMF_NAMESPACE;
|
||||
using namespace ILMTHREAD_NAMESPACE;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
|
||||
|
||||
ImageBuffers::ImageBuffers ():
|
||||
forward (true),
|
||||
rgbMode (false),
|
||||
emptyBuffersSemaphore (NUM_BUFFERS),
|
||||
fullBuffersSemaphore (0),
|
||||
exitSemaphore1 (0),
|
||||
exitSemaphore2 (0)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ImageBuffers::numBuffers ()
|
||||
{
|
||||
return NUM_BUFFERS;
|
||||
}
|
||||
|
||||
|
||||
OPENEXR_IMF_NAMESPACE::FrameBuffer &
|
||||
ImageBuffers::frameBuffer (int i)
|
||||
{
|
||||
assert (i >= 0 && i < NUM_BUFFERS);
|
||||
return _frameBuffers[i];
|
||||
}
|
||||
|
||||
|
||||
char * &
|
||||
ImageBuffers::pixels (int i, int channel)
|
||||
{
|
||||
assert (i >= 0 && i < NUM_BUFFERS && channel >= 0 && channel < 3);
|
||||
return _pixels[i][channel];
|
||||
}
|
||||
|
||||
|
||||
int &
|
||||
ImageBuffers::frameNumber (int i)
|
||||
{
|
||||
assert (i >= 0 && i < NUM_BUFFERS);
|
||||
return _frameNumbers[i];
|
||||
}
|
||||
167
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/ImageBuffers.h
Normal file
167
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/ImageBuffers.h
Normal file
@@ -0,0 +1,167 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_IMAGE_BUFFERS_H
|
||||
#define INCLUDED_IMAGE_BUFFERS_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// class ImageBuffers
|
||||
//
|
||||
// This class implements a ring buffer for a fixed number frames
|
||||
// of an image sequence. The playExr program uses this ring buffer
|
||||
// to transport images from the file reading thread to the display
|
||||
// thread. For each frame, the ImageBuffer contains:
|
||||
//
|
||||
// * buffers for the pixels in the frame's thee channels,
|
||||
// either R, G, B or Y, RY, BY
|
||||
//
|
||||
// * An Imf::FrameBuffer object that describes the layout of
|
||||
// the pixel buffers. This is used by the file reading thread.
|
||||
//
|
||||
// The ImageBuffer also stores the data window of the frames in
|
||||
// the image sequence, and a flag that indicates if the frames
|
||||
// contain RGB or luminance/chroma (Y, RY, BY) data.
|
||||
//
|
||||
// Two semaphores indicate which frames in the ring buffer are
|
||||
// empty and how many are full. The file reading thread fills
|
||||
// frames and the display thread empties them.
|
||||
//
|
||||
// The file reading thread executes a loop that looks like this:
|
||||
//
|
||||
// int i = 0;
|
||||
//
|
||||
// while (true)
|
||||
// {
|
||||
// emptyBuffersSemaphore.wait();
|
||||
// read next frame from a file, store it in buffer i;
|
||||
// fullBuffersSemaphore.post();
|
||||
// i = (i + 1) % numBuffers();
|
||||
// }
|
||||
//
|
||||
// The corresponding loop in the display thread looks like this:
|
||||
//
|
||||
// int i = 0;
|
||||
//
|
||||
// while (true)
|
||||
// {
|
||||
// fullBuffersSemaphore.wait();
|
||||
// display the image in buffer i;
|
||||
// emptyBuffersSemaphore.post();
|
||||
// i = (i + 1) % numBuffers();
|
||||
// }
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImathBox.h>
|
||||
#include <IlmThreadSemaphore.h>
|
||||
|
||||
|
||||
class ImageBuffers
|
||||
{
|
||||
public:
|
||||
|
||||
ImageBuffers ();
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Flag that indicates if we are playing forward or backward
|
||||
//----------------------------------------------------------
|
||||
|
||||
bool forward;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Flag that indicates if the frames contain RGB or luminance/chroma data
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool rgbMode;
|
||||
|
||||
//------------------------------------
|
||||
// Number of frames in the ring buffer
|
||||
//------------------------------------
|
||||
|
||||
int numBuffers ();
|
||||
|
||||
//------------------------------------------------
|
||||
// Access to the Imf::FrameBuffers
|
||||
// i must be in the range from 0 to numBuffers()-1
|
||||
//------------------------------------------------
|
||||
|
||||
OPENEXR_IMF_NAMESPACE::FrameBuffer & frameBuffer (int i);
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
// Access to the pixel buffers
|
||||
// i must be in the range from 0 to numBuffers()-1
|
||||
// channel must be in the range from 0 to 2
|
||||
//------------------------------------------------
|
||||
|
||||
char * & pixels (int i, int channel);
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Access to frame numbers that correspond the pixel buffers.
|
||||
// i must be in the range from 0 to numBuffers()-1
|
||||
//-----------------------------------------------------------
|
||||
|
||||
int & frameNumber (int i);
|
||||
|
||||
|
||||
//---------------------------
|
||||
// Data window for all frames
|
||||
//---------------------------
|
||||
|
||||
IMATH_NAMESPACE::Box2i dataWindow;
|
||||
|
||||
|
||||
//-----------
|
||||
// Semaphores
|
||||
//-----------
|
||||
|
||||
ILMTHREAD_NAMESPACE::Semaphore emptyBuffersSemaphore;
|
||||
ILMTHREAD_NAMESPACE::Semaphore fullBuffersSemaphore;
|
||||
ILMTHREAD_NAMESPACE::Semaphore exitSemaphore1;
|
||||
ILMTHREAD_NAMESPACE::Semaphore exitSemaphore2;
|
||||
|
||||
private:
|
||||
|
||||
static const int NUM_BUFFERS = 3;
|
||||
|
||||
OPENEXR_IMF_NAMESPACE::FrameBuffer _frameBuffers[NUM_BUFFERS];
|
||||
char * _pixels[NUM_BUFFERS][3];
|
||||
int _frameNumbers[NUM_BUFFERS];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
52
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/Makefile.am
Normal file
52
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/Makefile.am
Normal file
@@ -0,0 +1,52 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
if HAVE_CG
|
||||
|
||||
bin_PROGRAMS = playexr
|
||||
|
||||
playexr_CPPFLAGS = $(AM_CPPFLAGS)
|
||||
|
||||
INCLUDES = \
|
||||
@OPENEXR_CTL_CXXFLAGS@ \
|
||||
@GL_CXXFLAGS@ \
|
||||
@CG_CXXFLAGS@
|
||||
|
||||
LDADD = \
|
||||
@OPENEXR_CTL_LDFLAGS@ \
|
||||
@CG_LDFLAGS@ \
|
||||
@OPENEXR_CTL_LIBS@
|
||||
|
||||
|
||||
|
||||
|
||||
playexr_SOURCES = \
|
||||
main.cpp \
|
||||
playExr.cpp \
|
||||
playExr.h \
|
||||
fileNameForFrame.cpp \
|
||||
fileNameForFrame.h \
|
||||
FileReadingThread.cpp \
|
||||
FileReadingThread.h \
|
||||
ImageBuffers.cpp \
|
||||
ImageBuffers.h \
|
||||
Timer.cpp \
|
||||
Timer.h \
|
||||
ctlToLut.cpp \
|
||||
ctlToLut.h \
|
||||
osDependent.cpp \
|
||||
osDependent.h
|
||||
|
||||
endif
|
||||
|
||||
noinst_HEADERS = \
|
||||
playExr.h \
|
||||
fileNameForFrame.h \
|
||||
FileReadingThread.h \
|
||||
ImageBuffers.h \
|
||||
Timer.h \
|
||||
ctlToLut.cpp \
|
||||
ctlToLut.h \
|
||||
osDependent.h
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(playexr_SOURCES)
|
||||
182
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/Timer.cpp
Normal file
182
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/Timer.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Timing control for the display thread of the playExr prgram
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "Timer.h"
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static int
|
||||
gettimeofday (struct timeval *tv, void *tz)
|
||||
{
|
||||
union
|
||||
{
|
||||
ULONGLONG ns100; // time since 1 Jan 1601 in 100ns units
|
||||
FILETIME ft;
|
||||
} now;
|
||||
|
||||
GetSystemTimeAsFileTime (&now.ft);
|
||||
tv->tv_usec = long ((now.ns100 / 10LL) % 1000000LL);
|
||||
tv->tv_sec = long ((now.ns100 - 116444736000000000LL) / 10000000LL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Timer::Timer ():
|
||||
playState (RUNNING),
|
||||
_spf (1 / 24.0),
|
||||
_timingError (0),
|
||||
_framesSinceLastFpsFrame (0),
|
||||
_actualFrameRate (0)
|
||||
{
|
||||
gettimeofday (&_lastFrameTime, 0);
|
||||
_lastFpsFrameTime = _lastFrameTime;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Timer::waitUntilNextFrameIsDue ()
|
||||
{
|
||||
if (playState != RUNNING)
|
||||
{
|
||||
//
|
||||
// If we are not running, reset all timing state
|
||||
// variables and return without waiting.
|
||||
//
|
||||
|
||||
gettimeofday (&_lastFrameTime, 0);
|
||||
_timingError = 0;
|
||||
_lastFpsFrameTime = _lastFrameTime;
|
||||
_framesSinceLastFpsFrame = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// If less than _spf seconds have passed since the last frame
|
||||
// was displayed, sleep until exactly _spf seconds have gone by.
|
||||
//
|
||||
|
||||
timeval now;
|
||||
gettimeofday (&now, 0);
|
||||
|
||||
float timeSinceLastFrame = now.tv_sec - _lastFrameTime.tv_sec +
|
||||
(now.tv_usec - _lastFrameTime.tv_usec) * 1e-6f;
|
||||
|
||||
float timeToSleep = _spf - timeSinceLastFrame - _timingError;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
if (timeToSleep > 0)
|
||||
Sleep (int (timeToSleep * 1000.0f));
|
||||
|
||||
#else
|
||||
|
||||
if (timeToSleep > 0)
|
||||
{
|
||||
timespec ts;
|
||||
ts.tv_sec = (time_t) timeToSleep;
|
||||
ts.tv_nsec = (long) ((timeToSleep - ts.tv_sec) * 1e9f);
|
||||
nanosleep (&ts, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// If we slept, it is possible that we woke up a little too early
|
||||
// or a little too late. Keep track of the difference between
|
||||
// now and the exact time when we wanted to wake up; next time
|
||||
// we'll try sleep that much longer or shorter. This should
|
||||
// keep our average frame rate close to one fame every _spf seconds.
|
||||
//
|
||||
|
||||
gettimeofday (&now, 0);
|
||||
|
||||
timeSinceLastFrame = now.tv_sec - _lastFrameTime.tv_sec +
|
||||
(now.tv_usec - _lastFrameTime.tv_usec) * 1e-6f;
|
||||
|
||||
_timingError += timeSinceLastFrame - _spf;
|
||||
|
||||
if (_timingError < -2 * _spf)
|
||||
_timingError = -2 * _spf;
|
||||
|
||||
if (_timingError > 2 * _spf)
|
||||
_timingError = 2 * _spf;
|
||||
|
||||
_lastFrameTime = now;
|
||||
|
||||
//
|
||||
// Calculate our actual frame rate, averaged over several frames.
|
||||
//
|
||||
|
||||
if (_framesSinceLastFpsFrame >= 24)
|
||||
{
|
||||
float t = now.tv_sec - _lastFpsFrameTime.tv_sec +
|
||||
(now.tv_usec - _lastFpsFrameTime.tv_usec) * 1e-6f;
|
||||
|
||||
if (t > 0)
|
||||
_actualFrameRate = _framesSinceLastFpsFrame / t;
|
||||
|
||||
_framesSinceLastFpsFrame = 0;
|
||||
}
|
||||
|
||||
if (_framesSinceLastFpsFrame == 0)
|
||||
_lastFpsFrameTime = now;
|
||||
|
||||
_framesSinceLastFpsFrame += 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Timer::setDesiredFrameRate (float fps)
|
||||
{
|
||||
_spf = 1 / fps;
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
Timer::actualFrameRate ()
|
||||
{
|
||||
return _actualFrameRate;
|
||||
}
|
||||
115
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/Timer.h
Normal file
115
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/Timer.h
Normal file
@@ -0,0 +1,115 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_TIMER_H
|
||||
#define INCLUDED_TIMER_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Timing control for the display thread of the playExr prgram
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
enum PlayState
|
||||
{
|
||||
PREPARE_TO_RUN,
|
||||
RUNNING,
|
||||
PREPARE_TO_PAUSE,
|
||||
PAUSE,
|
||||
};
|
||||
|
||||
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
|
||||
//------------
|
||||
// Constructor
|
||||
//------------
|
||||
|
||||
Timer ();
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Timing control to maintain the desired frame rate:
|
||||
// the redrawWindow() function in the display thread calls
|
||||
// waitUntilNextFrameIsDue() before displaying each frame.
|
||||
//
|
||||
// If playState == RUNNING, then waitUntilNextFrameIsDue()
|
||||
// sleeps until the apropriate amount of time has elapsed
|
||||
// since the last call to waitUntilNextFrameIsDue().
|
||||
// If playState != RUNNING, then waitUntilNextFrameIsDue()
|
||||
// returns immediately.
|
||||
//--------------------------------------------------------
|
||||
|
||||
void waitUntilNextFrameIsDue ();
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// Set and get the frame rate, in frames per second
|
||||
//-------------------------------------------------
|
||||
|
||||
void setDesiredFrameRate (float fps);
|
||||
float actualFrameRate ();
|
||||
|
||||
|
||||
//-------------------
|
||||
// Current play state
|
||||
//-------------------
|
||||
|
||||
PlayState playState;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
float _spf; // desired frame rate,
|
||||
// in seconds per frame
|
||||
|
||||
timeval _lastFrameTime; // time when we displayed the
|
||||
// last frame
|
||||
|
||||
float _timingError; // cumulative timing error
|
||||
|
||||
timeval _lastFpsFrameTime; // state to keep track of the
|
||||
int _framesSinceLastFpsFrame; // actual frame trate, averaged
|
||||
float _actualFrameRate; // over several frames
|
||||
};
|
||||
|
||||
#endif
|
||||
465
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/ctlToLut.cpp
Normal file
465
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/ctlToLut.cpp
Normal file
@@ -0,0 +1,465 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Run a set of CTL transforms to generate a color lookup table.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ctlToLut.h"
|
||||
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
|
||||
#include <ImfCtlApplyTransforms.h>
|
||||
#include <CtlSimdInterpreter.h>
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <stdlib.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace Ctl;
|
||||
|
||||
using namespace OPENEXR_IMF_NAMESPACE;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
|
||||
#else
|
||||
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <stdlib.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace OPENEXR_IMF_NAMESPACE;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define WARNING(message) (cerr << "Warning: " << message << endl)
|
||||
|
||||
|
||||
float
|
||||
displayVideoGamma ()
|
||||
{
|
||||
//
|
||||
// Get the display's video gamma from an environment variable.
|
||||
// If this fails, use a default value (1/2.2).
|
||||
//
|
||||
|
||||
const char gammaEnv[] = "EXR_DISPLAY_VIDEO_GAMMA";
|
||||
float g = 2.2f;
|
||||
|
||||
if (const char *gamma = getenv (gammaEnv))
|
||||
{
|
||||
float tmp;
|
||||
int n = sscanf (gamma, " %f", &tmp);
|
||||
|
||||
if (n != 1)
|
||||
WARNING ("Cannot parse environment variable " << gammaEnv << "; "
|
||||
"using default value (" << g << ").");
|
||||
else if (tmp < 1.f)
|
||||
WARNING ("Display video gamma, specified in environment "
|
||||
"variable " << gammaEnv << " is out of range; "
|
||||
"using default value (" << g << ").");
|
||||
else
|
||||
g = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << gammaEnv << " is not set; "
|
||||
"using default value (" << g << ").");
|
||||
}
|
||||
|
||||
return 1.f / g;
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
initializeEnvHeader (Header &envHeader)
|
||||
{
|
||||
//
|
||||
// Initialize the "environment header" for the CTL
|
||||
// transforms by adding displayChromaticities,
|
||||
// displayWhiteLuminance and displaySurroundLuminance
|
||||
// attributes.
|
||||
//
|
||||
|
||||
//
|
||||
// Get the chromaticities of the display's primaries and
|
||||
// white point from an environment variable. If this fails,
|
||||
// assume chromaticities according to Rec. ITU-R BT.709.
|
||||
//
|
||||
|
||||
static const char chromaticitiesEnv[] = "CTL_DISPLAY_CHROMATICITIES";
|
||||
Chromaticities c; // default-initialized according to Rec. 709
|
||||
|
||||
if (const char *chromaticities = getenv (chromaticitiesEnv))
|
||||
{
|
||||
Chromaticities tmp;
|
||||
|
||||
int n = sscanf (chromaticities,
|
||||
" red %f %f green %f %f blue %f %f white %f %f",
|
||||
&tmp.red.x, &tmp.red.y,
|
||||
&tmp.green.x, &tmp.green.y,
|
||||
&tmp.blue.x, &tmp.blue.y,
|
||||
&tmp.white.x, &tmp.white.y);
|
||||
|
||||
if (n == 8)
|
||||
c = tmp;
|
||||
else
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
chromaticitiesEnv << "; using default value "
|
||||
"(chromaticities according to Rec. ITU-R BT.709).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << chromaticitiesEnv << " is "
|
||||
"not set; using default value (chromaticities according "
|
||||
"to Rec. ITU-R BT.709).");
|
||||
}
|
||||
|
||||
envHeader.insert ("displayChromaticities", ChromaticitiesAttribute (c));
|
||||
|
||||
//
|
||||
// Get the display's white luminance from an environment variable.
|
||||
// If this fails, assume 120 candelas per square meter.
|
||||
// (Screen aim luminance according to SMPTE RP 166.)
|
||||
//
|
||||
|
||||
static const char whiteLuminanceEnv[] = "CTL_DISPLAY_WHITE_LUMINANCE";
|
||||
static const float whiteLuminanceDefault = 120.0;
|
||||
float wl = whiteLuminanceDefault;
|
||||
|
||||
if (const char *whiteLuminance = getenv (whiteLuminanceEnv))
|
||||
{
|
||||
int n = sscanf (whiteLuminance, " %f", &wl);
|
||||
|
||||
if (n != 1)
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
whiteLuminanceEnv << "; using default value "
|
||||
"(" << wl << " candelas per square meter).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << whiteLuminanceEnv << " is "
|
||||
"is not set; using default value (" << wl << " candelas "
|
||||
"per square meter).");
|
||||
}
|
||||
|
||||
envHeader.insert ("displayWhiteLuminance", FloatAttribute (wl));
|
||||
|
||||
//
|
||||
// Get the display's surround luminance from an environment variable.
|
||||
// If this fails, assume 10% of the display's white luminance.
|
||||
// (Recommended setup according to SMPTE RP 166.)
|
||||
//
|
||||
|
||||
static const char surroundLuminanceEnv[] = "CTL_DISPLAY_SURROUND_LUMINANCE";
|
||||
float sl = wl * 0.1f;
|
||||
|
||||
if (const char *surroundLuminance = getenv (surroundLuminanceEnv))
|
||||
{
|
||||
int n = sscanf (surroundLuminance, " %f", &sl);
|
||||
|
||||
if (n != 1)
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
surroundLuminanceEnv << "; using default value "
|
||||
"(" << sl << " candelas per square meter).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << surroundLuminanceEnv << " is "
|
||||
"is not set; using default value (" << sl << " candelas "
|
||||
"per square meter).");
|
||||
}
|
||||
|
||||
envHeader.insert ("displaySurroundLuminance", FloatAttribute (sl));
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
displayTransformName ()
|
||||
{
|
||||
//
|
||||
// Get the name of the display transform from an environment
|
||||
// variable. If this fails, use a default name.
|
||||
//
|
||||
|
||||
static const char displayTransformEnv[] = "CTL_DISPLAY_TRANSFORM";
|
||||
static const char displayTransformDefault[] = "transform_display_video";
|
||||
const char *displayTransform = getenv (displayTransformEnv);
|
||||
|
||||
if (!displayTransform)
|
||||
{
|
||||
displayTransform = displayTransformDefault;
|
||||
|
||||
WARNING ("Environment variable " << displayTransformEnv << " "
|
||||
"is not set; using default value "
|
||||
"(\"" << displayTransform << "\").");
|
||||
}
|
||||
|
||||
return displayTransform;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void
|
||||
ctlToLut (vector<string> transformNames,
|
||||
Header inHeader,
|
||||
size_t lutSize,
|
||||
const half pixelValues[/*lutSize*/],
|
||||
half lut[/*lutSize*/])
|
||||
{
|
||||
//
|
||||
// If we do not have an explicit set of transform names
|
||||
// then find suitable look modification, rendering and
|
||||
// display transforms.
|
||||
//
|
||||
|
||||
if (transformNames.empty())
|
||||
{
|
||||
if (hasLookModTransform (inHeader))
|
||||
transformNames.push_back (lookModTransform (inHeader));
|
||||
|
||||
if (hasRenderingTransform (inHeader))
|
||||
transformNames.push_back (renderingTransform (inHeader));
|
||||
else
|
||||
transformNames.push_back ("transform_RRT");
|
||||
|
||||
transformNames.push_back (displayTransformName());
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize an input and an environment header:
|
||||
// Make sure that the headers contain information about the primaries
|
||||
// and the white point of the image files an the display, and about
|
||||
// the display's white luminance and surround luminance.
|
||||
//
|
||||
|
||||
Header envHeader;
|
||||
Header outHeader;
|
||||
|
||||
if (!hasChromaticities (inHeader))
|
||||
addChromaticities (inHeader, Chromaticities());
|
||||
|
||||
if (!hasAdoptedNeutral (inHeader))
|
||||
addAdoptedNeutral (inHeader, chromaticities(inHeader).white);
|
||||
|
||||
initializeEnvHeader (envHeader);
|
||||
|
||||
//
|
||||
// Set up input and output FrameBuffer objects for the CTL transforms.
|
||||
//
|
||||
|
||||
assert (lutSize % 4 == 0);
|
||||
|
||||
FrameBuffer inFb;
|
||||
|
||||
inFb.insert ("R",
|
||||
Slice (HALF, // type
|
||||
(char *)pixelValues, // base
|
||||
4 * sizeof (half), // xStride
|
||||
0)); // yStride
|
||||
|
||||
inFb.insert ("G",
|
||||
Slice (HALF, // type
|
||||
(char *)(pixelValues + 1), // base
|
||||
4 * sizeof (half), // xStride
|
||||
0)); // yStride
|
||||
|
||||
inFb.insert ("B",
|
||||
Slice (HALF, // type
|
||||
(char *)(pixelValues + 2), // base
|
||||
4 * sizeof (half), // xStride
|
||||
0)); // yStride
|
||||
|
||||
FrameBuffer outFb;
|
||||
|
||||
outFb.insert ("R_display",
|
||||
Slice (HALF, // type
|
||||
(char *)lut, // base
|
||||
4 * sizeof (half), // xStride
|
||||
0)); // yStride
|
||||
|
||||
outFb.insert ("G_display",
|
||||
Slice (HALF, // type
|
||||
(char *)(lut + 1), // base
|
||||
4 * sizeof (half), // xStride
|
||||
0)); // yStride
|
||||
|
||||
outFb.insert ("B_display",
|
||||
Slice (HALF, // type
|
||||
(char *)(lut + 2), // base
|
||||
4 * sizeof (half), // xStride
|
||||
0)); // yStride
|
||||
|
||||
//
|
||||
// Run the CTL transforms.
|
||||
//
|
||||
|
||||
SimdInterpreter interpreter;
|
||||
|
||||
#ifdef CTL_MODULE_BASE_PATH
|
||||
|
||||
//
|
||||
// The configuration scripts has defined a default
|
||||
// location for CTL modules. Include this location
|
||||
// in the CTL module search path.
|
||||
//
|
||||
|
||||
vector<string> paths = interpreter.modulePaths();
|
||||
paths.push_back (CTL_MODULE_BASE_PATH);
|
||||
interpreter.setModulePaths (paths);
|
||||
|
||||
#endif
|
||||
|
||||
ImfCtl::applyTransforms (interpreter,
|
||||
transformNames,
|
||||
Box2i (V2i (0, 0), V2i (lutSize / 4 - 1, 0)),
|
||||
envHeader,
|
||||
inHeader,
|
||||
inFb,
|
||||
outHeader,
|
||||
outFb);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#include <ImfStandardAttributes.h>
|
||||
#include <ImfHeader.h>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace OPENEXR_IMF_NAMESPACE;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
|
||||
|
||||
#define WARNING(message) (cerr << "Warning: " << message << endl)
|
||||
|
||||
|
||||
void
|
||||
ctlToLut (vector<string> transformNames,
|
||||
Header inHeader,
|
||||
size_t lutSize,
|
||||
const half pixelValues[/*lutSize*/],
|
||||
half lut[/*lutSize*/])
|
||||
{
|
||||
//
|
||||
// This program has been compiled without CTL support.
|
||||
//
|
||||
// Our fallback solution is to build a lookup table that
|
||||
// performs a coordinate transform from the primaries and
|
||||
// white point of the input files to the primaries and
|
||||
// white point of the display.
|
||||
//
|
||||
|
||||
//
|
||||
// Get the input file chromaticities
|
||||
//
|
||||
|
||||
Chromaticities fileChroma;
|
||||
|
||||
if (hasChromaticities (inHeader))
|
||||
fileChroma = chromaticities (inHeader);
|
||||
|
||||
//
|
||||
// Get the display chromaticities
|
||||
//
|
||||
|
||||
static const char chromaticitiesEnv[] = "CTL_DISPLAY_CHROMATICITIES";
|
||||
Chromaticities displayChroma;
|
||||
|
||||
if (const char *chromaticities = getenv (chromaticitiesEnv))
|
||||
{
|
||||
Chromaticities tmp;
|
||||
|
||||
int n = sscanf (chromaticities,
|
||||
" red %f %f green %f %f blue %f %f white %f %f",
|
||||
&tmp.red.x, &tmp.red.y,
|
||||
&tmp.green.x, &tmp.green.y,
|
||||
&tmp.blue.x, &tmp.blue.y,
|
||||
&tmp.white.x, &tmp.white.y);
|
||||
|
||||
if (n == 8)
|
||||
displayChroma = tmp;
|
||||
else
|
||||
WARNING ("Cannot parse environment variable " <<
|
||||
chromaticitiesEnv << "; using default value "
|
||||
"(chromaticities according to Rec. ITU-R BT.709).");
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING ("Environment variable " << chromaticitiesEnv << " is "
|
||||
"not set; using default value (chromaticities according "
|
||||
"to Rec. ITU-R BT.709).");
|
||||
}
|
||||
|
||||
//
|
||||
// Do the coordinate transform
|
||||
//
|
||||
|
||||
M44f M = RGBtoXYZ (fileChroma, 1) * XYZtoRGB (displayChroma, 1);
|
||||
|
||||
assert (lutSize % 4 == 0);
|
||||
|
||||
for (int i = 0; i < lutSize; i += 4)
|
||||
{
|
||||
V3f rgb (pixelValues[i], pixelValues[i + 1], pixelValues[i + 2]);
|
||||
rgb = rgb * M;
|
||||
|
||||
lut[i + 0] = rgb[0];
|
||||
lut[i + 1] = rgb[1];
|
||||
lut[i + 2] = rgb[2];
|
||||
lut[i + 3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
107
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/ctlToLut.h
Normal file
107
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/ctlToLut.h
Normal file
@@ -0,0 +1,107 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_CTL_TO_LUT_H
|
||||
#define INCLUDED_CTL_TO_LUT_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Run a set of CTL transforms to generate a color lookup table.
|
||||
//
|
||||
// Function ctlToLut() applies a series of CTL transforms to a
|
||||
// set of input pixel values, pixelValues, producing a color lookup
|
||||
// table, lut. A Cg shader in the display thread of the playexr
|
||||
// program will use this lookup table to approximate the effect
|
||||
// of applying the CTL transforms directly to the displayed images.
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// transformNames A list of the names of the CTL transforms that will
|
||||
// be applied to the input pixel values. If this list
|
||||
// is empty, ctlToLut() looks for a rendering transform
|
||||
// and a display transform:
|
||||
//
|
||||
// If inHeader contains a string attribute called
|
||||
// "renderingTransform" then the value of this attribute
|
||||
// is the name of the rendering transform.
|
||||
// If inHeader contains no such attribute, then the
|
||||
// name of the rendering transform is "transform_RRT".
|
||||
//
|
||||
// If the environment variable CTL_DISPLAY_TRANSFORM
|
||||
// is set, the value of the environment variable is
|
||||
// the name of the display transform.
|
||||
// If the environment variable is not set, then the name
|
||||
// of the display transform is "transform_display_video".
|
||||
//
|
||||
// inHeader The header of the first frame of the image sequence
|
||||
// displayed by playexr. The attributes in the header
|
||||
// can be read by the CTL transforms.
|
||||
//
|
||||
// lutSize Number of elements in the pixelValues and lut arrays.
|
||||
//
|
||||
// pixelValues,
|
||||
// lut Input and output pixel data arrays. Four channels
|
||||
// R, G, B and A are interleaved: RGBARGBARGBA...
|
||||
// The A channel is only for padding; it cannot be
|
||||
// accessed by the CTL transforms.
|
||||
//
|
||||
//
|
||||
// Function displayVideoGamma() returns 1/g, where g is the display's
|
||||
// video gamma. The value of g is read from the environment variable
|
||||
// EXR_DISPLAY_VIDEO_GAMMA. If the environment variable is not set,
|
||||
// then displayVideoGamma() returns 1 / 2.2.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfHeader.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <half.h>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
ctlToLut (std::vector<std::string> transformNames,
|
||||
OPENEXR_IMF_NAMESPACE::Header inHeader,
|
||||
size_t lutSize,
|
||||
const half pixelValues[/*lutSize*/],
|
||||
half lut[/*lutSize*/]);
|
||||
|
||||
float
|
||||
displayVideoGamma ();
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// function fileNameForFrame
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "fileNameForFrame.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
string
|
||||
fileNameForFrame (const string &fileNameTemplate, int frame)
|
||||
{
|
||||
//
|
||||
// Generate the file name for the specified frame by replacing
|
||||
// the first '%' character in the file name template with the
|
||||
// frame number.
|
||||
//
|
||||
|
||||
string::size_type i = fileNameTemplate.find ('%');
|
||||
|
||||
if (i != string::npos)
|
||||
{
|
||||
stringstream ss;
|
||||
|
||||
ss << fileNameTemplate.substr (0, i) <<
|
||||
frame <<
|
||||
fileNameTemplate.substr (i + 1);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
return fileNameTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_FILE_NAME_FOR_FRAME_H
|
||||
#define INCLUDED_FILE_NAME_FOR_FRAME_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// function fileNameForFrame
|
||||
//
|
||||
// Generate the file name for a given frame by replacing
|
||||
// the first '%' character in a file name template with the
|
||||
// frame number.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
std::string
|
||||
fileNameForFrame (const std::string &fileNameTemplate, int frame);
|
||||
|
||||
|
||||
#endif
|
||||
375
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/main.cpp
Normal file
375
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/main.cpp
Normal file
@@ -0,0 +1,375 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// playexr -- a program that plays back an
|
||||
// OpenEXR image sequence directly from disk.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "playExr.h"
|
||||
#include "osDependent.h"
|
||||
#include <IlmThread.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
usageMessage (const char argv0[], bool verbose = false)
|
||||
{
|
||||
cerr << "usage: " << argv0 << " "
|
||||
"[options] fileName [firstFrame lastFrame]" << endl;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
cerr << "\n"
|
||||
"Plays back a sequence of OpenEXR files. All files must\n"
|
||||
"have the same data window and the same set of channels.\n"
|
||||
"The names of the files are constructed by substituting\n"
|
||||
"the first '%' in fileName with firstFrame, firstFrame+1,\n"
|
||||
"firstFrame+2, ... lastFrame. For example,\n"
|
||||
"\n"
|
||||
" " << argv0 << " image.%.exr 1 100\n"
|
||||
"\n"
|
||||
"plays back image.1.exr, image.2.exr ... image.100.exr.\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
"\n"
|
||||
"-t n read the images using n parallel threads\n"
|
||||
"\n"
|
||||
"-f n images will be played back at a rate of n frames\n"
|
||||
" per second (assuming that reading and displaying\n"
|
||||
" an individual image file takes no more than 1/n\n"
|
||||
" seconds).\n"
|
||||
"\n"
|
||||
"-S n images will be displayed at n times their original\n"
|
||||
" width and height. n must be in the range from 0.1\n"
|
||||
" to 2.0.\n"
|
||||
"\n"
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
"-C s CTL transform s is applied to each image before it\n"
|
||||
" is displayed. Option -C can be specified multiple\n"
|
||||
" times to apply a series of transforms to each image.\n"
|
||||
" The transforms are applied in the order in which\n"
|
||||
" they appear on the command line.\n"
|
||||
"\n"
|
||||
"-i On machines where the graphics hardware does not\n"
|
||||
" directly support interpolation between texture map\n"
|
||||
" pixels images with smooth color gradients will\n"
|
||||
" exhibit contouring artifacts. Option -i selects\n"
|
||||
" software-based texture pixel interpolation. This\n"
|
||||
" avoids contouring but may slow down image playback.\n"
|
||||
"\n"
|
||||
#endif
|
||||
"-h prints this message\n"
|
||||
"\n"
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
"CTL transforms:\n"
|
||||
"\n"
|
||||
" If one or more CTL transforms are specified on\n"
|
||||
" the command line (using the -C flag), then those\n"
|
||||
" transforms are applied to the images.\n"
|
||||
" If no CTL transforms are specified on the command\n"
|
||||
" line then an optional look modification transform\n"
|
||||
" is applied, followed by a rendering transform and\n"
|
||||
" a display transform.\n"
|
||||
" The name of the look modification transform is\n"
|
||||
" taken from the lookModTransform attribute in the\n"
|
||||
" header of the first frame of the image sequence.\n"
|
||||
" If the header contains no such attribute, then no\n"
|
||||
" look modification transform is applied. The name\n"
|
||||
" of the rendering transform is taken from the\n"
|
||||
" renderingTransform attribute in the header of the\n"
|
||||
" first frame of the image sequence. If the header\n"
|
||||
" contains no such attribute, then the name of the\n"
|
||||
" rendering transform is \"transform_RRT.\" The\n"
|
||||
" name of the display transform is taken from the\n"
|
||||
" environment variable CTL_DISPLAY_TRANSFORM. If this\n"
|
||||
" environment variable is not set, then the name of\n"
|
||||
" the display transform is \"transform_display_video.\"\n"
|
||||
" The files that contain the CTL code for the\n"
|
||||
" transforms are located using the CTL_MODULE_PATH\n"
|
||||
" environment variable.\n"
|
||||
"\n"
|
||||
#endif
|
||||
"Playback frame rate:\n"
|
||||
"\n"
|
||||
" If the frame rate is not specified on the command\n"
|
||||
" line (using the -f flag), then the frame rate is\n"
|
||||
" determined by the framesPerSecond attribute in the\n"
|
||||
" header of the first frame of the image sequence.\n"
|
||||
" If the header contains no framesPerSecond attribute\n"
|
||||
" then the frame rate is set to 24 frames per second.\n"
|
||||
"\n"
|
||||
"Keyboard commands:\n"
|
||||
"\n"
|
||||
" L or P play forward / pause\n"
|
||||
" H play backward / pause\n"
|
||||
" K step one frame forward\n"
|
||||
" J step one frame backward\n"
|
||||
" > or . increase exposure\n"
|
||||
" < or , decrease exposure\n"
|
||||
#if HAVE_CTL_INTERPRETER
|
||||
" C CTL transforms on/off\n"
|
||||
#endif
|
||||
" O text overlay on/off\n"
|
||||
" F full-screen mode on/off\n"
|
||||
" Q or ESC quit\n"
|
||||
"\n";
|
||||
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
int exitStatus = 0;
|
||||
|
||||
|
||||
void
|
||||
quickexit ()
|
||||
{
|
||||
//
|
||||
// Hack to avoid crashes when someone presses the close or 'X'
|
||||
// button in the title bar of our window. Something GLUT does
|
||||
// while shutting down the program does not play well with
|
||||
// multiple threads. Bypassing GLUT's orderly shutdown by
|
||||
// calling _exit immediately avoids crashes.
|
||||
//
|
||||
|
||||
_exit (exitStatus);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
glutInit (&argc, argv);
|
||||
|
||||
const char *fileNameTemplate = 0;
|
||||
int firstFrame = 1;
|
||||
int lastFrame = 1;
|
||||
int numThreads = 0;
|
||||
float fps = -1;
|
||||
float xyScale = 1;
|
||||
vector<string> transformNames;
|
||||
bool useHwTexInterpolation = true;
|
||||
|
||||
//
|
||||
// Parse the command line.
|
||||
//
|
||||
|
||||
if (argc < 2)
|
||||
usageMessage (argv[0], true);
|
||||
|
||||
int i = 1;
|
||||
int j = 0;
|
||||
|
||||
while (i < argc)
|
||||
{
|
||||
if (!strcmp (argv[i], "-t"))
|
||||
{
|
||||
//
|
||||
// Set number of threads
|
||||
//
|
||||
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
numThreads = strtol (argv[i + 1], 0, 0);
|
||||
|
||||
if (numThreads < 0)
|
||||
{
|
||||
cerr << "Number of threads cannot be negative." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-f"))
|
||||
{
|
||||
//
|
||||
// Set frame rate
|
||||
//
|
||||
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
fps = strtod (argv[i + 1], 0);
|
||||
|
||||
if (fps < 1 || fps > 1000)
|
||||
{
|
||||
cerr << "Playback speed must be between "
|
||||
"1 and 1000 frames per second." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-S"))
|
||||
{
|
||||
//
|
||||
// Set image scale factor
|
||||
//
|
||||
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
xyScale = strtod (argv[i + 1], 0);
|
||||
|
||||
if (xyScale < 0.1 || xyScale > 2.0)
|
||||
{
|
||||
cerr << "Scale factor must be between 0.1 and 2.0." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-C"))
|
||||
{
|
||||
//
|
||||
// Apply a CTL transform
|
||||
//
|
||||
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
transformNames.push_back (argv[i + 1]);
|
||||
i += 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-i"))
|
||||
{
|
||||
//
|
||||
// Use software-based texture map interpolation
|
||||
//
|
||||
|
||||
useHwTexInterpolation = false;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-h"))
|
||||
{
|
||||
//
|
||||
// Print help message
|
||||
//
|
||||
|
||||
usageMessage (argv[0], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Image file name or frame number
|
||||
//
|
||||
|
||||
switch (j)
|
||||
{
|
||||
case 0:
|
||||
fileNameTemplate = argv[i];
|
||||
break;
|
||||
|
||||
case 1:
|
||||
firstFrame = strtol (argv[i], 0, 0);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
lastFrame = strtol (argv[i], 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (j != 1 && j != 3)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
if (firstFrame > lastFrame)
|
||||
{
|
||||
cerr << "Frame number of first frame is greater than "
|
||||
"frame number of last frame." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure that we have threading support.
|
||||
//
|
||||
|
||||
if (!ILMTHREAD_NAMESPACE::supportsThreads())
|
||||
{
|
||||
cerr << "This program requires multi-threading support.\n" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Play the image sequence.
|
||||
//
|
||||
|
||||
atexit (quickexit);
|
||||
|
||||
try
|
||||
{
|
||||
playExr (fileNameTemplate,
|
||||
firstFrame,
|
||||
lastFrame,
|
||||
numThreads,
|
||||
fps,
|
||||
xyScale,
|
||||
transformNames,
|
||||
useHwTexInterpolation);
|
||||
}
|
||||
catch (const exception &e)
|
||||
{
|
||||
cerr << e.what() << endl;
|
||||
exitStatus = 1;
|
||||
}
|
||||
|
||||
return exitStatus;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// OpenGL related code and definitions
|
||||
// that depend on the operating system.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "osDependent.h"
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void
|
||||
initAndCheckGlExtensions ()
|
||||
{
|
||||
#ifdef PLAYEXR_USE_APPLE_FLOAT_PIXELS
|
||||
|
||||
if (!glutExtensionSupported ("GL_APPLE_float_pixels"))
|
||||
{
|
||||
cerr << "This program requires OpenGL support for "
|
||||
"16-bit floating-point textures." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if (!glutExtensionSupported ("GL_ARB_texture_float") ||
|
||||
!glutExtensionSupported ("GL_ARB_half_float_pixel"))
|
||||
{
|
||||
cerr << "This program requires OpenGL support for "
|
||||
"16-bit floating-point textures." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (!glutExtensionSupported ("GL_ARB_fragment_shader"))
|
||||
{
|
||||
cerr << "This program requires OpenGL support for "
|
||||
"fragment shaders and the Cg shading language." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
GLenum err = glewInit();
|
||||
|
||||
if (GLEW_OK != err)
|
||||
{
|
||||
cerr << "Cannot initialize "
|
||||
"glew: " << glewGetErrorString (err) << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
86
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/osDependent.h
Normal file
86
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/osDependent.h
Normal file
@@ -0,0 +1,86 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_OS_DEPENDENT_H
|
||||
#define INCLUDED_OS_DEPENDENT_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// OpenGL related code and definitions
|
||||
// that depend on the operating system.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <GL/glew.h>
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#if defined __APPLE__
|
||||
|
||||
#include <GLUT/glut.h>
|
||||
#include <OpenGL/gl.h>
|
||||
#include <Cg/cgGL.h>
|
||||
|
||||
#ifndef GL_HALF_FLOAT_ARB
|
||||
#define PLAYEXR_USE_APPLE_FLOAT_PIXELS
|
||||
#endif
|
||||
|
||||
#ifndef GL_LUMINANCE16F_ARB
|
||||
#define GL_LUMINANCE16F_ARB GL_LUMINANCE_FLOAT16_APPLE
|
||||
#endif
|
||||
|
||||
#ifndef GL_RGBA16F_ARB
|
||||
#define GL_RGBA16F_ARB GL_RGBA_FLOAT16_APPLE
|
||||
#endif
|
||||
|
||||
#ifndef GL_HALF_FLOAT_ARB
|
||||
#define GL_HALF_FLOAT_ARB GL_HALF_APPLE
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#include <GL/glut.h>
|
||||
#include <GL/gl.h>
|
||||
#include <Cg/cgGL.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void initAndCheckGlExtensions ();
|
||||
|
||||
|
||||
#endif
|
||||
1498
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/playExr.cpp
Normal file
1498
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/playExr.cpp
Normal file
File diff suppressed because it is too large
Load Diff
57
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/playExr.h
Normal file
57
cs440-acg/ext/openexr/OpenEXR_Viewers/playexr/playExr.h
Normal file
@@ -0,0 +1,57 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_PLAY_EXR_H
|
||||
#define INCLUDED_PLAY_EXR_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Play an OpenEXR image sequence.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
void
|
||||
playExr (const char fileNameTemplate[],
|
||||
int firstFrame,
|
||||
int lastFrame,
|
||||
int numThreads,
|
||||
float fps,
|
||||
float xyScale,
|
||||
const std::vector<std::string> &transformNames,
|
||||
bool useHwTexInterpolation);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user