Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adsk Contrib - Add Built-in Transform and ociomakeclf app #1006

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6b70577
Adsk Contrib - Built-in Transforms
hodoulp Apr 29, 2020
43230fc
Fix MSVC build break
hodoulp Apr 29, 2020
a01daf0
Add Python bindings
hodoulp Apr 30, 2020
3ea6dc2
Fix a computation overflow
hodoulp Apr 30, 2020
c67902f
Fix a computation overflow, part II
hodoulp Apr 30, 2020
1cba010
Revert previous changes; Impose the right overflow
hodoulp Apr 30, 2020
e2cb95e
Fix Python bindings
hodoulp May 1, 2020
27b341e
Use CI builds to print values on all machines/compilers
hodoulp May 1, 2020
adcde73
Use CI builds to print values on all machines/compilers, disable the …
hodoulp May 1, 2020
8f633f1
Use CI builds to print values on all machines/compilers, remove some …
hodoulp May 1, 2020
db09611
Use CI builds to print values on all machines/compilers, remove some …
hodoulp May 1, 2020
34c7627
Use CI builds to print values on all machines/compilers, remove some …
hodoulp May 1, 2020
539efc1
Use CI builds to print values on all machines/compilers, remove some …
hodoulp May 1, 2020
7a73a8f
Use CI builds to print values on all machines/compilers, remove some …
hodoulp May 1, 2020
4f71e74
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
4f32162
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
76ec383
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
0aadea1
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
c3f3b77
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
94d79c3
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
00f8742
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
8ce095c
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
c304700
Try to bypass the AppleClang 11.0.3 bug
hodoulp May 1, 2020
60803f3
Merge branch 'master' into adsk_contrib/builtin_transform
hodoulp May 6, 2020
ca7fc6c
Merge branch 'master' into adsk_contrib/builtin_transform
hodoulp May 8, 2020
727fcd1
Warning when built-in camera transforms are not built
hodoulp May 10, 2020
8cace82
Improve the warning message
hodoulp May 11, 2020
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 @@ -111,6 +111,12 @@ endif()
option(OCIO_USE_SSE "Specify whether to enable SSE CPU performance optimizations" ON)
option(OCIO_INLINES_HIDDEN "Specify whether to build with -fvisibility-inlines-hidden" ${UNIX})

###############################################################################
# Supplemental builtins

# Add supplemental built-in transformations such as camera related one.
option(OCIO_ADD_EXTRA_BUILTINS "Specify whether to add supplemental built-in transforms" ON)
hodoulp marked this conversation as resolved.
Show resolved Hide resolved

###############################################################################
# Platform & Compiler dependent compilation flags

Expand Down
57 changes: 44 additions & 13 deletions include/OpenColorIO/OpenColorIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -1404,39 +1404,37 @@ class OCIOEXPORT Processor
const char * getCacheID() const;

//!cpp:function:: The ProcessorMetadata contains technical information
// such as the number of files and looks used in the processor.
// such as the number of files and looks used in the processor.
ConstProcessorMetadataRcPtr getProcessorMetadata() const;

//!cpp:function:: Get a FormatMetadata containing the top level metadata
// for the processor. For a processor from a CLF file,
// this corresponds to the ProcessList metadata.
// for the processor. For a processor from a CLF file, this corresponds to
// the ProcessList metadata.
const FormatMetadata & getFormatMetadata() const;

//!cpp:function:: Get the number of transforms that comprise the processor.
// Each transform has a (potentially empty) FormatMetadata.
// Each transform has a (potentially empty) FormatMetadata.
int getNumTransforms() const;
//!cpp:function:: Get a FormatMetadata containing the metadata for a
// transform within the processor. For a processor from
// a CLF file, this corresponds to the metadata associated
// with an individual process node.
// transform within the processor. For a processor from a CLF file, this
// corresponds to the metadata associated with an individual process node.
const FormatMetadata & getTransformFormatMetadata(int index) const;

//!cpp:function:: Return a cpp:class:`GroupTransform` that contains a
// copy of the transforms that comprise the processor.
// (Changes to it will not modify the original processor.)
// copy of the transforms that comprise the processor.
// (Changes to it will not modify the original processor.)
GroupTransformRcPtr createGroupTransform() const;

//!cpp:function:: Write the transforms comprising the processor to the stream.
// Writing (as opposed to Baking) is a lossless process.
// An exception is thrown if the processor cannot be
// losslessly written to the specified file format.
// Writing (as opposed to Baking) is a lossless process. An exception is thrown
// if the processor cannot be losslessly written to the specified file format.
void write(const char * formatName, std::ostream & os) const;

//!cpp:function:: Get the number of writers.
static int getNumWriteFormats();

//!cpp:function:: Get the writer at index, return empty string if
// an invalid index is specified.
// an invalid index is specified.
static const char * getFormatNameByIndex(int index);
static const char * getFormatExtensionByIndex(int index);

Expand Down Expand Up @@ -2555,6 +2553,39 @@ class OCIOEXPORT Context

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


///////////////////////////////////////////////////////////////////////////
//!rst::
// BuiltinTransformRegistry
// ************************
// The built-in transform registry contains all the existing built-in transforms which can
// be used by a configuration (version 2 or higher only).

//!cpp:class::
class OCIOEXPORT BuiltinTransformRegistry
{
public:
//!cpp:function:: Get the current built-in transform registry.
static ConstBuiltinTransformRegistryRcPtr Get() noexcept;

//!cpp:function:: Get the number of built-in transforms available.
virtual size_t getNumBuiltins() const noexcept = 0;
//!cpp:function:: Get the style string for the i-th built-in transform.
// The style is the ID string that identifies a given transform.
virtual const char * getBuiltinStyle(size_t index) const = 0;
//!cpp:function:: Get the description string for the i-th built-in transform.
virtual const char * getBuiltinDescription(size_t index) const = 0;

protected:
BuiltinTransformRegistry() = default;
virtual ~BuiltinTransformRegistry() = default;

private:
BuiltinTransformRegistry(const BuiltinTransformRegistry &) = delete;
BuiltinTransformRegistry & operator= (const BuiltinTransformRegistry &) = delete;
};


} // namespace OCIO_NAMESPACE

#endif // INCLUDED_OCIO_OPENCOLORIO_H
36 changes: 36 additions & 0 deletions include/OpenColorIO/OpenColorTransforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,42 @@ class OCIOEXPORT AllocationTransform : public Transform
extern OCIOEXPORT std::ostream& operator<< (std::ostream&, const AllocationTransform&);


//!rst:: //////////////////////////////////////////////////////////////////

//!cpp:class:: A built-in transform is similar to a FileTransform, but without the file.
// OCIO knows how to build a set of commonly used transforms on-demand, thus avoiding the need
// for external files and simplifying config authoring.
class OCIOEXPORT BuiltinTransform : public Transform
{
public:
//!cpp:function::
static BuiltinTransformRcPtr Create();

//!cpp:function::
virtual const char * getStyle() const noexcept = 0;
//!cpp:function:: Select an existing built-in transform style from the list accessible
// through :cpp:class:`BuiltinTransformRegistry`. The style is the ID string that identifies
// which transform to apply.
virtual void setStyle(const char * style) = 0;

//!cpp:function::
virtual const char * getDescription() const noexcept = 0;

//!cpp:function:: To never use i.e. only needed for the Python bindings with pybind11.
virtual ~BuiltinTransform() = default;

protected:
BuiltinTransform() = default;

private:
BuiltinTransform(const BuiltinTransform &) = delete;
BuiltinTransform & operator= (const BuiltinTransform &) = delete;
};

//!cpp:function::
extern OCIOEXPORT std::ostream & operator<<(std::ostream &, const BuiltinTransform &) noexcept;


//!rst:: //////////////////////////////////////////////////////////////////

//!cpp:class:: An implementation of the ASC Color Decision List (CDL), based on the ASC v1.2
Expand Down
12 changes: 12 additions & 0 deletions include/OpenColorIO/OpenColorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ typedef OCIO_SHARED_PTR<GpuShaderDesc> GpuShaderDescRcPtr;
//!cpp:type::
typedef OCIO_SHARED_PTR<const GpuShaderDesc> ConstGpuShaderDescRcPtr;

class OCIOEXPORT BuiltinTransformRegistry;
//!cpp:type::
typedef OCIO_SHARED_PTR<BuiltinTransformRegistry> BuiltinTransformRegistryRcPtr;
//!cpp:type::
typedef OCIO_SHARED_PTR<const BuiltinTransformRegistry> ConstBuiltinTransformRegistryRcPtr;


//!rst::
// Transforms
Expand All @@ -138,6 +144,12 @@ typedef OCIO_SHARED_PTR<const AllocationTransform> ConstAllocationTransformRcPtr
//!cpp:type::
typedef OCIO_SHARED_PTR<AllocationTransform> AllocationTransformRcPtr;

class OCIOEXPORT BuiltinTransform;
//!cpp:type::
typedef OCIO_SHARED_PTR<const BuiltinTransform> ConstBuiltinTransformRcPtr;
//!cpp:type::
typedef OCIO_SHARED_PTR<BuiltinTransform> BuiltinTransformRcPtr;

class OCIOEXPORT CDLTransform;
//!cpp:type::
typedef OCIO_SHARED_PTR<const CDLTransform> ConstCDLTransformRcPtr;
Expand Down
17 changes: 10 additions & 7 deletions src/OpenColorIO/Baker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ const char * Baker::getFormatExtensionByIndex(int index)

void Baker::setFormat(const char * formatName)
{
FileFormat* fmt = FormatRegistry::GetInstance().getFileFormatByName(formatName);
FormatInfoVec formatInfoVec;
fmt->getFormatInfo(formatInfoVec);
for(unsigned int i=0; i<formatInfoVec.size(); ++i)
FileFormat * fmt = FormatRegistry::GetInstance().getFileFormatByName(formatName);
if (fmt)
{
if(formatInfoVec[i].capabilities & FORMAT_CAPABILITY_BAKE)
FormatInfoVec formatInfoVec;
fmt->getFormatInfo(formatInfoVec);
for (unsigned int i = 0; i < formatInfoVec.size(); ++i)
{
getImpl()->m_formatName = formatName;
return;
if (formatInfoVec[i].capabilities & FORMAT_CAPABILITY_BAKE)
{
getImpl()->m_formatName = formatName;
return;
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions src/OpenColorIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ set(SOURCES
ScanlineHelper.cpp
Transform.cpp
transforms/AllocationTransform.cpp
transforms/builtins/ACES.cpp
transforms/builtins/BuiltinTransformRegistry.cpp
transforms/builtins/ColorMatrixHelpers.cpp
transforms/builtins/OpHelpers.cpp
transforms/BuiltinTransform.cpp
transforms/CDLTransform.cpp
transforms/ColorSpaceTransform.cpp
transforms/DisplayTransform.cpp
Expand All @@ -128,6 +133,18 @@ set(SOURCES
ViewTransform.cpp
)

if(OCIO_ADD_EXTRA_BUILTINS)
set(SOURCES_BUILTINS
transforms/builtins/ArriCameras.cpp
transforms/builtins/CanonCameras.cpp
transforms/builtins/PanasonicCameras.cpp
transforms/builtins/RedCameras.cpp
transforms/builtins/SonyCameras.cpp
)

list(INSERT SOURCES 0 ${SOURCES_BUILTINS})
endif()

if(WIN32 AND BUILD_SHARED_LIBS)

# Impose a versioned name on Windows to avoid binary name clashes
Expand Down Expand Up @@ -191,6 +208,13 @@ if(OCIO_USE_SSE)
)
endif()

if(OCIO_ADD_EXTRA_BUILTINS)
target_compile_definitions(OpenColorIO
PRIVATE
ADD_EXTRA_BUILTINS
)
endif()

if(MSVC AND BUILD_TYPE_DEBUG AND BUILD_SHARED_LIBS)
set_target_properties(OpenColorIO PROPERTIES
PDB_NAME ${PROJECT_NAME}_${LIBNAME_SUFFIX}
Expand Down
5 changes: 3 additions & 2 deletions src/OpenColorIO/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ const char * Context::resolveFileLocation(const char * filename) const
// Loop over each path, and try to find the file
std::ostringstream errortext;
errortext << "The specified file reference ";
errortext << " '" << filename << "' could not be located. ";
errortext << "'" << filename << "' could not be located. ";
errortext << "The following attempts were made: ";

for (unsigned int i = 0; i < searchpaths.size(); ++i)
Expand All @@ -368,8 +368,9 @@ const char * Context::resolveFileLocation(const char * filename) const
return getImpl()->m_resultsCache[filename].c_str();
}
if(i!=0) errortext << " : ";
errortext << expandedfullpath;
errortext << "'" << expandedfullpath << "'";
}
errortext << ".";

throw ExceptionMissingFile(errortext.str().c_str());
}
Expand Down
4 changes: 3 additions & 1 deletion src/OpenColorIO/MathUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.


#include <cmath>
#include <sstream>
#include <string.h>
#include <type_traits>
Expand Down Expand Up @@ -504,7 +506,7 @@ bool FloatsDiffer(const float expected, const float actual,
}
}

// TODO: Revisit the ULP comparison to use unsigned integers.
// TODO: Revisit the ULP comparison to only use unsigned integers.

// Comparing regular floats.
unsigned expectedBitsComp, actualBitsComp;
Expand Down
58 changes: 58 additions & 0 deletions src/OpenColorIO/OCIOYaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,55 @@ inline void save(YAML::Emitter& out, ConstAllocationTransformRcPtr t)
out << YAML::EndMap;
}

// BuiltinTransform

inline void load(const YAML::Node & node, BuiltinTransformRcPtr & t)
{
t = BuiltinTransform::Create();

std::string key;

for (const auto & iter : node)
{
const YAML::Node & first = iter.first;
const YAML::Node & second = iter.second;

load(first, key);

if (second.IsNull() || !second.IsDefined()) continue;

if (key == "style")
{
std::string transformStyle;
load(second, transformStyle);
t->setStyle(transformStyle.c_str());
}
else if (key == "direction")
{
TransformDirection dir = TRANSFORM_DIR_UNKNOWN;
load(second, dir);
t->setDirection(dir);
}
else
{
LogUnknownKeyWarning(node, first);
}
}
}

inline void save(YAML::Emitter & out, const ConstBuiltinTransformRcPtr & t)
{
out << YAML::VerbatimTag("BuiltinTransform");
out << YAML::Flow << YAML::BeginMap;

out << YAML::Key << "style";
out << YAML::Value << YAML::Flow << t->getStyle();

EmitBaseTransformKeyValues(out, t);

out << YAML::EndMap;
}

// CDLTransform

inline void load(const YAML::Node& node, CDLTransformRcPtr& t)
Expand Down Expand Up @@ -1922,6 +1971,12 @@ void load(const YAML::Node& node, TransformRcPtr& t)
load(node, temp);
t = temp;
}
else if(type == "BuiltinTransform")
{
BuiltinTransformRcPtr temp;
load(node, temp);
t = temp;
}
else if(type == "CDLTransform")
{
CDLTransformRcPtr temp;
Expand Down Expand Up @@ -2030,6 +2085,9 @@ void save(YAML::Emitter& out, ConstTransformRcPtr t)
if(ConstAllocationTransformRcPtr Allocation_tran = \
DynamicPtrCast<const AllocationTransform>(t))
save(out, Allocation_tran);
else if (ConstBuiltinTransformRcPtr builtin_tran = \
DynamicPtrCast<const BuiltinTransform>(t))
save(out, builtin_tran);
else if(ConstCDLTransformRcPtr CDL_tran = \
DynamicPtrCast<const CDLTransform>(t))
save(out, CDL_tran);
Expand Down
5 changes: 5 additions & 0 deletions src/OpenColorIO/OpBuilders.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ void BuildAllocationOp(OpRcPtrVec & ops,
const AllocationTransform & transform,
TransformDirection dir);

void BuildBuiltinOps(OpRcPtrVec & ops,
const Config & config,
const BuiltinTransform & transform,
TransformDirection dir);

void BuildCDLOp(OpRcPtrVec & ops,
const Config & config,
const CDLTransform & transform,
Expand Down
2 changes: 1 addition & 1 deletion src/OpenColorIO/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void Processor::Impl::write(const char * formatName, std::ostream & os) const
catch (std::exception & e)
{
std::ostringstream err;
err << "Error writing " << formatName << ":";
err << "Error writing format '" << formatName << "': ";
err << e.what();
throw Exception(err.str().c_str());
}
Expand Down
Loading