[gegl] colors.cl: Add some conversions
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] colors.cl: Add some conversions
- Date: Sun, 3 Nov 2013 05:38:41 +0000 (UTC)
commit 6b00f791a1ec2a94c232a553020fe3a68500fec8
Author: Daniel Sabo <DanielSabo gmail com>
Date: Sat Nov 2 21:28:38 2013 -0700
colors.cl: Add some conversions
gegl/opencl/gegl-cl-color.c | 5 +++++
opencl/colors.cl | 43 +++++++++++++++++++++++++++++++++++++++++++
opencl/colors.cl.h | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 0 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-color.c b/gegl/opencl/gegl-cl-color.c
index ae5fcf7..fc3da21 100644
--- a/gegl/opencl/gegl-cl-color.c
+++ b/gegl/opencl/gegl-cl-color.c
@@ -134,6 +134,7 @@ gegl_cl_color_compile_kernels (void)
{ babl_format ("YA float"), babl_format("RGBA float"), "yaf_to_rgbaf", NULL },
{ babl_format ("RGBA u8"), babl_format("YA float"), "rgbau8_to_yaf", NULL },
{ babl_format ("YA float"), babl_format("RGBA u8"), "yaf_to_rgbau8", NULL },
+ { babl_format ("RaGaBaA float"), babl_format("YA float"), "ragabaf_to_yaf", NULL },
{ babl_format ("RGBA float"), babl_format("R'G'B'A u8"), "rgbaf_to_rgba_gamma_u8", NULL },
{ babl_format ("RGBA float"), babl_format("R'G'B' u8"), "rgbaf_to_rgb_gamma_u8", NULL },
@@ -150,9 +151,13 @@ gegl_cl_color_compile_kernels (void)
{ babl_format ("RGBA float"), babl_format ("RGB float"), "rgbaf_to_rgbf", NULL },
+ { babl_format ("R'G'B' float"), babl_format ("RGBA float"), "rgb_gamma_f_to_rgbaf", NULL },
+
/* Reuse some conversions */
{ babl_format ("R'G'B' u8"), babl_format ("R'G'B'A float"), "rgbu8_to_rgbaf", NULL },
{ babl_format ("R'G'B'A u8"), babl_format ("R'G'B'A float"), "rgbau8_to_rgbaf", NULL },
+
+ { babl_format ("R'G'B' float"), babl_format ("RaGaBaA float"), "rgb_gamma_f_to_rgbaf", NULL },
};
ColorConversionInfo lut8_conversions[] = {
diff --git a/opencl/colors.cl b/opencl/colors.cl
index 9448a6d..2f74d66 100644
--- a/opencl/colors.cl
+++ b/opencl/colors.cl
@@ -176,6 +176,34 @@ __kernel void ragabaf_to_rgb_gamma_u8 (__global const float4 * in,
#endif
}
+/* -- R'G'B' float -- */
+
+/* R'G'B' float -> RGBA float */
+__kernel void rgb_gamma_f_to_rgbaf (__global const float * in,
+ __global float4 * out)
+{
+ int gid = get_global_id(0);
+ float4 out_v;
+
+#if (__OPENCL_VERSION__ != CL_VERSION_1_0)
+ float3 in_v;
+ in_v = vload3 (gid, in);
+ out_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);
+#else
+ float r = in[3 * gid + 0];
+ float g = in[3 * gid + 1];
+ float b = in[3 * gid + 2];
+ out_v = (float4)(gamma_2_2_to_linear(r),
+ gamma_2_2_to_linear(g),
+ gamma_2_2_to_linear(b),
+ 1.0f);
+#endif
+ out[gid] = out_v;
+}
+
/* -- R'G'B'A float -- */
/* rgba float -> r'g'b'a float */
@@ -409,6 +437,21 @@ __kernel void rgbaf_to_yaf (__global const float4 * in,
out[gid] = out_v;
}
+/* RaGaBaA float -> YA float */
+__kernel void ragabaf_to_yaf (__global const float4 * in,
+ __global float2 * out)
+{
+ int gid = get_global_id(0);
+ float4 in_v = in[gid];
+ float4 tmp_v = in_v / (float4) (in_v.w);
+
+ float luminance = tmp_v.x * RGB_LUMINANCE_RED +
+ tmp_v.y * RGB_LUMINANCE_GREEN +
+ tmp_v.z * RGB_LUMINANCE_BLUE;
+
+ out[gid] = (float2) (luminance, in_v.w);
+}
+
/* YA float -> RGBA float */
__kernel void yaf_to_rgbaf (__global const float2 * in,
__global float4 * out)
diff --git a/opencl/colors.cl.h b/opencl/colors.cl.h
index 43dd1a2..b5bc65a 100644
--- a/opencl/colors.cl.h
+++ b/opencl/colors.cl.h
@@ -177,6 +177,34 @@ static const char* colors_cl_source =
"#endif \n"
"} \n"
" \n"
+"/* -- R'G'B' float -- */ \n"
+" \n"
+"/* R'G'B' float -> RGBA float */ \n"
+"__kernel void rgb_gamma_f_to_rgbaf (__global const float * in, \n"
+" __global float4 * out) \n"
+"{ \n"
+" int gid = get_global_id(0); \n"
+" float4 out_v; \n"
+" \n"
+"#if (__OPENCL_VERSION__ != CL_VERSION_1_0) \n"
+" float3 in_v; \n"
+" in_v = vload3 (gid, in); \n"
+" out_v = (float4)(gamma_2_2_to_linear(in_v.x), \n"
+" gamma_2_2_to_linear(in_v.y), \n"
+" gamma_2_2_to_linear(in_v.z), \n"
+" 1.0f); \n"
+"#else \n"
+" float r = in[3 * gid + 0]; \n"
+" float g = in[3 * gid + 1]; \n"
+" float b = in[3 * gid + 2]; \n"
+" out_v = (float4)(gamma_2_2_to_linear(r), \n"
+" gamma_2_2_to_linear(g), \n"
+" gamma_2_2_to_linear(b), \n"
+" 1.0f); \n"
+"#endif \n"
+" out[gid] = out_v; \n"
+"} \n"
+" \n"
"/* -- R'G'B'A float -- */ \n"
" \n"
"/* rgba float -> r'g'b'a float */ \n"
@@ -410,6 +438,21 @@ static const char* colors_cl_source =
" out[gid] = out_v; \n"
"} \n"
" \n"
+"/* RaGaBaA float -> YA float */ \n"
+"__kernel void ragabaf_to_yaf (__global const float4 * in, \n"
+" __global float2 * out) \n"
+"{ \n"
+" int gid = get_global_id(0); \n"
+" float4 in_v = in[gid]; \n"
+" float4 tmp_v = in_v / (float4) (in_v.w); \n"
+" \n"
+" float luminance = tmp_v.x * RGB_LUMINANCE_RED + \n"
+" tmp_v.y * RGB_LUMINANCE_GREEN + \n"
+" tmp_v.z * RGB_LUMINANCE_BLUE; \n"
+" \n"
+" out[gid] = (float2) (luminance, in_v.w); \n"
+"} \n"
+" \n"
"/* YA float -> RGBA float */ \n"
"__kernel void yaf_to_rgbaf (__global const float2 * in, \n"
" __global float4 * out) \n"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]