blob: e5bb3643fb98fffe0e75ef53df476ff0ce4dc4fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* The OpenCL kernel comes from GEGL (www.gegl.org)
* File: gegl/opencl/gegl-cl-color-kernel.h
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2012 Victor Oliveira (victormatheus@gmail.com)
*/
/*!
[config]
name: GEGL rgb_gamma_u8_to_ragabaf
kernel_name: rgb_gamma_u8_to_ragabaf
global_size: 208320 1 1
local_size: 1 1 1
[test]
name: A
arg_in: 0 buffer uchar[624960] repeat 0 0 0 \
1 1 1 \
200 200 200 \
255 255 255
arg_out: 1 buffer float4[208320] repeat 0.0 0.0 0.0 1.0 \
0.000303 0.000303 0.000303 1.0 \
0.577580 0.577580 0.577580 1.0 \
1.0 1.0 1.0 1.0 \
tolerance 0.000001
!*/
float gamma_2_2_to_linear (float value)
{
if (value > 0.03928f)
return native_powr ((value + 0.055f) / 1.055f, 2.4f);
return value / 12.92f;
}
__kernel void rgb_gamma_u8_to_ragabaf (__global const uchar * in,
__global float4 * out)
{
int gid = get_global_id(0);
uchar3 in_vc;
in_vc.x = in[(gid * 3)];
in_vc.y = in[(gid * 3) + 1];
in_vc.z = in[(gid * 3) + 2];
float3 in_v = convert_float3(in_vc) / 255.0f;
float4 tmp_v;
tmp_v = (float4)(gamma_2_2_to_linear(in_v.x),
gamma_2_2_to_linear(in_v.y),
gamma_2_2_to_linear(in_v.z),
1.0f);
float4 out_v;
out_v = tmp_v * tmp_v.w;
out_v.w = tmp_v.w;
out[gid] = out_v;
}
|