Skip to content

Commit 3e7f95a

Browse files
committed
Fix ociocheck
Signed-off-by: Doug Walker <[email protected]>
1 parent a9ca7e5 commit 3e7f95a

File tree

1 file changed

+54
-13
lines changed

1 file changed

+54
-13
lines changed

src/apps/ociocheck/main.cpp

Lines changed: 54 additions & 13 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
{
@@ -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
{

0 commit comments

Comments
 (0)