diff options
author | Daniel Sabo <DanielSabo@gmail.com> | 2013-11-02 15:56:19 -0700 |
---|---|---|
committer | Daniel Sabo <DanielSabo@gmail.com> | 2013-11-02 17:39:07 -0700 |
commit | e90df9bc4d11087c6089746fd22739a71912d71d (patch) | |
tree | 872be0ef82a94a752e2df58fbd3497fe7a7590f6 /opencl | |
parent | 059646e6609cc3ff32c51ec0c29f033858381747 (diff) |
colors.cl: Add some conversions
Diffstat (limited to 'opencl')
-rw-r--r-- | opencl/colors.cl | 44 | ||||
-rw-r--r-- | opencl/colors.cl.h | 44 |
2 files changed, 88 insertions, 0 deletions
diff --git a/opencl/colors.cl b/opencl/colors.cl index 382cee9e..9448a6d5 100644 --- a/opencl/colors.cl +++ b/opencl/colors.cl @@ -66,6 +66,23 @@ __kernel void rgbaf_to_rgbau8 (__global const float4 * in, out[gid] = convert_uchar4_sat_rte(255.0f * out_v); } + +/* RGBA float -> RGB float */ +__kernel void rgbaf_to_rgbf (__global const float4 * in, + __global float * out) +{ + int gid = get_global_id(0); + float4 in_v = in[gid]; + +#if (__OPENCL_VERSION__ != CL_VERSION_1_0) + vstore3 (in_v.xyz, gid, out); +#else + out[3 * gid] = in_v.x; + out[3 * gid + 1] = in_v.y; + out[3 * gid + 2] = in_v.z; +#endif +} + /* -- RaGaBaA float -- */ /* RGBA float -> RaGaBaA float */ @@ -354,6 +371,19 @@ __kernel void yu8_to_yf (__global const uchar * in, out[gid] = out_v; } +/* -- Y float -- */ + +/* Y float -> RaGaBaA float */ +__kernel void yf_to_ragabaf (__global const float * in, + __global float4 * out) +{ + int gid = get_global_id(0); + float y = in[gid]; + float4 out_v = (float4) (y, y, y, 1.0f); + + out[gid] = out_v; +} + /* -- YA float -- */ /* babl reference file: babl/base/rgb-constants.h */ @@ -390,6 +420,20 @@ __kernel void yaf_to_rgbaf (__global const float2 * in, out[gid] = out_v; } +/* YA float -> RaGaBaA float */ +__kernel void yaf_to_ragabaf (__global const float2 * in, + __global float4 * out) +{ + int gid = get_global_id(0); + float2 in_v = in[gid]; + float4 out_v = (float4) (in_v.x * in_v.y, + in_v.x * in_v.y, + in_v.x * in_v.y, + in_v.y); + + out[gid] = out_v; +} + /* RGBA u8 -> YA float */ __kernel void rgbau8_to_yaf (__global const uchar4 * in, __global float2 * out) diff --git a/opencl/colors.cl.h b/opencl/colors.cl.h index 1acbbc68..43dd1a2f 100644 --- a/opencl/colors.cl.h +++ b/opencl/colors.cl.h @@ -67,6 +67,23 @@ static const char* colors_cl_source = " out[gid] = convert_uchar4_sat_rte(255.0f * out_v); \n" "} \n" " \n" +" \n" +"/* RGBA float -> RGB float */ \n" +"__kernel void rgbaf_to_rgbf (__global const float4 * in, \n" +" __global float * out) \n" +"{ \n" +" int gid = get_global_id(0); \n" +" float4 in_v = in[gid]; \n" +" \n" +"#if (__OPENCL_VERSION__ != CL_VERSION_1_0) \n" +" vstore3 (in_v.xyz, gid, out); \n" +"#else \n" +" out[3 * gid] = in_v.x; \n" +" out[3 * gid + 1] = in_v.y; \n" +" out[3 * gid + 2] = in_v.z; \n" +"#endif \n" +"} \n" +" \n" "/* -- RaGaBaA float -- */ \n" " \n" "/* RGBA float -> RaGaBaA float */ \n" @@ -355,6 +372,19 @@ static const char* colors_cl_source = " out[gid] = out_v; \n" "} \n" " \n" +"/* -- Y float -- */ \n" +" \n" +"/* Y float -> RaGaBaA float */ \n" +"__kernel void yf_to_ragabaf (__global const float * in, \n" +" __global float4 * out) \n" +"{ \n" +" int gid = get_global_id(0); \n" +" float y = in[gid]; \n" +" float4 out_v = (float4) (y, y, y, 1.0f); \n" +" \n" +" out[gid] = out_v; \n" +"} \n" +" \n" "/* -- YA float -- */ \n" " \n" "/* babl reference file: babl/base/rgb-constants.h */ \n" @@ -391,6 +421,20 @@ static const char* colors_cl_source = " out[gid] = out_v; \n" "} \n" " \n" +"/* YA float -> RaGaBaA float */ \n" +"__kernel void yaf_to_ragabaf (__global const float2 * in, \n" +" __global float4 * out) \n" +"{ \n" +" int gid = get_global_id(0); \n" +" float2 in_v = in[gid]; \n" +" float4 out_v = (float4) (in_v.x * in_v.y, \n" +" in_v.x * in_v.y, \n" +" in_v.x * in_v.y, \n" +" in_v.y); \n" +" \n" +" out[gid] = out_v; \n" +"} \n" +" \n" "/* RGBA u8 -> YA float */ \n" "__kernel void rgbau8_to_yaf (__global const uchar4 * in, \n" " __global float2 * out) \n" |