-
Notifications
You must be signed in to change notification settings - Fork 0
Adding new attributes to color spaces. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
193e33a
89a4162
8bf083e
57f5b38
295f965
1e08d6b
99af000
0d3b302
4e24d32
8b9b0e7
b85a71c
6b3c761
f1f8920
945e494
a73c230
c2f65f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,9 @@ class ColorSpace::Impl | |
| std::string m_equalityGroup; | ||
| std::string m_description; | ||
| std::string m_encoding; | ||
| std::string m_interopID; | ||
| std::string m_AMFTransformIDs; | ||
| std::string m_ICCProfileName; | ||
| StringUtils::StringVec m_aliases; | ||
|
|
||
| BitDepth m_bitDepth{ BIT_DEPTH_UNKNOWN }; | ||
|
|
@@ -62,6 +65,9 @@ class ColorSpace::Impl | |
| m_equalityGroup = rhs.m_equalityGroup; | ||
| m_description = rhs.m_description; | ||
| m_encoding = rhs.m_encoding; | ||
| m_interopID = rhs.m_interopID; | ||
| m_AMFTransformIDs = rhs.m_AMFTransformIDs; | ||
| m_ICCProfileName = rhs.m_ICCProfileName; | ||
| m_bitDepth = rhs.m_bitDepth; | ||
| m_isData = rhs.m_isData; | ||
| m_referenceSpaceType = rhs.m_referenceSpaceType; | ||
|
|
@@ -195,7 +201,7 @@ const char * ColorSpace::getFamily() const noexcept | |
|
|
||
| void ColorSpace::setFamily(const char * family) | ||
| { | ||
| getImpl()->m_family = family; | ||
| getImpl()->m_family = family ? family : ""; | ||
| } | ||
|
|
||
| const char * ColorSpace::getEqualityGroup() const noexcept | ||
|
|
@@ -205,7 +211,7 @@ const char * ColorSpace::getEqualityGroup() const noexcept | |
|
|
||
| void ColorSpace::setEqualityGroup(const char * equalityGroup) | ||
| { | ||
| getImpl()->m_equalityGroup = equalityGroup; | ||
| getImpl()->m_equalityGroup = equalityGroup ? equalityGroup : ""; | ||
| } | ||
|
|
||
| const char * ColorSpace::getDescription() const noexcept | ||
|
|
@@ -215,7 +221,37 @@ const char * ColorSpace::getDescription() const noexcept | |
|
|
||
| void ColorSpace::setDescription(const char * description) | ||
| { | ||
| getImpl()->m_description = description; | ||
| getImpl()->m_description = description ? description : ""; | ||
| } | ||
|
|
||
| const char * ColorSpace::getInteropID() const noexcept | ||
| { | ||
| return getImpl()->m_interopID.c_str(); | ||
| } | ||
|
|
||
| void ColorSpace::setInteropID(const char * interopID) | ||
| { | ||
| getImpl()->m_interopID = interopID ? interopID : ""; | ||
| } | ||
|
|
||
| const char * ColorSpace::getAMFTransformIDs() const noexcept | ||
| { | ||
| return getImpl()->m_AMFTransformIDs.c_str(); | ||
| } | ||
|
|
||
| void ColorSpace::setAMFTransformIDs(const char * amfTransformIDs) | ||
| { | ||
| getImpl()->m_AMFTransformIDs = amfTransformIDs ? amfTransformIDs : ""; | ||
| } | ||
|
|
||
| const char * ColorSpace::getICCProfileName() const noexcept | ||
| { | ||
| return getImpl()->m_ICCProfileName.c_str(); | ||
| } | ||
|
|
||
| void ColorSpace::setICCProfileName(const char * iccProfileName) | ||
| { | ||
| getImpl()->m_ICCProfileName = iccProfileName ? iccProfileName : ""; | ||
| } | ||
|
|
||
| BitDepth ColorSpace::getBitDepth() const noexcept | ||
|
|
@@ -265,7 +301,7 @@ const char * ColorSpace::getEncoding() const noexcept | |
|
|
||
| void ColorSpace::setEncoding(const char * encoding) | ||
| { | ||
| getImpl()->m_encoding = encoding; | ||
| getImpl()->m_encoding = encoding ? encoding : ""; | ||
| } | ||
|
|
||
| bool ColorSpace::isData() const noexcept | ||
|
|
@@ -371,7 +407,6 @@ std::ostream & operator<< (std::ostream & os, const ColorSpace & cs) | |
| break; | ||
| } | ||
| os << "name=" << cs.getName() << ", "; | ||
| std::string str{ cs.getFamily() }; | ||
| const auto numAliases = cs.getNumAliases(); | ||
| if (numAliases == 1) | ||
| { | ||
|
|
@@ -386,6 +421,15 @@ std::ostream & operator<< (std::ostream & os, const ColorSpace & cs) | |
| } | ||
| os << "], "; | ||
| } | ||
|
|
||
| std::string str; | ||
|
|
||
| str = cs.getInteropID(); | ||
| if (!str.empty()) | ||
| { | ||
| os << "interop_id=" << str << ", "; | ||
| } | ||
| str = cs.getFamily(); | ||
| if (!str.empty()) | ||
| { | ||
| os << "family=" << str << ", "; | ||
|
|
@@ -429,6 +473,16 @@ std::ostream & operator<< (std::ostream & os, const ColorSpace & cs) | |
| { | ||
| os << ", description=" << str; | ||
| } | ||
| str = cs.getAMFTransformIDs(); | ||
| if (!str.empty()) | ||
| { | ||
| os << ", amf_transform_ids=" << str; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| str = cs.getICCProfileName(); | ||
| if (!str.empty()) | ||
| { | ||
| os << ", icc_profile_name=" << str; | ||
| } | ||
| if(cs.getTransform(COLORSPACE_DIR_TO_REFERENCE)) | ||
| { | ||
| os << ",\n " << cs.getName() << " --> Reference"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,7 +247,7 @@ static constexpr unsigned LastSupportedMajorVersion = OCIO_VERSION_MAJOR; | |
|
|
||
| // For each major version keep the most recent minor. | ||
| static const unsigned int LastSupportedMinorVersion[] = {0, // Version 1 | ||
| 4 // Version 2 | ||
| 5 // Version 2 | ||
| }; | ||
|
|
||
| } // namespace | ||
|
|
@@ -1185,7 +1185,7 @@ ConstConfigRcPtr Config::CreateFromFile(const char * filename) | |
| // Check if it is an OCIOZ archive. | ||
| if (magicNumber[0] == 'P' && magicNumber[1] == 'K') | ||
| { | ||
| // Closing ifstream even though it should be close by ifstream deconstructor (RAII). | ||
| // Closing ifstream even though it should be closed by ifstream destructor (RAII). | ||
| ifstream.close(); | ||
|
|
||
| // The file should be an OCIOZ archive file. | ||
|
|
@@ -1499,7 +1499,8 @@ void Config::validate() const | |
|
|
||
|
|
||
| // Check for interchange roles requirements - scene-referred and display-referred. | ||
| if (getMajorVersion() >= 2 && getMinorVersion() >= 2) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would work only until v3.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. But you could use GetVersionHex() rather than making your own.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| unsigned int versionHex = (getMajorVersion() << 24) | (getMinorVersion() << 16); | ||
| if (versionHex >= 0x02020000u) // v2.2 or higher | ||
| { | ||
| bool hasRoleSceneLinear = false; | ||
| bool hasRoleCompositingLog = false; | ||
|
|
@@ -5426,6 +5427,8 @@ void Config::Impl::checkVersionConsistency(ConstTransformRcPtr & transform) cons | |
|
|
||
| void Config::Impl::checkVersionConsistency() const | ||
| { | ||
| unsigned int hexVersion = (m_majorVersion << 24) | (m_minorVersion << 16); | ||
|
|
||
| // Check for the Transforms. | ||
|
|
||
| ConstTransformVec transforms; | ||
|
|
@@ -5495,18 +5498,43 @@ void Config::Impl::checkVersionConsistency() const | |
| } | ||
| } | ||
|
|
||
| // Check for the DisplayColorSpaces. | ||
| // Check for the ColorSpaces. | ||
|
|
||
| if (m_majorVersion < 2) | ||
| const int nbCS = m_allColorSpaces->getNumColorSpaces(); | ||
| for (int i = 0; i < nbCS; ++i) | ||
| { | ||
| const int nbCS = m_allColorSpaces->getNumColorSpaces(); | ||
| for (int i = 0; i < nbCS; ++i) | ||
| const auto & cs = m_allColorSpaces->getColorSpaceByIndex(i); | ||
| if (m_majorVersion < 2) | ||
| { | ||
| const auto & cs = m_allColorSpaces->getColorSpaceByIndex(i); | ||
| if (MatchReferenceType(SEARCH_REFERENCE_SPACE_DISPLAY, cs->getReferenceSpaceType())) | ||
| if (MatchReferenceType(SEARCH_REFERENCE_SPACE_DISPLAY, cs->getReferenceSpaceType())) | ||
| { | ||
| throw Exception("Only version 2 (or higher) can have DisplayColorSpaces."); | ||
| } | ||
| } | ||
|
|
||
| if (hexVersion < 0x02050000) // Version 2.5 | ||
| { | ||
| if (*cs->getInteropID()) | ||
| { | ||
| std::ostringstream os; | ||
| os << "Config failed validation. The color space '" << cs->getName() << "' "; | ||
| os << "has non-empty InteropID and config version is less than 2.5."; | ||
| throw Exception(os.str().c_str()); | ||
| } | ||
| if (*cs->getAMFTransformIDs()) | ||
| { | ||
| std::ostringstream os; | ||
| os << "Config failed validation. The color space '" << cs->getName() << "' "; | ||
| os << "has non-empty AMFTransformIDs and config version is less than 2.5."; | ||
| throw Exception(os.str().c_str()); | ||
| } | ||
| if (*cs->getICCProfileName()) | ||
| { | ||
| std::ostringstream os; | ||
| os << "Config failed validation. The color space '" << cs->getName() << "' "; | ||
| os << "has non-empty ICCProfileName and config version is less than 2.5."; | ||
| throw Exception(os.str().c_str()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.