MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / ApplyCDL

Function ApplyCDL

tests/cpu/ops/cdl/CDLOp_tests.cpp:17–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace
16{
17void ApplyCDL(float * in, const float * ref, unsigned numPixels,
18 const double * slope, const double * offset,
19 const double * power, double saturation,
20 OCIO::CDLOpData::Style style, float errorThreshold)
21{
22 OCIO::CDLOpDataRcPtr data
23 = std::make_shared<OCIO::CDLOpData>(style,
24 OCIO::CDLOpData::ChannelParams(slope[0], slope[1], slope[2]),
25 OCIO::CDLOpData::ChannelParams(offset[0], offset[1], offset[2]),
26 OCIO::CDLOpData::ChannelParams(power[0], power[1], power[2]),
27 saturation);
28 OCIO::CDLOp cdlOp(data);
29
30 OCIO_CHECK_NO_THROW(cdlOp.validate());
31
32 const auto cpu = cdlOp.getCPUOp(true);
33 cpu->apply(in, in, numPixels);
34
35 for(unsigned idx=0; idx<(numPixels*4); ++idx)
36 {
37 // Using rel error with a large minExpected value of 1 will transition
38 // from absolute error for expected values < 1 and
39 // relative error for values > 1.
40 const bool equalRel = OCIO::EqualWithSafeRelError(in[idx],
41 ref[idx],
42 errorThreshold,
43 1.0f);
44 if (!equalRel)
45 {
46 std::ostringstream message;
47 message << "Index: " << idx;
48 message << " - Values: " << in[idx] << " and: " << ref[idx];
49 message << " - Threshold: " << errorThreshold;
50 OCIO_CHECK_ASSERT_MESSAGE(0, message.str());
51 }
52 }
53}
54
55}
56

Callers 1

OCIO_ADD_TESTFunction · 0.85

Calls 5

ChannelParamsClass · 0.85
EqualWithSafeRelErrorFunction · 0.85
validateMethod · 0.45
getCPUOpMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected