Skip to content

Commit df74525

Browse files
authored
Adsk Contrib - Fix the CDL write for CLF file format (#1526) (#1530)
Signed-off-by: Patrick Hodoul <[email protected]>
1 parent 9b619d8 commit df74525

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/OpenColorIO/fileformats/ctf/CTFTransform.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,17 +838,17 @@ void CDLWriter::writeContent() const
838838

839839
oss.str("");
840840
params = m_cdl->getSlopeParams();
841-
oss << params[0] << ", " << params[1] << ", " << params[2];
841+
oss << params[0] << " " << params[1] << " " << params[2];
842842
m_formatter.writeContentTag(TAG_SLOPE, oss.str());
843843

844844
oss.str("");
845845
params = m_cdl->getOffsetParams();
846-
oss << params[0] << ", " << params[1] << ", " << params[2];
846+
oss << params[0] << " " << params[1] << " " << params[2];
847847
m_formatter.writeContentTag(TAG_OFFSET, oss.str());
848848

849849
oss.str("");
850850
params = m_cdl->getPowerParams();
851-
oss << params[0] << ", " << params[1] << ", " << params[2];
851+
oss << params[0] << " " << params[1] << " " << params[2];
852852
m_formatter.writeContentTag(TAG_POWER, oss.str());
853853
}
854854
m_formatter.writeEndTag(TAG_SOPNODE);

tests/cpu/fileformats/FileFormatCTF_tests.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5725,9 +5725,9 @@ OCIO_ADD_TEST(CTFTransform, cdl_clf)
57255725
<SOPNode>
57265726
<Description>SOP description 1</Description>
57275727
<Description>SOP description 2</Description>
5728-
<Slope>1, 1.1, 1.2</Slope>
5729-
<Offset>0.2, 0.3, 0.4</Offset>
5730-
<Power>3.1, 3.2, 3.3</Power>
5728+
<Slope>1 1.1 1.2</Slope>
5729+
<Offset>0.2 0.3 0.4</Offset>
5730+
<Power>3.1 3.2 3.3</Power>
57315731
</SOPNode>
57325732
<SatNode>
57335733
<Description>Sat description 1</Description>
@@ -5740,6 +5740,24 @@ OCIO_ADD_TEST(CTFTransform, cdl_clf)
57405740

57415741
OCIO_CHECK_EQUAL(expected.size(), outputTransform.str().size());
57425742
OCIO_CHECK_EQUAL(expected, outputTransform.str());
5743+
5744+
// Now test if the read is working.
5745+
5746+
std::istringstream ctfStream;
5747+
ctfStream.str(expected);
5748+
5749+
std::string emptyString;
5750+
OCIO::LocalFileFormat tester;
5751+
OCIO::CachedFileRcPtr file = tester.read(ctfStream, emptyString, OCIO::INTERP_DEFAULT);
5752+
auto cachedFile = OCIO::DynamicPtrCast<OCIO::LocalCachedFile>(file);
5753+
5754+
const OCIO::ConstOpDataVec & opList = cachedFile->m_transform->getOps();
5755+
OCIO_REQUIRE_EQUAL(opList.size(), 1);
5756+
auto cdlData = std::dynamic_pointer_cast<const OCIO::CDLOpData>(opList[0]);
5757+
OCIO_REQUIRE_ASSERT(cdlData);
5758+
OCIO_CHECK_EQUAL(cdlData->getSlopeParams()[0], 1.);
5759+
OCIO_CHECK_EQUAL(cdlData->getSlopeParams()[1], 1.1);
5760+
OCIO_CHECK_EQUAL(cdlData->getSlopeParams()[2], 1.2);
57435761
}
57445762

57455763
OCIO_ADD_TEST(CTFTransform, cdl_ctf)
@@ -5768,9 +5786,9 @@ OCIO_ADD_TEST(CTFTransform, cdl_ctf)
57685786
"<ProcessList version=\"1.7\" id=\"cdl2\">\n"
57695787
" <ASC_CDL inBitDepth=\"32f\" outBitDepth=\"32f\" style=\"Fwd\">\n"
57705788
" <SOPNode>\n"
5771-
" <Slope>1, 1.1, 1.2</Slope>\n"
5772-
" <Offset>0.2, 0.3, 0.4</Offset>\n"
5773-
" <Power>3.1, 3.2, 3.3</Power>\n"
5789+
" <Slope>1 1.1 1.2</Slope>\n"
5790+
" <Offset>0.2 0.3 0.4</Offset>\n"
5791+
" <Power>3.1 3.2 3.3</Power>\n"
57745792
" </SOPNode>\n"
57755793
" <SatNode>\n"
57765794
" <Saturation>2.1</Saturation>\n"

0 commit comments

Comments
 (0)