This file is indexed.

/usr/share/ufo/ufo-basic-ops.cl is in libufo-data 0.15.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
const sampler_t imageSampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
const sampler_t imageSampler2 = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

__kernel
void operation_set (__write_only image2d_t out,
                    const float value)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  write_imagef(out, coord_w, value);
}

__kernel
void operation_inv (__read_only image2d_t in,
                 		__write_only image2d_t out)
{
	const uint X = get_global_id(0);
	const uint Y = get_global_id(1);

 	float2 coord_r;
	coord_r.x = (float)X + 0.5f;
	coord_r.y = (float)Y + 0.5f;

	int2 coord_w;
	coord_w.x = X;
	coord_w.y = Y;

	float value = read_imagef(in, imageSampler, coord_r).s0;
  value = (value != 0)? 1.0f / value : 0;
  write_imagef(out, coord_w, value);
}

__kernel
void operation_mul (__read_only image2d_t arg1_r,
                    __read_only image2d_t arg2_r,
                    __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  float2 coord_r;
  coord_r.x = (float)X + 0.5f;
  coord_r.y = (float)Y + 0.5f;

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float value = read_imagef(arg1_r, imageSampler, coord_r).s0 *
                read_imagef(arg2_r, imageSampler, coord_r).s0;

  write_imagef(out, coord_w, value);
}

__kernel
void operation_add (__read_only image2d_t arg1_r,
                    __read_only image2d_t arg2_r,
                    __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  float2 coord_r;
  coord_r.x = (float)X + 0.5f;
  coord_r.y = (float)Y + 0.5f;

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float value = read_imagef(arg1_r, imageSampler, coord_r).s0 +
                read_imagef(arg2_r, imageSampler, coord_r).s0;

  write_imagef(out, coord_w, value);
}

__kernel
void operation_deduction (__read_only image2d_t arg1_r,
                          __read_only image2d_t arg2_r,
                          __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  float2 coord_r;
  coord_r.x = (float)X + 0.5f;
  coord_r.y = (float)Y + 0.5f;

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float value = read_imagef(arg1_r, imageSampler, coord_r).s0 -
                read_imagef(arg2_r, imageSampler, coord_r).s0;

  write_imagef(out, coord_w, value);
}

__kernel
void operation_deduction2 (__read_only image2d_t arg1_r,
                           __read_only image2d_t arg2_r,
                           const float  modifier,
                           __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  float2 coord_r;
  coord_r.x = (float)X + 0.5f;
  coord_r.y = (float)Y + 0.5f;

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float value = read_imagef(arg1_r, imageSampler, coord_r).s0 -
                modifier * read_imagef(arg2_r, imageSampler, coord_r).s0;

  write_imagef(out, coord_w, value);
}

__kernel
void operation_add2 (__read_only image2d_t arg1_r,
                     __read_only image2d_t arg2_r,
                     const float  modifier,
                     __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  float2 coord_r;
  coord_r.x = (float)X + 0.5f;
  coord_r.y = (float)Y + 0.5f;

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float value = read_imagef(arg1_r, imageSampler, coord_r).s0 +
                modifier * read_imagef(arg2_r, imageSampler, coord_r).s0;

  write_imagef(out, coord_w, value);
}

__kernel
void op_mulRows (__read_only  image2d_t arg1_r,
                 __read_only  image2d_t arg2_r,
                 __write_only image2d_t out,
                const uint    offset)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  float2 coord_r;
  coord_r.x = (float)X + 0.5f;
  coord_r.y = (float)offset + (float)Y + 0.5f;

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = offset + Y;

  float value = read_imagef(arg1_r, imageSampler, coord_r).s0 *
                read_imagef(arg2_r, imageSampler, coord_r).s0;

  write_imagef(out, coord_w, value);
}

__kernel
void operation_gradient_magnitude (__read_only image2d_t arg_r,
                                   __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float2 coord_r[5];
  coord_r[0].x = (float)X + 0.5f;
  coord_r[0].y = (float)Y + 0.5f;
  coord_r[1].x = coord_r[0].x + 1;
  coord_r[1].y = coord_r[0].y;
  coord_r[2].x = coord_r[0].x - 1;
  coord_r[2].y = coord_r[0].y;
  coord_r[3].x = coord_r[0].x;
  coord_r[3].y = coord_r[0].y + 1;
  coord_r[4].x = coord_r[0].x;
  coord_r[4].y = coord_r[0].y - 1;

  float cell_value = read_imagef(arg_r, imageSampler2, coord_r[0]).s0;
  float d1 = read_imagef(arg_r, imageSampler2, coord_r[1]).s0 - cell_value;
  float d2 = read_imagef(arg_r, imageSampler2, coord_r[2]).s0 - cell_value;
  float d3 = read_imagef(arg_r, imageSampler2, coord_r[3]).s0 - cell_value;
  float d4 = read_imagef(arg_r, imageSampler2, coord_r[4]).s0 - cell_value;

  float value = sqrt ( (pow (d1, 2) + pow (d2, 2) + pow (d3, 2) + pow (d4, 2)) / 2.0f);
  write_imagef(out, coord_w, value);
}

__kernel
void operation_gradient_direction (__read_only image2d_t arg_r,
                                   __read_only image2d_t magnitude,
                                   __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float2 coord_r[5];
  coord_r[0].x = (float)X + 0.5f;
  coord_r[0].y = (float)Y + 0.5f;
  coord_r[1].x = coord_r[0].x + 1;
  coord_r[1].y = coord_r[0].y;
  coord_r[2].x = coord_r[0].x - 1;
  coord_r[2].y = coord_r[0].y;
  coord_r[3].x = coord_r[0].x;
  coord_r[3].y = coord_r[0].y + 1;
  coord_r[4].x = coord_r[0].x;
  coord_r[4].y = coord_r[0].y - 1;

  float values[5];
  values[0] = read_imagef(arg_r, imageSampler2, coord_r[0]).s0;
  values[1] = read_imagef(arg_r, imageSampler2, coord_r[1]).s0;
  values[2] = read_imagef(arg_r, imageSampler2, coord_r[2]).s0;
  values[3] = read_imagef(arg_r, imageSampler2, coord_r[3]).s0;
  values[4] = read_imagef(arg_r, imageSampler2, coord_r[4]).s0;

  float magnitudes[5];
  magnitudes[0] = read_imagef(magnitude, imageSampler2, coord_r[0]).s0;
  magnitudes[1] = read_imagef(magnitude, imageSampler2, coord_r[1]).s0;
  magnitudes[2] = read_imagef(magnitude, imageSampler2, coord_r[2]).s0;
  magnitudes[3] = read_imagef(magnitude, imageSampler2, coord_r[3]).s0;
  magnitudes[4] = read_imagef(magnitude, imageSampler2, coord_r[4]).s0;

  float direction = 0;
  if (magnitudes[0]) direction += (4 * values[0] - values[1] - values[2] - values[3] - values[4]) / magnitudes[0];
  if (magnitudes[1]) direction += (values[0] - values[1]) / magnitudes[1];
  if (magnitudes[2]) direction += (values[0] - values[2]) / magnitudes[2];
  if (magnitudes[3]) direction += (values[0] - values[3]) / magnitudes[3];
  if (magnitudes[4]) direction += (values[0] - values[4]) / magnitudes[4];

  write_imagef(out, coord_w, direction);
}


__kernel
void POSC (__read_only image2d_t arg_r,
           __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float2 coord_r;
  coord_r.x = X + 0.5f;
  coord_r.y = Y + 0.5f;

  float value = read_imagef(arg_r, imageSampler2, coord_r).s0;
  value = value > 0 ? value : 0;
  write_imagef(out, coord_w, value);
}

__kernel
void descent_grad (__read_only image2d_t arg_r,
                   __write_only image2d_t out)
{
  const uint X = get_global_id(0);
  const uint Y = get_global_id(1);

  int2 coord_w;
  coord_w.x = X;
  coord_w.y = Y;

  float2 coord_r[7];
  coord_r[0].x = X;
  coord_r[0].y = Y;
  coord_r[1].x = coord_r[0].x - 1;
  coord_r[1].y = coord_r[0].y;
  coord_r[2].x = coord_r[0].x;
  coord_r[2].y = coord_r[0].y - 1;
  coord_r[3].x = coord_r[0].x + 1;
  coord_r[3].y = coord_r[0].y;
  coord_r[4].x = coord_r[0].x;
  coord_r[4].y = coord_r[0].y + 1;
  coord_r[5].x = coord_r[0].x + 1;
  coord_r[5].y = coord_r[0].y - 1;
  coord_r[6].x = coord_r[0].x - 1;
  coord_r[6].y = coord_r[0].y + 1;

  float eps = 1E-8;
  float values[7];
  values[0] = read_imagef(arg_r, imageSampler2, coord_r[0]).s0;
  values[1] = read_imagef(arg_r, imageSampler2, coord_r[1]).s0;
  values[2] = read_imagef(arg_r, imageSampler2, coord_r[2]).s0;
  values[3] = read_imagef(arg_r, imageSampler2, coord_r[3]).s0;
  values[4] = read_imagef(arg_r, imageSampler2, coord_r[4]).s0;
  values[5] = read_imagef(arg_r, imageSampler2, coord_r[5]).s0;
  values[6] = read_imagef(arg_r, imageSampler2, coord_r[6]).s0;

  float t1, t2;
  float part[3];
  t1 = values[0] - values[1];
  t2 = values[0] - values[2];
  part[0] = (t1 + t2) / sqrt(eps + pow(t1, 2) + pow (t2, 2));
  t1 = values[3] - values[0];
  t2 = values[3] - values[5];
  part[1] = t1 / sqrt(eps + pow(t1, 2) + pow (t2, 2));
  t1 = values[4] - values[0];
  t2 = values[4] - values[6];
  part[2] = t1 / sqrt(eps + pow(t1, 2) + pow (t2, 2));

  float value = part[0] - part[1] - part[2];
  write_imagef(out, coord_w, value);
}