From 6de2bb3751b449abf06d44e4dda5e41b66df3f62 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 8 May 2022 23:47:12 +0200 Subject: Extract, test and slightly adjust the piecewise LUT for inverse gamma. --- test/rgb_xyz_test.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/rgb_xyz_test.cc b/test/rgb_xyz_test.cc index f64debc4..00787938 100644 --- a/test/rgb_xyz_test.cc +++ b/test/rgb_xyz_test.cc @@ -32,9 +32,10 @@ */ -#include "rgb_xyz.h" -#include "openjpeg_image.h" #include "colour_conversion.h" +#include "openjpeg_image.h" +#include "piecewise_lut.h" +#include "rgb_xyz.h" #include "stream_operators.h" #include #include @@ -149,6 +150,18 @@ BOOST_AUTO_TEST_CASE (rgb_xyz_test) } +/** Check the piecewise LUT that is used for inverse gamma calculation */ +BOOST_AUTO_TEST_CASE (rgb_xyz_lut_test) +{ + auto conversion = dcp::ColourConversion::rec709_to_xyz(); + auto lut = dcp::make_inverse_gamma_lut(conversion.out()); + + for (double x = 0; x < 1; x += 0.000001) { + BOOST_CHECK(std::abs(lrint(lut.lookup(x) * 4095) - lrint(pow(x, 1 / 2.6) * 4095)) < 2); + } +} + + static list notes; static void -- cgit v1.2.3