Skip to content

Commit

Permalink
Adsk Contrib - Improve heuristics for finding known color spaces (#1913)
Browse files Browse the repository at this point in the history
* Improve heuristics

Signed-off-by: Doug Walker <doug.walker@autodesk.com>

* Add some comments

Signed-off-by: Doug Walker <doug.walker@autodesk.com>

---------

Signed-off-by: Doug Walker <doug.walker@autodesk.com>
  • Loading branch information
doug-walker committed Dec 5, 2023
1 parent 41441bb commit d8852b5
Show file tree
Hide file tree
Showing 8 changed files with 4,475 additions and 56 deletions.
4 changes: 4 additions & 0 deletions include/OpenColorIO/OpenColorIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -2456,6 +2456,10 @@ class OCIOEXPORT Processor
*/
bool hasChannelCrosstalk() const;

/**
* Returns a hash string generated by hashing the cachedIDs of the (unoptimized) list of ops
* contained in the Processor. (This forms part of the key used by the config's processor cache.)
*/
const char * getCacheID() const;

/**
Expand Down
2 changes: 1 addition & 1 deletion include/OpenColorIO/OpenColorTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ extern OCIOEXPORT const char * OCIO_INACTIVE_COLORSPACES_ENVVAR;
* The envvar 'OCIO_OPTIMIZATION_FLAGS' provides a way to force a given optimization level.
* Remove the variable or set the value to empty to not use it. Set the value of the variable
* to the desired optimization level as either an integer or hexadecimal value.
* Ex: OCIO_OPTIMIZATION_FLAGS="20479" or "0x4FFF" for OPTIMIZATION_LOSSLESS.
* Ex: OCIO_OPTIMIZATION_FLAGS="144457667" or "0x89c3fc3" for OPTIMIZATION_LOSSLESS.
*/
extern OCIOEXPORT const char * OCIO_OPTIMIZATION_FLAGS_ENVVAR;

Expand Down
17 changes: 17 additions & 0 deletions src/OpenColorIO/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,23 @@ bool Config::isColorSpaceLinear(const char * colorSpace, ReferenceSpaceType refe
auto procToReference = config.getImpl()->getProcessorWithoutCaching(
config, t, TRANSFORM_DIR_FORWARD
);

// TODO: It could be useful to try and avoid evaluating points through ops that are
// expensive but highly unlikely to be linear (with inverse Lut3D being the prime example).
// There are some heuristics that are used in ConfigUtils.cpp that are intended to filter
// out color spaces from consideration before a processor is even calculated. However,
// those are not entirely appropriate here since one could imagine wanting to know if a
// color space involving a FileTransform (an ASC CDL being a good example) is linear.
// Likewise, one might want to know whether a color space involving a Look or ColorSpace
// Transform is linear (both of those are filtered out by the ConfigUtils heuristics).
// It seems like the right approach here is to go ahead and build the processor and
// thereby convert File/Look/ColorSpace Transforms into ops. But currently there is
// no method on the Processor class to know if it contains a Lut3D. There is the
// ProcessorMetadata files list, though that is not as precise. For example, it would
// not say if a CLF or CTF file contains a Lut3D or just a matrix. Probably the best
// solution would be to have each op sub-class provide an isLinear method and then
// surface that on the Processor class, iterating over each op in the Processor.

auto optCPUProc = procToReference->getOptimizedCPUProcessor(OPTIMIZATION_NONE);
optCPUProc->apply(desc, descDst);

Expand Down

0 comments on commit d8852b5

Please sign in to comment.