Skip to content

Commit eaa0281

Browse files
cozdasdoug-walker
andauthored
Adsk Contrib - Add Support for SMPTE ST 2036-1 compliant CLF files (#2265)
* Adding reading and writing support for SMPTE ST 2036-1 compliant CLF files. - Added "Id" element support per the spec. - Extended the CTFVersion class to handle non-numeric formats per the spec (which uses xmlns as the version) - CLF xml parser now strips the namespaces from the elements by default. This makes it possible to parse files with simple name spaces but complex name-spaced clf files may still fail. There is an internal switch to turn on/off the name space stripping. This way elements which need to retain the name spaces (such as the Info element) can still get the un-stripped names. - Extended the Input and Output Descriptor collection to hold multiple entries (similar to Description field) - CLF writer now writes the SMPTE xmlns version as well as the CompCLFVersion attribute. The resulting files can be read both by the Academy CLF parsers and SMPTE CLF parsers. - Generated cache hash IDs are now in the 8-4-4-4-12 UUID format to help complying with SMPTE id requirements - ociomakeclf tool now takes "--generateid" switch to for inserting newly added "Id element" into the target clf file. TODO: - Description and Descriptor elements need to collect the language attribute. - non-default namespace attributes (e.g. xmlns:foo) needs to be collected as root level attributes. - Those two TODO items need some re-factoring in the data collection code. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> * - Per the code review, exposing the newly added constant METADATA_ID_ELEMENT in python too. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> * - re-worked some part of the CLF parser and the CTFReaderTransform class to be able to collect richer metadata. - Now collecting the language attribute of the Description, input and output descriptor elements. - Also collecting the non-default xmlns attributes at the root level. - Updated the tests accordingly. - Replaced clf/pre-smpte_only/matrix_example.clf with clf/matrix_example_utf8.clf in some for some Reference tests. - Added format information to the ociomakeclf tool's help text. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> * - nmake the compilers happy. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> * - make the compilers happy pt2 Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> * - make the compilers happy pt3 (we need to make Windows compiler settings as picky as other platforms) Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> --------- Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com> Co-authored-by: Doug Walker <doug.walker@autodesk.com>
1 parent a1ab61e commit eaa0281

121 files changed

Lines changed: 37775 additions & 798 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/OpenColorIO/OpenColorTypes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,13 @@ extern OCIOEXPORT const char * METADATA_NAME;
977977
*/
978978
extern OCIOEXPORT const char * METADATA_ID;
979979

980+
/**
981+
* An ID when stored as an XML element rather than as an attribute. This is the
982+
* preferred mechanism in the SMPTE ST 2036-1 version of the CLF format. If
983+
* present, it is only available from the top-level FormatMetadata.
984+
*/
985+
extern OCIOEXPORT const char * METADATA_ID_ELEMENT;
986+
980987
/*!rst::
981988
Caches
982989
******

src/OpenColorIO/HashUtils.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright Contributors to the OpenColorIO Project.
33

44
#include <sstream>
5+
#include <iomanip>
56

67
#include <OpenColorIO/OpenColorIO.h>
78

@@ -25,4 +26,27 @@ std::string CacheIDHash(const char * array, std::size_t size)
2526
return oss.str();
2627
}
2728

29+
std::string CacheIDHashUUID(const char * array, std::size_t size)
30+
{
31+
XXH128_hash_t hash = XXH3_128bits(array, size);
32+
33+
// Make sure that we have full, zero-padded 32 chars.
34+
std::stringstream oss;
35+
oss << std::hex << std::setfill('0');
36+
oss << std::setw(16) << hash.high64;
37+
oss << std::setw(16) << hash.low64;
38+
39+
// Format into 8-4-4-4-12 form.
40+
std::string hex = oss.str();
41+
std::string uuid =
42+
hex.substr(0, 8) + "-" +
43+
hex.substr(8, 4) + "-" +
44+
hex.substr(12, 4) + "-" +
45+
hex.substr(16, 4) + "-" +
46+
hex.substr(20, 12);
47+
48+
return uuid;
49+
}
50+
51+
2852
} // namespace OCIO_NAMESPACE

src/OpenColorIO/HashUtils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ namespace OCIO_NAMESPACE
1414

1515
std::string CacheIDHash(const char * array, std::size_t size);
1616

17+
// Generates 128 bit UUID in the form of 8-4-4-4-12 using the hash of the passed
18+
// string.
19+
std::string CacheIDHashUUID(const char * array, std::size_t size);
20+
1721
} // namespace OCIO_NAMESPACE
1822

1923
#endif

src/OpenColorIO/Processor.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,9 @@ const char * Processor::Impl::getCacheID() const
330330

331331
if(!m_cacheID.empty()) return m_cacheID.c_str();
332332

333-
if(m_ops.empty())
334-
{
335-
m_cacheID = "<NOOP>";
336-
}
337-
else
338-
{
339-
const std::string fullstr = m_ops.getCacheID();
340-
m_cacheID = CacheIDHash(fullstr.c_str(), fullstr.size());
341-
}
333+
// Note: empty ops vector will also create a UUID.
334+
const std::string fullstr = m_ops.getCacheID();
335+
m_cacheID = CacheIDHashUUID(fullstr.c_str(), fullstr.size());
342336

343337
return m_cacheID.c_str();
344338
}

0 commit comments

Comments
 (0)