Disabled external gits

This commit is contained in:
2022-04-07 18:46:57 +02:00
parent 88cb3426ad
commit 15e7120d6d
5316 changed files with 4563444 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
Developers:
-----------
Christopher Horvath <encino@pixar.com>

View File

@@ -0,0 +1,60 @@
##-*****************************************************************************
## Copyright (c) 2012, Pixar. All rights reserved. *
## *
## This license governs use of the accompanying software. If you *
## use the software, you accept this license. If you do not accept *
## the license, do not use the software. *
## *
## 1. Definitions *
## The terms "reproduce," "reproduction," "derivative works," and *
## "distribution" have the same meaning here as under U.S. *
## copyright law. A "contribution" is the original software, or *
## any additions or changes to the software. *
## A "contributor" is any person or entity that distributes its *
## contribution under this license. *
## "Licensed patents" are a contributor's patent claims that read *
## directly on its contribution. *
## *
## 2. Grant of Rights *
## (A) Copyright Grant- Subject to the terms of this license, *
## including the license conditions and limitations in section 3, *
## each contributor grants you a non-exclusive, worldwide, *
## royalty-free copyright license to reproduce its contribution, *
## prepare derivative works of its contribution, and distribute *
## its contribution or any derivative works that you create. *
## (B) Patent Grant- Subject to the terms of this license, *
## including the license conditions and limitations in section 3, *
## each contributor grants you a non-exclusive, worldwide, *
## royalty-free license under its licensed patents to make, have *
## made, use, sell, offer for sale, import, and/or otherwise *
## dispose of its contribution in the software or derivative works *
## of the contribution in the software. *
## *
## 3. Conditions and Limitations *
## (A) No Trademark License- This license does not grant you *
## rights to use any contributor's name, logo, or trademarks. *
## (B) If you bring a patent claim against any contributor over *
## patents that you claim are infringed by the software, your *
## patent license from such contributor to the software ends *
## automatically. *
## (C) If you distribute any portion of the software, you must *
## retain all copyright, patent, trademark, and attribution *
## notices that are present in the software. *
## (D) If you distribute any portion of the software in source *
## code form, you may do so only under this license by including a *
## complete copy of this license with your distribution. If you *
## distribute any portion of the software in compiled or object *
## code form, you may only do so under a license that complies *
## with this license. *
## (E) The software is licensed "as-is." You bear the risk of *
## using it. The contributors give no express warranties, *
## guarantees or conditions. You may have additional consumer *
## rights under your local laws which this license cannot change. *
## To the extent permitted under your local laws, the contributors *
## exclude the implied warranties of merchantability, fitness for *
## a particular purpose and non-infringement. *
##-*****************************************************************************
##-*****************************************************************************
## Written by Pixar, 2011-2012.
##-*****************************************************************************

View File

@@ -0,0 +1,13 @@
Version 1.0.0:
* Initial release of this code.
Version 1.0.1:
* Fixed misinterpretation of values read from "deepopacity" dtex files.
The data stored is actually transmission, or 1.0-opacity, which means
that "deepopacity" dtex values actually monotonically decrease from 1
to 0. We have updated the comments and documentation to reflect this
and have fixed the PxOneChanDeepOpacity file to convert the data
as it is read out of the file.

View File

@@ -0,0 +1,611 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar, 2011-2012.
//-*****************************************************************************
#include "PxDeepUtils.h"
#include "PxDeepOutPixel.h"
#include "PxDeepOutRow.h"
#include "PxBaseDeepHelper.h"
#include "PxOneChanDeepOpacity.h"
#include "PxOneChanDeepAlpha.h"
#include "PxFourChanDeepRgba.h"
#include <dtex.h>
#include <ImfDeepScanLineOutputFile.h>
#include <ImfPartType.h>
#include <ImfChannelList.h>
#include <ImfStandardAttributes.h>
#include <ImfHeader.h>
#include <ImathVec.h>
#include <ImathBox.h>
#include <ImathMatrix.h>
#include <half.h>
#include <assert.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
#include <float.h>
//-*****************************************************************************
// DTEX CONVERTER EXPLANATION!
//-*****************************************************************************
// There are six possible code paths through converting the dtex data. They are:
// DeepOpacity, Continuous
// DeepOpacity, Discrete
// DeepAlpha, Continuous
// DeepAlpha, Discrete
// DeepRGBA, Continuous
// DeepRGBA, Discrete
// The newer dtex usages allow for other combinations of channels, but we
// are temporarily just supporting these six paths for sake of simplicity.
// We will eventually support arbitrary outputs and multiple views.
//
// We had an earlier version of this code which condensed these six code
// pathways into a single function, with templated functors to provide
// specific differing behavior for each of the different possibilities, and
// while it may have been slightly less code, the resulting loops were very hard
// to read and understand. Because each of the different pathways
// has some specific kernel of knowledge necessary to make it work, we
// chose instead to break each one out separately, to clearly expose the
// behavior in each case.
//
// The terminology for Density, Visibility, DeepOpacity, DepthRanges,
// along with explanations of the constants are provided in
// PxDeepUtils.h
//
// Our DeepOutPixel helper class is in PxDeepOutPixel.h
//
// Our DeepOutRow helper class is in PxDeepOutRow.h
//
// The Base Helper class, which loops over rows, and then pixels of those
// rows, is in PxBaseDeepHelper.h
//
// The DeepOpacity subclasses (discrete/continuous) of BaseDeepHelper are in
// PxOneChanDeepOpacity.h
//
// The DeepAlpha subclasses (discrete/continuous) of BaseDeepHelper are in
// PxOneChanDeepAlpha.h
//
// The DeepRgba subclasses (discrete/continuous) of BaseDeepHelper are in
// PxFourChanDeepAlpha.h
//
//-*****************************************************************************
namespace PxDeep {
//-*****************************************************************************
template <typename RGBA_T>
void ConvertDtexFile( const std::string& i_fileName,
const std::string& i_outFileName,
const Parameters& i_params )
{
int dtexOpenError = DTEX_NOERR;
DtexFile* dtexFile = NULL;
DtexCache* dtexCache = NULL;
if ( i_fileName.length() )
{
// We probably don't need 10000 tiles in the cache, but it's
// fine for now.
dtexCache = DtexCreateCache( 10000, NULL );
dtexOpenError = DtexOpenFile( i_fileName.c_str(),
"rb", dtexCache, &dtexFile );
}
if ( !dtexFile )
{
if ( i_fileName.length() == 0 )
{
PXDU_THROW( "no filename specified" );
}
else if ( dtexOpenError != DTEX_NOERR )
{
PXDU_THROW( "error (" << dtexOpenError
<< " opening file: " << i_fileName );
}
else
{
PXDU_THROW( "missing file: " << i_fileName );
}
}
// Just handling the first image in the Dtex file for now.
DtexImage* image;
DtexGetImageByIndex( dtexFile, 0, &image );
float NP[16];
DtexNP( image, NP );
float Nl[16];
DtexNl( image, Nl );
int numDtexChans = DtexNumChan( image );
if ( numDtexChans != 1 &&
numDtexChans != 3 &&
numDtexChans != 4 )
{
DtexClose( dtexFile );
PXDU_THROW( "ERROR: only 1, 3 or 4 channel dtex files are supported.\n"
<< "Dtex file " << i_fileName
<< " contains " << numDtexChans << " channels.\n"
<< "In the case of 3 channels, the data is assumed to be\n"
<< "3-channel opacity, and for now, at least, only the\n"
<< "first channel is used, rather than all three.\n" );
}
int w = DtexWidth( image );
int h = DtexHeight( image );
// Extract the parameters so we can conditionally modify them.
Parameters params = i_params;
// If we're reading anything more than 1 channel,
// we can't (for now) assume it's a deepOpacity signal,
// so we turn off the deepOpacity flag.
// We also make sure RGB is turned on when RGB data is present.
if ( numDtexChans == 4 )
{
params.deepOpacity = false;
params.doRGB = true;
}
// If we're discrete, we don't necessarily need to output deepBack.
// However, from a pipeline point of view it is often preferable to have
// all the channels actually in existence, even if they're redundant.
// Nonetheless, if
if ( !params.discrete )
{
params.doDeepBack = true;
}
// Determine the output size
int outWidth = w;
int outHeight = h;
if ( params.sideways )
{
outWidth = h;
outHeight = w;
}
// Create the windows.
Imath::Box2i dataWindow( Imath::V2i( 0, 0 ),
Imath::V2i( outWidth-1, outHeight-1 ) );
Imath::Box2i displayWindow = dataWindow;
// Create the header.
Imf::Header header( displayWindow,
dataWindow,
1,
Imath::V2f( 0.0f, 0.0f ),
1,
Imf::INCREASING_Y,
Imf::ZIPS_COMPRESSION );
// Add Np/Nl to the header.
Imath::M44f NPm( NP[0], NP[1], NP[2], NP[3],
NP[4], NP[5], NP[6], NP[7],
NP[8], NP[9], NP[10], NP[11],
NP[12], NP[13], NP[14], NP[15] );
addWorldToNDC( header, NPm );
Imath::M44f Nlm( Nl[0], Nl[1], Nl[2], Nl[3],
Nl[4], Nl[5], Nl[6], Nl[7],
Nl[8], Nl[9], Nl[10], Nl[11],
Nl[12], Nl[13], Nl[14], Nl[15] );
addWorldToCamera( header, Nlm );
// Add channels to the header.
// RGB
if ( params.doRGB )
{
header.channels().insert( "R",
Imf::Channel( ImfPixelType<RGBA_T>() ) );
header.channels().insert( "G",
Imf::Channel( ImfPixelType<RGBA_T>() ) );
header.channels().insert( "B",
Imf::Channel( ImfPixelType<RGBA_T>() ) );
}
// A
header.channels().insert( "A",
Imf::Channel( ImfPixelType<RGBA_T>() ) );
// Deep Front (z)
header.channels().insert( "Z",
Imf::Channel( Imf::FLOAT ) );
// Deep Back
if ( params.doDeepBack )
{
header.channels().insert( "ZBack",
Imf::Channel( Imf::FLOAT ) );
}
// Tell header to be deep!
header.setType( Imf::DEEPSCANLINE );
// Create output file, and fill it up!
{
Imf::DeepScanLineOutputFile outputFile( i_outFileName.c_str(),
header );
// Process deep pixels.
if ( numDtexChans < 4 )
{
if ( params.discrete )
{
if ( params.deepOpacity )
{
OneChanDeepOpacityDiscrete<RGBA_T> op( dtexFile,
numDtexChans,
params );
op.processDeepBox( outputFile, dataWindow );
}
else
{
OneChanDeepAlphaDiscrete<RGBA_T> op( dtexFile,
numDtexChans,
params );
op.processDeepBox( outputFile, dataWindow );
}
}
else
{
if ( params.deepOpacity )
{
OneChanDeepOpacityContinuous<RGBA_T> op( dtexFile,
numDtexChans,
params );
op.processDeepBox( outputFile, dataWindow );
}
else
{
OneChanDeepAlphaContinuous<RGBA_T> op( dtexFile,
numDtexChans,
params );
op.processDeepBox( outputFile, dataWindow );
}
}
}
else
{
if ( params.discrete )
{
FourChanDeepRgbaDiscrete<RGBA_T> op( dtexFile,
numDtexChans,
params );
op.processDeepBox( outputFile, dataWindow );
}
else
{
FourChanDeepRgbaContinuous<RGBA_T> op( dtexFile,
numDtexChans,
params );
op.processDeepBox( outputFile, dataWindow );
}
}
} // Output file has gone out of scope, and should be closed!
std::cout << "Wrote file: " << i_outFileName << std::endl;
// Close it up!
if ( dtexFile )
{
DtexClose( dtexFile );
}
if ( dtexCache )
{
DtexDestroyCache( dtexCache );
}
}
} // End namespace PxDeep
//-*****************************************************************************
// Print Usage.
void PrintUsage( const std::string& i_cmd, std::ostream& ostr )
{
ostr << "DtexToExr: USAGE: "
<< i_cmd
<< std::endl << std::endl
<< "\t <inFileName.dtex>"
<< std::endl << std::endl
<< "\t <outFileName.exr>"
<< std::endl << std::endl
<< "\t --deepOpacity (DEFAULT) "
<< "\n\t\t (corresponds to output channels \'deepopacity\')"
<< std::endl << std::endl
<< "\t --deepAlpha "
<< "\n\t\t (corresponds to output channels \'a\' or \'rgba\')"
<< std::endl << std::endl
<< "\t --discrete (DEFAULT) "
<< "\n\t\t (corresponds to \'volumeinterpretation discrete\')"
<< std::endl << std::endl
<< "\t --continuous "
<< "\n\t\t (corresponds to \'volumeinterpretation continuous\')"
<< std::endl << std::endl
<< "\t --full "
<< "\n\t\t (use full 32-bit precision for non-depth (RGBA) data)"
<< std::endl << std::endl
<< "\t --half (DEFAULT) "
<< "\n\t\t (use half 16-bit precision for non-depth (RGBA) data)"
<< std::endl << std::endl
<< "\t --multRgb "
<< "\n\t\t (multiply RGB data by Alpha, "
<< "implying that source data is unpremultiplied)"
<< std::endl << std::endl
<< "\t --sideways [true|false]"
<< "\n\t\t (rotate image 90 deg clockwise)"
<< std::endl << std::endl
<< "\t --compressionError <float> (DEFAULT: 0.0f) "
<< "\n\t\t (compress dtex data before converting to deep exr)"
<< std::endl << std::endl
<< "\t --keepZeroAlpha "
<< "\n\t\t (don\'t discard samples with zero alpha)"
<< std::endl << std::endl
<< "\t --discardZeroAlpha (DEFAULT) "
<< "\n\t\t (discard samples with zero alpha)"
<< std::endl << std::endl
<< "\t -h,--h,--help "
<< "\n\t\t (print this message and exit)"
<< std::endl << std::endl;
}
//-*****************************************************************************
inline bool GoodFileName( const std::string& i_fileName )
{
return !( ( i_fileName.length() == 0 ||
i_fileName == "" ||
i_fileName[0] == '-' ) );
}
//-*****************************************************************************
// Argument parsing. So inelegant, but libarg is not widely supported, and
// boost::program_options is, well, boost. Also - not particularly awesome.
void ParseArguments( int argc, char* argv[],
bool& o_full,
std::string& o_dtexFileName,
std::string& o_exrFileName,
PxDeep::Parameters& o_params )
{
if ( argc < 3 )
{
PrintUsage( argv[0], std::cerr );
exit( -1 );
}
// Make our params match what the usage string says by default.
o_full = false;
o_dtexFileName = "";
o_exrFileName = "";
o_params.deepOpacity = true;
o_params.discrete = true;
o_params.multiplyColorByAlpha = false;
o_params.sideways = false;
o_params.discardZeroAlphaSamples = true;
o_params.doDeepBack = true;
o_params.doRGB = false;
o_params.compressionError = 0.0f;
// Eat up the args!
for ( int argi = 1; argi < argc; ++argi )
{
std::string arg = argv[argi];
if ( arg == "-h" || arg == "-help" || arg == "--help" )
{
PrintUsage( argv[0], std::cerr );
exit( -1 );
}
else if ( argi == 1 )
{
if ( !GoodFileName( arg ) )
{
PrintUsage( argv[0], std::cerr );
PXDU_THROW( "Bad file name: " << arg );
}
o_dtexFileName = arg;
}
else if ( argi == 2 )
{
if ( !GoodFileName( arg ) )
{
PrintUsage( argv[0], std::cerr );
PXDU_THROW( "Bad file name: " << arg );
}
o_exrFileName = arg;
}
else if ( arg == "--deepOpacity" )
{
o_params.deepOpacity = true;
}
else if ( arg == "--deepAlpha" )
{
o_params.deepOpacity = false;
}
else if ( arg == "--discrete" )
{
o_params.discrete = true;
}
else if ( arg == "--continuous" )
{
o_params.discrete = false;
}
else if ( arg == "--full" )
{
o_full = true;
}
else if ( arg == "--half" )
{
o_full = false;
}
else if ( arg == "--multRgb" )
{
o_params.multiplyColorByAlpha = true;
}
else if ( arg == "--sideways" )
{
if ( argi <= argc-1 )
{
std::cout << argv[argi+1] << std::endl;
if ( strcmp(argv[argi+1], "true") == 0 )
{
o_params.sideways = true;
++argi;
}
else if ( strcmp(argv[argi+1], "false") == 0 )
{
o_params.sideways = false;
++argi;
}
else if ( argv[argi+1][0] == '-' )
{
// found another arg. sideways has no parameter, which means sideways is on.
o_params.sideways = true;
}
else
{
// sideways must be followed by "true", "false", another arg, or nothing.
PXDU_THROW( "Invalid parameter for --sideways: " << argv[argi+1] );
}
}
else
{
o_params.sideways = true;
}
}
else if ( arg == "--compressionError" )
{
if ( argi >= argc-1 )
{
PrintUsage( argv[0], std::cerr );
PXDU_THROW( "Unspecified compression error." );
}
o_params.compressionError = atof( argv[argi+1] );
++argi;
}
else if ( arg == "--keepZeroAlpha" )
{
o_params.discardZeroAlphaSamples = false;
}
else if ( arg == "--discardZeroAlpha" )
{
o_params.discardZeroAlphaSamples = true;
}
else
{
PrintUsage( argv[0], std::cerr );
PXDU_THROW( "Unknown command line argument: " << arg );
}
}
}
//-*****************************************************************************
// MAIN FUNCTION
//-*****************************************************************************
int main( int argc, char *argv[] )
{
try
{
PxDeep::Parameters params;
std::string dtexFileName;
std::string exrFileName;
bool full;
ParseArguments( argc, argv, full,
dtexFileName, exrFileName,
params );
if ( full )
{
PxDeep::ConvertDtexFile<float>( dtexFileName,
exrFileName,
params );
}
else
{
PxDeep::ConvertDtexFile<half>( dtexFileName,
exrFileName,
params );
}
}
catch ( std::exception& exc )
{
std::cerr << "ERROR EXCEPTION: " << exc.what() << std::endl;
exit( -1 );
}
catch ( ... )
{
std::cerr << "UNKNOWN EXCEPTION." << std::endl;
exit( -1 );
}
return 0;
}

View File

@@ -0,0 +1,365 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@@ -0,0 +1,18 @@
## Process this file with automake to produce Makefile.in
# tell autoconf to include the m4 macros in the /m4 directory
# (an alternative to the acinclude.m4 mechanism)
ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = DtexToExr
INCLUDES = @OPENEXR_CXXFLAGS@ @PRMANSDK_CXXFLAGS@
LDADD = @OPENEXR_LDFLAGS@ @OPENEXR_LIBS@ @PRMANSDK_LDFLAGS@ @PRMANSDK_LIBS@ -lz
DtexToExr_SOURCES = PxDeepUtils.cpp DtexToExr.cpp

View File

@@ -0,0 +1,115 @@
##-*****************************************************************************
## Copyright (c) 2012, Pixar. All rights reserved. *
## *
## This license governs use of the accompanying software. If you *
## use the software, you accept this license. If you do not accept *
## the license, do not use the software. *
## *
## 1. Definitions *
## The terms "reproduce," "reproduction," "derivative works," and *
## "distribution" have the same meaning here as under U.S. *
## copyright law. A "contribution" is the original software, or *
## any additions or changes to the software. *
## A "contributor" is any person or entity that distributes its *
## contribution under this license. *
## "Licensed patents" are a contributor's patent claims that read *
## directly on its contribution. *
## *
## 2. Grant of Rights *
## (A) Copyright Grant- Subject to the terms of this license, *
## including the license conditions and limitations in section 3, *
## each contributor grants you a non-exclusive, worldwide, *
## royalty-free copyright license to reproduce its contribution, *
## prepare derivative works of its contribution, and distribute *
## its contribution or any derivative works that you create. *
## (B) Patent Grant- Subject to the terms of this license, *
## including the license conditions and limitations in section 3, *
## each contributor grants you a non-exclusive, worldwide, *
## royalty-free license under its licensed patents to make, have *
## made, use, sell, offer for sale, import, and/or otherwise *
## dispose of its contribution in the software or derivative works *
## of the contribution in the software. *
## *
## 3. Conditions and Limitations *
## (A) No Trademark License- This license does not grant you *
## rights to use any contributor's name, logo, or trademarks. *
## (B) If you bring a patent claim against any contributor over *
## patents that you claim are infringed by the software, your *
## patent license from such contributor to the software ends *
## automatically. *
## (C) If you distribute any portion of the software, you must *
## retain all copyright, patent, trademark, and attribution *
## notices that are present in the software. *
## (D) If you distribute any portion of the software in source *
## code form, you may do so only under this license by including a *
## complete copy of this license with your distribution. If you *
## distribute any portion of the software in compiled or object *
## code form, you may only do so under a license that complies *
## with this license. *
## (E) The software is licensed "as-is." You bear the risk of *
## using it. The contributors give no express warranties, *
## guarantees or conditions. You may have additional consumer *
## rights under your local laws which this license cannot change. *
## To the extent permitted under your local laws, the contributors *
## exclude the implied warranties of merchantability, fitness for *
## a particular purpose and non-infringement. *
##-*****************************************************************************
##-*****************************************************************************
## Written by Pixar, 2011-2012.
##-*****************************************************************************
BUILDTMP = obj
IPATH = -I${DTEXTOEXR_PREFIX}/include/OpenEXR \
-I${DTEXTOEXR_RMANROOT}/include/prmansdk-160 \
-I${DTEXTOEXR_RMANROOT}/include
LPATH = -L${DTEXTOEXR_PREFIX}/lib \
-L${DTEXTOEXR_RMANROOT}/lib/prmansdk-160 \
-L${DTEXTOEXR_RMANROOT}/lib \
-Wl,-rpath ${DTEXTOEXR_PREFIX}/lib \
-Wl,-rpath ${DTEXTOEXR_RMANROOT}/lib/prmansdk-160 \
-Wl,-rpath ${DTEXTOEXR_RMANROOT}/lib
LIBS = -lIlmImf -lImath -lIlmThread -lIex -lHalf \
-lprman \
-lpthread -lm
CXX = /usr/bin/g++
LN = /usr/bin/g++
CFLAGS = -g
HFILES = PxBaseDeepHelper.h \
PxDeepOutPixel.h \
PxDeepOutRow.h \
PxDeepUtils.h \
PxFourChanDeepRgba.h \
PxOneChanDeepAlpha.h \
PxOneChanDeepOpacity.h
OFILES = ${BUILDTMP}/PxDeepUtils.o \
${BUILDTMP}/DtexToExr.o
all: ${BUILDTMP}/DtexToExr
${BUILDTMP}/PxDeepUtils.o: PxDeepUtils.h PxDeepUtils.cpp
mkdir -p ${BUILDTMP}
${CXX} PxDeepUtils.cpp -c -o ${BUILDTMP}/PxDeepUtils.o ${CFLAGS} ${IPATH}
${BUILDTMP}/DtexToExr.o: DtexToExr.cpp ${HFILES}
mkdir -p ${BUILDTMP}
${CXX} DtexToExr.cpp -c -o ${BUILDTMP}/DtexToExr.o ${CFLAGS} ${IPATH}
${BUILDTMP}/DtexToExr: ${OFILES}
mkdir -p ${BUILDTMP}
${LN} ${OFILES} -o ${BUILDTMP}/DtexToExr ${CFLAGS} ${IPATH} ${LPATH} ${LIBS}
install: ${BUILDTMP}/DtexToExr
/bin/cp -f ${BUILDTMP}/DtexToExr ${DTEXTOEXR_PREFIX}/bin/DtexToExr
clean:
/bin/rm ${OFILES}
/bin/rm ${BUILDTMP}/DtexToExr

View File

@@ -0,0 +1,2 @@
Version 1.0.0
- initial release

View File

@@ -0,0 +1,330 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar Animation Studios, 2011-2012.
//-*****************************************************************************
#ifndef _PxDeepBaseHelper_h_
#define _PxDeepBaseHelper_h_
#include "PxDeepUtils.h"
#include "PxDeepOutPixel.h"
#include "PxDeepOutRow.h"
#include <dtex.h>
#include <ImfDeepScanLineOutputFile.h>
#include <ImfPartType.h>
#include <ImfChannelList.h>
#include <ImathVec.h>
#include <ImathBox.h>
namespace PxDeep {
//-*****************************************************************************
// PARAMETERS STRUCT
//-*****************************************************************************
// This allows us to keep function signatures from changing around too much
// as the parameter set grows & changes, which it always does.
struct Parameters
{
Parameters()
: deepOpacity( true )
, discrete( true )
, multiplyColorByAlpha( false )
, sideways( false )
, discardZeroAlphaSamples( true )
, doDeepBack( true )
, doRGB( true )
, compressionError( 0.0f ) {}
bool deepOpacity;
bool discrete;
bool multiplyColorByAlpha;
bool sideways;
bool discardZeroAlphaSamples;
bool doDeepBack;
bool doRGB;
float compressionError;
};
//-*****************************************************************************
// BASE DEEP HELPER CLASS
//-*****************************************************************************
// The intention of this templated base class is to provide consistent
// storage vectors for spans and deep pixels across multiple pixel reads,
// so we don't slow down constantly creating and destroying std::vectors.
// This class has a "processDeepBox" function which does the work.
template <typename RGBA_T, typename DERIVED, typename SPAN>
class BaseDeepHelper
{
public:
typedef DERIVED sub_type;
typedef SPAN span_type;
BaseDeepHelper( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: m_dtexFile( i_dtexFile )
, m_numDtexChans( i_numDtexChans )
, m_params( i_params )
{
m_image = NULL;
DtexGetImageByIndex( m_dtexFile, 0, &m_image );
m_fileWidth = DtexWidth( m_image );
m_fileHeight = DtexHeight( m_image );
m_pixel = DtexMakePixel( m_numDtexChans );
m_rawPixel = DtexMakePixel( m_numDtexChans );
}
~BaseDeepHelper()
{
DtexDestroyPixel( m_pixel );
DtexDestroyPixel( m_rawPixel );
}
void processDeepBox( Imf::DeepScanLineOutputFile& o_file,
const Imath::Box2i& i_box );
protected:
DtexFile* m_dtexFile;
int m_numDtexChans;
Parameters m_params;
DtexImage* m_image;
int m_fileWidth;
int m_fileHeight;
DtexPixel* m_pixel;
DtexPixel* m_rawPixel;
std::vector<span_type> m_spans;
DeepOutPixel<RGBA_T> m_deepOutPixel;
};
//-*****************************************************************************
//-*****************************************************************************
// SPAN CLASSES
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
// These span objects are used by the helper classes below to keep track
// of the information read out of the DTEX file, so it can be processed.
// They have an ordering operator which sorts them by depth and then index.
// We use double precision for 'viz', for reasons described in the 'VIZ'
// section of the explanatory comments in the PxDeepUtils library.
struct Span
{
Span() : in( 0.0f ), out( 0.0f ), viz( 0.0 ), index( 0 ) {}
float in;
float out;
double viz;
int index;
void clear()
{
in = 0.0f;
out = 0.0f;
viz = 0.0;
index = 0;
}
bool operator<( const Span& i_other ) const
{
if ( in < i_other.in )
{
return true;
}
else if ( in == i_other.in )
{
return index < i_other.index;
}
else
{
return false;
}
}
};
//-*****************************************************************************
// Because the RGB values here are unpremultiplied, we use double precision
// to avoid precision loss when going (RGB/A)*A.
struct SpanRgba : public Span
{
SpanRgba() : Span() { rgb[0] = 0.0; rgb[1] = 0.0; rgb[2] = 0.0; }
double rgb[3];
void clear()
{
Span::clear();
rgb[0] = 0.0;
rgb[1] = 0.0;
rgb[2] = 0.0;
}
};
//-*****************************************************************************
// As above, we use double precision for viz.
struct SpanOpac : public Span
{
SpanOpac() : Span(), deepViz( 0.0 ) {}
double deepViz;
void clear()
{
Span::clear();
deepViz = 0.0;
}
};
//-*****************************************************************************
// The box processing simply loops over the rows, compresses each pixel, then
// converts from dtex representation to deep exr representation, and finally
// writes the rows to the file.
template <typename RGBA_T, typename DERIVED, typename SPAN>
void BaseDeepHelper<RGBA_T,DERIVED,SPAN>::processDeepBox
(
Imf::DeepScanLineOutputFile& o_file,
const Imath::Box2i& i_box )
{
int width = ( i_box.max.x - i_box.min.x ) + 1;
DeepOutRow<RGBA_T> outRow( width, m_params.doDeepBack, m_params.doRGB );
for ( int y = i_box.max.y; y >= i_box.min.y; --y )
{
outRow.clear();
for ( int x = i_box.min.x; x <= i_box.max.x; ++x )
{
if ( m_params.sideways )
{
DtexGetPixel( m_image, m_fileWidth - 1 - y,
m_fileHeight - 1 - x, m_rawPixel );
}
else
{
DtexGetPixel( m_image, x,
m_fileHeight - 1 - y, m_rawPixel );
}
// Get the number of input points.
int numPointsIn = DtexPixelGetNumPoints( m_rawPixel );
if ( numPointsIn < 0 )
{
PXDU_THROW( "Negative num points returned at dtex pixel: "
<< x << ", " << y );
}
// Compress the pixel.
if ( numPointsIn > 1 && m_params.compressionError > 0.0f )
{
DtexCompressPixel( m_rawPixel, m_pixel,
m_params.compressionError );
DtexFinishPixel( m_pixel );
}
else
{
DtexCopyPixel( m_pixel, m_rawPixel );
DtexFinishPixel( m_pixel );
}
// Get num points of compressed pixel.
int numPts = DtexPixelGetNumPoints( m_pixel );
// If no samples here, continue on.
if ( numPts < 1 )
{
outRow.addHole( x - i_box.min.x );
continue;
}
m_deepOutPixel.clear();
m_deepOutPixel.reserve( numPts * m_numDtexChans );
// Process the deep pixels.
DERIVED* derivedThis = static_cast<DERIVED*>( this );
derivedThis->processDeepPixel( numPts );
// Add the pixel to the row.
outRow.addPixel( x - i_box.min.x, m_deepOutPixel );
}
// Create the frame buffer.
// I'm not sure if this can be reused from row to row.
Imf::DeepFrameBuffer frameBuffer;
// Set the deep out row into the framebuffer.
outRow.setFrameBuffer( frameBuffer );
// Write row.
o_file.setFrameBuffer( frameBuffer );
o_file.writePixels( 1 );
}
}
} // End namespace PxDeep
#endif

View File

@@ -0,0 +1,166 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar Animation Studios, 2011-2012.
//-*****************************************************************************
#ifndef _PxDeepOutPixel_h_
#define _PxDeepOutPixel_h_
#include "PxDeepUtils.h"
namespace PxDeep {
//-*****************************************************************************
//-*****************************************************************************
// DEEP OUT PIXEL
//-*****************************************************************************
//-*****************************************************************************
// While constructing a deep out pixel from a dtex pixel, we reuse some
// temporary storage.
template <typename RGBA_T>
struct DeepOutPixel
{
size_t size() const
{
return deepFront.size();
}
void clear()
{
deepFront.clear();
deepBack.clear();
red.clear();
green.clear();
blue.clear();
alpha.clear();
}
void reserve( size_t N )
{
deepFront.reserve( N );
deepBack.reserve( N );
red.reserve( N );
green.reserve( N );
blue.reserve( N );
alpha.reserve( N );
}
void push_back( float i_depth,
RGBA_T i_alpha )
{
deepFront.push_back( i_depth );
deepBack.push_back( i_depth );
red.push_back( 0.0f );
green.push_back( 0.0f );
blue.push_back( 0.0f );
alpha.push_back( i_alpha );
}
void push_back( float i_deepFront,
float i_deepBack,
RGBA_T i_alpha )
{
deepFront.push_back( i_deepFront );
deepBack.push_back( i_deepBack );
red.push_back( 0.0f );
green.push_back( 0.0f );
blue.push_back( 0.0f );
alpha.push_back( i_alpha );
}
void push_back( float i_depth,
RGBA_T i_red,
RGBA_T i_green,
RGBA_T i_blue,
RGBA_T i_alpha )
{
deepFront.push_back( i_depth );
deepBack.push_back( i_depth );
red.push_back( i_red );
green.push_back( i_green );
blue.push_back( i_blue );
alpha.push_back( i_alpha );
}
void push_back( float i_deepFront,
float i_deepBack,
RGBA_T i_red,
RGBA_T i_green,
RGBA_T i_blue,
RGBA_T i_alpha )
{
deepFront.push_back( i_deepFront );
deepBack.push_back( i_deepBack );
red.push_back( i_red );
green.push_back( i_green );
blue.push_back( i_blue );
alpha.push_back( i_alpha );
}
std::vector<float> deepFront;
std::vector<float> deepBack;
std::vector<RGBA_T> red;
std::vector<RGBA_T> green;
std::vector<RGBA_T> blue;
std::vector<RGBA_T> alpha;
};
}
#endif

View File

@@ -0,0 +1,299 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar Animation Studios, 2011-2012.
//-*****************************************************************************
#ifndef _PxDeepOutRow_h_
#define _PxDeepOutRow_h_
#include "PxDeepUtils.h"
#include "PxDeepOutPixel.h"
#include <ImfDeepScanLineOutputFile.h>
#include <ImfDeepFrameBuffer.h>
#include <ImfPartType.h>
#include <ImfChannelList.h>
namespace PxDeep {
//-*****************************************************************************
//-*****************************************************************************
// DEEP OUT ROW
//-*****************************************************************************
//-*****************************************************************************
template <typename RGBA_T>
class DeepOutRow
{
public:
DeepOutRow( int i_width, bool i_doDeepBack, bool i_doRGB );
void clear();
void addHole( int i_x )
{
m_sampleCounts[i_x] = 0;
}
void addPixel( int i_x, const DeepOutPixel<RGBA_T>& i_pixel );
void setFrameBuffer( Imf::DeepFrameBuffer& o_frameBuffer );
protected:
// Width of the row.
int m_width;
// Whether or not to bother with deep back
bool m_doDeepBack;
// Whether or not to bother with RGB
bool m_doRGB;
// Scanline sample buffers.
std::vector<uint> m_sampleCounts;
// The pointers to data at each pixel
std::vector<float*> m_deepFrontPtrs;
std::vector<float*> m_deepBackPtrs;
std::vector<RGBA_T*> m_redPtrs;
std::vector<RGBA_T*> m_greenPtrs;
std::vector<RGBA_T*> m_bluePtrs;
std::vector<RGBA_T*> m_alphaPtrs;
// The data itself.
std::vector<float> m_deepFrontSamples;
std::vector<float> m_deepBackSamples;
std::vector<RGBA_T> m_redSamples;
std::vector<RGBA_T> m_greenSamples;
std::vector<RGBA_T> m_blueSamples;
std::vector<RGBA_T> m_alphaSamples;
};
//-*****************************************************************************
template <typename T>
inline void VecAppend( T& i_dst, const T& i_src )
{
i_dst.insert( i_dst.end(), i_src.begin(), i_src.end() );
}
//-*****************************************************************************
template <typename RGBA_T>
DeepOutRow<RGBA_T>::DeepOutRow( int i_width, bool i_doDeepBack, bool i_doRGB )
: m_width( i_width )
, m_doDeepBack( i_doDeepBack )
, m_doRGB( i_doRGB )
{
m_sampleCounts.resize( ( size_t )m_width );
m_deepFrontPtrs.resize( ( size_t )m_width );
if ( m_doDeepBack )
{
m_deepBackPtrs.resize( ( size_t )m_width );
}
if ( m_doRGB )
{
m_redPtrs.resize( ( size_t )m_width );
m_greenPtrs.resize( ( size_t )m_width );
m_bluePtrs.resize( ( size_t )m_width );
}
m_alphaPtrs.resize( ( size_t )m_width );
}
//-*****************************************************************************
template <typename RGBA_T>
void DeepOutRow<RGBA_T>::clear()
{
std::fill( m_sampleCounts.begin(),
m_sampleCounts.end(),
( uint )0 );
m_deepFrontSamples.clear();
m_deepBackSamples.clear();
m_redSamples.clear();
m_greenSamples.clear();
m_blueSamples.clear();
m_alphaSamples.clear();
}
//-*****************************************************************************
template <typename RGBA_T>
void DeepOutRow<RGBA_T>::addPixel( int i_x,
const DeepOutPixel<RGBA_T>& i_pixel )
{
int npoints = i_pixel.size();
m_sampleCounts[i_x] = npoints;
if ( npoints > 0 )
{
VecAppend( m_deepFrontSamples, i_pixel.deepFront );
if ( m_doDeepBack )
{
VecAppend( m_deepBackSamples, i_pixel.deepBack );
}
if ( m_doRGB )
{
VecAppend( m_redSamples, i_pixel.red );
VecAppend( m_greenSamples, i_pixel.green );
VecAppend( m_blueSamples, i_pixel.blue );
}
VecAppend( m_alphaSamples, i_pixel.alpha );
}
}
//-*****************************************************************************
template <typename RGBA_T>
void DeepOutRow<RGBA_T>::setFrameBuffer( Imf::DeepFrameBuffer& o_frameBuffer )
{
// Set up the pointers.
float *deepFrontLastPtr = m_deepFrontSamples.data();
float *deepBackLastPtr = m_deepBackSamples.data();
RGBA_T *redLastPtr = m_redSamples.data();
RGBA_T *greenLastPtr = m_greenSamples.data();
RGBA_T *blueLastPtr = m_blueSamples.data();
RGBA_T *alphaLastPtr = m_alphaSamples.data();
for ( int x = 0; x < m_width; ++x )
{
m_deepFrontPtrs[x] = deepFrontLastPtr;
if ( m_doDeepBack )
{
m_deepBackPtrs[x] = deepBackLastPtr;
}
if ( m_doRGB )
{
m_redPtrs[x] = redLastPtr;
m_greenPtrs[x] = greenLastPtr;
m_bluePtrs[x] = blueLastPtr;
}
m_alphaPtrs[x] = alphaLastPtr;
int c = m_sampleCounts[x];
deepFrontLastPtr += c;
deepBackLastPtr += c;
redLastPtr += c;
greenLastPtr += c;
blueLastPtr += c;
alphaLastPtr += c;
}
// Sample counts
o_frameBuffer.insertSampleCountSlice(
Imf::Slice( Imf::UINT,
( char * )m_sampleCounts.data(),
sizeof( uint ), // x stride
0 ) ); // y stride
// RGB
if ( m_doRGB )
{
o_frameBuffer.insert(
"R",
Imf::DeepSlice( ImfPixelType<RGBA_T>(),
( char * )m_redPtrs.data(),
sizeof( RGBA_T* ), // xstride
0, // ystride
sizeof( RGBA_T ) ) ); // sample stride
o_frameBuffer.insert(
"G",
Imf::DeepSlice( ImfPixelType<RGBA_T>(),
( char * )m_greenPtrs.data(),
sizeof( RGBA_T* ), // xstride
0, // ystride
sizeof( RGBA_T ) ) ); // sample stride
o_frameBuffer.insert(
"B",
Imf::DeepSlice( ImfPixelType<RGBA_T>(),
( char * )m_bluePtrs.data(),
sizeof( RGBA_T* ), // xstride
0, // ystride
sizeof( RGBA_T ) ) ); // sample stride
}
// ALPHA
o_frameBuffer.insert(
"A",
Imf::DeepSlice( ImfPixelType<RGBA_T>(),
( char * )m_alphaPtrs.data(),
sizeof( RGBA_T* ), // xstride
0, // ystride
sizeof( RGBA_T ) ) ); // sample stride
// DEEP FRONT
o_frameBuffer.insert(
"Z",
Imf::DeepSlice( Imf::FLOAT,
( char * )m_deepFrontPtrs.data(),
sizeof( float* ), // xstride
0, // ystride
sizeof( float ) ) ); // sample stride
// DEEP BACK
if ( m_doDeepBack )
{
o_frameBuffer.insert(
"ZBack",
Imf::DeepSlice( Imf::FLOAT,
( char * )m_deepBackPtrs.data(),
sizeof( float* ), // xstride
0, // ystride
sizeof( float ) ) ); // sample stride
}
}
} // End namespace PxDeep
#endif

View File

@@ -0,0 +1,199 @@
//-*****************************************************************************
// Copyright (C) Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar Animation Studios, 2011-2012.
//-*****************************************************************************
#include "PxDeepUtils.h"
namespace PxDeep {
//-*****************************************************************************
// Density/Viz/DZ calculations are always performed in double precision.
// We try to leave them alone as much as possible, but the logarithm can get
// weird for very very small numbers. The "isfinite" call basically rules
// out NaN and Infinity results, though it doesn't bother with subnormal
// numbers, since the error case we're worried about is log being too big.
// viz = exp( -dz * density )
// log( viz ) = -dz * density
// density = -log( viz ) / dz
double DensityFromVizDz( double i_viz, double i_dz )
{
assert( i_viz >= 0.0 );
assert( i_viz <= 1.0 );
assert( i_dz >= 0.0 );
if ( i_viz >= 1.0 )
{
// There's no attenuation at all, so there's no density!
return 0.0;
}
else if ( i_viz <= 0.0 )
{
// There's total attenuation, so we use our max density.
return PXDU_DENSITY_OF_VIZ_0;
}
else if ( i_dz <= 0.0 )
{
// There's no depth, and viz is greater than zero,
// so we assume the density is as high as possible
return PXDU_DENSITY_OF_VIZ_0;
}
else
{
double d = -log( i_viz ) / i_dz;
if ( !isfinite( d ) )
{
return PXDU_DENSITY_OF_VIZ_0;
}
else
{
return d;
}
}
}
//-*****************************************************************************
// We can often treat "density times dz" as a single quantity without
// separating it.
// viz = exp( -densityTimesDz )
// log( viz ) = -densityTimesDz
// densityTimesDz = -log( viz )
double DensityTimesDzFromViz( double i_viz )
{
assert( i_viz >= 0.0 );
assert( i_viz <= 1.0 );
if ( i_viz >= 1.0 )
{
// There's no attenuation at all, so there's no density!
return 0.0;
}
else if ( i_viz <= 0.0 )
{
// There's total attenuation, so we use our max density.
return PXDU_DENSITY_OF_VIZ_0 * PXDU_DZ_OF_VIZ_0;
}
else
{
double d = -log( i_viz );
if ( !isfinite( d ) )
{
return PXDU_DENSITY_OF_VIZ_0 * PXDU_DZ_OF_VIZ_0;
}
else
{
return d;
}
}
}
//-*****************************************************************************
// viz = exp( -dz * density )
// log( viz ) = -dz * density
// dz = -log( viz ) / density
// Note that this is basically the same as the computation above.
double DzFromVizDensity( double i_viz, double i_density )
{
assert( i_viz >= 0.0 );
assert( i_viz <= 1.0 );
assert( i_density >= 0.0 );
if ( i_viz >= 1.0 )
{
// There's no attenuation, so there's no depth.
return 0.0;
}
else if ( i_viz <= 0.0 )
{
// There's total attenuation, so we use the smallest depth
// for our max density.
return PXDU_DZ_OF_VIZ_0;
}
else if ( i_density <= 0.0 )
{
// Hmmm. There's no density, but there is some attenuation,
// which basically implies an infinite depth.
// We'll use the minimum density.
// This whole part is hacky at best.
double dz = -log( i_viz ) / PXDU_MIN_NON_ZERO_DENSITY;
if ( !isfinite( dz ) )
{
return PXDU_MAX_DZ;
}
else
{
return dz;
}
}
else
{
double dz = -log( i_viz ) / i_density;
if ( !isfinite( dz ) )
{
return PXDU_MAX_DZ;
}
else
{
return dz;
}
}
}
} // End namespace PxDeep

View File

@@ -0,0 +1,507 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar Animation Studios, 2011-2012.
//-*****************************************************************************
#ifndef _PxDeepUtils_h_
#define _PxDeepUtils_h_
#include <ImfNamespace.h>
#include <ImfPixelType.h>
#include <ImfPartType.h>
#include <ImathFun.h>
#include <ImathVec.h>
#include <ImathBox.h>
#include <ImathMatrix.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <iostream>
#include <exception>
#include <stdexcept>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <dtex.h>
#include <half.h>
#include <math.h>
#include <float.h>
#include <cmath>
#include <sys/types.h>
using std::isfinite;
namespace PxDeep {
//-*****************************************************************************
// The large block of comments below explains our working terminology and
// the justification of our limits & magic numbers. In a few places, the
// use of centimeters as a spatial unit does affect the absolute position of
// various minima and maxima, but in normal usage those should be well outside
// working ranges.
//-*****************************************************************************
//-*****************************************************************************
// DENSITY
//-*****************************************************************************
// "Density" refers to the the optical density which, when integrated
// through a line, produces an alpha. The relationship between alpha, density,
// and line segment of a given length "dz" is as follows:
//
// alpha = 1.0 - exp( -dz * density )
//
// We use a minimum non-zero density in some places in our code, which
// represents the density of dry air at atmospheric pressure. Though
// different wavelengths of light are attenuated differently, the average
// attenuation is 10^-5 per meter. To make it very minimal,
// we'll work with 1/10th that density (tiny tiny). Since our facility
// works in centimeters, this works out to (using & rearranging the
// equation above)
//
// 10^-6 = 1.0 - exp( -100.0 * MIN_NON_ZERO_DENSITY )
// exp( -100.0 * MIN_NON_ZERO_DENSITY ) = 1.0 - 10^-6
// -100.0 * MIN_NON_ZERO_DENSITY = log( 1.0 - 10^-6 )
// MIN_NON_ZERO_DENSITY = log( 1.0 - 10^-6 ) / -100.0
// MIN_NON_ZERO_DENSITY = 1.0000050000290891e-08
//
// We use double precision for density and dz calculations.
//
//-*****************************************************************************
// VISIBILITY (or 'VIZ', or 'TRANSMISSION')
//-*****************************************************************************
// Throughout the code below, we transform "alpha" into its inverse, which is
// transmissivity, or visibility, or for short, 'viz'. The relationship between
// alpha and viz is simple:
//
// alpha = 1.0 - viz, or viz = 1.0 - alpha.
//
// Similarly, the relationship between viz and density & dz is simple:
//
// viz = exp( -dz * density )
// log( viz ) = -dz * density
//
// Viz is easier to work with than alpha, because to accumulate a total
// visibility of many adjacent samples, the relationship is just, for the
// set of sample viz's: {viz0, viz1, viz2, ..., vizN-1}
//
// totalViz = viz0 * viz1 * viz2 * ... * vizN-1
//
// It's interesting to note that for any given set of spans, their accumulated
// visibility is the same regardless of what order they're accumulated in,
// since A*B == B*A.
//
// When using viz, we use double precision because the operation
// 1.0f - ( 1.0f - a ) loses precision, and we want as little of that as
// possible!
//
//-*****************************************************************************
// DEPTH RANGES
//-*****************************************************************************
// Because we need to be able to arithmetically manipulate depths, we place
// a range on the valid depth values. Positive Infinity is a valid depth value
// to be stored in a DTEX file, but in order to make everything else work, we
// set the maximum depth to near (but not at) FLT_MAX, 10^30. Similarly, we
// set the minimum depth to just slightly greater than zero, 10^-4. This
// could potentially clip effects being deep composited with very small
// distances and units of meters.
//
//-*****************************************************************************
// DEEP OPACITY
//-*****************************************************************************
// "Deep Opacity" refers to a depth function in which the sample at each point
// represents the total accumulated opacity at that depth. This represents
// the way that deep shadows would have been produced by renderman with the
// Display Driver Line: "deepshad" "deepopacity", except that the files actually
// store the inverse (1.0-opacity) at each point. It is important to note
// that for any given Dtex deepopacity sample, the value represents the
// accumulation of visibility on the NEAR side of the sample - up to and
// including the sample's depth, but no further in depth. Deep Opacity
// functions are monotonically decreasing in depth, and are always
// between 0 and 1.
//
// A complication arises when the 0'th continuous deep opacity sample has a
// non-zero deep opacity, because we don't have enough information to infer
// where the continuous span that ends at the 0th sample begins in depth. We
// solve the problem by interrogating the entire deep pixel for the maximum
// density of all its spans (see above), and then solving for what dz
// would produce the given accumulated alpha for that max density. The
// near point of the initial span is then 'dz' units in front of the 0th
// sample depth.
//
// We sometimes use 'deepViz' to in the code below to refer to 1.0 - deepOpacity
//
//-*****************************************************************************
// DEEP ALPHA
//-*****************************************************************************
// "Deep Alpha" refers to a depth function in which the sample at each point
// represents the non-accumulated alpha of that single sample. When interpreting
// the depth function as continuous instead of discrete, Deep Alpha represents
// the alpha of the FAR side of the sample - from the depth of the sample
// up to, but not including, the depth of the next sample.
//
// A complication arises when the last continuous deep alpha sample has a
// non-zero deep alpha, because we don't have enough information to infer
// where the continuous span that begins at the last sample ends in depth. We
// solve this problem analagously to how we solve the DeepOpacity problem.
// We get the maximum density along the entire deep pixel and extrapolate to
// determine an end depth.
//
//-*****************************************************************************
// DEEP RGBA
//-*****************************************************************************
// Deep RGBA is exactly the same as Deep Alpha, for both discrete and
// continuous cases, with the additional R,G, and B channels carried along.
// The RGB can be read as premultiplied by alpha, or not. The output deep
// pixel expects RGB to be premultiplied by alpha.
// The use of premultiplied alpha makes it possible to entangle emitted and
// reflected light - basically "glows", when premultiplied R,G,B are non-zero
// but alpha is zero. However, in order for us to collapse coindicent samples,
// we need to temporarily store RGB unpremultiplied. We simply don't affect
// the samples that have zero alpha, and don't remultiply samples that have
// zero alpha. There's no way for uncombined samples that had non-zero alpha
// to produce a combined sample with zero alpha, so any sample that has
// zero alpha at the end of all the combining was entirely composed of zero
// alpha samples to begin with. SO, if the alpha is zero, we don't
// multiply by it!
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
// UTILITY CONSTANTS AND FUNCTIONS
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
// Explained above in the "Density" section of the comments.
// We set this value to one tenth the attenuation of light in dry air
// at atmospheric pressure.
// 10^-6 = 1.0 - exp( -100.0 * MIN_NON_ZERO_DENSITY )
// exp( -100.0 * MIN_NON_ZERO_DENSITY ) = 1.0 - 10^-6
// -100.0 * MIN_NON_ZERO_DENSITY = log( 1.0 - 10^-6 )
// MIN_NON_ZERO_DENSITY = log( 1.0 - 10^-6 ) / -100.0
// MIN_NON_ZERO_DENSITY = 1.0000050000290891e-08
// static const double MIN_NON_ZERO_DENSITY = log( 1.0 - 1.0e-6 ) / -100.0;
#define PXDU_MIN_NON_ZERO_DENSITY 1.0000050000290891e-08L
//-*****************************************************************************
// The change in depth which produces maximum alpha for maximum density.
// We want this to be small without risking subnormality.
// static const double DZ_OF_ALPHA_1 = 0.001;
// static const double DZ_OF_VIZ_0 = 0.001;
#define PXDU_DZ_OF_ALPHA_1 0.001
#define PXDU_DZ_OF_VIZ_0 0.001
//-*****************************************************************************
// We set the max density of alpha 1 to the density which would produce
// an alpha of 0.99999 in a distance of 0.001 centimeters (DZ_OF_ALPHA_1)
//
// 0.99999 = 1.0 - exp( -0.001 * MAX_DENSITY )
// exp( -0.001 * MAX_DENSITY ) = 1.0 - 0.99999
// -0.001 * MAX_DENSITY = log( 1.0 - 0.99999 )
// MAX_DENSITY = log( 1.0 - 0.99999 ) / -0.001
// MAX_DENSITY = 11512.925464974779
// static const double DENSITY_OF_ALPHA_1 = log( 1.0 - 0.99999 ) / -0.001;
// static const double DENSITY_OF_VIZ_0 = DENSITY_OF_ALPHA_1;
#define PXDU_DENSITY_OF_ALPHA_1 11512.92546497478
#define PXDU_DENSITY_OF_VIZ_0 11512.92546497478
//-*****************************************************************************
// Just in case we need it. These are the constants used above.
#define PXDU_MAX_NON_OPAQUE_ALPHA 0.99999
#define PXDU_MIN_NON_OPAQUE_VIZ 0.00001
#define PXDU_MIN_NON_TRANSPARENT_ALPHA 0.00001
#define PXDU_MAX_NON_TRANSPARENT_VIZ 0.99999
//-*****************************************************************************
// Explained above in the "Depth" section of the comments.
// static const double MIN_DEEP_DEPTH = 1.0e-4;
// static const double MAX_DEEP_DEPTH = 1.0e30;
#define PXDU_MIN_DEEP_DEPTH 1.0e-4
#define PXDU_MAX_DEEP_DEPTH 1.0e30
//-*****************************************************************************
// A maximum depth change (dz)
// static const double MAX_DZ = double( MAX_DEEP_DEPTH ) -
// double( MIN_DEEP_DEPTH );
#define PXDU_MAX_DZ 1.0e30
//-*****************************************************************************
// IEEE 754 floats can be incremented to the "next" positive float
// in this manner, for positive float inputs.
inline float IncrementPositiveFloat( float i_a, int32_t i_inc=1 )
{
typedef union
{
int32_t i;
float f;
} intfloat;
intfloat a;
a.f = i_a;
a.i += i_inc;
return a.f;
}
//-*****************************************************************************
// IEEE 754 floats can be decremented to the "previous" positive float
// in this manner, for positive float inputs.
inline float DecrementPositiveFloat( float i_a, int32_t i_inc=1 )
{
typedef union
{
int32_t i;
float f;
} intfloat;
intfloat a;
a.f = i_a;
a.i -= i_inc;
return a.f;
}
//-*****************************************************************************
// From: man isinf
// isinf(x) returns 1 if x is positive infinity, and -1 if x is nega-
// tive infinity.
template <typename T>
inline bool IsInfinity( T i_f )
{
return ( isinf( i_f ) == 1 );
}
//-*****************************************************************************
// A zero-nan functon, which actually zeros inf as well.
template <typename T>
inline T ZeroNAN( T i_f )
{
if ( !isfinite( i_f ) ) { return ( T )0; }
else { return i_f; }
}
//-*****************************************************************************
template <typename T>
inline T ClampDepth( T i_depth )
{
if ( IsInfinity( i_depth ) )
{
return PXDU_MAX_DEEP_DEPTH;
}
else
{
return Imath::clamp( i_depth,
( T )PXDU_MIN_DEEP_DEPTH,
( T )PXDU_MAX_DEEP_DEPTH );
}
}
//-*****************************************************************************
template <typename T>
inline T ClampDz( T i_dz )
{
return Imath::clamp( ZeroNAN( i_dz ), ( T )0, ( T )PXDU_MAX_DZ );
}
//-*****************************************************************************
template <typename T>
inline T ClampNonZeroDz( T i_dz )
{
return Imath::clamp( ZeroNAN( i_dz ),
( T )PXDU_DZ_OF_ALPHA_1,
( T )PXDU_MAX_DZ );
}
//-*****************************************************************************
template <typename T>
inline T ClampAlpha( T i_alpha )
{
return Imath::clamp( ZeroNAN( i_alpha ), ( T )0, ( T )1 );
}
//-*****************************************************************************
// "plausible" in this case means not completely transparent, nor
// completely opaque.
template <typename T>
inline T ClampPlausibleAlpha( T i_alpha )
{
return Imath::clamp( ZeroNAN( i_alpha ),
( T )PXDU_MIN_NON_TRANSPARENT_ALPHA,
( T )PXDU_MAX_NON_OPAQUE_ALPHA );
}
//-*****************************************************************************
template <typename T>
inline double ClampViz( T i_viz )
{
return Imath::clamp( ZeroNAN( i_viz ), ( T )0, ( T )1 );
}
//-*****************************************************************************
// "plausible" in this case means not completely transparent, nor
// completely opaque.
template <typename T>
inline T ClampPlausibleViz( T i_viz )
{
return Imath::clamp( ZeroNAN( i_viz ),
( T )PXDU_MIN_NON_OPAQUE_VIZ,
( T )PXDU_MAX_NON_TRANSPARENT_VIZ );
}
//-*****************************************************************************
// Plausible density is clamped between min non-zero density
// and density of alpha 1.
template <typename T>
inline T ClampPlausibleDensity( T i_density )
{
return Imath::clamp( ZeroNAN( i_density ),
( T )PXDU_MIN_NON_ZERO_DENSITY,
( T )PXDU_DENSITY_OF_ALPHA_1 );
}
//-*****************************************************************************
// Density/Viz/DZ calculations are always performed in double precision.
// We try to leave them alone as much as possible, but the logarithm can get
// weird for very very small numbers. The "isfinite" call basically rules
// out NaN and Infinity results, though it doesn't bother with subnormal
// numbers, since the error case we're worried about is log being too big.
// viz = exp( -dz * density )
// log( viz ) = -dz * density
// density = -log( viz ) / dz
double DensityFromVizDz( double i_viz, double i_dz );
//-*****************************************************************************
// We can often treat "density times dz" as a single quantity without
// separating it.
// viz = exp( -densityTimesDz )
// log( viz ) = -densityTimesDz
// densityTimesDz = -log( viz )
double DensityTimesDzFromViz( double i_viz );
//-*****************************************************************************
// Plausible density defined above.
inline double PlausibleDensityFromVizDz( double i_viz, double i_dz )
{
return ClampPlausibleDensity( DensityFromVizDz( i_viz, i_dz ) );
}
//-*****************************************************************************
// viz = exp( -dz * density )
// log( viz ) = -dz * density
// dz = -log( viz ) / density
// Note that this is basically the same as the computation above.
double DzFromVizDensity( double i_viz, double i_density );
//-*****************************************************************************
// viz = exp( -dz * density ) // valid for all finite numbers.
// negative densities or dz's will give greater than 1 viz's, which will
// get clamped!
inline double VizFromDensityDz( double i_density, double i_dz )
{
return ClampViz( exp( -ZeroNAN( i_density * i_dz ) ) );
}
//-*****************************************************************************
// same as above.
inline double VizFromDensityTimesDz( double i_densityTimesDz )
{
return ClampViz( exp( -ZeroNAN( i_densityTimesDz ) ) );
}
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
// IMF SPECIFIC STUFF
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
//-*****************************************************************************
template <typename T>
Imf::PixelType ImfPixelType();
template <>
inline Imf::PixelType ImfPixelType<half>() { return Imf::HALF; }
template <>
inline Imf::PixelType ImfPixelType<float>() { return Imf::FLOAT; }
template <>
inline Imf::PixelType ImfPixelType<uint>() { return Imf::UINT; }
//-*****************************************************************************
// Handy exception macro.
#define PXDU_THROW( TEXT ) \
do \
{ \
std::stringstream sstr; \
sstr << TEXT; \
std::runtime_error exc( sstr.str() ); \
throw( exc ); \
} \
while( 0 )
} // End namespace PxDeep
#endif

View File

@@ -0,0 +1,511 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar, 2011-2012.
//-*****************************************************************************
#ifndef _PxFourChanDeepRgba_h_
#define _PxFourChanDeepRgba_h_
#include "PxDeepUtils.h"
#include "PxBaseDeepHelper.h"
namespace PxDeep {
//-*****************************************************************************
// FOUR CHANNEL DEEP RGBA CONTINUOUS
//-*****************************************************************************
template <typename RGBA_T>
class FourChanDeepRgbaContinuous
: public BaseDeepHelper<RGBA_T,
FourChanDeepRgbaContinuous<RGBA_T>,SpanRgba>
{
public:
typedef BaseDeepHelper<RGBA_T,
FourChanDeepRgbaContinuous<RGBA_T>,SpanRgba>
super_type;
typedef FourChanDeepRgbaContinuous<RGBA_T> this_type;
typedef typename super_type::span_type span_type;
FourChanDeepRgbaContinuous( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: BaseDeepHelper<RGBA_T,
FourChanDeepRgbaContinuous<RGBA_T>,SpanRgba>
( i_dtexFile,
i_numDtexChans,
i_params ) {}
void processDeepPixel( int i_numPts );
};
//-*****************************************************************************
// FOUR CHANNEL DEEP RGBA DISCRETE
//-*****************************************************************************
template <typename RGBA_T>
class FourChanDeepRgbaDiscrete
: public BaseDeepHelper<RGBA_T,
FourChanDeepRgbaDiscrete<RGBA_T>,SpanRgba>
{
public:
typedef BaseDeepHelper<RGBA_T,
FourChanDeepRgbaDiscrete<RGBA_T>,SpanRgba>
super_type;
typedef FourChanDeepRgbaDiscrete<RGBA_T> this_type;
typedef typename super_type::span_type span_type;
FourChanDeepRgbaDiscrete( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: BaseDeepHelper<RGBA_T,
FourChanDeepRgbaDiscrete<RGBA_T>,SpanRgba>
( i_dtexFile,
i_numDtexChans,
i_params ) {}
void processDeepPixel( int i_numPts );
};
//-*****************************************************************************
template <typename RGBA_T>
void FourChanDeepRgbaContinuous<RGBA_T>::processDeepPixel( int i_numPts )
{
assert( i_numPts > 0 );
// Loop over all the dtex points and get their deepAlphas
// and their depths. Enforce the case that deepAlpha
// is always between 0 and 1.
(this->m_spans).resize( ( size_t )i_numPts );
for ( int j = 0; j < i_numPts; ++j )
{
float z;
float pts[4];
DtexPixelGetPoint( (this->m_pixel), j, &z, ( float * )pts );
z = ClampDepth( z );
double red = ZeroNAN( pts[0] );
double green = ZeroNAN( pts[1] );
double blue = ZeroNAN( pts[2] );
double alpha = ClampAlpha( pts[3] );
span_type& spanJ = (this->m_spans)[j];
spanJ.clear();
spanJ.in = z;
spanJ.out = z;
spanJ.viz = ClampViz( 1.0 - alpha );
spanJ.index = j;
// Only unpremult if the data is assumed to be premultiplied,
// which is when the params say DON'T multiply color by alpha.
if ( alpha > 0.0 && !(this->m_params).multiplyColorByAlpha )
{
spanJ.rgb[0] = red / alpha;
spanJ.rgb[1] = green / alpha;
spanJ.rgb[2] = blue / alpha;
}
else
{
spanJ.rgb[0] = red;
spanJ.rgb[1] = green;
spanJ.rgb[2] = blue;
}
}
// Sort the spans.
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
// Combine identical depths.
double maxDensity = PXDU_MIN_NON_ZERO_DENSITY;
{
int activeBegin = 0;
int activeEnd = 0;
float interestingDepth = 0.0f;
int numRemoved = 0;
while ( activeBegin < i_numPts )
{
span_type& spanActiveBegin = (this->m_spans)[activeBegin];
float nextInterestingDepth = spanActiveBegin.in;
assert( nextInterestingDepth > interestingDepth );
activeEnd = i_numPts;
for ( int a = activeBegin + 1; a < i_numPts; ++a )
{
span_type& spanNext = (this->m_spans)[a];
assert( spanNext.in > interestingDepth );
assert( spanNext.in >= nextInterestingDepth );
if ( spanNext.in > nextInterestingDepth )
{
// This span is not active in this round,
// set activeEnd and get out.
activeEnd = a;
break;
}
else
{
// This span has an identical depth to
// the previous one, so we must combine their
// alphas and eliminate the depth.
// We simply add their unpremultiplied color.
spanActiveBegin.viz *= spanNext.viz;
spanActiveBegin.rgb[0] += spanNext.rgb[0];
spanActiveBegin.rgb[1] += spanNext.rgb[1];
spanActiveBegin.rgb[2] += spanNext.rgb[2];
spanNext.in = FLT_MAX;
spanNext.out = FLT_MAX;
++numRemoved;
}
}
spanActiveBegin.viz = ClampViz( spanActiveBegin.viz );
// Accumulate density from here to the next point.
if ( activeEnd < i_numPts )
{
span_type& spanNext = (this->m_spans)[activeEnd];
double dz = spanNext.in - spanActiveBegin.in;
assert( spanNext.in > spanActiveBegin.in );
assert( dz > 0.0 );
double density = DensityFromVizDz( spanActiveBegin.viz,
dz );
maxDensity = std::max( maxDensity, density );
}
activeBegin = activeEnd;
interestingDepth = nextInterestingDepth;
}
// If any removed, re-sort the list and remove the end
// points.
if ( numRemoved > 0 )
{
assert( numRemoved < i_numPts );
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
i_numPts -= numRemoved;
(this->m_spans).resize( i_numPts );
}
}
// Handle the single point case.
if ( i_numPts == 1 )
{
span_type& span0 = (this->m_spans)[0];
if ( (this->m_params).discardZeroAlphaSamples &&
span0.viz >= 1.0 )
{
// Nothing!
return;
}
span0.out = ClampDepth(
IncrementPositiveFloat( span0.in ) );
double alpha = ClampAlpha( 1.0 - span0.viz );
// If the alpha is zero, and we're still here, it means
// that the spans are either completely transparent and
// the user has elected to keep them anyway, in which case
// no multiplication by alpha is needed, or alternatively,
// they're "glow" spans which have zero alpha but non-zero
// color. Those glow spans were not unpremultiplied above,
// and therefore do not need to be premultiplied here.
// SO! If alpha is zero, we don't premultiply.
if ( alpha > 0.0 )
{
span0.rgb[0] *= alpha;
span0.rgb[1] *= alpha;
span0.rgb[2] *= alpha;
}
(this->m_deepOutPixel).push_back( span0.in,
span0.out,
span0.rgb[0],
span0.rgb[1],
span0.rgb[2],
alpha );
return;
}
// Put the spans back out.
// If the last point has a non-zero alpha, extrapolate the
// maximum density to create an end point.
for ( int j = 0; j < i_numPts; ++j )
{
span_type& spanJ = (this->m_spans)[j];
if ( (this->m_params).discardZeroAlphaSamples &&
spanJ.viz >= 1.0 )
{
// This span is transparent, ignore it.
continue;
}
if ( j < i_numPts-1 )
{
spanJ.out = (this->m_spans)[j+1].in;
}
else
{
// This is the last point.
// If it has non-zero alpha, it needs depth,
// which we use the max density for.
if ( spanJ.viz >= 1.0 )
{
// Don't need to worry about this last span!
// It is at the end of the continuous span, and
// is completely transparent.
continue;
}
double dz = DzFromVizDensity( spanJ.viz, maxDensity );
spanJ.out = ClampDepth( spanJ.in + dz );
if ( spanJ.out <= spanJ.in )
{
spanJ.out =
ClampDepth( IncrementPositiveFloat( spanJ.in ) );
}
}
double alpha = ClampAlpha( 1.0 - spanJ.viz );
// If the alpha is zero, and we're still here, it means
// that the spans are either completely transparent and
// the user has elected to keep them anyway, in which case
// no multiplication by alpha is needed, or alternatively,
// they're "glow" spans which have zero alpha but non-zero
// color. Those glow spans were not unpremultiplied above,
// and therefore do not need to be premultiplied here.
// SO! If alpha is zero, we don't premultiply.
if ( alpha > 0.0 )
{
spanJ.rgb[0] *= alpha;
spanJ.rgb[1] *= alpha;
spanJ.rgb[2] *= alpha;
}
// Set the channels!
(this->m_deepOutPixel).push_back( spanJ.in,
spanJ.out,
spanJ.rgb[0],
spanJ.rgb[1],
spanJ.rgb[2],
alpha );
}
}
//-*****************************************************************************
template <typename RGBA_T>
void FourChanDeepRgbaDiscrete<RGBA_T>::processDeepPixel( int i_numPts )
{
assert( i_numPts > 0 );
// Loop over all the dtex points and get their deepAlphas
// and their depths. Enforce the case that deepAlpha
// is always between 0 and 1.
(this->m_spans).resize( ( size_t )i_numPts );
for ( int j = 0; j < i_numPts; ++j )
{
float z;
float pts[4];
DtexPixelGetPoint( (this->m_pixel), j, &z, ( float * )pts );
z = ClampDepth( z );
double red = ZeroNAN( pts[0] );
double green = ZeroNAN( pts[1] );
double blue = ZeroNAN( pts[2] );
double alpha = ClampAlpha( pts[3] );
span_type& spanJ = (this->m_spans)[j];
spanJ.clear();
spanJ.in = z;
spanJ.out = z;
spanJ.viz = ClampViz( 1.0 - alpha );
spanJ.index = j;
// Only unpremult if the data is assumed to be premultiplied,
// which is when the params say DON'T multiply color by alpha.
if ( alpha > 0.0 && !(this->m_params).multiplyColorByAlpha )
{
spanJ.rgb[0] = red / alpha;
spanJ.rgb[1] = green / alpha;
spanJ.rgb[2] = blue / alpha;
}
else
{
spanJ.rgb[0] = red;
spanJ.rgb[1] = green;
spanJ.rgb[2] = blue;
}
}
// Sort the spans.
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
// Combine identical depths.
{
int activeBegin = 0;
int activeEnd = 0;
float interestingDepth = 0.0f;
int numRemoved = 0;
while ( activeBegin < i_numPts )
{
span_type& spanActiveBegin = (this->m_spans)[activeBegin];
float nextInterestingDepth = spanActiveBegin.in;
assert( nextInterestingDepth > interestingDepth );
activeEnd = i_numPts;
for ( int a = activeBegin + 1; a < i_numPts; ++a )
{
span_type& spanNext = (this->m_spans)[a];
assert( spanNext.in > interestingDepth );
assert( spanNext.in >= nextInterestingDepth );
if ( spanNext.in > nextInterestingDepth )
{
// This span is not active in this round,
// set activeEnd and get out.
activeEnd = a;
break;
}
else
{
// This span has an identical depth to
// the previous one, so we must combine their
// alphas and eliminate the depth.
// We simply add their unpremultiplied color.
spanActiveBegin.viz *= spanNext.viz;
spanActiveBegin.rgb[0] += spanNext.rgb[0];
spanActiveBegin.rgb[1] += spanNext.rgb[1];
spanActiveBegin.rgb[2] += spanNext.rgb[2];
spanNext.in = FLT_MAX;
spanNext.out = FLT_MAX;
++numRemoved;
}
}
spanActiveBegin.viz = ClampViz( spanActiveBegin.viz );
activeBegin = activeEnd;
interestingDepth = nextInterestingDepth;
}
// If any removed, re-sort the list and remove the end
// points.
if ( numRemoved > 0 )
{
assert( numRemoved < i_numPts );
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
i_numPts -= numRemoved;
(this->m_spans).resize( i_numPts );
}
}
// Put the spans back out.
// If the last point has a non-zero alpha, extrapolate the
// maximum density to create an end point.
for ( int j = 0; j < i_numPts; ++j )
{
span_type& spanJ = (this->m_spans)[j];
if ( (this->m_params).discardZeroAlphaSamples &&
spanJ.viz >= 1.0 )
{
// This span is transparent, ignore it.
continue;
}
double alpha = ClampAlpha( 1.0 - spanJ.viz );
// If the alpha is zero, and we're still here, it means
// that the spans are either completely transparent and
// the user has elected to keep them anyway, in which case
// no multiplication by alpha is needed, or alternatively,
// they're "glow" spans which have zero alpha but non-zero
// color. Those glow spans were not unpremultiplied above,
// and therefore do not need to be premultiplied here.
// SO! If alpha is zero, we don't premultiply.
if ( alpha > 0.0 )
{
spanJ.rgb[0] *= alpha;
spanJ.rgb[1] *= alpha;
spanJ.rgb[2] *= alpha;
}
// Set the channels!
(this->m_deepOutPixel).push_back( spanJ.in,
spanJ.rgb[0],
spanJ.rgb[1],
spanJ.rgb[2],
alpha );
}
}
} // End namespace PxDeep
#endif

View File

@@ -0,0 +1,410 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar, 2011-2012.
//-*****************************************************************************
#ifndef _PxOneChanDeepAlpha_h_
#define _PxOneChanDeepAlpha_h_
#include "PxDeepUtils.h"
#include "PxBaseDeepHelper.h"
namespace PxDeep {
//-*****************************************************************************
// ONE CHANNEL DEEP ALPHA CONTINUOUS
//-*****************************************************************************
template <typename RGBA_T>
class OneChanDeepAlphaContinuous
: public BaseDeepHelper<RGBA_T,
OneChanDeepAlphaContinuous<RGBA_T>,Span>
{
public:
typedef BaseDeepHelper<RGBA_T,
OneChanDeepAlphaContinuous<RGBA_T>,Span>
super_type;
typedef OneChanDeepAlphaContinuous<RGBA_T> this_type;
typedef typename super_type::span_type span_type;
OneChanDeepAlphaContinuous( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: BaseDeepHelper<RGBA_T,
OneChanDeepAlphaContinuous<RGBA_T>,Span>
( i_dtexFile,
i_numDtexChans,
i_params ) {}
void processDeepPixel( int i_numPts );
};
//-*****************************************************************************
// ONE CHANNEL DEEP ALPHA DISCRETE
//-*****************************************************************************
template <typename RGBA_T>
class OneChanDeepAlphaDiscrete
: public BaseDeepHelper<RGBA_T,
OneChanDeepAlphaDiscrete<RGBA_T>,Span>
{
public:
typedef BaseDeepHelper<RGBA_T,
OneChanDeepAlphaDiscrete<RGBA_T>,Span>
super_type;
typedef OneChanDeepAlphaDiscrete<RGBA_T> this_type;
typedef typename super_type::span_type span_type;
OneChanDeepAlphaDiscrete( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: BaseDeepHelper<RGBA_T,
OneChanDeepAlphaDiscrete<RGBA_T>,Span>
( i_dtexFile,
i_numDtexChans,
i_params ) {}
void processDeepPixel( int i_numPts );
};
//-*****************************************************************************
template <typename RGBA_T>
void OneChanDeepAlphaContinuous<RGBA_T>::processDeepPixel( int i_numPts )
{
assert( i_numPts > 0 );
// Loop over all the dtex points and get their deepAlphas
// and their depths. Enforce the case that deepAlpha
// is always between 0 and 1.
// Also, find a good "best slope" for extraplolation.
(this->m_spans).resize( ( size_t )i_numPts );
for ( int j = 0; j < i_numPts; ++j )
{
float z;
float pts[4];
DtexPixelGetPoint( (this->m_pixel), j, &z, ( float * )pts );
z = ClampDepth( z );
double alpha = ClampAlpha( pts[0] );
span_type& spanJ = (this->m_spans)[j];
spanJ.clear();
spanJ.in = z;
spanJ.out = z;
spanJ.viz = ClampViz( 1.0 - alpha );
spanJ.index = j;
}
// Sort the spans.
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
// Combine identical depths, gathering max density along
// the way.
double maxDensity = PXDU_MIN_NON_ZERO_DENSITY;
{
int activeBegin = 0;
int activeEnd = 0;
float interestingDepth = 0.0f;
int numRemoved = 0;
while ( activeBegin < i_numPts )
{
span_type& spanActiveBegin = (this->m_spans)[activeBegin];
float nextInterestingDepth = spanActiveBegin.in;
assert( nextInterestingDepth > interestingDepth );
activeEnd = i_numPts;
for ( int a = activeBegin + 1; a < i_numPts; ++a )
{
span_type& spanNext = (this->m_spans)[a];
assert( spanNext.in > interestingDepth );
assert( spanNext.in >= nextInterestingDepth );
if ( spanNext.in > nextInterestingDepth )
{
// This span is not active in this round,
// set activeEnd and get out.
activeEnd = a;
break;
}
else
{
// This span has an identical depth to
// the previous one, so we must combine their
// vizs and eliminate the depth.
spanActiveBegin.viz *= spanNext.viz;
spanNext.in = FLT_MAX;
spanNext.out = FLT_MAX;
++numRemoved;
}
}
spanActiveBegin.viz = ClampViz( spanActiveBegin.viz );
// Accumulate density from here to the next point.
if ( activeEnd < i_numPts )
{
span_type& spanNext = (this->m_spans)[activeEnd];
double dz = spanNext.in - spanActiveBegin.in;
assert( spanNext.in > spanActiveBegin.in );
assert( dz > 0.0 );
double density = DensityFromVizDz( spanActiveBegin.viz,
dz );
maxDensity = std::max( maxDensity, density );
}
activeBegin = activeEnd;
interestingDepth = nextInterestingDepth;
}
// If any removed, re-sort the list and remove the end
// points.
if ( numRemoved > 0 )
{
assert( numRemoved < i_numPts );
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
i_numPts -= numRemoved;
(this->m_spans).resize( i_numPts );
}
}
// Handle the single point case.
if ( i_numPts == 1 )
{
span_type& span0 = (this->m_spans)[0];
if ( (this->m_params).discardZeroAlphaSamples &&
span0.viz >= 1.0 )
{
// Nothing!
return;
}
span0.out = ClampDepth( IncrementPositiveFloat( span0.in ) );
float alphaF = ClampAlpha( 1.0 - span0.viz );
(this->m_deepOutPixel).push_back( span0.in,
span0.out,
alphaF );
return;
}
// Put the spans back out.
// If the last point has a non-zero alpha, extrapolate the
// maximum density to create an end point.
for ( int j = 0; j < i_numPts; ++j )
{
span_type& spanJ = (this->m_spans)[j];
if ( (this->m_params).discardZeroAlphaSamples &&
spanJ.viz >= 1.0 )
{
// This span is transparent, ignore it.
continue;
}
// Set the out points.
if ( j < i_numPts-1 )
{
spanJ.out = (this->m_spans)[j+1].in;
}
else
{
// This is the last point.
// If it has non-zero alpha, it needs depth,
// which we use the max density for.
if ( spanJ.viz >= 1.0 )
{
// Don't need to worry about this last span!
// It is at the end of the continuous span, and
// is completely transparent.
continue;
}
double dz = DzFromVizDensity( spanJ.viz, maxDensity );
spanJ.out = ClampDepth( spanJ.in + dz );
if ( spanJ.out <= spanJ.in )
{
spanJ.out = ClampDepth(
IncrementPositiveFloat( spanJ.in ) );
}
}
float alphaF = ClampAlpha( 1.0 - spanJ.viz );
(this->m_deepOutPixel).push_back( spanJ.in,
spanJ.out,
alphaF );
}
}
//-*****************************************************************************
template <typename RGBA_T>
void OneChanDeepAlphaDiscrete<RGBA_T>::processDeepPixel( int i_numPts )
{
assert( i_numPts > 0 );
// Loop over all the dtex points and get their deepAlphas
// and their depths. Enforce the case that deepAlpha
// is always between 0 and 1.
// Also, find a good "best slope" for extraplolation.
(this->m_spans).resize( ( size_t )i_numPts );
for ( int j = 0; j < i_numPts; ++j )
{
float z;
float pts[4];
DtexPixelGetPoint( (this->m_pixel), j, &z, ( float * )pts );
z = ClampDepth( z );
double alpha = ClampAlpha( pts[0] );
span_type& spanJ = (this->m_spans)[j];
spanJ.clear();
spanJ.in = z;
spanJ.viz = ClampViz( 1.0 - alpha );
spanJ.index = j;
}
// Sort the spans.
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
// Combine identical depths.
{
int activeBegin = 0;
int activeEnd = 0;
float interestingDepth = 0.0f;
int numRemoved = 0;
while ( activeBegin < i_numPts )
{
span_type& spanActiveBegin = (this->m_spans)[activeBegin];
float nextInterestingDepth = spanActiveBegin.in;
assert( nextInterestingDepth > interestingDepth );
activeEnd = i_numPts;
for ( int a = activeBegin + 1; a < i_numPts; ++a )
{
span_type& spanNext = (this->m_spans)[a];
assert( spanNext.in > interestingDepth );
assert( spanNext.in >= nextInterestingDepth );
if ( spanNext.in > nextInterestingDepth )
{
// This span is not active in this round,
// set activeEnd and get out.
activeEnd = a;
break;
}
else
{
// This span has an identical depth to
// the previous one, so we must combine their
// alphas and eliminate the depth.
spanActiveBegin.viz *= spanNext.viz;
spanNext.in = FLT_MAX;
++numRemoved;
}
}
spanActiveBegin.viz = ClampViz( spanActiveBegin.viz );
activeBegin = activeEnd;
interestingDepth = nextInterestingDepth;
}
// If any removed, re-sort the list and remove the end
// points.
if ( numRemoved > 0 )
{
assert( numRemoved < i_numPts );
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
i_numPts -= numRemoved;
(this->m_spans).resize( i_numPts );
}
}
// Put the spans back out.
for ( int j = 0; j < i_numPts; ++j )
{
span_type& spanJ = (this->m_spans)[j];
if ( (this->m_params).discardZeroAlphaSamples &&
spanJ.viz >= 1.0 )
{
// This span is transparent, ignore it.
continue;
}
float alphaF = ClampAlpha( 1.0 - spanJ.viz );
// Set the channels!
(this->m_deepOutPixel).push_back( spanJ.in,
alphaF );
}
}
} // End namespace PxDeep
#endif

View File

@@ -0,0 +1,497 @@
//-*****************************************************************************
// Copyright (c) 2012, Pixar. All rights reserved. *
// *
// This license governs use of the accompanying software. If you *
// use the software, you accept this license. If you do not accept *
// the license, do not use the software. *
// *
// 1. Definitions *
// The terms "reproduce," "reproduction," "derivative works," and *
// "distribution" have the same meaning here as under U.S. *
// copyright law. A "contribution" is the original software, or *
// any additions or changes to the software. *
// A "contributor" is any person or entity that distributes its *
// contribution under this license. *
// "Licensed patents" are a contributor's patent claims that read *
// directly on its contribution. *
// *
// 2. Grant of Rights *
// (A) Copyright Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free copyright license to reproduce its contribution, *
// prepare derivative works of its contribution, and distribute *
// its contribution or any derivative works that you create. *
// (B) Patent Grant- Subject to the terms of this license, *
// including the license conditions and limitations in section 3, *
// each contributor grants you a non-exclusive, worldwide, *
// royalty-free license under its licensed patents to make, have *
// made, use, sell, offer for sale, import, and/or otherwise *
// dispose of its contribution in the software or derivative works *
// of the contribution in the software. *
// *
// 3. Conditions and Limitations *
// (A) No Trademark License- This license does not grant you *
// rights to use any contributor's name, logo, or trademarks. *
// (B) If you bring a patent claim against any contributor over *
// patents that you claim are infringed by the software, your *
// patent license from such contributor to the software ends *
// automatically. *
// (C) If you distribute any portion of the software, you must *
// retain all copyright, patent, trademark, and attribution *
// notices that are present in the software. *
// (D) If you distribute any portion of the software in source *
// code form, you may do so only under this license by including a *
// complete copy of this license with your distribution. If you *
// distribute any portion of the software in compiled or object *
// code form, you may only do so under a license that complies *
// with this license. *
// (E) The software is licensed "as-is." You bear the risk of *
// using it. The contributors give no express warranties, *
// guarantees or conditions. You may have additional consumer *
// rights under your local laws which this license cannot change. *
// To the extent permitted under your local laws, the contributors *
// exclude the implied warranties of merchantability, fitness for *
// a particular purpose and non-infringement. *
//-*****************************************************************************
//-*****************************************************************************
// Written by Pixar, 2011-2012.
//-*****************************************************************************
#ifndef _PxOneChanDeepOpacity_h_
#define _PxOneChanDeepOpacity_h_
#include "PxDeepUtils.h"
#include "PxBaseDeepHelper.h"
namespace PxDeep {
//-*****************************************************************************
// ONE CHANNEL DEEP OPACITY CONTINUOUS
//-*****************************************************************************
template <typename RGBA_T>
class OneChanDeepOpacityContinuous
: public BaseDeepHelper<RGBA_T,
OneChanDeepOpacityContinuous<RGBA_T>,SpanOpac>
{
public:
typedef BaseDeepHelper<RGBA_T,
OneChanDeepOpacityContinuous<RGBA_T>,SpanOpac>
super_type;
typedef OneChanDeepOpacityContinuous<RGBA_T> this_type;
typedef typename super_type::span_type span_type;
OneChanDeepOpacityContinuous( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: BaseDeepHelper<RGBA_T,
OneChanDeepOpacityContinuous<RGBA_T>,SpanOpac>
( i_dtexFile,
i_numDtexChans,
i_params ) {}
void processDeepPixel( int i_numPts );
};
//-*****************************************************************************
// ONE CHANNEL DEEP OPACITY DISCRETE
//-*****************************************************************************
template <typename RGBA_T>
class OneChanDeepOpacityDiscrete
: public BaseDeepHelper<RGBA_T,
OneChanDeepOpacityDiscrete<RGBA_T>,SpanOpac>
{
public:
typedef BaseDeepHelper<RGBA_T,
OneChanDeepOpacityDiscrete<RGBA_T>,SpanOpac>
super_type;
typedef OneChanDeepOpacityDiscrete<RGBA_T> this_type;
typedef typename super_type::span_type span_type;
OneChanDeepOpacityDiscrete( DtexFile* i_dtexFile,
int i_numDtexChans,
const Parameters& i_params )
: BaseDeepHelper<RGBA_T,
OneChanDeepOpacityDiscrete<RGBA_T>,SpanOpac>
( i_dtexFile,
i_numDtexChans,
i_params ) {}
void processDeepPixel( int i_numPts );
};
//-*****************************************************************************
template <typename RGBA_T>
void OneChanDeepOpacityContinuous<RGBA_T>::processDeepPixel( int i_numPts )
{
assert( i_numPts > 0 );
// Loop over all the dtex points and get their deepOpacities and
// depths.
(this->m_spans).resize( ( size_t )i_numPts );
for ( int j = 0; j < i_numPts; ++j )
{
float z;
float pts[4];
DtexPixelGetPoint( (this->m_pixel), j, &z, ( float * )pts );
z = ClampDepth( z );
span_type& spanJ = (this->m_spans)[j];
spanJ.clear();
spanJ.in = z;
spanJ.out = z;
// Data stored in dtex files for "deepopacity" is actually
// "deeptransmission", monotonically decreasing from an initial
// value of 1.0. We just convert it to viz directly.
// (viz == transmissivity)
spanJ.deepViz = ClampViz( pts[0] );
spanJ.index = j;
}
// Sort the spans by depth (and then index)
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
// Combine identical depths, accumulating maximum density
// along the way. Because we have deep opacity,
// coincident samples use the maximum deepOpacity value.
double maxDensity = PXDU_MIN_NON_ZERO_DENSITY;
{
int prevSpanIndex = 0;
int activeBegin = 0;
int activeEnd = 0;
float interestingDepth = 0.0f;
int numRemoved = 0;
while ( activeBegin < i_numPts )
{
span_type& spanActiveBegin = (this->m_spans)[activeBegin];
float nextInterestingDepth = spanActiveBegin.in;
assert( nextInterestingDepth > interestingDepth );
// This loop combines all the coincident samples
// into a single sample, invalidates the other coincident
// samples, and sets activeEnd to point to the next
// sample with a larger depth.
activeEnd = i_numPts;
for ( int a = activeBegin + 1; a < i_numPts; ++a )
{
span_type& spanNext = (this->m_spans)[a];
assert( spanNext.in > interestingDepth );
assert( spanNext.in >= nextInterestingDepth );
if ( spanNext.in > nextInterestingDepth )
{
// This span is not active in this round,
// set activeEnd and get out.
activeEnd = a;
break;
}
else
{
// This span has an identical depth to
// the previous one, so we use whichever one has the
// largest deep opacity, which equates to the
// smallest deep viz.
spanActiveBegin.deepViz =
std::min( spanActiveBegin.deepViz,
spanNext.deepViz );
spanNext.in = FLT_MAX;
spanNext.out = FLT_MAX;
++numRemoved;
}
}
// Okay, the deep vizibility at our in point
// is equal to the total vizibility before us,
// which is the deep vizibility at the previous point,
// times the vizibility of this point.
// deepViz = deepVizPrev * viz
// viz = deepViz / deepVizPrev;
if ( activeBegin == 0 )
{
spanActiveBegin.viz = spanActiveBegin.deepViz;
}
else
{
span_type& spanPrev = (this->m_spans)[prevSpanIndex];
// Make sure the deep visibilities are
// monotonically decreasing with depth.
spanActiveBegin.deepViz =
std::min( spanActiveBegin.deepViz,
spanPrev.deepViz );
if ( spanPrev.deepViz > 0.0 )
{
// If we have non-zero accumulated visibility,
// we can compute the span visibility.
spanActiveBegin.viz = spanActiveBegin.deepViz /
spanPrev.deepViz;
}
else
{
// If we have zero accumulated visibility,
// then the span visibility is also zero.
spanActiveBegin.viz = 0.0;
}
// Use the viz of this span to update the
// max density.
spanActiveBegin.viz = ClampViz( spanActiveBegin.viz );
spanActiveBegin.in = spanPrev.out;
double dz = spanActiveBegin.out - spanActiveBegin.in;
assert( dz > 0.0 );
assert( spanActiveBegin.out > spanActiveBegin.in );
double density = DensityFromVizDz( spanActiveBegin.viz,
dz );
maxDensity = std::max( maxDensity, density );
}
prevSpanIndex = activeBegin;
activeBegin = activeEnd;
interestingDepth = nextInterestingDepth;
}
// If any removed, re-sort the list and remove the end
// points.
if ( numRemoved > 0 )
{
assert( numRemoved < i_numPts );
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
i_numPts -= numRemoved;
(this->m_spans).resize( i_numPts );
}
}
// Handle the single point case.
if ( i_numPts == 1 )
{
span_type& span0 = (this->m_spans)[0];
if ( (this->m_params).discardZeroAlphaSamples &&
span0.viz >= 1.0 )
{
// Nothing!
return;
}
span0.in = ClampDepth( DecrementPositiveFloat( span0.out ) );
float alphaF = ClampAlpha( 1.0 - span0.viz );
(this->m_deepOutPixel).push_back( span0.in,
span0.out,
alphaF );
return;
}
// Put the spans back out.
// If the first point has a non-zero alpha, extrapolate the
// maximum density to create a begin point.
for ( int j = 0; j < i_numPts; ++j )
{
span_type& spanJ = (this->m_spans)[j];
if ( (this->m_params.discardZeroAlphaSamples) &&
spanJ.viz >= 1.0 )
{
// This span is transparent, ignore it.
continue;
}
if ( j == 0 )
{
// This is first point.
// If it has non-zero alpha, it needs depth,
// which we use the max density for.
if ( spanJ.viz >= 1.0 )
{
// Don't need to worry about this last span!
// It is at the end of the continuous span, and
// is completely transparent.
continue;
}
double dz = DzFromVizDensity( spanJ.viz, maxDensity );
spanJ.in = ClampDepth( spanJ.out - dz );
if ( spanJ.out <= spanJ.in )
{
spanJ.in = ClampDepth(
DecrementPositiveFloat( spanJ.out ) );
}
}
float alphaF = ClampAlpha( 1.0 - spanJ.viz );
// Set the channels!
(this->m_deepOutPixel).push_back( spanJ.in,
spanJ.out,
alphaF );
}
}
//-*****************************************************************************
template <typename RGBA_T>
void OneChanDeepOpacityDiscrete<RGBA_T>::processDeepPixel( int i_numPts )
{
assert( i_numPts > 0 );
// Loop over all the dtex points and get their deepOpacities and
// depths.
(this->m_spans).resize( ( size_t )i_numPts );
for ( int j = 0; j < i_numPts; ++j )
{
float z;
float pts[4];
DtexPixelGetPoint( (this->m_pixel), j, &z, ( float * )pts );
z = ClampDepth( z );
span_type& spanJ = (this->m_spans)[j];
spanJ.clear();
spanJ.in = z;
spanJ.out = z;
// Data stored in dtex files for "deepopacity" is actually
// "deeptransmission", monotonically decreasing from an initial
// value of 1.0. We just convert it to viz directly.
// (viz == transmissivity)
spanJ.deepViz = ClampViz( pts[0] );
spanJ.index = j;
}
// Sort the spans.
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
// Combine identical depths. Because we have deep opacity,
// coincident samples use the maximum deepOpacity value.
{
int prevSpanIndex = 0;
int activeBegin = 0;
int activeEnd = 0;
float interestingDepth = 0.0f;
int numRemoved = 0;
while ( activeBegin < i_numPts )
{
span_type& spanActiveBegin = (this->m_spans)[activeBegin];
float nextInterestingDepth = spanActiveBegin.in;
assert( nextInterestingDepth > interestingDepth );
// This loop combines all the coincident samples
// into a single sample, invalidates the other coincident
// samples, and sets activeEnd to point to the next
// sample with a larger depth.
activeEnd = i_numPts;
for ( int a = activeBegin + 1; a < i_numPts; ++a )
{
span_type& spanNext = (this->m_spans)[a];
assert( spanNext.in > interestingDepth );
assert( spanNext.in >= nextInterestingDepth );
if ( spanNext.in > nextInterestingDepth )
{
// This span is not active in this round,
// set activeEnd and get out.
activeEnd = a;
break;
}
else
{
// This span has an identical depth to
// the previous one, so we use whichever one has the
// largest deep opacity, which equates to the
// smallest deep viz.
spanActiveBegin.deepViz =
std::min( spanActiveBegin.deepViz,
spanNext.deepViz );
spanNext.in = FLT_MAX;
spanNext.out = FLT_MAX;
++numRemoved;
}
}
// Okay, the deep vizibility at our in point
// is equal to the total vizibility before us,
// which is the deep vizibility at the previous point,
// times the vizibility of this point.
// deepViz = deepVizPrev * viz
// viz = deepViz / deepVizPrev;
if ( activeBegin == 0 )
{
spanActiveBegin.viz = spanActiveBegin.deepViz;
}
else
{
span_type& spanPrev = (this->m_spans)[prevSpanIndex];
// Make sure the deep visibilities are
// monotonically decreasing with depth.
spanActiveBegin.deepViz =
std::min( spanActiveBegin.deepViz,
spanPrev.deepViz );
if ( spanPrev.deepViz > 0.0 )
{
// If we have non-zero accumulated visibility,
// we can compute the span visibility.
spanActiveBegin.viz = spanActiveBegin.deepViz /
spanPrev.deepViz;
}
else
{
// If we have zero accumulated visibility,
// then the span visibility is also zero.
spanActiveBegin.viz = 0.0;
}
// Clean up the viz!
spanActiveBegin.viz = ClampViz( spanActiveBegin.viz );
}
prevSpanIndex = activeBegin;
activeBegin = activeEnd;
interestingDepth = nextInterestingDepth;
}
// If any removed, re-sort the list and remove the end
// points.
if ( numRemoved > 0 )
{
assert( numRemoved < i_numPts );
std::sort( (this->m_spans).begin(), (this->m_spans).end() );
i_numPts -= numRemoved;
(this->m_spans).resize( i_numPts );
}
}
// Put the spans back out.
for ( int j = 0; j < i_numPts; ++j )
{
span_type& spanJ = (this->m_spans)[j];
if ( (this->m_params).discardZeroAlphaSamples &&
spanJ.viz >= 1.0 )
{
// This span is transparent, ignore it.
continue;
}
float alphaF = ClampAlpha( 1.0 - spanJ.viz );
(this->m_deepOutPixel).push_back( spanJ.in,
alphaF );
}
}
} // End namespace PxDeep
#endif

View File

@@ -0,0 +1,85 @@
//-*****************************************************************************
Pixar's Dtex to Exr conversion utility
Aug 1, 2012 - first checkin to OpenEXR 2.0 branch of OpenEXR git repository.
This utility converts a DTEX deep shadow file to an OpenEXR 2.0 deep exr file,
formerly, ".odz" (or .dexr, or whatever extension your facility may use). As of
the first checkin, the utility only supports 1, 3, or 4-channel dtex files,
corresponding to deep alpha or deep RGBA only. The Nuke DTEX reader, which
uses basically the same code, will support a more complete arbitrary channel
set, and this utility may be upgraded as well. We also only support a single
view for the time being.
DTEX has a complicated set of interpretations, which represent six separate
code paths for conversion to the deep representation in OpenEXR 2.0. They
represent the permutations of these exemplary Display Driver config strings
to prman:
Display "+filename.dtex" "deepshad" "deepopacity" "string volumeinterpretation" "continuous"
Display "+filename.dtex" "deepshad" "deepopacity" "string volumeinterpretation" "discrete"
Display "+filename.dtex" "deepshad" "a" "string volumeinterpretation" "continuous"
Display "+filename.dtex" "deepshad" "a" "string volumeinterpretation" "discrete"
Display "+filename.dtex" "deepshad" "rgba" "string volumeinterpretation" "continuous"
Display "+filename.dtex" "deepshad" "rgba" "string volumeinterpretation" "discrete"
In our terminology, these six options are called:
OneChanDeepOpacityContinuous
OneChanDeepOpacityDiscrete
OneChanDeepAlphaContinuous
OneChanDeepAlphaDiscrete
FourChanDeepRgbaContinuous
FourChanDeepRgbaDiscrete
Renderman will write out both 1-channel and 3-channel opacity in the
"deepopacity" case, which we currently only use the first channel of, as
we are only targeting a single opacity curve in space. This may evolve in
the future.
There are weird gotchas for each of these 6 cases, and they are documented
in the PxDeepUtils.h file, along with specific comments in each of the six
header files that correspond to each case:
PxOneChanDeepOpacityContinuous.h
PxOneChanDeepOpacityDiscrete.h
PxOneChanDeepAlphaContinuous.h
PxOneChanDeepAlphaDiscrete.h
PxFourChanDeepRgbaContinuous.h
PxFourChanDeepRgbaDiscrete.h
The gotchas relate to several issues, mostly to do with coincident or
out-of-order samples, precision issues, compression artifacts, and the
differences between the "deepopacity" vs "deepalpha" interpretations.
With "deepopacity" (the pre-prman 16 usage), opacity values stored in
dtex files were accumulated, so they were bounded between 0 and 1. The
values stored are actually not opacities, but rather transmissivities
(1-opacity), and monotonically decreased from fully transparent (1)
to fully opaque (0). This representation is ideal for meaningful error
minimization during compression, and also for usage as a shadow map
by a renderer, because the extinction at a particular depth, at a
particular pixel, can be evaluated with a single look-up. However,
this representation is poor for deep compositing, because each of the
samples includes data from smaller depth samples, and recombination is
difficult. With these types of files, when using volumetric (continuous)
interpretation, the samples represent the accumulated transmissivity at
the NEAR SIDE of a depth span, and our code paths take this into account.
With all other usages - "a" and "rgba", the values represent filtered
samples of the given field at that point in space. The alpha values
will be between 0 and 1, but are not guaranteed to be increasing or
decreasing. This presents a strange problem for volumetric interpretation,
as what does it mean to describe the alpha of an infintesimally small
region of space (point sample). The best interpretation of the data
in this case uses the alpha to represent the accumulated opacity of
the region of space nearer than the sample, and thus each sample
represents the FAR SIDE of a depth span. Our code paths take this into
account as well.
Please see the files for additional comments, and the command
"dtexToExr" may be run with -h, --h, --help, or no arguments to
print its usage.
-Christopher Horvath, Aug 2012, Pixar

View File

@@ -0,0 +1,60 @@
#! /bin/sh
# If we're on OS X, use glibtoolize instead of toolize
HOSTTYPE=`uname`
if [ "$HOSTTYPE" == "Darwin" ]; 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. DtexToExr 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 DtexToExr."
echo

View File

@@ -0,0 +1,223 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(DtexToExr, 1.0.0)
AC_SUBST(DTEXTOEXR_VERSION, 1.0.0)
AC_CANONICAL_HOST
AC_CONFIG_SRCDIR(DtexToExr.cpp)
AM_INIT_AUTOMAKE(1.6.3) dnl Require automake 1.6.3 or better
AM_MAINTAINER_MODE
LIBTOOL_CURRENT=6
LIBTOOL_REVISION=0
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
dnl
dnl get ccflags and libs from openexr and prmansdk packages
dnl
dnl
dnl get ccflags and libs from other packages in use and check
dnl whether test programs compile.
dnl OpenEXR is required. IlmBase is required.
dnl
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])
PRMANSDK_CXXFLAGS=""
PRMANSDK_LDFLAGS=""
PRMANSDK_LIBS=""
PRMANSDK_LIBNAME="prman"
AC_ARG_WITH(
[prmansdk-include-dir],
[AS_HELP_STRING([--with-prmansdk-include-dir],
[prman sdk include directory])],
[PRMANSDK_CXXFLAGS="-I$withval"])
AC_ARG_WITH(
[prmansdk-lib-dir],
[AS_HELP_STRING([--with-prmansdk-lib-dir],
[prman sdk library directory])],
[PRMANSDK_LDFLAGS="-L$withval -Wl,-rpath $withval"])
AC_ARG_WITH(
[prmansdk-libname],
[AS_HELP_STRING([--with-prmansdk-libname],
[prman sdk library name (default:prman)])],
[PRMANSDK_LIBNAME="$withval"])
PRMANSDK_LIBS="-l$PRMANSDK_LIBNAME"
export PRMANSDK_CXXFLAGS
export PRMANSDK_LDFLAGS
export PRMANSDK_LIBS
export PRMANSDK_LIBNAME
AC_SUBST([PRMANSDK_CXXFLAGS])
AC_SUBST([PRMANSDK_LDFLAGS])
AC_SUBST([PRMANSDK_LIBS])
AC_SUBST([PRMANSDK_LIBNAME])
CXXFLAGS="$CXXFLAGS $PRMANSDK_CXXFLAGS $OPENEXR_CXXFLAGS"
LDFLAGS="$LDFLAGS $PRMANSDK_LDFLAGS $OPENEXR_LDFLAGS"
dnl
dnl OpenEXR test program
dnl
AM_COMPILELINKRUN(
[OpenEXR],
[openexrtest],
[$OPENEXR_CXXFLAGS],
[$OPENEXR_LDFLAGS],
[$OPENEXR_LIBS],[[
#include <stdlib.h>
#include <ImfTestFile.h>
#include <OpenEXRConfig.h>
]],
[[OPENEXR_IMF_NAMESPACE::isOpenExrFile("notExist");]],
AC_MSG_RESULT([Compiled and ran OpenEXR test program.]),
AC_MSG_ERROR([Could not compile OpenEXR test program.]))
dnl
dnl Dtex test program
dnl
AM_COMPILELINKRUN(
[PrmanSDK],
[prmansdktest],
[$PRMANSDK_CXXFLAGS],
[$PRMANSDK_LDFLAGS],
[$PRMANSDK_LIBS],
[[
#include <stdio.h>
#include <stdlib.h>
#include <dtex.h>
]],
[[
DtexCache* dtexCache = DtexCreateCache( 10000, NULL );
if ( dtexCache ) { DtexDestroyCache( dtexCache ); }
]],
AC_MSG_RESULT([Compiled and ran PrmanSDK test program.]),
AC_MSG_ERROR([Could not compile PrmanSDK test program.]))
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
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)
AC_OUTPUT([
Makefile
])
if test "x$build_osxuniversal" = xyes; then
AC_MSG_RESULT([
---------------------------------------------
Summary for DtexToExr features:
build OS X universal binaries $build_osxuniversal
---------------------------------------------
])
else
AC_MSG_RESULT([
---------------------------------------------
Summary for DtexToExr features:
---------------------------------------------
])
fi

View 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])
])

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,368 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option `$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl `shared' nor `disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [0], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the `shared' and
# `disable-shared' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the `static' and
# `disable-static' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the `fast-install'
# and `disable-fast-install' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
# LT_INIT options.
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[pic_mode="$withval"],
[pic_mode=default])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])

View File

@@ -0,0 +1,123 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59 which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])

View File

@@ -0,0 +1,23 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# Generated from ltversion.in.
# serial 3017 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.2.6b])
m4_define([LT_PACKAGE_REVISION], [1.3017])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.2.6b'
macro_revision='1.3017'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

View File

@@ -0,0 +1,92 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 4 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])

View 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])
])

View 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
])