6 BIT_LENGTH = int(math.pow(2, BIT_DEPTH))
7 COLOR_DEPTH = BIT_LENGTH - 1
11 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 /* This file is auto-generated by the build scripts; edits will be lost
36 cc = open('src/lut.cc', 'w')
40 print >>cc,"#include \"lut.h\""
43 /* sRGB color matrix for XYZ -> RGB */
44 float color_matrix[3][3] = {
45 { 3.240454836, -1.537138850, -0.498531547},
46 {-0.969266390, 1.876010929, 0.041556082},
47 { 0.055643420, -0.204025854, 1.057225162}
52 float lut_in[COLOR_DEPTH + 1] = {\n
54 \t * Reference white: DCI
57 """ % (BIT_DEPTH, DCI_GAMMA)
60 for i in range(0, BIT_LENGTH):
61 v = math.pow (i / (BIT_LENGTH - 1.0), DCI_GAMMA);
66 if i < BIT_LENGTH - 1:
67 print >> cc,"%06f, " % v,
74 print >> cc,"%06f" % v
79 int lut_out[COLOR_DEPTH + 1] = {
81 \t * Reference white: sRGB
87 for i in range (0, BIT_LENGTH):
88 v = i / (BIT_LENGTH - 1.0)
90 if (v < (0.04045 / 12.92)):
93 v = (1.055 * pow (v, (1 / SRGB_GAMMA))) - 0.055;
100 if i < BIT_LENGTH - 1:
101 print >> cc, "%d, " % v,
112 h = open('src/lut.h', 'w')
117 #define COLOR_DEPTH (%d)
118 #define DCI_COEFFICIENT (48.0/52.37)
120 extern float color_matrix[3][3];
121 extern int lut_out[COLOR_DEPTH + 1];
122 extern float lut_in[COLOR_DEPTH + 1];
125 if __name__ == "__main__":