Skip to content

Conversation

@cozdas
Copy link
Owner

@cozdas cozdas commented May 28, 2025

  • Adding AMF transform ID, interop id and icc profile name fields to color spaces with phyton bindings, java bindings, unit test
  • With the newly added unit tests discovered crasher issues some of the "char *" taking functions and fixed the crashers.
  • Also hardened Platform::Strcasecmp() and Platoform::Strncasecmp() against nullptr.

cozdas added 3 commits May 25, 2025 21:17
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
- adding python docs for AMF transform IDs and interop ID.
- With the newly added unit tests discovered crasher issues some of the "char *" taking functions and fixed the crashers
- Also hardened Platform::Strcasecmp() and Platoform::Strncasecmp() against nullptr.

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Copy link

@doug-walker doug-walker left a comment

Choose a reason for hiding this comment

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

We need to decide what version checks should be added to Config.cpp. It looks like the current code will read and write these attributes for any config version. For writing, we don't want to allow them in configs with version less than 2.5 since old readers would not handle them. I guess we could always read them from any version?


Specify the transform for the appropriate direction. Setting the transform to null will clear it.


Choose a reason for hiding this comment

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

Did you generate this manually rather than via the process specified here?
https://opencolorio.readthedocs.io/en/latest/guides/contributing/contributing.html

Copy link
Owner Author

Choose a reason for hiding this comment

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

I reverted the changes but failed to build the rst locally both on Windows and Mac.

// Test setting to nullptr
cs->setDescription(nullptr);
cs->setAmfTransformIDs(nullptr);
OCIO_CHECK_EQUAL(std::string(cs->getAmfTransformIDs()), "");

Choose a reason for hiding this comment

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

Would be a more interesting test if the value was not already "".

@doug-walker
Copy link

Please add some Python tests, though they do not have to be as thorough as the CPU tests.

cozdas added 3 commits June 4, 2025 15:07
- Reverting the manual changes to python frozen docs
- capitalizing the acronyms in the functions names, adding underscores to the yaml keywords
- changing the new keyword's ordering in the yaml file
- bumping the config minor version number for v2 to 5
- new fields are now restricted to v2.5 and higher (checkVersionConsistency() is updated to detect violations)
- Fixing the version check logic error in Config::validate()
- Added basic pyhton tests
- fixed / extended the color space cpu tests

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
…y added fields.

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
…macros.

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
str = cs.getAMFTransformIDs();
if (!str.empty())
{
os << ", amf_transform_ids=" << str;
Copy link
Owner Author

@cozdas cozdas Jun 5, 2025

Choose a reason for hiding this comment

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

Note that we're not parsing the string value that AMFTransformIDs field holds. Since the formatting stayed the same, that is multiple entities are separated with the newline character, this may create EOLs in the ostream.

Is this OK? Or should we try to create a list from each entity here (that requires tokenizing the string with /n/r separators).

Choose a reason for hiding this comment

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

Description has the same problem. Maybe for both we should just add something like "=(non-empty)" rather than trying to include the whole string? Or a hash value?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll leave those as-is for now, we can decide/change if a real need arises.

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
.def("getAmfTransformIDs", &ColorSpace::getAmfTransformIDs,
DOC(ColorSpace, getAmfTransformIDs))
.def("setAmfTransformIDs", &ColorSpace::setAmfTransformIDs, "amfTransformIDs"_a,
DOC(ColorSpace, setAmfTransformIDs))
Copy link
Owner Author

Choose a reason for hiding this comment

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

Do we want to add any of these newly added fields as an Init() function parameter which is defined in line 80 above?

Choose a reason for hiding this comment

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

Sure, as long as they go at the end and have default values so as not to break existing code.



// Check for interchange roles requirements - scene-referred and display-referred.
if (getMajorVersion() >= 2 && getMinorVersion() >= 2)
Copy link
Owner Author

Choose a reason for hiding this comment

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

This would work only until v3.0

Choose a reason for hiding this comment

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

Good catch. But you could use GetVersionHex() rather than making your own.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I saw that but that's a global function returning the library's version, not the config's current version.
I can add a function to Config class but that may break ABI.

cozdas added 2 commits June 4, 2025 18:47
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
str = cs.getAMFTransformIDs();
if (!str.empty())
{
os << ", amf_transform_ids=" << str;

Choose a reason for hiding this comment

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

Description has the same problem. Maybe for both we should just add something like "=(non-empty)" rather than trying to include the whole string? Or a hash value?



// Check for interchange roles requirements - scene-referred and display-referred.
if (getMajorVersion() >= 2 && getMinorVersion() >= 2)

Choose a reason for hiding this comment

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

Good catch. But you could use GetVersionHex() rather than making your own.

aliases.push_back(cs->getAlias(aidx));
}
out << YAML::Flow << YAML::Value << aliases;
}

Choose a reason for hiding this comment

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

When reading, there is no need for version checks here since checkVersionConsistency will be called after the load. However, when saving, it seems like we need to avoid writing if the version is less than 2.5. Otherwise we would produce a config that won't load in earlier libraries, right? Validate is not called before a serialize.

Although, looking at the ColorSpace loader, maybe it only logs a warning on an unrecognized key. So perhaps we have an option?

Copy link
Owner Author

Choose a reason for hiding this comment

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

We're calling the checkVersionConsistency() when saving too. It's in the Config::serialize() function.


# Test setting None (should convert to empty string)
self.colorspace.setICCProfileName(None)
self.assertEqual(self.colorspace.getICCProfileName(), '')

Choose a reason for hiding this comment

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

The value should be initialized to something other than an empty string to be a valid test.

Copy link
Owner Author

Choose a reason for hiding this comment

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

good catch.

*
* The interop ID is a standardized identifier for commonly used color spaces.
* These IDs are defined by the Academy Software Foundation's ColorInterop project
* to standardize color space naming across the industry.

Choose a reason for hiding this comment

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

Suggest:
The interop ID is a standardized identifier to uniquely identify commonly used color spaces. These IDs are defined by the Academy Software Foundation's Color Interop Forum project. If you create your own ID, you must prefix it with unique characters that will ensure it won't conflict with future Color Interop Forum IDs.

OCIO_CHECK_NO_THROW(cs->setInteropID(nullptr));
OCIO_CHECK_EQUAL(std::string(cs->getInteropID()), "");

// Test copy constructor preserves ICC profile name

Choose a reason for hiding this comment

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

Update comment.

And minor, but these comments should all end in a period.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Looks like the Cursor is also having difficulty sticking to this unusual comment syntax guideline even though the rest of the code has periods in the comments. :)

OCIO_CHECK_EQUAL(cfgString, os.str());
}

// Test that the interop_id can't be used in v2.0 config

Choose a reason for hiding this comment

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

Is this significantly different than the check below (2.0 vs. 2.4 is probably not worth a separate test)?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Tests here are using the v2 yaml "Start" snippet above to create from a stream (de-serialization)
Tests below using v2.4 are exercising the other, serialization direction.

aliases = cs.getAliases()
self.assertEqual(len(aliases), 2)
self.assertEqual(aliases[0], 'alias1')
self.assertEqual(aliases[1], 'alias2')
Copy link
Owner Author

Choose a reason for hiding this comment

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

Not sure why this is deleted. Restoring.

cozdas added 7 commits June 5, 2025 22:23
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
…her branch.

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
I was unable to build this locally so modified the CI workflow to upload the docs folder as an artifact in a separate branch. Even that was not readily consumable, I had to manually pick the differences and the remove the duplicate PyOpenColorIO in the entity names (i.e. PyOpenColorIO.PyOpenColorIO.ColorSpace)

Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
Copy link

@doug-walker doug-walker left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants