4" * Copyright (c) 2018 Danil Iashchenko\n"
6" * This file is part of FFmpeg.\n"
8" * FFmpeg is free software; you can redistribute it and/or\n"
9" * modify it under the terms of the GNU Lesser General Public\n"
10" * License as published by the Free Software Foundation; either\n"
11" * version 2.1 of the License, or (at your option) any later version.\n"
13" * FFmpeg is distributed in the hope that it will be useful,\n"
14" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
15" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
16" * Lesser General Public License for more details.\n"
18" * You should have received a copy of the GNU Lesser General Public\n"
19" * License along with FFmpeg; if not, write to the Free Software\n"
20" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
24"__kernel void erosion_global(__write_only image2d_t dst,\n"
25" __read_only image2d_t src,\n"
27" __constant int *coord)\n"
29" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
30" CLK_ADDRESS_CLAMP_TO_EDGE |\n"
31" CLK_FILTER_NEAREST);\n"
33" int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
35" float4 px = read_imagef(src, sampler, loc);\n"
36" float limit = px.x - threshold;\n"
41" for (int i = -1; i <= 1; i++) {\n"
42" for (int j = -1; j <= 1; j++) {\n"
43" if (coord[(j + 1) * 3 + (i + 1)] == 1) {\n"
44" float4 cur = read_imagef(src, sampler, loc + (int2)(i, j));\n"
45" if (cur.x < px.x) {\n"
51" if (limit > px.x) {\n"
52" px = (float4)(limit);\n"
54" write_imagef(dst, loc, px);\n"
58"__kernel void dilation_global(__write_only image2d_t dst,\n"
59" __read_only image2d_t src,\n"
61" __constant int *coord)\n"
63" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
64" CLK_ADDRESS_CLAMP_TO_EDGE |\n"
65" CLK_FILTER_NEAREST);\n"
67" int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
69" float4 px = read_imagef(src, sampler, loc);\n"
70" float limit = px.x + threshold;\n"
75" for (int i = -1; i <= 1; i++) {\n"
76" for (int j = -1; j <= 1; j++) {\n"
77" if (coord[(j + 1) * 3 + (i + 1)] == 1) {\n"
78" float4 cur = read_imagef(src, sampler, loc + (int2)(i, j));\n"
79" if (cur.x > px.x) {\n"
85" if (limit < px.x) {\n"
86" px = (float4)(limit);\n"
88" write_imagef(dst, loc, px);\n"
const char * ff_source_neighbor_cl