2 Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file test/colour_conversion_test.cc
21 * @brief Various tests of ColourConversion.
24 #include "lib/colour_conversion.h"
25 #include <dcp/colour_matrix.h>
26 #include <dcp/gamma_transfer_function.h>
27 #include <libxml++/libxml++.h>
28 #include <boost/test/unit_test.hpp>
31 using boost::shared_ptr;
33 BOOST_AUTO_TEST_CASE (colour_conversion_test1)
35 ColourConversion A (dcp::ColourConversion::srgb_to_xyz ());
36 ColourConversion B (dcp::ColourConversion::rec709_to_xyz ());
38 BOOST_CHECK_EQUAL (A.identifier(), "9840c601d2775bf1b3847254bbaa36a9");
39 BOOST_CHECK_EQUAL (B.identifier(), "0778fbc5c87470f58820604a66992579");
42 BOOST_AUTO_TEST_CASE (colour_conversion_test2)
44 ColourConversion A (dcp::ColourConversion::srgb_to_xyz ());
46 xmlpp::Element* root = doc.create_root_node ("Test");
49 doc.write_to_string_formatted ("UTF-8"),
50 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
52 " <InputTransferFunction>\n"
53 " <Type>ModifiedGamma</Type>\n"
54 " <Power>2.4</Power>\n"
55 " <Threshold>0.04045</Threshold>\n"
58 " </InputTransferFunction>\n"
59 " <YUVToRGB>0</YUVToRGB>\n"
60 " <RedX>0.64</RedX>\n"
61 " <RedY>0.33</RedY>\n"
62 " <GreenX>0.3</GreenX>\n"
63 " <GreenY>0.6</GreenY>\n"
64 " <BlueX>0.15</BlueX>\n"
65 " <BlueY>0.06</BlueY>\n"
66 " <WhiteX>0.3127</WhiteX>\n"
67 " <WhiteY>0.329</WhiteY>\n"
68 " <OutputGamma>2.6</OutputGamma>\n"
73 BOOST_AUTO_TEST_CASE (colour_conversion_test3)
75 ColourConversion A (dcp::ColourConversion::rec709_to_xyz ());
77 xmlpp::Element* root = doc.create_root_node ("Test");
80 doc.write_to_string_formatted ("UTF-8"),
81 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
83 " <InputTransferFunction>\n"
84 " <Type>ModifiedGamma</Type>\n"
85 " <Power>2.222222222222222</Power>\n"
86 " <Threshold>0.081</Threshold>\n"
89 " </InputTransferFunction>\n"
90 " <YUVToRGB>1</YUVToRGB>\n"
91 " <RedX>0.64</RedX>\n"
92 " <RedY>0.33</RedY>\n"
93 " <GreenX>0.3</GreenX>\n"
94 " <GreenY>0.6</GreenY>\n"
95 " <BlueX>0.15</BlueX>\n"
96 " <BlueY>0.06</BlueY>\n"
97 " <WhiteX>0.3127</WhiteX>\n"
98 " <WhiteY>0.329</WhiteY>\n"
99 " <OutputGamma>2.6</OutputGamma>\n"