Disabled external gits
This commit is contained in:
16
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/.cvsignore
Normal file
16
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/.cvsignore
Normal file
@@ -0,0 +1,16 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
config.h.in
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
libtool
|
||||
stamp-h
|
||||
aclocal.m4
|
||||
OpenEXR.pc
|
||||
autom4te.cache
|
||||
ltmain.sh
|
||||
stamp-h.in
|
||||
depcomp
|
||||
.deps
|
22
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/CMakeLists.txt
Normal file
22
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
# yue.nicholas@gmail.com
|
||||
|
||||
ADD_EXECUTABLE ( exrmaketiled
|
||||
makeTiled.cpp
|
||||
main.cpp
|
||||
Image.cpp
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES ( exrmaketiled
|
||||
IlmImf
|
||||
IlmThread${ILMBASE_LIBSUFFIX}
|
||||
Iex${ILMBASE_LIBSUFFIX}
|
||||
Half
|
||||
${PTHREAD_LIB}
|
||||
${ZLIB_LIBRARIES}
|
||||
)
|
||||
|
||||
INSTALL ( TARGETS
|
||||
exrmaketiled
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_PREFIX}/bin
|
||||
)
|
125
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/Image.cpp
Normal file
125
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/Image.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Classes for storing OpenEXR images in memory.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "Image.h"
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
using namespace IMF;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
using namespace std;
|
||||
|
||||
|
||||
ImageChannel::ImageChannel (Image &image): _image (image)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
ImageChannel::~ImageChannel ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Image::Image (): _dataWindow (Box2i (V2i (0, 0), V2i (0, 0)))
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Image::Image (const Box2i &dataWindow): _dataWindow (dataWindow)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
Image::~Image ()
|
||||
{
|
||||
for (ChannelMap::iterator i = _channels.begin(); i != _channels.end(); ++i)
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Image::resize (const IMATH_NAMESPACE::Box2i &dataWindow)
|
||||
{
|
||||
_dataWindow = dataWindow;
|
||||
|
||||
for (ChannelMap::iterator i = _channels.begin(); i != _channels.end(); ++i)
|
||||
i->second->resize (width(), height());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Image::addChannel (const string &name, PixelType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case IMF::HALF:
|
||||
_channels[name] = new HalfChannel (*this, width(), height());
|
||||
break;
|
||||
|
||||
case IMF::FLOAT:
|
||||
_channels[name] = new FloatChannel (*this, width(), height());
|
||||
break;
|
||||
|
||||
case IMF::UINT:
|
||||
_channels[name] = new UIntChannel (*this, width(), height());
|
||||
break;
|
||||
|
||||
default:
|
||||
throw IEX_NAMESPACE::ArgExc ("Unknown channel type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImageChannel &
|
||||
Image::channel (const string &name)
|
||||
{
|
||||
return *_channels.find(name)->second;
|
||||
}
|
||||
|
||||
|
||||
const ImageChannel &
|
||||
Image::channel (const string &name) const
|
||||
{
|
||||
return *_channels.find(name)->second;
|
||||
}
|
263
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/Image.h
Normal file
263
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/Image.h
Normal file
@@ -0,0 +1,263 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDED_IMAGE_H
|
||||
#define INCLUDED_IMAGE_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Classes for storing OpenEXR images in memory.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfPixelType.h>
|
||||
#include <ImfFrameBuffer.h>
|
||||
#include <ImfArray.h>
|
||||
#include <ImathBox.h>
|
||||
#include <half.h>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
|
||||
class Image;
|
||||
|
||||
|
||||
class ImageChannel
|
||||
{
|
||||
public:
|
||||
|
||||
friend class Image;
|
||||
|
||||
ImageChannel (Image &image);
|
||||
virtual ~ImageChannel();
|
||||
|
||||
virtual IMF::Slice slice () const = 0;
|
||||
|
||||
Image & image () {return _image;}
|
||||
const Image & image () const {return _image;}
|
||||
|
||||
private:
|
||||
|
||||
virtual void resize (int width, int height) = 0;
|
||||
|
||||
Image & _image;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class TypedImageChannel: public ImageChannel
|
||||
{
|
||||
public:
|
||||
|
||||
TypedImageChannel (Image &image, int width, int height);
|
||||
virtual ~TypedImageChannel ();
|
||||
|
||||
IMF::PixelType pixelType () const;
|
||||
|
||||
virtual IMF::Slice slice () const;
|
||||
|
||||
T & operator () (int x, int y);
|
||||
const T & operator () (int x, int y) const;
|
||||
|
||||
private:
|
||||
|
||||
virtual void resize (int width, int height);
|
||||
|
||||
IMF::Array2D<T> _pixels;
|
||||
};
|
||||
|
||||
|
||||
typedef TypedImageChannel<half> HalfChannel;
|
||||
typedef TypedImageChannel<float> FloatChannel;
|
||||
typedef TypedImageChannel<unsigned int> UIntChannel;
|
||||
|
||||
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
|
||||
Image ();
|
||||
Image (const IMATH_NAMESPACE::Box2i &dataWindow);
|
||||
~Image ();
|
||||
|
||||
const IMATH_NAMESPACE::Box2i & dataWindow () const;
|
||||
void resize (const IMATH_NAMESPACE::Box2i &dataWindow);
|
||||
|
||||
int width () const;
|
||||
int height () const;
|
||||
|
||||
void addChannel (const std::string &name,
|
||||
IMF::PixelType type);
|
||||
|
||||
ImageChannel & channel (const std::string &name);
|
||||
const ImageChannel & channel (const std::string &name) const;
|
||||
|
||||
template <class T>
|
||||
TypedImageChannel<T> & typedChannel (const std::string &name);
|
||||
|
||||
template <class T>
|
||||
const TypedImageChannel<T> & typedChannel (const std::string &name) const;
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map <std::string, ImageChannel *> ChannelMap;
|
||||
|
||||
IMATH_NAMESPACE::Box2i _dataWindow;
|
||||
ChannelMap _channels;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Implementation of templates and inline functions.
|
||||
//
|
||||
|
||||
template <class T>
|
||||
TypedImageChannel<T>::TypedImageChannel (Image &image, int width, int height):
|
||||
ImageChannel (image),
|
||||
_pixels (height, width)
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedImageChannel<T>::~TypedImageChannel ()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline OPENEXR_IMF_INTERNAL_NAMESPACE::PixelType
|
||||
HalfChannel::pixelType () const
|
||||
{
|
||||
return OPENEXR_IMF_INTERNAL_NAMESPACE::HALF;
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline OPENEXR_IMF_INTERNAL_NAMESPACE::PixelType
|
||||
FloatChannel::pixelType () const
|
||||
{
|
||||
return OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT;
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline OPENEXR_IMF_INTERNAL_NAMESPACE::PixelType
|
||||
UIntChannel::pixelType () const
|
||||
{
|
||||
return OPENEXR_IMF_INTERNAL_NAMESPACE::UINT;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
OPENEXR_IMF_INTERNAL_NAMESPACE::Slice
|
||||
TypedImageChannel<T>::slice () const
|
||||
{
|
||||
const IMATH_NAMESPACE::Box2i &dw = image().dataWindow();
|
||||
int w = dw.max.x - dw.min.x + 1;
|
||||
|
||||
return OPENEXR_IMF_INTERNAL_NAMESPACE::Slice (pixelType(),
|
||||
(char *) (&_pixels[0][0] - dw.min.y * w - dw.min.x),
|
||||
sizeof (T),
|
||||
w * sizeof (T));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline const T &
|
||||
TypedImageChannel<T>::operator () (int x, int y) const
|
||||
{
|
||||
return _pixels[y][x];
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T &
|
||||
TypedImageChannel<T>::operator () (int x, int y)
|
||||
{
|
||||
return _pixels[y][x];
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
TypedImageChannel<T>::resize (int width, int height)
|
||||
{
|
||||
_pixels.resizeEraseUnsafe (height, width);
|
||||
}
|
||||
|
||||
|
||||
inline const IMATH_NAMESPACE::Box2i &
|
||||
Image::dataWindow () const
|
||||
{
|
||||
return _dataWindow;
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
Image::width () const
|
||||
{
|
||||
return _dataWindow.max.x - _dataWindow.min.x + 1;
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
Image::height () const
|
||||
{
|
||||
return _dataWindow.max.y - _dataWindow.min.y + 1;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
TypedImageChannel<T> &
|
||||
Image::typedChannel (const std::string &name)
|
||||
{
|
||||
return dynamic_cast <TypedImageChannel<T>&> (channel (name));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
const TypedImageChannel<T> &
|
||||
Image::typedChannel (const std::string &name) const
|
||||
{
|
||||
return dynamic_cast <const TypedImageChannel<T>&> (channel (name));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
24
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/Makefile.am
Normal file
24
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/Makefile.am
Normal file
@@ -0,0 +1,24 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
bin_PROGRAMS = exrmaketiled
|
||||
|
||||
INCLUDES = -I$(top_builddir) \
|
||||
-I$(top_srcdir)/IlmImf -I$(top_srcdir)/config \
|
||||
@ILMBASE_CXXFLAGS@
|
||||
|
||||
LDADD = @ILMBASE_LDFLAGS@ @ILMBASE_LIBS@ \
|
||||
$(top_builddir)/IlmImf/libIlmImf.la \
|
||||
-lz
|
||||
|
||||
exrmaketiled_SOURCES = main.cpp \
|
||||
Image.h Image.cpp \
|
||||
makeTiled.cpp makeTiled.h \
|
||||
namespaceAlias.h
|
||||
|
||||
noinst_HEADERS = Image.h makeTiled.h
|
||||
|
||||
EXTRA_DIST = main.cpp \
|
||||
Image.h Image.cpp \
|
||||
makeTiled.cpp makeTiled.h \
|
||||
namespaceAlias.h \
|
||||
CMakeLists.txt
|
435
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/main.cpp
Normal file
435
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/main.cpp
Normal file
@@ -0,0 +1,435 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// exrmaketiled -- program that produces tiled
|
||||
// multiresolution versions of OpenEXR images.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "makeTiled.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "namespaceAlias.h"
|
||||
using namespace IMF;
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
usageMessage (const char argv0[], bool verbose = false)
|
||||
{
|
||||
cerr << "usage: " << argv0 << " [options] infile outfile" << endl;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
cerr << "\n"
|
||||
"Reads an OpenEXR image from infile, produces a tiled\n"
|
||||
"version of the image, and saves the result in outfile.\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
"\n"
|
||||
"-o produces a ONE_LEVEL image (default)\n"
|
||||
"\n"
|
||||
"-m produces a MIPMAP_LEVELS multiresolution image\n"
|
||||
"\n"
|
||||
"-r produces a RIPMAP_LEVELS multiresolution image\n"
|
||||
"\n"
|
||||
"-f c when a MIPMAP_LEVELS or RIPMAP_LEVELS image\n"
|
||||
" is produced, image channel c will be resampled\n"
|
||||
" without low-pass filtering. This option can\n"
|
||||
" be specified multiple times to disable low-pass\n"
|
||||
" filtering for mutiple channels.\n"
|
||||
"\n"
|
||||
"-e x y when a MIPMAP_LEVELS or RIPMAP_LEVELS image\n"
|
||||
" is produced, low-pass filtering takes samples\n"
|
||||
" outside the image's data window. This requires\n"
|
||||
" extrapolating the image. Option -e specifies\n"
|
||||
" how the image is extrapolated horizontally and\n"
|
||||
" vertically (black/clamp/periodic/mirror, default\n"
|
||||
" is clamp).\n"
|
||||
"\n"
|
||||
"-t x y sets the tile size in the output image to\n"
|
||||
" x by y pixels (default is 64 by 64)\n"
|
||||
"\n"
|
||||
"-d sets level size rounding to ROUND_DOWN (default)\n"
|
||||
"\n"
|
||||
"-u sets level size rounding to ROUND_UP\n"
|
||||
"\n"
|
||||
"-z x sets the data compression method to x\n"
|
||||
" (none/rle/zip/piz/pxr24/b44/b44a/dwaa/dwab,\n"
|
||||
" default is zip)\n"
|
||||
"\n"
|
||||
"-v verbose mode\n"
|
||||
"\n"
|
||||
"-h prints this message\n"
|
||||
"\n"
|
||||
"Multipart Options:\n"
|
||||
"\n"
|
||||
"-p i part number, default is 0\n";
|
||||
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
Compression
|
||||
getCompression (const string &str)
|
||||
{
|
||||
Compression c;
|
||||
|
||||
if (str == "no" || str == "none" || str == "NO" || str == "NONE")
|
||||
{
|
||||
c = NO_COMPRESSION;
|
||||
}
|
||||
else if (str == "rle" || str == "RLE")
|
||||
{
|
||||
c = RLE_COMPRESSION;
|
||||
}
|
||||
else if (str == "zip" || str == "ZIP")
|
||||
{
|
||||
c = ZIP_COMPRESSION;
|
||||
}
|
||||
else if (str == "piz" || str == "PIZ")
|
||||
{
|
||||
c = PIZ_COMPRESSION;
|
||||
}
|
||||
else if (str == "pxr24" || str == "PXR24")
|
||||
{
|
||||
c = PXR24_COMPRESSION;
|
||||
}
|
||||
else if (str == "b44" || str == "B44")
|
||||
{
|
||||
c = B44_COMPRESSION;
|
||||
}
|
||||
else if (str == "b44a" || str == "B44A")
|
||||
{
|
||||
c = B44A_COMPRESSION;
|
||||
}
|
||||
else if (str == "dwaa" || str == "DWAA")
|
||||
{
|
||||
c = DWAA_COMPRESSION;
|
||||
}
|
||||
else if (str == "dwab" || str == "DWAB")
|
||||
{
|
||||
c = DWAB_COMPRESSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Unknown compression method \"" << str << "\"." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
Extrapolation
|
||||
getExtrapolation (const string &str)
|
||||
{
|
||||
Extrapolation e;
|
||||
|
||||
if (str == "black" || str == "BLACK")
|
||||
{
|
||||
e = BLACK;
|
||||
}
|
||||
else if (str == "clamp" || str == "CLAMP")
|
||||
{
|
||||
e = CLAMP;
|
||||
}
|
||||
else if (str == "periodic" || str == "PERIODIC")
|
||||
{
|
||||
e = PERIODIC;
|
||||
}
|
||||
else if (str == "mirror" || str == "MIRROR")
|
||||
{
|
||||
e = MIRROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Unknown extrapolation method \"" << str << "\"." << endl;
|
||||
exit (1);
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
void
|
||||
getPartNum (int argc,
|
||||
char **argv,
|
||||
int &i,
|
||||
int *j)
|
||||
{
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
*j = strtol (argv[i + 1], 0, 0);
|
||||
cout << "part number: "<< *j << endl;
|
||||
i += 2;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char *inFile = 0;
|
||||
const char *outFile = 0;
|
||||
LevelMode mode = ONE_LEVEL;
|
||||
LevelRoundingMode roundingMode = ROUND_DOWN;
|
||||
Compression compression = ZIP_COMPRESSION;
|
||||
int tileSizeX = 64;
|
||||
int tileSizeY = 64;
|
||||
set<string> doNotFilter;
|
||||
Extrapolation extX = CLAMP;
|
||||
Extrapolation extY = CLAMP;
|
||||
bool verbose = false;
|
||||
|
||||
//
|
||||
// Parse the command line.
|
||||
//
|
||||
|
||||
if (argc < 2)
|
||||
usageMessage (argv[0], true);
|
||||
|
||||
int i = 1;
|
||||
int partnum = 0;
|
||||
|
||||
while (i < argc)
|
||||
{
|
||||
if (!strcmp (argv[i], "-o"))
|
||||
{
|
||||
//
|
||||
// generate a ONE_LEVEL image
|
||||
//
|
||||
|
||||
mode = ONE_LEVEL;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-m"))
|
||||
{
|
||||
//
|
||||
// Generate a MIPMAP_LEVELS image
|
||||
//
|
||||
|
||||
mode = MIPMAP_LEVELS;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-r"))
|
||||
{
|
||||
//
|
||||
// Generate a RIPMAP_LEVELS image
|
||||
//
|
||||
|
||||
mode = RIPMAP_LEVELS;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-f"))
|
||||
{
|
||||
//
|
||||
// Don't low-pass filter the specified image channel
|
||||
//
|
||||
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
doNotFilter.insert (argv[i + 1]);
|
||||
i += 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-e"))
|
||||
{
|
||||
//
|
||||
// Set x and y extrapolation method
|
||||
//
|
||||
|
||||
if (i > argc - 3)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
extX = getExtrapolation (argv[i + 1]);
|
||||
extY = getExtrapolation (argv[i + 2]);
|
||||
i += 3;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-t"))
|
||||
{
|
||||
//
|
||||
// Set tile size
|
||||
//
|
||||
|
||||
if (i > argc - 3)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
tileSizeX = strtol (argv[i + 1], 0, 0);
|
||||
tileSizeY = strtol (argv[i + 2], 0, 0);
|
||||
|
||||
if (tileSizeX <= 0 || tileSizeY <= 0)
|
||||
{
|
||||
cerr << "Tile size must be greater than zero." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
i += 3;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-d"))
|
||||
{
|
||||
//
|
||||
// Round down
|
||||
//
|
||||
|
||||
roundingMode = ROUND_DOWN;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-u"))
|
||||
{
|
||||
//
|
||||
// Round down
|
||||
//
|
||||
|
||||
roundingMode = ROUND_UP;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-z"))
|
||||
{
|
||||
//
|
||||
// Set compression method
|
||||
//
|
||||
|
||||
if (i > argc - 2)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
compression = getCompression (argv[i + 1]);
|
||||
i += 2;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-v"))
|
||||
{
|
||||
//
|
||||
// Verbose mode
|
||||
//
|
||||
|
||||
verbose = true;
|
||||
i += 1;
|
||||
}
|
||||
else if (!strcmp (argv[i], "-h"))
|
||||
{
|
||||
//
|
||||
// Print help message
|
||||
//
|
||||
|
||||
usageMessage (argv[0], true);
|
||||
}
|
||||
else if (!strcmp (argv[i], "-p"))
|
||||
{
|
||||
getPartNum (argc, argv, i, &partnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Image file name
|
||||
//
|
||||
|
||||
if (inFile == 0)
|
||||
inFile = argv[i];
|
||||
else
|
||||
outFile = argv[i];
|
||||
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (inFile == 0 || outFile == 0)
|
||||
usageMessage (argv[0]);
|
||||
|
||||
if (!strcmp (inFile, outFile))
|
||||
{
|
||||
cerr << "Input and output cannot be the same file." << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Load inFile, and save a tiled version in outFile.
|
||||
//
|
||||
|
||||
int exitStatus = 0;
|
||||
|
||||
//
|
||||
// check input
|
||||
//
|
||||
{
|
||||
MultiPartInputFile input (inFile);
|
||||
int parts = input.parts();
|
||||
|
||||
if (partnum < 0 || partnum >= parts){
|
||||
cerr << "ERROR: you asked for part " << partnum << " in " << inFile;
|
||||
cerr << ", which only has " << parts << " parts\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Header h = input.header (partnum);
|
||||
if (h.type() == DEEPTILE || h.type() == DEEPSCANLINE)
|
||||
{
|
||||
cerr << "Cannot make tile for deep data" << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
makeTiled (inFile, outFile, partnum,
|
||||
mode, roundingMode, compression,
|
||||
tileSizeX, tileSizeY,
|
||||
doNotFilter,
|
||||
extX, extY,
|
||||
verbose);
|
||||
}
|
||||
catch (const exception &e)
|
||||
{
|
||||
cerr << e.what() << endl;
|
||||
exitStatus = 1;
|
||||
}
|
||||
|
||||
return exitStatus;
|
||||
}
|
754
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/makeTiled.cpp
Normal file
754
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/makeTiled.cpp
Normal file
@@ -0,0 +1,754 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Produce a tiled version of an OpenEXR image.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "makeTiled.h"
|
||||
#include "Image.h"
|
||||
|
||||
#include "ImfTiledInputPart.h"
|
||||
#include "ImfTiledOutputPart.h"
|
||||
#include "ImfInputPart.h"
|
||||
#include "ImfOutputPart.h"
|
||||
#include "ImfDeepScanLineInputPart.h"
|
||||
#include "ImfDeepScanLineOutputPart.h"
|
||||
#include "ImfDeepTiledInputPart.h"
|
||||
#include "ImfDeepTiledOutputPart.h"
|
||||
#include "ImfChannelList.h"
|
||||
#include "ImfChannelList.h"
|
||||
#include "ImfFrameBuffer.h"
|
||||
#include "ImfStandardAttributes.h"
|
||||
#include "ImathFun.h"
|
||||
#include "Iex.h"
|
||||
#include "ImfMisc.h"
|
||||
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "namespaceAlias.h"
|
||||
using namespace IMF;
|
||||
using namespace IMATH_NAMESPACE;
|
||||
using namespace std;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
string
|
||||
extToString (Extrapolation ext)
|
||||
{
|
||||
string str;
|
||||
|
||||
switch (ext)
|
||||
{
|
||||
case BLACK:
|
||||
str = "black";
|
||||
break;
|
||||
|
||||
case CLAMP:
|
||||
str = "clamp";
|
||||
break;
|
||||
|
||||
case PERIODIC:
|
||||
str = "periodic";
|
||||
break;
|
||||
|
||||
case MIRROR:
|
||||
str = "mirror";
|
||||
break;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
mirror (int x, int w)
|
||||
{
|
||||
int d = divp (x, w);
|
||||
int m = modp (x, w);
|
||||
return (d & 1)? w - 1 - m: m;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
double
|
||||
sampleX (const TypedImageChannel<T> &channel,
|
||||
int w,
|
||||
double x,
|
||||
int y,
|
||||
Extrapolation ext)
|
||||
{
|
||||
//
|
||||
// Sample an image channel at location (x, y), where
|
||||
// x is a floating point number, and y is an integer.
|
||||
//
|
||||
|
||||
int xs = IMATH_NAMESPACE::floor (x);
|
||||
int xt = xs + 1;
|
||||
double s = xt - x;
|
||||
double t = 1 - s;
|
||||
double vs=0.0;
|
||||
double vt=0.0;
|
||||
|
||||
switch (ext)
|
||||
{
|
||||
case BLACK:
|
||||
|
||||
vs = (xs >= 0 && xs < w)? double (channel (xs, y)): 0.0;
|
||||
vt = (xt >= 0 && xt < w)? double (channel (xt, y)): 0.0;
|
||||
break;
|
||||
|
||||
case CLAMP:
|
||||
|
||||
xs = clamp (xs, 0, w - 1);
|
||||
xt = clamp (xt, 0, w - 1);
|
||||
vs = channel (xs, y);
|
||||
vt = channel (xt, y);
|
||||
break;
|
||||
|
||||
case PERIODIC:
|
||||
|
||||
xs = modp (xs, w);
|
||||
xt = modp (xt, w);
|
||||
vs = channel (xs, y);
|
||||
vt = channel (xt, y);
|
||||
break;
|
||||
|
||||
case MIRROR:
|
||||
|
||||
xs = mirror (xs, w);
|
||||
xt = mirror (xt, w);
|
||||
vs = channel (xs, y);
|
||||
vt = channel (xt, y);
|
||||
break;
|
||||
}
|
||||
|
||||
return s * vs + t * vt;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
double
|
||||
sampleY (const TypedImageChannel<T> &channel,
|
||||
int h,
|
||||
int x,
|
||||
double y,
|
||||
Extrapolation ext)
|
||||
{
|
||||
//
|
||||
// Sample an image channel at location (x, y), where
|
||||
// x is an integer, and y is a floating point number.
|
||||
//
|
||||
|
||||
int ys = IMATH_NAMESPACE::floor (y);
|
||||
int yt = ys + 1;
|
||||
double s = yt - y;
|
||||
double t = 1 - s;
|
||||
double vs=0.0;
|
||||
double vt=0.0;
|
||||
|
||||
switch (ext)
|
||||
{
|
||||
case BLACK:
|
||||
|
||||
vs = (ys >= 0 && ys < h)? double (channel (x, ys)): 0.0;
|
||||
vt = (yt >= 0 && yt < h)? double (channel (x, yt)): 0.0;
|
||||
break;
|
||||
|
||||
case CLAMP:
|
||||
|
||||
ys = clamp (ys, 0, h - 1);
|
||||
yt = clamp (yt, 0, h - 1);
|
||||
vs = channel (x, ys);
|
||||
vt = channel (x, yt);
|
||||
break;
|
||||
|
||||
case PERIODIC:
|
||||
|
||||
ys = modp (ys, h);
|
||||
yt = modp (yt, h);
|
||||
vs = channel (x, ys);
|
||||
vt = channel (x, yt);
|
||||
break;
|
||||
|
||||
case MIRROR:
|
||||
|
||||
ys = mirror (ys, h);
|
||||
yt = mirror (yt, h);
|
||||
vs = channel (x, ys);
|
||||
vt = channel (x, yt);
|
||||
break;
|
||||
}
|
||||
|
||||
return s * vs + t * vt;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T
|
||||
filterX (const TypedImageChannel<T> &channel,
|
||||
int w,
|
||||
double x,
|
||||
int y,
|
||||
Extrapolation ext)
|
||||
{
|
||||
//
|
||||
// Horizontal four-tap filter, centered on pixel (x + 0.5, y)
|
||||
//
|
||||
|
||||
return T (0.125 * sampleX (channel, w, x - 1, y, ext) +
|
||||
0.375 * sampleX (channel, w, x, y, ext) +
|
||||
0.375 * sampleX (channel, w, x + 1, y, ext) +
|
||||
0.125 * sampleX (channel, w, x + 2, y, ext));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
T
|
||||
filterY (const TypedImageChannel<T> &channel,
|
||||
int h,
|
||||
int x,
|
||||
double y,
|
||||
Extrapolation ext)
|
||||
{
|
||||
//
|
||||
// Vertical four-tap filter, centered on pixel (x, y + 0.5)
|
||||
//
|
||||
|
||||
return T (0.125 * sampleY (channel, h, x, y - 1, ext) +
|
||||
0.375 * sampleY (channel, h, x, y, ext) +
|
||||
0.375 * sampleY (channel, h, x, y + 1, ext) +
|
||||
0.125 * sampleY (channel, h, x, y + 2, ext));
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
reduceX (const TypedImageChannel<T> &channel0,
|
||||
TypedImageChannel<T> &channel1,
|
||||
bool filter,
|
||||
Extrapolation &ext,
|
||||
bool odd)
|
||||
{
|
||||
//
|
||||
// Shrink an image channel, channel0, horizontally
|
||||
// by a factor of 2, and store the result in channel1.
|
||||
//
|
||||
|
||||
int w0 = channel0.image().width();
|
||||
int w1 = channel1.image().width();
|
||||
int h1 = channel1.image().height();
|
||||
|
||||
if (filter)
|
||||
{
|
||||
//
|
||||
// Low-pass filter and resample.
|
||||
// For pixels (0, y) and (w1 - 1, y) in channel 1,
|
||||
// the low-pass filter in channel0 is centered on
|
||||
// pixels (0.5, y) and (w0 - 1.5, y) respectively.
|
||||
//
|
||||
|
||||
double f = (w1 > 1)? double (w0 - 2) / (w1 - 1): 1;
|
||||
|
||||
for (int y = 0; y < h1; ++y)
|
||||
for (int x = 0; x < w1; ++x)
|
||||
channel1 (x, y) = filterX (channel0, w0, x * f, y, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Resample, skipping every other pixel, without
|
||||
// low-pass filtering. In order to keep the image
|
||||
// from sliding to the right if the channel is
|
||||
// resampled repeatedly, we skip the rightmost
|
||||
// pixel of every row on even passes, and the
|
||||
// leftmost pixel on odd passes.
|
||||
//
|
||||
|
||||
int offset = odd? ((w0 - 1) - 2 * (w1 - 1)): 0;
|
||||
|
||||
for (int y = 0; y < h1; ++y)
|
||||
for (int x = 0; x < w1; ++x)
|
||||
channel1 (x, y) = channel0 (2 * x + offset, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
void
|
||||
reduceY (const TypedImageChannel<T> &channel0,
|
||||
TypedImageChannel<T> &channel1,
|
||||
bool filter,
|
||||
Extrapolation ext,
|
||||
bool odd)
|
||||
{
|
||||
//
|
||||
// Shrink an image channel, channel0, vertically
|
||||
// by a factor of 2, and store the result in channel1.
|
||||
//
|
||||
|
||||
int w1 = channel1.image().width();
|
||||
int h0 = channel0.image().height();
|
||||
int h1 = channel1.image().height();
|
||||
|
||||
if (filter)
|
||||
{
|
||||
//
|
||||
// Low-pass filter and resample.
|
||||
// For pixels (x, 0) and (x, h1 - 1) in channel 1,
|
||||
// the low-pass filter in channel0 is centered on
|
||||
// pixels (x, 0.5) and (x, h0 - 1.5) respectively.
|
||||
//
|
||||
|
||||
double f = (h1 > 1)? double (h0 - 2) / (h1 - 1): 1;
|
||||
|
||||
for (int y = 0; y < h1; ++y)
|
||||
for (int x = 0; x < w1; ++x)
|
||||
channel1 (x, y) = filterY (channel0, h0, x, y * f, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Resample, skipping every other pixel, without
|
||||
// low-pass filtering. In order to keep the image
|
||||
// from sliding towards the top if the channel is
|
||||
// resampled repeatedly, we skip the top pixel of
|
||||
// every column on even passes, and the bottom pixel
|
||||
// on odd passes.
|
||||
//
|
||||
|
||||
int offset = odd? ((h0 - 1) - 2 * (h1 - 1)): 0;
|
||||
|
||||
for (int y = 0; y < h1; ++y)
|
||||
for (int x = 0; x < w1; ++x)
|
||||
channel1 (x, y) = channel0 (x, 2 * y + offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
reduceX (const ChannelList &channels,
|
||||
const set<string> &doNotFilter,
|
||||
Extrapolation ext,
|
||||
bool odd,
|
||||
const Image &image0,
|
||||
Image &image1)
|
||||
{
|
||||
//
|
||||
// Shrink image image0 horizontally by a factor of 2,
|
||||
// and store the result in image image1.
|
||||
//
|
||||
|
||||
for (ChannelList::ConstIterator i = channels.begin();
|
||||
i != channels.end();
|
||||
++i)
|
||||
{
|
||||
const char *name = i.name();
|
||||
const Channel &channel = i.channel();
|
||||
bool filter = (doNotFilter.find (name) == doNotFilter.end());
|
||||
|
||||
switch (channel.type)
|
||||
{
|
||||
case IMF::HALF:
|
||||
|
||||
reduceX (image0.typedChannel<half> (name),
|
||||
image1.typedChannel<half> (name),
|
||||
filter, ext, odd);
|
||||
break;
|
||||
|
||||
case IMF::FLOAT:
|
||||
|
||||
reduceX (image0.typedChannel<float> (name),
|
||||
image1.typedChannel<float> (name),
|
||||
filter, ext, odd);
|
||||
break;
|
||||
|
||||
case IMF::UINT:
|
||||
|
||||
reduceX (image0.typedChannel<unsigned int> (name),
|
||||
image1.typedChannel<unsigned int> (name),
|
||||
filter, ext, odd);
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
reduceY (const ChannelList &channels,
|
||||
const set<string> &doNotFilter,
|
||||
Extrapolation ext,
|
||||
bool odd,
|
||||
const Image &image0,
|
||||
Image &image1)
|
||||
{
|
||||
//
|
||||
// Shrink image image0 vertically by a factor of 2,
|
||||
// and store the result in image image1.
|
||||
//
|
||||
|
||||
for (ChannelList::ConstIterator i = channels.begin();
|
||||
i != channels.end();
|
||||
++i)
|
||||
{
|
||||
const char *name = i.name();
|
||||
const Channel &channel = i.channel();
|
||||
bool filter = (doNotFilter.find (name) == doNotFilter.end());
|
||||
|
||||
switch (channel.type)
|
||||
{
|
||||
case IMF::HALF:
|
||||
|
||||
reduceY (image0.typedChannel<half> (name),
|
||||
image1.typedChannel<half> (name),
|
||||
filter, ext, odd);
|
||||
break;
|
||||
|
||||
case IMF::FLOAT:
|
||||
|
||||
reduceY (image0.typedChannel<float> (name),
|
||||
image1.typedChannel<float> (name),
|
||||
filter, ext, odd);
|
||||
break;
|
||||
|
||||
case IMF::UINT:
|
||||
|
||||
reduceY (image0.typedChannel<unsigned int> (name),
|
||||
image1.typedChannel<unsigned int> (name),
|
||||
filter, ext, odd);
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
storeLevel (TiledOutputPart &out,
|
||||
const ChannelList &channels,
|
||||
int lx,
|
||||
int ly,
|
||||
const Image &image)
|
||||
{
|
||||
//
|
||||
// Store the pixels for level (lx, ly) in output file out.
|
||||
//
|
||||
|
||||
FrameBuffer fb;
|
||||
|
||||
for (ChannelList::ConstIterator i = channels.begin();
|
||||
i != channels.end();
|
||||
++i)
|
||||
{
|
||||
const char *name = i.name();
|
||||
fb.insert (name, image.channel(name).slice());
|
||||
}
|
||||
|
||||
out.setFrameBuffer (fb);
|
||||
|
||||
for (int y = 0; y < out.numYTiles (ly); ++y)
|
||||
for (int x = 0; x < out.numXTiles (lx); ++x)
|
||||
out.writeTile (x, y, lx, ly);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void
|
||||
makeTiled (const char inFileName[],
|
||||
const char outFileName[],
|
||||
int partnum,
|
||||
LevelMode mode,
|
||||
LevelRoundingMode roundingMode,
|
||||
Compression compression,
|
||||
int tileSizeX,
|
||||
int tileSizeY,
|
||||
const set<string> &doNotFilter,
|
||||
Extrapolation extX,
|
||||
Extrapolation extY,
|
||||
bool verbose)
|
||||
{
|
||||
Image image0;
|
||||
Image image1;
|
||||
Image image2;
|
||||
Header header;
|
||||
FrameBuffer fb;
|
||||
vector<Header> headers;
|
||||
|
||||
//
|
||||
// Load the input image
|
||||
//
|
||||
|
||||
MultiPartInputFile input (inFileName);
|
||||
int parts = input.parts();
|
||||
|
||||
for (int p = 0 ; p < parts; p++)
|
||||
{
|
||||
if (verbose)
|
||||
cout << "reading file " << inFileName << endl;
|
||||
|
||||
if(p == partnum)
|
||||
{
|
||||
InputPart in (input, p);
|
||||
header = in.header();
|
||||
if (hasEnvmap (header) && mode != ONE_LEVEL)
|
||||
{
|
||||
//
|
||||
// Proper low-pass filtering and subsampling
|
||||
// of environment maps is not implemented in
|
||||
// this program.
|
||||
//
|
||||
|
||||
throw IEX_NAMESPACE::NoImplExc ("This program cannot generate "
|
||||
"multiresolution environment maps. "
|
||||
"Use exrenvmap instead.");
|
||||
}
|
||||
|
||||
image0.resize (header.dataWindow());
|
||||
|
||||
for (ChannelList::ConstIterator i = header.channels().begin();
|
||||
i != header.channels().end();
|
||||
++i)
|
||||
{
|
||||
const char *name = i.name();
|
||||
const Channel &channel = i.channel();
|
||||
|
||||
if (channel.xSampling != 1 || channel.ySampling != 1)
|
||||
{
|
||||
throw IEX_NAMESPACE::InputExc ("Sub-sampled image channels are "
|
||||
"not supported in tiled files.");
|
||||
}
|
||||
|
||||
image0.addChannel (name, channel.type);
|
||||
image1.addChannel (name, channel.type);
|
||||
image2.addChannel (name, channel.type);
|
||||
fb.insert (name, image0.channel(name).slice());
|
||||
}
|
||||
|
||||
in.setFrameBuffer (fb);
|
||||
in.readPixels (header.dataWindow().min.y, header.dataWindow().max.y);
|
||||
|
||||
|
||||
//
|
||||
// Generate the header for the output file by modifying
|
||||
// the input file's header
|
||||
//
|
||||
|
||||
header.setTileDescription (TileDescription (tileSizeX, tileSizeY,
|
||||
mode, roundingMode));
|
||||
|
||||
header.compression() = compression;
|
||||
header.lineOrder() = INCREASING_Y;
|
||||
|
||||
if (mode != ONE_LEVEL)
|
||||
addWrapmodes (header, extToString (extX) + "," + extToString (extY));
|
||||
|
||||
//
|
||||
// set tileDescription, type, and chunckcount for multipart
|
||||
//
|
||||
header.setType(TILEDIMAGE);
|
||||
int chunkcount = getChunkOffsetTableSize(header, true);
|
||||
header.setChunkCount(chunkcount);
|
||||
|
||||
headers.push_back(header);
|
||||
}
|
||||
else
|
||||
{
|
||||
Header h = input.header(p);
|
||||
headers.push_back(h);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Store the highest-resolution level of the image in the output file
|
||||
//
|
||||
|
||||
MultiPartOutputFile output (outFileName, &headers[0], headers.size());
|
||||
|
||||
for(int p = 0 ; p < parts; p++)
|
||||
{
|
||||
if (p == partnum)
|
||||
{
|
||||
try
|
||||
{
|
||||
TiledOutputPart out (output, partnum);
|
||||
// TiledOutputFile out (outFileName, header);
|
||||
|
||||
|
||||
out.setFrameBuffer (fb);
|
||||
|
||||
if (verbose)
|
||||
cout << "writing file " << outFileName << "\n"
|
||||
"level (0, 0)" << endl;
|
||||
|
||||
for (int y = 0; y < out.numYTiles (0); ++y)
|
||||
for (int x = 0; x < out.numXTiles (0); ++x)
|
||||
out.writeTile (x, y, 0);
|
||||
|
||||
//
|
||||
// If necessary, generate the lower-resolution mipmap
|
||||
// or ripmap levels, and store them in the output file.
|
||||
//
|
||||
|
||||
if (mode == MIPMAP_LEVELS)
|
||||
{
|
||||
for (int l = 1; l < out.numLevels(); ++l)
|
||||
{
|
||||
image1.resize (out.dataWindowForLevel (l, l - 1));
|
||||
|
||||
reduceX (header.channels(),
|
||||
doNotFilter,
|
||||
extX,
|
||||
l & 1,
|
||||
image0,
|
||||
image1);
|
||||
|
||||
image0.resize (out.dataWindowForLevel (l, l));
|
||||
|
||||
reduceY (header.channels(),
|
||||
doNotFilter,
|
||||
extY,
|
||||
l & 1,
|
||||
image1,
|
||||
image0);
|
||||
|
||||
if (verbose)
|
||||
cout << "level (" << l << ", " << l << ")" << endl;
|
||||
|
||||
storeLevel (out, header.channels(), l, l, image0);
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == RIPMAP_LEVELS)
|
||||
{
|
||||
Image *iptr0 = &image0;
|
||||
Image *iptr1 = &image1;
|
||||
Image *iptr2 = &image2;
|
||||
|
||||
for (int ly = 0; ly < out.numYLevels(); ++ly)
|
||||
{
|
||||
if (ly < out.numYLevels() - 1)
|
||||
{
|
||||
iptr2->resize (out.dataWindowForLevel (0, ly + 1));
|
||||
|
||||
reduceY (header.channels(),
|
||||
doNotFilter,
|
||||
extY,
|
||||
ly & 1,
|
||||
*iptr0,
|
||||
*iptr2);
|
||||
}
|
||||
|
||||
for (int lx = 0; lx < out.numXLevels(); ++lx)
|
||||
{
|
||||
if (lx != 0 || ly != 0)
|
||||
{
|
||||
if (verbose)
|
||||
cout << "level (" << lx << ", " << ly << ")" << endl;
|
||||
|
||||
storeLevel (out, header.channels(), lx, ly, *iptr0);
|
||||
}
|
||||
|
||||
if (lx < out.numXLevels() - 1)
|
||||
{
|
||||
iptr1->resize (out.dataWindowForLevel (lx + 1, ly));
|
||||
|
||||
reduceX (header.channels(),
|
||||
doNotFilter,
|
||||
extX,
|
||||
lx & 1,
|
||||
*iptr0,
|
||||
*iptr1);
|
||||
|
||||
swap (iptr0, iptr1);
|
||||
}
|
||||
}
|
||||
|
||||
swap (iptr2, iptr0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const exception &e)
|
||||
{
|
||||
cerr << e.what() << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Header header = headers[p];
|
||||
std::string type = header.type();
|
||||
if (type == TILEDIMAGE)
|
||||
{
|
||||
TiledInputPart in (input, p);
|
||||
TiledOutputPart out (output, p);
|
||||
out.copyPixels (in);
|
||||
}
|
||||
else if (type == SCANLINEIMAGE)
|
||||
{
|
||||
using std::max; InputPart in (input, p);
|
||||
OutputPart out (output, p);
|
||||
out.copyPixels (in);
|
||||
}
|
||||
else if (type == DEEPSCANLINE)
|
||||
{
|
||||
DeepScanLineInputPart in (input,p);
|
||||
DeepScanLineOutputPart out (output,p);
|
||||
out.copyPixels (in);
|
||||
}
|
||||
else if (type == DEEPTILE)
|
||||
{
|
||||
DeepTiledInputPart in (input,p);
|
||||
DeepTiledOutputPart out (output,p);
|
||||
out.copyPixels (in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
cout << "done." << endl;
|
||||
}
|
||||
|
80
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/makeTiled.h
Normal file
80
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/makeTiled.h
Normal file
@@ -0,0 +1,80 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef INCLUDED_MAKE_TILED_H
|
||||
#define INCLUDED_MAKE_TILED_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Produce a tiled version of an OpenEXR image.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <ImfPartType.h>
|
||||
#include <ImfMultiPartOutputFile.h>
|
||||
#include <ImfMultiPartInputFile.h>
|
||||
#include <ImfTileDescription.h>
|
||||
#include <ImfCompression.h>
|
||||
#include <OpenEXRConfig.h>
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include "namespaceAlias.h"
|
||||
|
||||
enum Extrapolation
|
||||
{
|
||||
BLACK,
|
||||
CLAMP,
|
||||
PERIODIC,
|
||||
MIRROR
|
||||
};
|
||||
|
||||
|
||||
void makeTiled (const char inFileName[],
|
||||
const char outFileName[],
|
||||
int partnum,
|
||||
IMF::LevelMode mode,
|
||||
IMF::LevelRoundingMode roundingMode,
|
||||
IMF::Compression compression,
|
||||
int tileSizeX,
|
||||
int tileSizeY,
|
||||
const std::set<std::string> &doNotFilter,
|
||||
Extrapolation extX,
|
||||
Extrapolation extY,
|
||||
bool verbose);
|
||||
|
||||
|
||||
#endif
|
45
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/namespaceAlias.h
Normal file
45
cs440-acg/ext/openexr/OpenEXR/exrmaketiled/namespaceAlias.h
Normal file
@@ -0,0 +1,45 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2012, Industrial Light & Magic, a division of Lucas
|
||||
// Digital Ltd. LLC
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Industrial Light & Magic nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
#ifndef NAMESPACEALIAS_H_
|
||||
#define NAMESPACEALIAS_H_
|
||||
|
||||
#include <ImfNamespace.h>
|
||||
#include <ImathNamespace.h>
|
||||
#include <IexNamespace.h>
|
||||
|
||||
namespace IMF = OPENEXR_IMF_NAMESPACE;
|
||||
namespace IMATH = IMATH_NAMESPACE;
|
||||
namespace IEX = IEX_NAMESPACE;
|
||||
|
||||
#endif /* NAMESPACEALIAS_H_ */
|
Reference in New Issue
Block a user