Skip to content

Commit 792ae6a

Browse files
committed
test: improve color management test in imagebufalgo_test (AcademySoftwareFoundation#4063)
Add a few more assertion checks and error messages in imagebufalgo_test. I observe that if somebody runs the testsuite with `$OCIO` set to a config that doesn't contain the required color space names for this test, it will fail. As a backstop, use the default built-in config if the initial request fails. That will always give a working processor between these spaces if OCIO >= 2.2 is being used. Also one more tiny SPI-specific enhancement to hacky identification of nonconforming color space names in our old configs. Signed-off-by: Larry Gritz <[email protected]>
1 parent 728ca95 commit 792ae6a

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/libOpenImageIO/color_ocio.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ ColorConfig::Impl::classify_by_name(CSInfo& cs)
612612
} else if (cs.name == "srgbf" || cs.name == "srgbh" || cs.name == "srgb16"
613613
|| cs.name == "srgb8") {
614614
cs.setflag(CSInfo::is_srgb, srgb_alias);
615+
} else if (cs.name == "srgblnf" || cs.name == "srgblnh"
616+
|| cs.name == "srgbln16" || cs.name == "srgbln8") {
617+
cs.setflag(CSInfo::is_lin_srgb, lin_srgb_alias);
615618
}
616619
#endif
617620

src/libOpenImageIO/imagebufalgo_test.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,19 +1140,31 @@ void
11401140
test_color_management()
11411141
{
11421142
ColorConfig config;
1143+
auto processor = config.createColorProcessor("lin_srgb", "srgb");
1144+
// These color spaces might not be found if the site running this test
1145+
// has a weirdo OCIO config that doesn't contain those names. If we fail,
1146+
// try again using the built-in config (OCIO 2.2+) and hope for the best.
1147+
if (!processor)
1148+
processor = ColorConfig("ocio://default")
1149+
.createColorProcessor("lin_srgb", "srgb");
1150+
OIIO_CHECK_ASSERT(processor);
11431151

11441152
// Test the IBA::colorconvert version that works on a color at a time
11451153
{
1146-
auto processor = config.createColorProcessor("lin_srgb", "srgb");
1147-
float rgb[3] = { 0.5f, 0.5f, 0.5f };
1148-
ImageBufAlgo::colorconvert(rgb, processor.get(), false);
1154+
float rgb[3] = { 0.5f, 0.5f, 0.5f };
1155+
bool r = ImageBufAlgo::colorconvert(rgb, processor.get(), false);
1156+
OIIO_CHECK_ASSERT(r);
1157+
if (!r)
1158+
OIIO::print("colorconvert error: {}\n", OIIO::geterror());
11491159
OIIO_CHECK_EQUAL_THRESH(rgb[1], 0.735356983052449f, 1.0e-5);
11501160
}
11511161
{
1152-
auto processor = config.createColorProcessor("lin_srgb", "srgb");
1153-
float rgb[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
1154-
ImageBufAlgo::colorconvert(rgb, processor.get(), true);
1155-
OIIO_CHECK_EQUAL_THRESH(rgb[1], 0.735356983052449f, 1.0e-5);
1162+
float rgba[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
1163+
bool r = ImageBufAlgo::colorconvert(rgba, processor.get(), true);
1164+
OIIO_CHECK_ASSERT(r);
1165+
if (!r)
1166+
OIIO::print("colorconvert error: {}\n", OIIO::geterror());
1167+
OIIO_CHECK_EQUAL_THRESH(rgba[1], 0.735356983052449f, 1.0e-5);
11561168
}
11571169
}
11581170

0 commit comments

Comments
 (0)