From f3067c317a1cf303871468ba8d8b54b841b487e1 Mon Sep 17 00:00:00 2001 From: Eric Renaud-Houde Date: Wed, 1 Nov 2023 12:48:31 -0400 Subject: [PATCH 1/2] Skip processor concatenation if the display view transform is also data. Signed-off-by: Eric Renaud-Houde --- src/OpenColorIO/Config.cpp | 15 ++++++++++++--- tests/cpu/Config_tests.cpp | 8 ++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index a17d1dc288..0557ae9544 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -4723,16 +4723,25 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr if (!p2) { throw Exception("Can't create the processor for the destination config " - "and the destination color space."); + "and the destination display view transform."); } ProcessorRcPtr processor = Processor::Create(); processor->getImpl()->setProcessorCacheFlags(srcConfig->getImpl()->m_cacheFlags); - // If the source color spaces is a data space, its corresponding processor + const char* csName = dstConfig->getDisplayViewColorSpaceName(dstDisplay, dstView); + const char* displayColorSpaceName = View::UseDisplayName(csName) ? dstDisplay : csName; + ConstColorSpaceRcPtr displayColorSpace = dstConfig->getColorSpace(displayColorSpaceName); + if (!displayColorSpace) + { + throw Exception("Can't create the processor for the destination config: " + "display color space not found."); + } + + // If either of the color spaces are data spaces, its corresponding processor // will be empty, but need to make sure the entire result is also empty to // better match the semantics of how data spaces are handled. - if (!srcColorSpace->isData()) + if (!srcColorSpace->isData() && !displayColorSpace->isData()) { if (direction == TRANSFORM_DIR_INVERSE) { diff --git a/tests/cpu/Config_tests.cpp b/tests/cpu/Config_tests.cpp index 5d30fda5fc..59d1472dbb 100644 --- a/tests/cpu/Config_tests.cpp +++ b/tests/cpu/Config_tests.cpp @@ -5924,6 +5924,7 @@ ocio_profile_version: 2 displayname: - ! {name: view1, colorspace: displaytest1} - ! {name: view2, view_transform: vt1, display_colorspace: display2} + - ! {name: view3, colorspace: data_space} view_transforms: - ! @@ -6166,6 +6167,13 @@ ocio_profile_version: 2 auto ff4 = OCIO_DYNAMIC_POINTER_CAST(t4); OCIO_CHECK_ASSERT(ff4); + // If one of the spaces is a data space, the whole result must be a no-op. + OCIO_CHECK_NO_THROW(p = OCIO::Config::GetProcessorFromConfigs( + config2, "test2", config1, "displayname", "view3", OCIO::TRANSFORM_DIR_FORWARD)); + OCIO_REQUIRE_ASSERT(p); + group = p->createGroupTransform(); + OCIO_REQUIRE_EQUAL(group->getNumTransforms(), 0); + constexpr const char * SIMPLE_CONFIG3{ R"( ocio_profile_version: 2 From a8044533c90282fbb9f898197608682c31d0fe4e Mon Sep 17 00:00:00 2001 From: Eric Renaud-Houde Date: Mon, 13 Nov 2023 11:23:04 -0500 Subject: [PATCH 2/2] Moved missing display color space exception before processor creation. Signed-off-by: Eric Renaud-Houde --- src/OpenColorIO/Config.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index 0557ae9544..ccfb134b45 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -4719,6 +4719,15 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr "the source color space."); } + const char* csName = dstConfig->getDisplayViewColorSpaceName(dstDisplay, dstView); + const char* displayColorSpaceName = View::UseDisplayName(csName) ? dstDisplay : csName; + ConstColorSpaceRcPtr displayColorSpace = dstConfig->getColorSpace(displayColorSpaceName); + if (!displayColorSpace) + { + throw Exception("Can't create the processor for the destination config: " + "display color space not found."); + } + auto p2 = dstConfig->getProcessor(dstContext, dstInterchangeName, dstDisplay, dstView, direction); if (!p2) { @@ -4729,15 +4738,6 @@ ConstProcessorRcPtr Config::GetProcessorFromConfigs(const ConstContextRcPtr & sr ProcessorRcPtr processor = Processor::Create(); processor->getImpl()->setProcessorCacheFlags(srcConfig->getImpl()->m_cacheFlags); - const char* csName = dstConfig->getDisplayViewColorSpaceName(dstDisplay, dstView); - const char* displayColorSpaceName = View::UseDisplayName(csName) ? dstDisplay : csName; - ConstColorSpaceRcPtr displayColorSpace = dstConfig->getColorSpace(displayColorSpaceName); - if (!displayColorSpace) - { - throw Exception("Can't create the processor for the destination config: " - "display color space not found."); - } - // If either of the color spaces are data spaces, its corresponding processor // will be empty, but need to make sure the entire result is also empty to // better match the semantics of how data spaces are handled.