[gegl] Fix opencl constrast-curve operation
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Fix opencl constrast-curve operation
- Date: Thu, 1 Oct 2015 16:34:15 +0000 (UTC)
commit dda2a7d50460b3c3a2c21499760446fbedd7eb81
Author: André Tupinambá <andrelrt gmail com>
Date: Sun Sep 20 10:46:37 2015 -0300
Fix opencl constrast-curve operation
opencl/contrast-curve.cl | 13 ++++---------
opencl/contrast-curve.cl.h | 13 ++++---------
2 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/opencl/contrast-curve.cl b/opencl/contrast-curve.cl
index 4abf13e..15f816c 100644
--- a/opencl/contrast-curve.cl
+++ b/opencl/contrast-curve.cl
@@ -23,16 +23,11 @@ __kernel void cl_contrast_curve(__global const float2 *in,
{
int gid = get_global_id(0);
float2 in_v = in[gid];
- int x = in_v.x * num_sampling_points;
- float y;
- if(x < 0)
- y = curve[0];
- else if (x < num_sampling_points)
- y = curve[x];
- else
- y = curve[num_sampling_points - 1];
+ int idx = (int) fmin(num_sampling_points - 1,
+ fmax(0f,
+ in_v.x * num_sampling_points));
- out[gid] = (float2) (y, in_v.y);
+ out[gid] = (float2) (curve[idx], in_v.y);
}
diff --git a/opencl/contrast-curve.cl.h b/opencl/contrast-curve.cl.h
index 7912cd7..a6903c7 100644
--- a/opencl/contrast-curve.cl.h
+++ b/opencl/contrast-curve.cl.h
@@ -24,16 +24,11 @@ static const char* contrast_curve_cl_source =
"{ \n"
" int gid = get_global_id(0); \n"
" float2 in_v = in[gid]; \n"
-" int x = in_v.x * num_sampling_points; \n"
-" float y; \n"
" \n"
-" if(x < 0) \n"
-" y = curve[0]; \n"
-" else if (x < num_sampling_points) \n"
-" y = curve[x]; \n"
-" else \n"
-" y = curve[num_sampling_points - 1]; \n"
+" int idx = (int) fmin(num_sampling_points - 1, \n"
+" fmax(0f, \n"
+" in_v.x * num_sampling_points)); \n"
" \n"
-" out[gid] = (float2) (y, in_v.y); \n"
+" out[gid] = (float2) (curve[idx], in_v.y); \n"
"} \n"
;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]