Skip to content

Commit 6a1dff6

Browse files
authored
Adsk Contrib - Fix interop ID issue in ociocheck (#2204)
* Fix ociocheck Signed-off-by: Doug Walker <[email protected]> * Minor improvements Signed-off-by: Doug Walker <[email protected]> --------- Signed-off-by: Doug Walker <[email protected]>
1 parent 449d1f2 commit 6a1dff6

File tree

4 files changed

+60
-19
lines changed

4 files changed

+60
-19
lines changed

src/OpenColorIO/Config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ void Config::validate() const
14611461
os << "Config failed color space validation. ";
14621462
os << "The color space '" << name << "' ";
14631463
os << "refers to an interop ID, '" << interop << "', ";
1464-
os << "which is not defined in this config.";
1464+
os << "which is not a color space name or alias.";
14651465
getImpl()->m_validationtext = os.str();
14661466
throw Exception(getImpl()->m_validationtext.c_str());
14671467
}

src/OpenColorIO/ViewingRules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ViewingRule
9191
os << "The rule '" << m_name << "' ";
9292
os << "refers to encoding '" << std::string(encName);
9393
os << "' that is not used by any of the color spaces.";
94-
LogWarning(os.str());
94+
LogInfo(os.str());
9595
}
9696
}
9797
if (numCS + numEnc == 0)

src/apps/ociocheck/main.cpp

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const char * DESC_STRING = "\n\n"
2828
"that has been manually edited, using the '-o' option.\n";
2929

3030

31-
// returns true if the interopID is valid
31+
// Returns true if the interopID is valid.
3232
bool isValidInteropID(const std::string& id)
3333
{
3434
// See https://github.com/AcademySoftwareFoundation/ColorInterop for the details.
@@ -56,7 +56,7 @@ bool isValidInteropID(const std::string& id)
5656
"srgb_rec709_display",
5757
"g24_rec709_display",
5858
"srgb_p3d65_display",
59-
"srgbx_p3d65_display",
59+
"srgbe_p3d65_display",
6060
"pq_p3d65_display",
6161
"pq_rec2020_display",
6262
"hlg_rec2020_display",
@@ -70,44 +70,45 @@ bool isValidInteropID(const std::string& id)
7070
if (id.empty())
7171
return true;
7272

73-
// Check if has a namespace.
73+
// Check if the ID has a namespace.
7474
size_t pos = id.find(':');
7575
if (pos == std::string::npos)
7676
{
77-
// No namespace, so id must be in the Color Interop Forum ID list.
77+
// No namespace, so the ID must be in the Color Interop Forum ID list.
7878
if (cifTextureIDs.count(id) == 0 && cifDisplayIDs.count(id)==0)
7979
{
80-
std::cout << "ERROR: InteropID '" << id << "' is not valid. "
81-
"It should either be one of Color Interop Forum standard IDs or "
80+
std::cout << "WARNING: InteropID '" << id << "' is not valid. "
81+
"It should either be one of the Color Interop Forum standard IDs or "
8282
"it must contain a namespace followed by ':', e.g. 'mycompany:mycolorspace'." <<
8383
std::endl;
8484
return false;
8585
}
8686
}
8787
else
8888
{
89-
// Namespace found, split into namespace and id.
89+
// Namespace found, split into namespace and ID.
9090
std::string ns = id.substr(0, pos);
9191
std::string cs = id.substr(pos+1);
9292

93-
// Id should not be in the Color Interop Forum ID list.
93+
// The ID should not be in the Color Interop Forum ID list.
9494
if (cifTextureIDs.count(cs) > 0 || cifDisplayIDs.count(cs)> 0)
9595
{
96-
std::cout << "ERROR: InteropID '" << id << "' is not valid. "
97-
"The ID part must not be one of the Color Interop Forum standard IDs when a namespace is used." <<
98-
std::endl;
96+
std::cout << "WARNING: InteropID '" << id << "' is not valid. "
97+
"The ID part must not be one of the Color Interop Forum standard IDs "
98+
"when a namespace is used." << std::endl;
9999
return false;
100100
}
101101
}
102102

103-
// all clear.
103+
// All clear.
104104
return true;
105105
}
106106

107107
int main(int argc, const char **argv)
108108
{
109109
bool help = false;
110110
int errorcount = 0;
111+
int warningcount = 0;
111112
std::string inputconfig;
112113
std::string outputconfig;
113114

@@ -357,6 +358,7 @@ int main(int argc, const char **argv)
357358
if(!cs)
358359
{
359360
std::cout << "WARNING: NOT DEFINED (" << role << ")" << std::endl;
361+
warningcount += 1;
360362
}
361363
}
362364
}
@@ -369,6 +371,9 @@ int main(int argc, const char **argv)
369371
OCIO::SEARCH_REFERENCE_SPACE_ALL, // Iterate over scene & display color spaces.
370372
OCIO::COLORSPACE_ALL); // Iterate over active & inactive color spaces.
371373

374+
bool foundCategory = false;
375+
bool foundNoCategory = false;
376+
372377
for(int i=0; i<numCS; ++i)
373378
{
374379
OCIO::ConstColorSpaceRcPtr cs = config->getColorSpace(config->getColorSpaceNameByIndex(
@@ -381,10 +386,16 @@ int main(int argc, const char **argv)
381386
{
382387
if (!isValidInteropID(interopID))
383388
{
384-
errorcount += 1;
389+
warningcount += 1;
385390
}
386391
}
387392

393+
if(!config->isInactiveColorSpace(cs->getName()))
394+
{
395+
if(cs->getNumCategories() > 0) foundCategory = true;
396+
else foundNoCategory = true;
397+
}
398+
388399
// Try to load the transform for the to_ref direction -- this will load any LUTs.
389400
bool toRefOK = true;
390401
std::string toRefErrorText;
@@ -440,6 +451,14 @@ int main(int argc, const char **argv)
440451
std::cout << cs->getName() << std::endl;
441452
}
442453
}
454+
455+
if(foundCategory && foundNoCategory)
456+
{
457+
// Categories should either be missing in all, or present in all active items.
458+
std::cout << "\nWARNING: The config has some color spaces "
459+
"where the categories are not set.\n";
460+
warningcount += 1;
461+
}
443462
}
444463

445464
{
@@ -453,11 +472,20 @@ int main(int argc, const char **argv)
453472
std::cout << "no named transforms defined" << std::endl;
454473
}
455474

475+
bool foundCategory = false;
476+
bool foundNoCategory = false;
477+
456478
for(int i = 0; i<numNT; ++i)
457479
{
458480
OCIO::ConstNamedTransformRcPtr nt = config->getNamedTransform(
459481
config->getNamedTransformNameByIndex(OCIO::NAMEDTRANSFORM_ALL, i));
460482

483+
if(!config->isInactiveColorSpace(nt->getName()))
484+
{
485+
if(nt->getNumCategories() > 0) foundCategory = true;
486+
else foundNoCategory = true;
487+
}
488+
461489
// Try to load the transform -- this will load any LUTs.
462490
bool fwdOK = true;
463491
std::string fwdErrorText;
@@ -513,6 +541,14 @@ int main(int argc, const char **argv)
513541
std::cout << nt->getName() << std::endl;
514542
}
515543
}
544+
545+
if(foundCategory && foundNoCategory)
546+
{
547+
// Categories should either be missing in all, or present in all active items.
548+
std::cout << "\nWARNING: The config has some named transforms "
549+
"where the categories are not set.\n";
550+
warningcount += 1;
551+
}
516552
}
517553

518554
{
@@ -605,11 +641,11 @@ int main(int argc, const char **argv)
605641
StringUtils::StringVec svec = StringUtils::SplitByLines(logGuard.output());
606642
if (!StringUtils::Contain(svec, "[OpenColorIO Error]"))
607643
{
608-
std::cout << "passed" << std::endl;
644+
std::cout << "Validation: passed" << std::endl;
609645
}
610646
else
611647
{
612-
std::cout << "failed" << std::endl;
648+
std::cout << "Validation: failed" << std::endl;
613649
errorcount += 1;
614650
}
615651
}
@@ -618,7 +654,7 @@ int main(int argc, const char **argv)
618654
std::cout << "ERROR:" << std::endl;
619655
errorcount += 1;
620656
std::cout << exception.what() << std::endl;
621-
std::cout << "failed" << std::endl;
657+
std::cout << "Validation: failed" << std::endl;
622658
}
623659

624660
std::cout << std::endl;
@@ -657,6 +693,11 @@ int main(int argc, const char **argv)
657693
return 1;
658694
}
659695

696+
if(warningcount > 0)
697+
{
698+
std::cout << "\nWarnings encountered: " << warningcount << std::endl;
699+
}
700+
660701
std::cout << std::endl;
661702
if(errorcount == 0)
662703
{

tests/cpu/ColorSpace_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ active_views: []
715715
OCIO_CHECK_THROW_WHAT(config->validate(),
716716
OCIO::Exception,
717717
"Config failed color space validation. The color space 'raw' refers "
718-
"to an interop ID, 'data', which is not defined in this config.");
718+
"to an interop ID, 'data', which is not a color space name or alias.");
719719
}
720720

721721
// Test that the interop id can be found in another color space.

0 commit comments

Comments
 (0)