diff options
Diffstat (limited to 'opencl/mono-mixer.cl.h')
-rw-r--r-- | opencl/mono-mixer.cl.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/opencl/mono-mixer.cl.h b/opencl/mono-mixer.cl.h index 7b2fbc83..7a655ac1 100644 --- a/opencl/mono-mixer.cl.h +++ b/opencl/mono-mixer.cl.h @@ -3,11 +3,23 @@ static const char* mono_mixer_cl_source = " __global float2 *dst_buf, \n" " float red, \n" " float green, \n" -" float blue) \n" +" float blue, \n" +" const int preserve_luminocity) \n" "{ \n" " int gid = get_global_id(0); \n" " float4 in_v = src_buf[gid]; \n" -" dst_buf[gid].x = in_v.x * red + in_v.y * green + in_v.z * blue; \n" +" float norm_factor = 1.0f; \n" +" \n" +" if (preserve_luminocity) \n" +" { \n" +" float sum = red + green + blue; \n" +" if (sum == 0.0) \n" +" norm_factor = 1.0f; \n" +" else \n" +" norm_factor = fabs (1.0f / sum); \n" +" } \n" +" \n" +" dst_buf[gid].x = (in_v.x * red + in_v.y * green + in_v.z * blue) * norm_factor;\n" " dst_buf[gid].y = in_v.w; \n" "} \n" ; |