FFmpeg
Loading...
Searching...
No Matches
neighbor.c
Go to the documentation of this file.
1// Generated from libavfilter/opencl/neighbor.cl
3"/*\n"
4" * Copyright (c) 2018 Danil Iashchenko\n"
5" *\n"
6" * This file is part of FFmpeg.\n"
7" *\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"
12" *\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"
17" *\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"
21" */\n"
22"\n"
23"\n"
24"__kernel void erosion_global(__write_only image2d_t dst,\n"
25" __read_only image2d_t src,\n"
26" float threshold,\n"
27" __constant int *coord)\n"
28"{\n"
29" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
30" CLK_ADDRESS_CLAMP_TO_EDGE |\n"
31" CLK_FILTER_NEAREST);\n"
32"\n"
33" int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
34"\n"
35" float4 px = read_imagef(src, sampler, loc);\n"
36" float limit = px.x - threshold;\n"
37" if (limit < 0) {\n"
38" limit = 0;\n"
39" }\n"
40"\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"
46" px = cur;\n"
47" }\n"
48" }\n"
49" }\n"
50" }\n"
51" if (limit > px.x) {\n"
52" px = (float4)(limit);\n"
53" }\n"
54" write_imagef(dst, loc, px);\n"
55"}\n"
56"\n"
57"\n"
58"__kernel void dilation_global(__write_only image2d_t dst,\n"
59" __read_only image2d_t src,\n"
60" float threshold,\n"
61" __constant int *coord)\n"
62"{\n"
63" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
64" CLK_ADDRESS_CLAMP_TO_EDGE |\n"
65" CLK_FILTER_NEAREST);\n"
66"\n"
67" int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
68"\n"
69" float4 px = read_imagef(src, sampler, loc);\n"
70" float limit = px.x + threshold;\n"
71" if (limit > 1) {\n"
72" limit = 1;\n"
73" }\n"
74"\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"
80" px = cur;\n"
81" }\n"
82" }\n"
83" }\n"
84" }\n"
85" if (limit < px.x) {\n"
86" px = (float4)(limit);\n"
87" }\n"
88" write_imagef(dst, loc, px);\n"
89"}\n"
90;
const char * ff_source_neighbor_cl
Definition neighbor.c:2