~ubuntu-branches/ubuntu/vivid/rawstudio/vivid

« back to all changes in this revision

Viewing changes to src/color.h

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2011-07-28 17:36:32 UTC
  • mfrom: (2.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20110728173632-5czluz9ye3c83zc5
Tags: 2.0-1
* [3750b2cf] Merge commit 'upstream/2.0'
* [63637468] Removing Patch, not necessary anymore.
* [2fb580dc] Add new build-dependencies.
* [c57d953b] Run dh_autoreconf due to patches in configure.in
* [13febe39] Add patch to remove the libssl requirement.
* [5ae773fe] Replace libjpeg62-dev by libjpeg8-dev :)
* [1969d755] Don't build static libraries.
* [7cfe0a2e] Add a patch to fix the plugin directory path.
  As plugins are shared libraries, they need to go into /usr/lib,
  not into /usr/share.
  Thanks to Andrew McMillan
* [c1d0d9dd] Don't install .la files for all plugins and libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2006-2009 Anders Brander <anders@brander.dk> and 
3
 
 * Anders Kvist <akv@lnxbx.dk>
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
18
 
 */
19
 
 
20
 
#ifndef _COLOR_H_
21
 
#define _COLOR_H_
22
 
 
23
 
#include "x86_cpu.h"
24
 
 
25
 
/* luminance weight, notice that these is used for linear data */
26
 
 
27
 
#define RLUM (0.3086)
28
 
#define GLUM (0.6094)
29
 
#define BLUM (0.0820)
30
 
 
31
 
#define GAMMA 2.2 /* this is ONLY used to render the histogram */
32
 
 
33
 
#define _MAX(in, max) if (in>max) max=in
34
 
 
35
 
#ifdef __i386__
36
 
#define _MAX_CMOV(in, max) \
37
 
asm volatile (\
38
 
        "cmpl   %1, %0\n\t"\
39
 
        "cmovl  %1, %0\n\t"\
40
 
        :"+r" (max)\
41
 
        :"r" (in)\
42
 
)
43
 
#endif
44
 
 
45
 
#define _CLAMP(in, max) if (in>max) in=max
46
 
 
47
 
#ifdef __i386__
48
 
#define _CLAMP_CMOV(in, max) \
49
 
asm volatile (\
50
 
        "cmpl   %0, %1\n\t"\
51
 
        "cmovl  %1, %0\n\t"\
52
 
        :"+r" (in)\
53
 
        :"r" (max)\
54
 
)
55
 
#endif
56
 
 
57
 
#define _CLAMP65535(a) a = MAX(MIN(65535,a),0)
58
 
 
59
 
#ifdef __i386__
60
 
#define _CLAMP65535_CMOV(value) \
61
 
asm volatile (\
62
 
        "xorl %%ecx, %%ecx\n\t"\
63
 
        "cmpl %%ecx, %0\n\t"\
64
 
        "cmovl %%ecx, %0\n\t"\
65
 
        "movl   $65535, %%ecx\n\t"\
66
 
        "cmpl %0, %%ecx\n\t"\
67
 
        "cmovl %%ecx, %0\n\t"\
68
 
        :"+r" (value)\
69
 
        :\
70
 
        :"%ecx"\
71
 
)
72
 
#endif
73
 
 
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)
76
 
 
77
 
#if defined (__i386__) || defined (__x86_64__)
78
 
#define _CLAMP65535_TRIPLET_CMOV(a, b, c) \
79
 
asm volatile (\
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)\
95
 
        :\
96
 
        :"%"REG_c\
97
 
)
98
 
#endif
99
 
 
100
 
#define _CLAMP255(a) a = MAX(MIN(255,a),0)
101
 
 
102
 
#ifdef __i386__
103
 
#define _CLAMP255_CMOV(value) \
104
 
asm volatile (\
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"\
111
 
        :"+r" (value)\
112
 
        :\
113
 
        :"%ecx"\
114
 
)
115
 
#endif
116
 
 
117
 
#define COLOR_BLACK(c) do { c.red=0; c.green=0; c.blue=0; } while (0)
118
 
 
119
 
enum {
120
 
        R=0,
121
 
        G=1,
122
 
        B=2,
123
 
        G2=3
124
 
};
125
 
 
126
 
#endif /* _COLOR_H_ */