3 "#line 1 \"libavfilter/opencl/neighbor.cl\"\n"
5 " * Copyright (c) 2018 Danil Iashchenko\n"
7 " * This file is part of FFmpeg.\n"
9 " * FFmpeg is free software; you can redistribute it and/or\n"
10 " * modify it under the terms of the GNU Lesser General Public\n"
11 " * License as published by the Free Software Foundation; either\n"
12 " * version 2.1 of the License, or (at your option) any later version.\n"
14 " * FFmpeg is distributed in the hope that it will be useful,\n"
15 " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
16 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
17 " * Lesser General Public License for more details.\n"
19 " * You should have received a copy of the GNU Lesser General Public\n"
20 " * License along with FFmpeg; if not, write to the Free Software\n"
21 " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
25 "__kernel void erosion_global(__write_only image2d_t dst,\n"
26 " __read_only image2d_t src,\n"
28 " __constant int *coord)\n"
30 " const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
31 " CLK_ADDRESS_CLAMP_TO_EDGE |\n"
32 " CLK_FILTER_NEAREST);\n"
34 " int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
36 " float4 px = read_imagef(src, sampler, loc);\n"
37 " float limit = px.x - threshold;\n"
42 " for (int i = -1; i <= 1; i++) {\n"
43 " for (int j = -1; j <= 1; j++) {\n"
44 " if (coord[(j + 1) * 3 + (i + 1)] == 1) {\n"
45 " float4 cur = read_imagef(src, sampler, loc + (int2)(i, j));\n"
46 " if (cur.x < px.x) {\n"
52 " if (limit > px.x) {\n"
53 " px = (float4)(limit);\n"
55 " write_imagef(dst, loc, px);\n"
59 "__kernel void dilation_global(__write_only image2d_t dst,\n"
60 " __read_only image2d_t src,\n"
62 " __constant int *coord)\n"
64 " const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
65 " CLK_ADDRESS_CLAMP_TO_EDGE |\n"
66 " CLK_FILTER_NEAREST);\n"
68 " int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
70 " float4 px = read_imagef(src, sampler, loc);\n"
71 " float limit = px.x + threshold;\n"
76 " for (int i = -1; i <= 1; i++) {\n"
77 " for (int j = -1; j <= 1; j++) {\n"
78 " if (coord[(j + 1) * 3 + (i + 1)] == 1) {\n"
79 " float4 cur = read_imagef(src, sampler, loc + (int2)(i, j));\n"
80 " if (cur.x > px.x) {\n"
86 " if (limit < px.x) {\n"
87 " px = (float4)(limit);\n"
89 " write_imagef(dst, loc, px);\n"
const char * ff_opencl_source_neighbor