2
* Copyright (C) 2006-2009 Anders Brander <anders@brander.dk> and
3
* Anders Kvist <akv@lnxbx.dk>
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25
/* luminance weight, notice that these is used for linear data */
31
#define GAMMA 2.2 /* this is ONLY used to render the histogram */
33
#define _MAX(in, max) if (in>max) max=in
36
#define _MAX_CMOV(in, max) \
45
#define _CLAMP(in, max) if (in>max) in=max
48
#define _CLAMP_CMOV(in, max) \
57
#define _CLAMP65535(a) a = MAX(MIN(65535,a),0)
60
#define _CLAMP65535_CMOV(value) \
62
"xorl %%ecx, %%ecx\n\t"\
64
"cmovl %%ecx, %0\n\t"\
65
"movl $65535, %%ecx\n\t"\
67
"cmovl %%ecx, %0\n\t"\
74
#define _CLAMP65535_TRIPLET(a, b, c) \
75
a = MAX(MIN(65535,a),0);b = MAX(MIN(65535,b),0);c = MAX(MIN(65535,c),0)
77
#if defined (__i386__) || defined (__x86_64__)
78
#define _CLAMP65535_TRIPLET_CMOV(a, b, c) \
80
"xor %%"REG_c", %%"REG_c"\n\t"\
81
"cmp %%"REG_c", %0\n\t"\
82
"cmovl %%"REG_c", %0\n\t"\
83
"cmp %%"REG_c", %1\n\t"\
84
"cmovl %%"REG_c", %1\n\t"\
85
"cmp %%"REG_c", %2\n\t"\
86
"cmovl %%"REG_c", %2\n\t"\
87
"mov $0xffff, %%"REG_c"\n\t"\
88
"cmp %%"REG_c", %0\n\t"\
89
"cmovg %%"REG_c", %0\n\t"\
90
"cmp %%"REG_c", %1\n\t"\
91
"cmovg %%"REG_c", %1\n\t"\
92
"cmp %%"REG_c", %2\n\t"\
93
"cmovg %%"REG_c", %2\n\t"\
94
:"+r" (a), "+r" (b), "+r" (c)\
100
#define _CLAMP255(a) a = MAX(MIN(255,a),0)
103
#define _CLAMP255_CMOV(value) \
105
"xorl %%ecx, %%ecx\n\t"\
106
"cmpl %%ecx, %0\n\t"\
107
"cmovl %%ecx, %0\n\t"\
108
"movl $255, %%ecx\n\t"\
109
"cmpl %0, %%ecx\n\t"\
110
"cmovl %%ecx, %0\n\t"\
117
#define COLOR_BLACK(c) do { c.red=0; c.green=0; c.blue=0; } while (0)
126
#endif /* _COLOR_H_ */