diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-04-22 13:58:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-04-22 13:58:16 +0100 |
| commit | 86bfdeb77f55b379302a65b22f57fc0583ec6b3c (patch) | |
| tree | 66ed8eb0e4855c520b1b1a0d9dae052a0ad5bfe6 /test | |
| parent | 3c88524c9a2418d6d2d8b8eac29737c95b9a7411 (diff) | |
Express colour conversions as chromaticities and adjust so that
everything is specified as something_to_xyz and then you can get
an inverse LUT if you want one.
Diffstat (limited to 'test')
| -rw-r--r-- | test/colour_conversion_test.cc | 32 | ||||
| -rw-r--r-- | test/decryption_test.cc | 2 | ||||
| -rw-r--r-- | test/rgb_xyz_test.cc | 4 | ||||
| -rw-r--r-- | test/round_trip_test.cc | 4 |
4 files changed, 22 insertions, 20 deletions
diff --git a/test/colour_conversion_test.cc b/test/colour_conversion_test.cc index 9111b918..2eb5edf5 100644 --- a/test/colour_conversion_test.cc +++ b/test/colour_conversion_test.cc @@ -28,9 +28,9 @@ using boost::shared_ptr; using namespace dcp; static void -check_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, float gamma) +check_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, bool inverse, float gamma) { - double const * lut = tf->lut (bit_depth); + double const * lut = tf->lut (bit_depth, inverse); int const count = rint (pow (2.0, bit_depth)); for (int i = 0; i < count; ++i) { @@ -39,9 +39,9 @@ check_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, float gamma) } static void -check_modified_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, double power, double threshold, double A, double B) +check_modified_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, bool inverse, double power, double threshold, double A, double B) { - double const * lut = tf->lut (bit_depth); + double const * lut = tf->lut (bit_depth, inverse); int const count = rint (pow (2.0, bit_depth)); for (int i = 0; i < count; ++i) { @@ -58,25 +58,25 @@ BOOST_AUTO_TEST_CASE (colour_conversion_test1) { ColourConversion cc = ColourConversion::srgb_to_xyz (); - check_modified_gamma (cc.in(), 8, 2.4, 0.04045, 0.055, 12.92); - check_modified_gamma (cc.in(), 12, 2.4, 0.04045, 0.055, 12.92); - check_modified_gamma (cc.in(), 16, 2.4, 0.04045, 0.055, 12.92); + check_modified_gamma (cc.in(), 8, false, 2.4, 0.04045, 0.055, 12.92); + check_modified_gamma (cc.in(), 12, false, 2.4, 0.04045, 0.055, 12.92); + check_modified_gamma (cc.in(), 16, false, 2.4, 0.04045, 0.055, 12.92); - check_gamma (cc.out(), 8, 1 / 2.6); - check_gamma (cc.out(), 12, 1 / 2.6); - check_gamma (cc.out(), 16, 1 / 2.6); + check_gamma (cc.out(), 8, true, 1 / 2.6); + check_gamma (cc.out(), 12, true, 1 / 2.6); + check_gamma (cc.out(), 16, true, 1 / 2.6); } BOOST_AUTO_TEST_CASE (colour_conversion_test2) { ColourConversion cc = ColourConversion::rec709_to_xyz (); - check_modified_gamma (cc.in(), 8, 1 / 0.45, 0.081, 0.099, 4.5); - check_modified_gamma (cc.in(), 12, 1 / 0.45, 0.081, 0.099, 4.5); - check_modified_gamma (cc.in(), 16, 1 / 0.45, 0.081, 0.099, 4.5); + check_modified_gamma (cc.in(), 8, false, 1 / 0.45, 0.081, 0.099, 4.5); + check_modified_gamma (cc.in(), 12, false, 1 / 0.45, 0.081, 0.099, 4.5); + check_modified_gamma (cc.in(), 16, false, 1 / 0.45, 0.081, 0.099, 4.5); - check_gamma (cc.out(), 8, 1 / 2.6); - check_gamma (cc.out(), 12, 1 / 2.6); - check_gamma (cc.out(), 16, 1 / 2.6); + check_gamma (cc.out(), 8, true, 1 / 2.6); + check_gamma (cc.out(), 12, true, 1 / 2.6); + check_gamma (cc.out(), 16, true, 1 / 2.6); } diff --git a/test/decryption_test.cc b/test/decryption_test.cc index 282e74f3..0080fe3e 100644 --- a/test/decryption_test.cc +++ b/test/decryption_test.cc @@ -50,7 +50,7 @@ get_frame (dcp::DCP const & dcp) shared_ptr<dcp::XYZImage> xyz = j2k_frame->xyz_image(); uint8_t* argb = new uint8_t[xyz->size().width * xyz->size().height * 4]; - dcp::xyz_to_rgba (j2k_frame->xyz_image(), dcp::ColourConversion::xyz_to_srgb(), argb); + dcp::xyz_to_rgba (j2k_frame->xyz_image(), dcp::ColourConversion::srgb_to_xyz(), argb); return make_pair (argb, xyz->size ()); } diff --git a/test/rgb_xyz_test.cc b/test/rgb_xyz_test.cc index 26411870..0b427893 100644 --- a/test/rgb_xyz_test.cc +++ b/test/rgb_xyz_test.cc @@ -134,7 +134,9 @@ BOOST_AUTO_TEST_CASE (xyz_rgb_range_test) scoped_array<uint8_t> rgb (new uint8_t[2 * 2 * 6]); notes.clear (); - dcp::xyz_to_rgb (xyz, dcp::ColourConversion::xyz_to_srgb (), rgb.get(), 2 * 6, boost::optional<dcp::NoteHandler> (boost::bind (¬e_handler, _1, _2))); + dcp::xyz_to_rgb ( + xyz, dcp::ColourConversion::srgb_to_xyz (), rgb.get(), 2 * 6, boost::optional<dcp::NoteHandler> (boost::bind (¬e_handler, _1, _2)) + ); /* The 6 out-of-range samples should have been noted */ BOOST_REQUIRE_EQUAL (notes.size(), 6); diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index dcaa6939..9f1030da 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -110,10 +110,10 @@ BOOST_AUTO_TEST_CASE (round_trip_test) shared_ptr<dcp::XYZImage> xyz_B = mxf_B->get_frame(0)->xyz_image (); scoped_array<uint8_t> frame_A (new uint8_t[xyz_A->size().width * xyz_A->size().height * 4]); - dcp::xyz_to_rgba (xyz_A, dcp::ColourConversion::xyz_to_srgb(), frame_A.get()); + dcp::xyz_to_rgba (xyz_A, dcp::ColourConversion::srgb_to_xyz(), frame_A.get()); scoped_array<uint8_t> frame_B (new uint8_t[xyz_B->size().width * xyz_B->size().height * 4]); - dcp::xyz_to_rgba (xyz_B, dcp::ColourConversion::xyz_to_srgb(), frame_B.get()); + dcp::xyz_to_rgba (xyz_B, dcp::ColourConversion::srgb_to_xyz(), frame_B.get()); BOOST_CHECK_EQUAL (xyz_A->size().width, xyz_B->size().width); BOOST_CHECK_EQUAL (xyz_A->size().height, xyz_B->size().height); |
