1 /* === S Y N F I G ========================================================= */
2 /*!	\file
3 **	\brief Common definitions for color classes
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **	Copyright (c) 2007, 2008 Chris Moore
10 **	Copyright (c) 2012-2013 Carlos López
11 **	Copyright (c) 2015 Diego Barrios Romero
12 **
13 **	This package is free software; you can redistribute it and/or
14 **	modify it under the terms of the GNU General Public License as
15 **	published by the Free Software Foundation; either version 2 of
16 **	the License, or (at your option) any later version.
17 **
18 **	This package 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 GNU
21 **	General Public License for more details.
22 **	\endlegal
23 */
24 /* ========================================================================= */
25 
26 /* === S T A R T =========================================================== */
27 
28 #ifndef __SYNFIG_COLOR_COMMON_H
29 #define __SYNFIG_COLOR_COMMON_H
30 
31 /* === H E A D E R S ======================================================= */
32 
33 #include <cmath>
34 #include <stdint.h>
35 #include <synfig/gamma.h>
36 #include <synfig/string.h>
37 #include <synfig/angle.h>
38 
39 #ifdef USE_HALF_TYPE
40 #include <OpenEXR/half.h>
41 #endif
42 
43 /* === M A C R O S ========================================================= */
44 
45 #define use_colorspace_gamma()	App::use_colorspace_gamma
46 #define colorspace_gamma()		(2.2f)
47 #define gamma_in(x)				((x>=0) ? pow((float)x,1.0f/colorspace_gamma()) : -pow((float)-x,1.0f/colorspace_gamma()))
48 #define gamma_out(x)			((x>=0) ? pow((float)x,     colorspace_gamma()) : -pow((float)-x,     colorspace_gamma()))
49 
50 namespace synfig {
51 
52 #ifdef USE_HALF_TYPE
53 typedef half ColorReal;
54 #else
55 typedef float ColorReal;
56 #endif
57 
58 static const float EncodeYUV[3][3]=
59 {
60 	{ 0.299f, 0.587f, 0.114f },
61 	{ -0.168736f, -0.331264f, 0.5f },
62 	{ 0.5f, -0.418688f, -0.081312f }
63 };
64 
65 static const float DecodeYUV[3][3]=
66 {
67 	{ 1.0f, 0.0f, 1.402f },
68 	{ 1.0f, -0.344136f, -0.714136f },
69 	{ 1.0f, 1.772f, 0.0f }
70 };
71 
72 
73 } // synfig namespace
74 
75 #endif // __SYNFIG_COLOR_COMMON_H
76 
77