@@ -244,6 +244,8 @@ OCIO_ADD_TEST(FileFormatICC, test_apply)
244244{
245245 OCIO::ContextRcPtr context = OCIO::Context::Create ();
246246 {
247+ // This test uses a profile where the TRC is a 1024 element LUT.
248+
247249 static const std::string iccFileName (" icc-test-3.icm" );
248250 OCIO::OpRcPtrVec ops;
249251 OCIO_CHECK_NO_THROW (BuildOpsTest (ops, iccFileName, context, OCIO::TRANSFORM_DIR_INVERSE));
@@ -287,7 +289,8 @@ OCIO_ADD_TEST(FileFormatICC, test_apply)
287289 op->apply (srcImage, 3 );
288290 }
289291
290- // Values outside [0.0, 1.0] are clamped and won't round-trip.
292+ // Currently the LUT-based TRC's clamp the values outside
293+ // [0.0, 1.0], thus those values won't round-trip.
291294 static constexpr float bckImage[] = {
292295 0 .0f , 0 .0f , 0 .3f , 0 .0f ,
293296 0 .4f , 0 .5f , 0 .6f , 0 .5f ,
@@ -301,34 +304,43 @@ OCIO_ADD_TEST(FileFormatICC, test_apply)
301304 }
302305
303306 {
307+ // This test uses a profile where the TRC is
308+ // a parametric curve of type 0 (basic gamma) with
309+ // gamma values {2.174, 2.174, 2.174, 1.0}.
310+
304311 static const std::string iccFileName (" icc-test-2.pf" );
305312 OCIO::OpRcPtrVec ops;
306313 OCIO_CHECK_NO_THROW (BuildOpsTest (ops, iccFileName, context, OCIO::TRANSFORM_DIR_INVERSE));
307314 OCIO_CHECK_NO_THROW (ops.finalize ());
308315 OCIO_CHECK_NO_THROW (ops.optimize (OCIO::OPTIMIZATION_LOSSLESS));
316+ OCIO_REQUIRE_EQUAL (2 , ops.size ());
317+ OCIO_CHECK_EQUAL (" <GammaOp>" , ops[0 ]->getInfo ());
318+ OCIO_CHECK_EQUAL (" <MatrixOffsetOp>" , ops[1 ]->getInfo ());
309319
310320 // apply ops
311- float srcImage[] = {
321+ const std::array< float , 12 > srcImage {
312322 -0 .1f , 0 .0f , 0 .3f , 0 .0f ,
313323 0 .4f , 0 .5f , 0 .6f , 0 .5f ,
314324 0 .7f , 1 .0f , 1 .9f , 1 .0f };
315325
316- const float dstImage[] = {
317- 0 .012437f , 0 .004702f , 0 .070333f , 0 .0f ,
326+ const std::array< float , 12 > dstImage {
327+ 0 .009241f , 0 .003003f , 0 .070198f , 0 .0f ,
318328 0 .188392f , 0 .206965f , 0 .343595f , 0 .5f ,
319- 0 .693246f , 0 .863199f , 1 .07867f , 1 .0f };
329+ 1 .210462f , 1 .058761f , 4 .003706f , 1 .0f };
330+
331+ std::array<float , 12 > testImage = srcImage;
320332
321333 for (const auto & op : ops)
322334 {
323- op->apply (srcImage , 3 );
335+ op->apply (testImage. data () , 3 );
324336 }
325337
326338 // Compare results
327339 const float error = 2e-5f ;
328340
329341 for (unsigned int i = 0 ; i<12 ; ++i)
330342 {
331- OCIO_CHECK_CLOSE (srcImage [i], dstImage[i], error);
343+ OCIO_CHECK_CLOSE (testImage [i], dstImage[i], error);
332344 }
333345
334346 // Invert the processing.
@@ -337,24 +349,22 @@ OCIO_ADD_TEST(FileFormatICC, test_apply)
337349 OCIO_CHECK_NO_THROW (BuildOpsTest (opsInv, iccFileName, context, OCIO::TRANSFORM_DIR_FORWARD));
338350 OCIO_CHECK_NO_THROW (opsInv.finalize ());
339351 OCIO_CHECK_NO_THROW (opsInv.optimize (OCIO::OPTIMIZATION_LOSSLESS));
352+ OCIO_REQUIRE_EQUAL (2 , opsInv.size ());
353+ OCIO_CHECK_EQUAL (" <MatrixOffsetOp>" , opsInv[0 ]->getInfo ());
354+ OCIO_CHECK_EQUAL (" <GammaOp>" , opsInv[1 ]->getInfo ());
340355
341356 for (const auto & op : opsInv)
342357 {
343- op->apply (srcImage , 3 );
358+ op->apply (testImage. data () , 3 );
344359 }
345360
346- // Values outside [0.0, 1.0] are clamped and won't round-trip.
347- const float bckImage[] = {
348- 0 .0f , 0 .0f , 0 .3f , 0 .0f ,
349- 0 .4f , 0 .5f , 0 .6f , 0 .5f ,
350- 0 .7f , 1 .0f , 1 .0f , 1 .0f };
351-
352- // Compare results
361+ // For pure-gamma TRCs, values outside [0.0, 1.0] are NOT clamped
362+ // thus those values should round-trip correctly.
353363 const float error2 = 2e-4f ;
354364
355365 for (unsigned int i = 0 ; i<12 ; ++i)
356366 {
357- OCIO_CHECK_CLOSE (srcImage [i], bckImage [i], error2);
367+ OCIO_CHECK_CLOSE (testImage [i], srcImage [i], error2);
358368 }
359369 }
360370
0 commit comments