2 Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
37 #include <boost/optional.hpp>
46 class ColourConversion;
49 /** Convert an XYZ image to RGBA.
50 * @param xyz_image Image in XYZ.
51 * @param conversion Colour conversion to use.
52 * @param argb Buffer to fill with RGBA data. The format of the data is:
55 * Byte /- 0 -------|- 1 --------|- 2 --------|- 3 --------|- 4 --------|- 5 --------| ...
56 * |(0, 0) Blue|(0, 0)Green |(0, 0) Red |(0, 0) Alpha|(0, 1) Blue |(0, 1) Green| ...
59 * So that the first byte is the blue component of the pixel at x=0, y=0, the second
60 * is the green component, and so on.
62 * Lines are packed so that the second row directly follows the first.
64 extern void xyz_to_rgba (
65 std::shared_ptr<const OpenJPEGImage>,
66 ColourConversion const & conversion,
72 /** Convert an XYZ image to 48bpp RGB.
73 * @param xyz_image Frame in XYZ.
74 * @param conversion Colour conversion to use.
75 * @param rgb Buffer to fill with RGB data. Format is packed RGB
76 * 16:16:16, 48bpp, 16R, 16G, 16B, with the 2-byte value for each
77 * R/G/B component stored as little-endian; i.e. AV_PIX_FMT_RGB48LE.
78 * @param stride Stride for RGB data in bytes.
79 * @param note Optional handler for any notes that may be made during the conversion (e.g. when clamping occurs).
81 extern void xyz_to_rgb (
82 std::shared_ptr<const OpenJPEGImage>,
83 ColourConversion const & conversion,
86 boost::optional<NoteHandler> note = boost::optional<NoteHandler> ()
90 /** @param rgb RGB data; packed RGB 16:16:16, 48bpp, 16R, 16G, 16B,
91 * with the 2-byte value for each R/G/B component stored as
92 * little-endian; i.e. AV_PIX_FMT_RGB48LE.
93 * @param size size of RGB image in pixels.
94 * @param size stride of RGB data in pixels.
96 extern std::shared_ptr<OpenJPEGImage> rgb_to_xyz (
100 ColourConversion const & conversion,
101 boost::optional<NoteHandler> note = boost::optional<NoteHandler> ()
105 /** @param conversion Colour conversion.
106 * @param matrix Filled in with the product of the RGB to XYZ matrix, the Bradford transform and the DCI companding.
108 extern void combined_rgb_to_xyz (ColourConversion const & conversion, double* matrix);