@@ -36,33 +36,52 @@ void CompareFloats(const std::string& floats1, const std::string& floats2)
3636OCIO_ADD_TEST (Baker, bake_3dlut)
3737{
3838 constexpr const char * myProfile =
39- " ocio_profile_version: 1 \n "
39+ " ocio_profile_version: 2 \n "
4040 " \n "
41- " strictparsing: false\n "
41+ " file_rules:\n "
42+ " - !<Rule> {name: Default, colorspace: lnh}\n "
4243 " \n "
4344 " displays:\n "
4445 " display1:\n "
45- " - !<View> {name: view1, colorspace: test}\n "
46+ " - !<View> {name: view1, colorspace: gamma22}\n "
47+ " - !<View> {name: view2, looks: satlook, colorspace: gamma22}\n "
4648 " \n "
4749 " looks:\n "
4850 " - !<Look>\n "
49- " name : mylook \n "
51+ " name : contrastlook \n "
5052 " process_space : lnh\n "
5153 " transform : !<ExponentTransform> {value: [2.2, 2.2, 2.2, 1]}\n "
54+ " - !<Look>\n "
55+ " name : satlook\n "
56+ " process_space : lnh\n "
57+ " transform : !<CDLTransform> {sat: 2}\n "
5258 " \n "
53- " colorspaces :\n "
59+ " colorspaces:\n "
5460 " - !<ColorSpace>\n "
5561 " name : lnh\n "
5662 " bitdepth : 16f\n "
5763 " isdata : false\n "
5864 " allocation : lg2\n "
5965 " \n "
6066 " - !<ColorSpace>\n "
61- " name : test \n "
67+ " name : gamma22 \n "
6268 " bitdepth : 8ui\n "
6369 " isdata : false\n "
6470 " allocation : uniform\n "
65- " to_reference : !<ExponentTransform> {value: [2.2, 2.2, 2.2, 1]}\n " ;
71+ " to_reference : !<ExponentTransform> {value: [2.2, 2.2, 2.2, 1]}\n "
72+ " \n "
73+ " named_transforms:\n "
74+ " - !<NamedTransform>\n "
75+ " name: logcnt\n "
76+ " transform: !<LogCameraTransform>\n "
77+ " log_side_slope: 0.247189638318671\n "
78+ " log_side_offset: 0.385536998692443\n "
79+ " lin_side_slope: 5.55555555555556\n "
80+ " lin_side_offset: 0.0522722750251688\n "
81+ " lin_side_break: 0.0105909904954696\n "
82+ " base: 10\n "
83+ " direction: inverse\n "
84+ " \n " ;
6685
6786 constexpr const char * expectedLut =
6887 " CSPLUTV100\n "
@@ -96,7 +115,9 @@ OCIO_ADD_TEST(Baker, bake_3dlut)
96115 std::istringstream is (myProfile);
97116 OCIO::ConstConfigRcPtr config;
98117 OCIO_CHECK_NO_THROW (config = OCIO::Config::CreateFromStream (is));
118+ OCIO_CHECK_NO_THROW (config->validate ());
99119 OCIO_REQUIRE_EQUAL (config->getNumColorSpaces (), 2 );
120+ OCIO_REQUIRE_EQUAL (config->getNumNamedTransforms (), 1 );
100121
101122 {
102123 OCIO::BakerRcPtr bake = OCIO::Baker::Create ();
@@ -117,8 +138,8 @@ OCIO_ADD_TEST(Baker, bake_3dlut)
117138 bake->setLooks (" foo, +bar" );
118139 OCIO_CHECK_EQUAL (" foo, +bar" , std::string (bake->getLooks ()));
119140 bake->setLooks (" " );
120- bake->setTargetSpace (" test " );
121- OCIO_CHECK_EQUAL (" test " , std::string (bake->getTargetSpace ()));
141+ bake->setTargetSpace (" gamma22 " );
142+ OCIO_CHECK_EQUAL (" gamma22 " , std::string (bake->getTargetSpace ()));
122143 bake->setShaperSize (4 );
123144 OCIO_CHECK_EQUAL (4 , bake->getShaperSize ());
124145 bake->setCubeSize (2 );
@@ -153,7 +174,7 @@ OCIO_ADD_TEST(Baker, bake_3dlut)
153174 bake->setConfig (config);
154175 bake->setFormat (" resolve_cube" );
155176 bake->setInputSpace (" lnh" );
156- bake->setLooks (" mylook " );
177+ bake->setLooks (" contrastlook " );
157178 bake->setDisplayView (" display1" , " view1" );
158179 bake->setCubeSize (10 );
159180 std::ostringstream os;
@@ -171,14 +192,54 @@ R"(LUT_1D_SIZE 10
1711920.777778 0.777778 0.777778
1721930.888889 0.888889 0.888889
1731941.000000 1.000000 1.000000
195+ )" };
196+
197+ OCIO_CHECK_EQUAL (expectedCube.size (), os.str ().size ());
198+ OCIO_CHECK_EQUAL (expectedCube, os.str ());
199+ }
200+
201+ {
202+ OCIO::BakerRcPtr bake = OCIO::Baker::Create ();
203+ bake->setConfig (config);
204+ bake->setFormat (" resolve_cube" );
205+ bake->setInputSpace (" lnh" );
206+ bake->setShaperSpace (" logcnt" );
207+ bake->setDisplayView (" display1" , " view2" );
208+ bake->setShaperSize (10 );
209+ bake->setCubeSize (2 );
210+ std::ostringstream os;
211+ OCIO_CHECK_NO_THROW (bake->bake (os));
212+
213+ const std::string expectedCube{
214+ R"( LUT_1D_SIZE 10
215+ LUT_1D_INPUT_RANGE -0.017290 55.080036
216+ LUT_3D_SIZE 2
217+ 0.000000 0.000000 0.000000
218+ 0.763998 0.763998 0.763998
219+ 0.838479 0.838479 0.838479
220+ 0.882030 0.882030 0.882030
221+ 0.912925 0.912925 0.912925
222+ 0.936887 0.936887 0.936887
223+ 0.956464 0.956464 0.956464
224+ 0.973016 0.973016 0.973016
225+ 0.987354 0.987354 0.987354
226+ 1.000000 1.000000 1.000000
227+ 0.000000 0.000000 0.000000
228+ 8.054426 0.000000 0.000000
229+ 0.000000 6.931791 0.000000
230+ 6.384501 6.384501 0.000000
231+ 0.000000 0.000000 8.336130
232+ 7.904850 0.000000 7.904850
233+ 0.000000 6.751890 6.751890
234+ 6.185304 6.185304 6.185304
174235)" };
175236
176237 OCIO_CHECK_EQUAL (expectedCube.size (), os.str ().size ());
177238 OCIO_CHECK_EQUAL (expectedCube, os.str ());
178239 }
179240}
180241
181- OCIO_ADD_TEST (Baker, baking_config )
242+ OCIO_ADD_TEST (Baker, baking_validation )
182243{
183244 OCIO::BakerRcPtr bake;
184245 std::ostringstream os;
@@ -232,10 +293,18 @@ OCIO_ADD_TEST(Baker, baking_config)
232293 to_reference: !<LogTransform> {}
233294
234295 - !<ColorSpace>
235- name : Crosstalk
296+ name : Saturation
236297 isdata : false
237298 to_reference: !<CDLTransform> {sat: 0.5}
238299
300+ - !<ColorSpace>
301+ name : Log2sRGB
302+ isdata : false
303+ to_reference: !<GroupTransform>
304+ children:
305+ - !<LogTransform> {base: 2, direction: inverse}
306+ - !<MatrixTransform> {matrix: [3.2409, -1.5373, -0.4986, 0, -0.9692, 1.8759, 0.0415, 0, 0.0556, -0.2039, 1.0569, 0, 0, 0, 0, 1 ], direction: inverse}
307+
239308 - !<ColorSpace>
240309 name : sRGB
241310 isdata : false
@@ -249,6 +318,12 @@ OCIO_ADD_TEST(Baker, baking_config)
249318 isdata : false
250319 from_reference : !<ExponentTransform> {value: [2.2, 2.2, 2.2, 1], direction: inverse}
251320
321+ named_transforms:
322+
323+ - !<NamedTransform>
324+ name: Log2NT
325+ transform: !<LogTransform> {base: 2}
326+
252327 inactive_colorspaces: [RawInactive]
253328 )" ;
254329
@@ -450,12 +525,56 @@ OCIO_ADD_TEST(Baker, baking_config)
450525 bake->setConfig (config);
451526 bake->setInputSpace (" Raw" );
452527 bake->setTargetSpace (" sRGB" );
453- bake->setShaperSpace (" Crosstalk " );
528+ bake->setShaperSpace (" Saturation " );
454529 bake->setFormat (" cinespace" );
455530
456531 os.str (" " );
457532 OCIO_CHECK_THROW_WHAT (bake->bake (os), OCIO::Exception,
458- " The specified shaper space, 'Crosstalk ' has channel crosstalk, which "
533+ " The specified shaper space, 'Saturation ' has channel crosstalk, which "
459534 " is not appropriate for shapers. Please select an alternate shaper "
460535 " space or omit this option." );
536+
537+ // Using shaper space without Crosstalk (after optimization).
538+ bake = OCIO::Baker::Create ();
539+ bake->setConfig (config);
540+ bake->setInputSpace (" sRGB" );
541+ bake->setTargetSpace (" Raw" );
542+ bake->setShaperSpace (" Log2sRGB" );
543+ bake->setFormat (" cinespace" );
544+
545+ os.str (" " );
546+ OCIO_CHECK_NO_THROW (bake->bake (os));
547+
548+ // Using NamedTransform as shaper space.
549+ bake = OCIO::Baker::Create ();
550+ bake->setConfig (config);
551+ bake->setInputSpace (" sRGB" );
552+ bake->setTargetSpace (" Raw" );
553+ bake->setShaperSpace (" Log2NT" );
554+ bake->setFormat (" cinespace" );
555+
556+ os.str (" " );
557+ OCIO_CHECK_NO_THROW (bake->bake (os));
558+
559+ // Using NamedTransform as input space is not supported.
560+ bake = OCIO::Baker::Create ();
561+ bake->setConfig (config);
562+ bake->setInputSpace (" Log2NT" );
563+ bake->setTargetSpace (" sRGB" );
564+ bake->setFormat (" cinespace" );
565+
566+ os.str (" " );
567+ OCIO_CHECK_THROW_WHAT (bake->bake (os), OCIO::Exception,
568+ " Could not find input colorspace 'Log2NT'." );
569+
570+ // Using NamedTransform as target space is not supported.
571+ bake = OCIO::Baker::Create ();
572+ bake->setConfig (config);
573+ bake->setInputSpace (" sRGB" );
574+ bake->setTargetSpace (" Log2NT" );
575+ bake->setFormat (" cinespace" );
576+
577+ os.str (" " );
578+ OCIO_CHECK_THROW_WHAT (bake->bake (os), OCIO::Exception,
579+ " Could not find target colorspace 'Log2NT'." );
461580}
0 commit comments