Skip to content
Open
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ option(OCIO_BUILD_FROZEN_DOCS "Specify whether to build frozen documentation, ne
option(OCIO_BUILD_DOCS "Specify whether to build documentation" ${OCIO_BUILD_FROZEN_DOCS})

option(OCIO_BUILD_PYTHON "Specify whether to build python bindings" ON)

option(OCIO_LUT_SUPPORT "Specify wheter to build with LUT and file-transform support. Requies Expat dependency" ON)
option(OCIO_ARCHIVE_SUPPORT "Specify whether to build with OCIOZ archive support. Requires ZLIB dependency " ON)
option(OCIO_USE_HALF_LOOKUP_TABLE "Determines if the imath library should 64k LUT for half conversions." ON)
option(OCIO_HAS_STUDIO_CONFIG "If OFF, built-in studio config will be removed from the library." ON)

set (OCIO_PYTHON_VERSION "" CACHE STRING
"Preferred Python version (if any) in case multiple are available")

Expand Down
3 changes: 3 additions & 0 deletions include/OpenColorIO/OpenColorABI.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#define OCIO_VERSION_MAJOR @OpenColorIO_VERSION_MAJOR@
#define OCIO_VERSION_MINOR @OpenColorIO_VERSION_MINOR@

// Experimental switches to streamline OCIO library.
#cmakedefine01 OCIO_LUT_SUPPORT
#cmakedefine01 OCIO_ARCHIVE_SUPPORT

// Highlight deprecated methods or classes.
#if defined(_MSC_VER)
Expand Down
19 changes: 17 additions & 2 deletions include/OpenColorIO/OpenColorIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class OCIOEXPORT Exception : public std::runtime_error
Exception() = delete;
/// Constructor that takes a string as the exception message.
explicit Exception(const char *);
explicit Exception(const std::string&);
explicit Exception(const std::ostringstream&);
explicit Exception(const std::stringstream&);

/// Constructor that takes an existing exception.
Exception(const Exception &);
Exception & operator= (const Exception &) = delete;
Expand Down Expand Up @@ -228,6 +232,7 @@ extern OCIOEXPORT void SetCurrentConfig(const ConstConfigRcPtr & config);
*/
extern OCIOEXPORT const char * ResolveConfigPath(const char * originalPath) noexcept;

#if OCIO_ARCHIVE_SUPPORT
/**
* \brief Extract an OCIO Config archive.
*
Expand All @@ -247,6 +252,7 @@ extern OCIOEXPORT void ExtractOCIOZArchive(
const char * archivePath,
const char * destinationDir
);
#endif //OCIO_ARCHIVE_SUPPORT

/**
* \brief
Expand Down Expand Up @@ -1480,6 +1486,7 @@ class OCIOEXPORT Config
void setConfigIOProxy(ConfigIOProxyRcPtr ciop);
ConfigIOProxyRcPtr getConfigIOProxy() const;

#if OCIO_ARCHIVE_SUPPORT
/**
* \brief Verify if the config is archivable.
*
Expand Down Expand Up @@ -1530,6 +1537,7 @@ class OCIOEXPORT Config
* \param ostream The output stream to write to.
*/
void archive(std::ostream & ostream) const;
#endif //OCIO_ARCHIVE_SUPPORT

Config(const Config &) = delete;
Config& operator= (const Config &) = delete;
Expand Down Expand Up @@ -2041,7 +2049,7 @@ class OCIOEXPORT ColorSpace
* Specify the transform for the appropriate direction.
* Setting the transform to null will clear it.
*/
void setTransform(const ConstTransformRcPtr & transform, ColorSpaceDirection dir);
void setTransform(const ConstTransformRcPtr& transform, ColorSpaceDirection dir);

ColorSpace(const ColorSpace &) = delete;
ColorSpace& operator= (const ColorSpace &) = delete;
Expand Down Expand Up @@ -2761,7 +2769,7 @@ class OCIOEXPORT ProcessorMetadata
};



#if OCIO_LUT_SUPPORT
/**
* In certain situations it is necessary to serialize transforms into a variety
* of application specific LUT formats. Note that not all file formats that may
Expand Down Expand Up @@ -2893,6 +2901,7 @@ class OCIOEXPORT Baker
Impl * getImpl() { return m_impl; }
const Impl * getImpl() const { return m_impl; }
};
#endif //OCIO_LUT_SUPPORT


///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3206,13 +3215,15 @@ class OCIOEXPORT GpuShaderCreator
/// End to collect the shader data.
virtual void end();

#if OCIO_LUT_SUPPORT
/// Some graphic cards could have 1D & 2D textures with size limitations.
virtual void setTextureMaxWidth(unsigned maxWidth) = 0;
virtual unsigned getTextureMaxWidth() const noexcept = 0;

/// Allow 1D GPU resource type, otherwise always using 2D resources for 1D LUTs.
virtual void setAllowTexture1D(bool allowed) = 0;
virtual bool getAllowTexture1D() const = 0;
#endif //OCIO_LUT_SUPPORT

/**
* To avoid global texture sampler and uniform name clashes always append an increasing index
Expand Down Expand Up @@ -3264,6 +3275,7 @@ class OCIOEXPORT GpuShaderCreator
*/
DynamicPropertyRcPtr getDynamicProperty(DynamicPropertyType type) const;

#if OCIO_LUT_SUPPORT
enum TextureType
{
TEXTURE_RED_CHANNEL, ///< Only need a red channel texture
Expand Down Expand Up @@ -3306,6 +3318,7 @@ class OCIOEXPORT GpuShaderCreator
unsigned edgelen,
Interpolation interpolation,
const float * values) = 0;
#endif //OCIO_LUT_SUPPORT

// Methods to specialize parts of a OCIO shader program
virtual void addToDeclareShaderCode(const char * shaderCode);
Expand Down Expand Up @@ -3533,6 +3546,7 @@ class OCIOEXPORT GpuShaderDesc : public GpuShaderCreator
/// Returns name of uniform and data as parameter.
virtual const char * getUniform(unsigned index, UniformData & data) const = 0;

#if OCIO_LUT_SUPPORT
// 1D lut related methods
virtual unsigned getNumTextures() const noexcept = 0;
virtual void getTexture(unsigned index,
Expand All @@ -3553,6 +3567,7 @@ class OCIOEXPORT GpuShaderDesc : public GpuShaderCreator
unsigned & edgelen,
Interpolation & interpolation) const = 0;
virtual void get3DTextureValues(unsigned index, const float *& values) const = 0;
#endif //OCIO_LUT_SUPPORT

/// Get the complete OCIO shader program.
const char * getShaderText() const noexcept;
Expand Down
13 changes: 10 additions & 3 deletions include/OpenColorIO/OpenColorTransforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class OCIOEXPORT FormatMetadata
*/
virtual const char * getName() const noexcept = 0;
virtual void setName(const char * name) noexcept = 0;
virtual void setName(const std::string& name) noexcept = 0;

/**
* Convenience method to easily get/set the 'id' attribute. This corresponds to the
* ProcessNode id attribute from a CLF/CTF file or the ColorCorrection id attribute from a
Expand Down Expand Up @@ -141,6 +143,7 @@ class OCIOEXPORT Transform
Transform() = default;
};

// TODO: this operator can just call virtual print function, which will simplify things a lot. /coz 2024-04-16
extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Transform&);


Expand Down Expand Up @@ -226,7 +229,7 @@ class OCIOEXPORT BuiltinTransform : public Transform
//
extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const BuiltinTransform &) noexcept;


#if OCIO_LUT_SUPPORT
/**
* \brief
* An implementation of the ASC Color Decision List (CDL), based on the ASC v1.2
Expand Down Expand Up @@ -328,6 +331,7 @@ class OCIOEXPORT CDLTransform : public Transform
};

extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const CDLTransform &);
#endif //OCIO_LUT_SUPPORT


class OCIOEXPORT ColorSpaceTransform : public Transform
Expand Down Expand Up @@ -1022,7 +1026,7 @@ class OCIOEXPORT ExposureContrastTransform : public Transform
extern OCIOEXPORT std::ostream & operator<<(std::ostream &,
const ExposureContrastTransform &);


#if OCIO_LUT_SUPPORT
class OCIOEXPORT FileTransform : public Transform
{
public:
Expand Down Expand Up @@ -1095,6 +1099,7 @@ class OCIOEXPORT FileTransform : public Transform
};

extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const FileTransform &);
#endif //OCIO_LUT_SUPPORT


/**
Expand Down Expand Up @@ -1608,7 +1613,7 @@ class OCIOEXPORT LookTransform : public Transform

extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const LookTransform &);


#if OCIO_LUT_SUPPORT
/// Represents a 1D-LUT transform.
class OCIOEXPORT Lut1DTransform : public Transform
{
Expand Down Expand Up @@ -1785,6 +1790,8 @@ class OCIOEXPORT Lut3DTransform : public Transform
};

extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const Lut3DTransform&);
#endif //OCIO_LUT_SUPPORT


/**
* Represents an MX+B Matrix transform.
Expand Down
4 changes: 4 additions & 0 deletions include/OpenColorIO/OpenColorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ class OCIOEXPORT ExposureContrastTransform;
typedef OCIO_SHARED_PTR<const ExposureContrastTransform> ConstExposureContrastTransformRcPtr;
typedef OCIO_SHARED_PTR<ExposureContrastTransform> ExposureContrastTransformRcPtr;

#if OCIO_LUT_SUPPORT
class OCIOEXPORT FileTransform;
typedef OCIO_SHARED_PTR<const FileTransform> ConstFileTransformRcPtr;
typedef OCIO_SHARED_PTR<FileTransform> FileTransformRcPtr;
#endif //OCIO_LUT_SUPPORT

class OCIOEXPORT FixedFunctionTransform;
typedef OCIO_SHARED_PTR<const FixedFunctionTransform> ConstFixedFunctionTransformRcPtr;
Expand Down Expand Up @@ -219,13 +221,15 @@ class OCIOEXPORT LogTransform;
typedef OCIO_SHARED_PTR<const LogTransform> ConstLogTransformRcPtr;
typedef OCIO_SHARED_PTR<LogTransform> LogTransformRcPtr;

#if OCIO_LUT_SUPPORT
class OCIOEXPORT Lut1DTransform;
typedef OCIO_SHARED_PTR<const Lut1DTransform> ConstLut1DTransformRcPtr;
typedef OCIO_SHARED_PTR<Lut1DTransform> Lut1DTransformRcPtr;

class OCIOEXPORT Lut3DTransform;
typedef OCIO_SHARED_PTR<const Lut3DTransform> ConstLut3DTransformRcPtr;
typedef OCIO_SHARED_PTR<Lut3DTransform> Lut3DTransformRcPtr;
#endif //OCIO_LUT_SUPPORT

class OCIOEXPORT MatrixTransform;
typedef OCIO_SHARED_PTR<const MatrixTransform> ConstMatrixTransformRcPtr;
Expand Down
26 changes: 14 additions & 12 deletions src/OpenColorIO/Baker.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.
#include <OpenColorIO/OpenColorIO.h>
#if OCIO_LUT_SUPPORT


#include <iostream>

#include <OpenColorIO/OpenColorIO.h>

#include "transforms/FileTransform.h"
#include "BakingUtils.h"
Expand Down Expand Up @@ -135,7 +136,7 @@ void Baker::setFormat(const char * formatName)
std::ostringstream os;
os << "File format " << formatName;
os << " does not support baking.";
throw Exception(os.str().c_str());
throw Exception(os);
}

const char * Baker::getFormat() const
Expand Down Expand Up @@ -243,7 +244,7 @@ void Baker::bake(std::ostream & os) const
std::ostringstream err;
err << "The format named '" << getImpl()->m_formatName;
err << "' could not be found. ";
throw Exception(err.str().c_str());
throw Exception(err);
}

FormatInfoVec fmtInfoVec;
Expand Down Expand Up @@ -284,14 +285,14 @@ void Baker::bake(std::ostream & os) const
{
std::ostringstream os;
os << "Could not find input colorspace '" << inputSpace << "'.";
throw Exception(os.str().c_str());
throw Exception(os);
}

if(colorSpaceMode && !getConfig()->getColorSpace(targetSpace.c_str()))
{
std::ostringstream os;
os << "Could not find target colorspace '" << targetSpace << "'.";
throw Exception(os.str().c_str());
throw Exception(os);
}

if(displayViewMode)
Expand Down Expand Up @@ -332,13 +333,13 @@ void Baker::bake(std::ostream & os) const
{
std::ostringstream os;
os << "Could not find display '" << display << "'.";
throw Exception(os.str().c_str());
throw Exception(os);
}
else if (!foundView)
{
std::ostringstream os;
os << "Could not find view '" << view << "'.";
throw Exception(os.str().c_str());
throw Exception(os);
}
}

Expand All @@ -348,7 +349,7 @@ void Baker::bake(std::ostream & os) const
std::ostringstream os;
os << "The format '" << getImpl()->m_formatName << "' does not support";
os << " transformations with channel crosstalk.";
throw Exception(os.str().c_str());
throw Exception(os);
}

if(getCubeSize() != -1 && getCubeSize() < 2)
Expand All @@ -363,15 +364,15 @@ void Baker::bake(std::ostream & os) const
{
std::ostringstream os;
os << "The format '" << getImpl()->m_formatName << "' does not support shaper space.";
throw Exception(os.str().c_str());
throw Exception(os);
}

if(!shaperSpace.empty() && getShaperSize() != -1 && getShaperSize() < 2)
{
std::ostringstream os;
os << "A shaper space '" << getShaperSpace() << "' has";
os << " been specified, so the shaper size must be 2 or larger.";
throw Exception(os.str().c_str());
throw Exception(os);
}

if(!shaperSpace.empty())
Expand All @@ -386,7 +387,7 @@ void Baker::bake(std::ostream & os) const
os << "' has channel crosstalk, which is not appropriate for";
os << " shapers. Please select an alternate shaper space or";
os << " omit this option.";
throw Exception(os.str().c_str());
throw Exception(os);
}
}

Expand All @@ -399,7 +400,7 @@ void Baker::bake(std::ostream & os) const
std::ostringstream err;
err << "Error baking " << getImpl()->m_formatName << ":";
err << e.what();
throw Exception(err.str().c_str());
throw Exception(err);
}

//
Expand All @@ -414,3 +415,4 @@ void Baker::bake(std::ostream & os) const
}

} // namespace OCIO_NAMESPACE
#endif //OCIO_LUT_SUPPORT
3 changes: 3 additions & 0 deletions src/OpenColorIO/BakingUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "BakingUtils.h"

#if OCIO_LUT_SUPPORT

namespace OCIO_NAMESPACE
{

Expand Down Expand Up @@ -131,3 +133,4 @@ void GetTargetRange(const Baker & baker, float& start, float& end)
}

} // namespace OCIO_NAMESPACE
#endif //OCIO_LUT_SUPPORT
6 changes: 3 additions & 3 deletions src/OpenColorIO/BitDepthUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ double GetBitDepthMaxValue(BitDepth in)
std::string err(errBDNotSupported);
err += BitDepthToString(in);
err += ".";
throw Exception(err.c_str());
throw Exception(err);
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ bool IsFloatBitDepth(BitDepth in)
std::string err(errBDNotSupported);
err += BitDepthToString(in);
err += ".";
throw Exception(err.c_str());
throw Exception(err);
}
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ unsigned GetChannelSizeInBytes(BitDepth in)
std::string err(errBDNotSupported);
err += BitDepthToString(in);
err += ".";
throw Exception(err.c_str());
throw Exception(err);
}
}
}
Expand Down
Loading