Skip to content

Adsk Contrib - Enhanced methods to find an equivalent color space between configs#1788

Merged
doug-walker merged 27 commits into
AcademySoftwareFoundation:mainfrom
autodesk-forks:adsk_contrib/getProcessorToBuiltinCS-enhancements
Jun 27, 2023
Merged

Adsk Contrib - Enhanced methods to find an equivalent color space between configs#1788
doug-walker merged 27 commits into
AcademySoftwareFoundation:mainfrom
autodesk-forks:adsk_contrib/getProcessorToBuiltinCS-enhancements

Conversation

@cedrik-fuoco-adsk
Copy link
Copy Markdown
Contributor

Adds several new methods to be used to identify a common color space between a pair of configs that may be used as an interchange space. If the official interchange roles are not present, heuristics are used to search for a suitable color space.

IdentifyBuiltinColorSpace -- Searches a user config to find the name of an equivalent color space to a color space in one of the Built-in configs. For example, "What is the name in this config for the sRGB - Texture color space from the default Built-in config?"

IdentifyInterchangeSpace -- Identifies the pair of color space names to be used as the interchange space to allow conversion between color spaces in a user config and one of the built-in configs. This is the fundamental function that contains the heuristics for trying to identify known color spaces and is used by IdentifyBuiltinColorSpace and in the GetProcessorFrom/ToBuiltinColorSpace methods added in PR #1710.

This improves upon and extends upon PR #1710. One piece of feedback on that PR is that it would be helpful to be able to use the heuristics to extract the names of the interchange color spaces rather than a Processor. This gives the application more flexibility in how that information is persisted and may reduce the number of times that any heuristics (that search through a config's color spaces) need to be run.

In addition, following up on the TODO mentioned in PR #1710, we refactored most of the heuristics code to move it out of the already crowded Config.cpp and into the new ConfigUtils.cpp module. The heuristics themselves were not significantly changed.

A lot of additional unit tests were added to test more scenarios involving the heuristics.

Finally, an issue was fixed in GetProcessorFromConfigs so that the returned Processor is a no-op if either of the color spaces in the two configs is a data space.

cedrik-fuoco-adsk and others added 10 commits December 23, 2022 13:24
…ce and AreProcessorsEquivalent.

- Remove some include of Processor.h where it wasn't needed.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…onfig.cpp instead.

Fixing identations issues.
Fixing styling issues.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Moving the creation of the editable config into the wrapper of isColorSpaceLinear instead of doing it inside the function.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…onfig and one for builtin.

Adding back isColorSpaceLinear inside Config.cpp since we need access to getProcessorWithoutCaching.
Refactor some of config utils function to return index instead of string.
Creating editable config in the two wrappers to prevent processor caching.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
// That should never happen.
return -1;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 1097-1504 were moved to ConfigUtils.cpp, without significant changes. This is the heuristics code and we wanted to move this out of Config.cpp, since this module is already so long and the heuristics are essentially their own somewhat self-contained set of functions.

Comment thread src/OpenColorIO/Config.cpp Outdated
getImpl()->setProcessorCacheFlags(flags);
}

//////////////////////////////////////////////////////////////////
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 4740-4835 is simply a cut/paste move from farther down in this module. This code is from another one of our recent PRs and we decided it belongs better in this location.

@remia
Copy link
Copy Markdown
Collaborator

remia commented May 2, 2023

Looks good to me, do we need Python bindings for the new methods?

cedrik-fuoco-adsk and others added 15 commits May 5, 2023 09:52
…pace methods.

Adding a couple python unit tests to cover the new methods (same unit test as the C++ side, but not all of them)

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…ce and AreProcessorsEquivalent.

- Remove some include of Processor.h where it wasn't needed.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…onfig.cpp instead.

Fixing identations issues.
Fixing styling issues.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Moving the creation of the editable config into the wrapper of isColorSpaceLinear instead of doing it inside the function.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…onfig and one for builtin.

Adding back isColorSpaceLinear inside Config.cpp since we need access to getProcessorWithoutCaching.
Refactor some of config utils function to return index instead of string.
Creating editable config in the two wrappers to prevent processor caching.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
…pace methods.

Adding a couple python unit tests to cover the new methods (same unit test as the C++ side, but not all of them)

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
…ments

Signed-off-by: Cédrik Fuoco <105517825+cedrik-fuoco-adsk@users.noreply.github.com>
Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Comment thread tests/python/ColorSpaceTest.py
@cedrik-fuoco-adsk
Copy link
Copy Markdown
Contributor Author

The failed workflow is expected as there was an issue with that workflow on the main branch. We merged the fix into the main branch yesterday.

@doug-walker
Copy link
Copy Markdown
Collaborator

Taking note here that I verified that this PR fixes a bug in GetProcessorFromBuiltinColorSpace reported by a user of OCIO 2.2.1. As a result, we will plan to include this branch in the upcoming 2.2.2 release rather than waiting for 2.3.

@doug-walker
Copy link
Copy Markdown
Collaborator

I'm going to go ahead and merge this since we need it for the config merge feature we're working on. The CI problem on macOS with docs=ON is unrelated to the code in this PR.

@doug-walker doug-walker merged commit 8e801dc into AcademySoftwareFoundation:main Jun 27, 2023
@doug-walker doug-walker deleted the adsk_contrib/getProcessorToBuiltinCS-enhancements branch June 27, 2023 21:44
doug-walker added a commit to autodesk-forks/OpenColorIO that referenced this pull request Dec 6, 2023
…ween configs (AcademySoftwareFoundation#1788)

* - Implementation of identifyInterchangeSpace, identifyBuiltinColorSpace and AreProcessorsEquivalent.
- Remove some include of Processor.h where it wasn't needed.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Moving code from Config.cpp to ConfigUtils.cpp and using wrapper in Config.cpp instead.
Fixing identations issues.
Fixing styling issues.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Typo and comments tweaks
Moving the creation of the editable config into the wrapper of isColorSpaceLinear instead of doing it inside the function.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Splitting identifyInterchangeSpace into two methods, one for source config and one for builtin.
Adding back isColorSpaceLinear inside Config.cpp since we need access to getProcessorWithoutCaching.
Refactor some of config utils function to return index instead of string.
Creating editable config in the two wrappers to prevent processor caching.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Tentative change to phase out isProcessorEquivalent.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Refactor code and add tests

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

* Remove unused method

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

* Remove unused method, tk 2

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

* Tweak comments

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

* Python binding for IdentifyInterchangeSpace and IdentifyBuiltinColorSpace methods.
Adding a couple python unit tests to cover the new methods (same unit test as the C++ side, but not all of them)

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* - Implementation of identifyInterchangeSpace, identifyBuiltinColorSpace and AreProcessorsEquivalent.
- Remove some include of Processor.h where it wasn't needed.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Moving code from Config.cpp to ConfigUtils.cpp and using wrapper in Config.cpp instead.
Fixing identations issues.
Fixing styling issues.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Typo and comments tweaks
Moving the creation of the editable config into the wrapper of isColorSpaceLinear instead of doing it inside the function.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Splitting identifyInterchangeSpace into two methods, one for source config and one for builtin.
Adding back isColorSpaceLinear inside Config.cpp since we need access to getProcessorWithoutCaching.
Refactor some of config utils function to return index instead of string.
Creating editable config in the two wrappers to prevent processor caching.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Tentative change to phase out isProcessorEquivalent.

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Refactor code and add tests

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

* Remove unused method

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

* Remove unused method, tk 2

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

* Tweak comments

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

* Python binding for IdentifyInterchangeSpace and IdentifyBuiltinColorSpace methods.
Adding a couple python unit tests to cover the new methods (same unit test as the C++ side, but not all of them)

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Fixing problem with the rebase

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

* Make sure the unit test is using the static method

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>

---------

Signed-off-by: Cédrik Fuoco <cedrik.fuoco@autodesk.com>
Signed-off-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Cédrik Fuoco <105517825+cedrik-fuoco-adsk@users.noreply.github.com>
Co-authored-by: Doug Walker <doug.walker@autodesk.com>
Signed-off-by: Doug Walker <Doug.Walker@autodesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants