Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 6 additions & 62 deletions site/spi/Makefile-bits-spcomp2
Original file line number Diff line number Diff line change
Expand Up @@ -17,82 +17,26 @@ $(info Including spi/Makefile-bits-spcomp2)
# release versions on the svn server.
#

OPENIMAGEIO_SPCOMP2_VERSION=29
OPENIMAGEIO_SPCOMP2_VERSION=30

# Default namespace
NAMESPACE ?= 'OpenImageIO_SPI'
SOVERSION ?= ${OPENIMAGEIO_SPCOMP2_VERSION}
SPCOMP2_RPATH ?= ""

## Spinux (current)
ifeq ($(SP_ARCH), spinux1_x86_64)
platform=spinux1
COMPILER=gcc44m64
FIELD3D_HOME="/shots/spi/home/lib/SpComp2/Field3D/spinux1-gcc44m64/v116"
SPCOMP2_RPATH=$(FIELD3D_HOME)/lib
MY_CMAKE_FLAGS += \
-DOPENGL_gl_LIBRARY=/usr/lib64/xorg.nvidia.3d/libGL.so \
-DILMBASE_CUSTOM=1 \
-DILMBASE_CUSTOM_LIBRARIES="SpiImath SpiHalf SpiIlmThread SpiIex" \
-DOPENEXR_CUSTOM=1 \
-DOPENEXR_CUSTOM_LIBRARY="SpiIlmImf" \
-DHDF5_CUSTOM=1 \
-DHDF5_INCLUDE_DIRS=/usr/include \
-DHDF5_LIBRARIES=/usr/lib64/libhdf5.so \
-DFIELD3D_HOME=$(FIELD3D_HOME)
-DILMBASE_CUSTOM=1 \
-DILMBASE_CUSTOM_LIBRARIES="SpiImath SpiHalf SpiIlmThread SpiIex" \
-DOPENEXR_CUSTOM=1 \
-DOPENEXR_CUSTOM_LIBRARY="SpiIlmImf"
endif # endif spinux1_x86_64


## CentOS (deprecated)
ifeq (${SP_ARCH}, rhel40_x86_64)
platform=rhel40m64
# used by spcomp2 installer
COMPILER=gcc34m64
OPENEXR_VERSION=1.4.0
BOOST_VERSION=1_34_1
Boost_VERSION="103401"
QTDIR=/usr/local64/qt-4.4
Boost_LIBRARIES="-lboost_filesystem-gcc34-mt-${BOOST_VERSION} -lboost_regex-gcc34-mt-${BOOST_VERSION} -lboost_thread-gcc34-mt-${BOOST_VERSION} "
SPCOMP2_RPATH=/usr/local64/lib/boost-${BOOST_VERSION}:/usr/local64/openexr/${OPENEXR_VERSION}/lib64
MY_CMAKE_FLAGS += \
-DSPECIAL_COMPILE_FLAGS="-include ${working_dir}/site/spi/include/spi_ns.h -include ${working_dir}/site/spi/include/tiff.h -DTIFF_OLD_VERSION" \
-DBOOST_CUSTOM=1 \
-DBoost_INCLUDE_DIRS=/usr/local64/include/boost-${BOOST_VERSION} \
-DBoost_LIBRARY_DIRS=/usr/local64/lib/boost-${BOOST_VERSION} \
-DBoost_LIBRARIES=$(Boost_LIBRARIES) \
-DBoost_VERSION=$(Boost_VERSION) \
-DILMBASE_HOME=/usr/local64/openexr/${OPENEXR_VERSION} \
-DILMBASE_INCLUDE_DIR=/usr/local64/openexr/${OPENEXR_VERSION}/include \
-DOPENEXR_VERSION=${OPENEXR_VERSION} \
-DOPENEXR_VERSION_DIGITS="010400" \
-DOPENEXR_HOME=/usr/local64/openexr/${OPENEXR_VERSION} \
-DQT_SEARCH_PATH=${QTDIR} \
-DQT_QMAKE_EXECUTABLE=${QTDIR}/bin/qmake

ifeq (${USE_PYTHON},1)
PYTHON_VERSION ?= 2.5

ifeq (${PYTHON_VERSION},2.5)
PYTHONLIB=/usr/local64/lib/libspi-python2.5.so
Boost_Python_LIBRARIES="-L/net/apps/rhel40m64/boost/1_34_1/gcc34/lib/python25 -Wl,-rpath,/net/apps/rhel40m64/boost/1_34_1/gcc34/lib/python25 -lboost_python-gcc34-mt-${BOOST_VERSION}"
else
PYTHONLIB=/usr/local64/lib/libpython${PYTHON_VERSION}.so
Boost_Python_LIBRARIES="-lboost_python-gcc34-mt-${BOOST_VERSION}"
endif

Boost_FOUND=TRUE
MY_CMAKE_FLAGS += \
-DQT_DIR=/usr/local \
-DBoost_Python_LIBRARIES=${Boost_Python_LIBRARIES} \
-DPYTHON_INCLUDE_PATH=/usr/local64/include/python${PYTHON_VERSION} \
-DPYTHON_LIBRARIES=${PYTHONLIB} \
-DPYTHONLIBS_FOUND=1

endif

endif # endif rhel40_x86_64



all: dist

.PHONY: spcomp2_install spcomp2_install_local clean all
Expand Down
6 changes: 6 additions & 0 deletions src/include/imagebufalgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ bool DLLPUBLIC isMonochrome(const ImageBuf &src);
/// (current subimage, and current mipmap level)
std::string DLLPUBLIC computePixelHashSHA1(const ImageBuf &src);

/// Compute the sha1 byte hash for all the pixels in the image.
/// (current subimage, and current mipmap level)
std::string DLLPUBLIC computePixelHashSHA1(const ImageBuf &src,
const std::string & extrainfo);



/// Set dst, over the pixel range [xbegin,xend) x [ybegin,yend), to be a
/// resized version of src (mapping such that the "full" image window of
Expand Down
16 changes: 15 additions & 1 deletion src/libOpenImageIO/imagebufalgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,14 @@ ImageBufAlgo::isMonochrome(const ImageBuf &src)
};

std::string
ImageBufAlgo::computePixelHashSHA1(const ImageBuf &src)
ImageBufAlgo::computePixelHashSHA1(const ImageBuf &src,
const std::string & extrainfo)
{
std::string hash_digest;

CSHA1 sha;
sha.Reset ();

// Do one scanline at a time, to keep to < 2^32 bytes each
imagesize_t scanline_bytes = src.spec().scanline_bytes();
ASSERT (scanline_bytes < std::numeric_limits<unsigned int>::max());
Expand All @@ -665,12 +667,24 @@ ImageBufAlgo::computePixelHashSHA1(const ImageBuf &src)
src.spec().format, &tmp[0]);
sha.Update (&tmp[0], (unsigned int) scanline_bytes);
}

// If extra info is specified, also include it in the sha computation
if(!extrainfo.empty()) {
sha.Update ((const unsigned char*) extrainfo.c_str(), extrainfo.size());
}

sha.Final ();
sha.ReportHashStl (hash_digest, CSHA1::REPORT_HEX_SHORT);

return hash_digest;
}

std::string
ImageBufAlgo::computePixelHashSHA1(const ImageBuf &src)
{
return computePixelHashSHA1 (src, "");
}



namespace { // anonymous namespace
Expand Down
127 changes: 70 additions & 57 deletions src/maketx/maketx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static bool noresize = true;
static Imath::M44f Mcam(0.0f), Mscr(0.0f); // Initialize to 0
static bool separate = false;
static bool nomipmap = false;
static bool embed_hash = false;
static bool embed_hash = false; // Ignored.
static bool prman_metadata = false;
static bool constant_color_detect = false;
static bool monochrome_detect = false;
Expand Down Expand Up @@ -247,7 +247,11 @@ getargs (int argc, char *argv[])
std::cerr << "maketx ERROR: could not make filter '" << filtername << "\n";
exit (EXIT_FAILURE);
}

if (embed_hash && verbose) {
std::cerr << "maketx WARNING: The --embed_hash option is deprecated, and no longer necessary.\n";
std::cerr << " (Hashes are always computed.)\n";
}

// std::cout << "Converting " << filenames[0] << " to " << outputfilename << "\n";
}

Expand Down Expand Up @@ -305,9 +309,6 @@ set_oiio_options(TypeDesc out_dataformat)
// Enable constant color optimizations
constant_color_detect = true;

// Always embed the image hash info
embed_hash = true;

// Force fixed tile-size across the board
tile[0] = 64;
tile[1] = 64;
Expand Down Expand Up @@ -629,11 +630,10 @@ make_texturemap (const char *maptypename = "texture map")
stat_readtime += readtimer();

// If requested - and we're a constant color - make a tiny texture instead
// FIXME: Add the appropriate metadata to also advertise this fact.
std::vector<float> constantColor(src.nchannels());
bool isConstantColor = (constant_color_detect && ImageBufAlgo::isConstantColor (src, &constantColor[0]));
bool isConstantColor = ImageBufAlgo::isConstantColor (src, &constantColor[0]);

if (isConstantColor) {
if (isConstantColor && constant_color_detect) {
int newwidth = std::max (1, std::min (src.spec().width, tile[0]));
int newheight = std::max (1, std::min (src.spec().height, tile[1]));

Expand Down Expand Up @@ -683,13 +683,6 @@ make_texturemap (const char *maptypename = "texture map")
}
}

std::string hash_digest;
if (embed_hash) {
hash_digest = ImageBufAlgo::computePixelHashSHA1 (src);
if (verbose)
std::cout << " SHA-1: " << hash_digest << std::endl;
}

if (shadowmode) {
// Some special checks for shadow maps
if (src.spec().nchannels != 1) {
Expand Down Expand Up @@ -749,48 +742,6 @@ make_texturemap (const char *maptypename = "texture map")

dstspec.attribute ("Software", full_command_line);

// Update the ImageDescription
std::string desc = dstspec.get_string_attribute ("ImageDescription");
bool updatedDesc = false;

// FIXME: We need to do real dictionary style partial updates on the
// ImageDescription. I.e., set one key without affecting the
// other keys. But in the meantime, just clear it out if
// it appears the incoming image was a maketx style texture.

if ((desc.find("SHA-1=") != std::string::npos) ||
(desc.find("ConstantColor=") != std::string::npos)) {
desc = "";
}

if (hash_digest.length()) {
if (desc.length())
desc += " ";
desc += "SHA-1=";
desc += hash_digest;
updatedDesc = true;
}

if (isConstantColor) {
std::ostringstream os; // Emulate a JSON array
os << "[";
for(unsigned int i=0; i<constantColor.size(); ++i) {
if (i!=0) os << ",";
os << constantColor[i];
}
os << "]";

if (desc.length())
desc += " ";
desc += "ConstantColor=";
desc += os.str();
updatedDesc = true;
}

if (updatedDesc) {
dstspec.attribute ("ImageDescription", desc);
}

if (shadowmode) {
dstspec.attribute ("textureformat", "Shadow");
if (prman_metadata)
Expand Down Expand Up @@ -907,6 +858,68 @@ make_texturemap (const char *maptypename = "texture map")
}
stat_resizetime += resizetimer();


// Update the toplevel ImageDescription with the sha1 pixel hash and constant color
std::string desc = dstspec.get_string_attribute ("ImageDescription");
bool updatedDesc = false;

// FIXME: We need to do real dictionary style partial updates on the
// ImageDescription. I.e., set one key without affecting the
// other keys. But in the meantime, just clear it out if
// it appears the incoming image was a maketx style texture.

if ((desc.find ("SHA-1=") != std::string::npos) ||
(desc.find ("ConstantColor=") != std::string::npos)) {
desc = "";
}


// The hash is only computed for the top mipmap level of pixel data.
// Thus, any additional information that will effect the lower levels
// (such as filtering information) needs to be manually added into the
// hash.
std::ostringstream addlHashData;
addlHashData << filtername << " ";
addlHashData << filterwidth << " ";

std::string hash_digest = ImageBufAlgo::computePixelHashSHA1 (*toplevel,
addlHashData.str());
if (hash_digest.length()) {
if (desc.length())
desc += " ";
desc += "SHA-1=";
desc += hash_digest;
if (verbose)
std::cout << " SHA-1: " << hash_digest << std::endl;
updatedDesc = true;
}

if (isConstantColor) {
std::ostringstream os; // Emulate a JSON array
os << "[";
for (unsigned int i=0; i<constantColor.size(); ++i) {
if (i!=0) os << ",";
os << constantColor[i];
}
os << "]";

if (desc.length())
desc += " ";
desc += "ConstantColor=";
desc += os.str();
if (verbose)
std::cout << " ConstantColor: " << os.str() << std::endl;
updatedDesc = true;
}

if (updatedDesc) {
dstspec.attribute ("ImageDescription", desc);
}



// Write out, and compute, the mipmap levels for the speicifed image

std::string outformat = fileformatname.empty() ? outputfilename : fileformatname;
write_mipmap (*toplevel, dstspec, outputfilename, outformat, out_dataformat,
!shadowmode && !nomipmap);
Expand Down