FFmpeg
4.3
libavfilter
opencl
unsharp.c
Go to the documentation of this file.
1
// Generated from libavfilter/opencl/unsharp.cl
2
const
char
*
ff_opencl_source_unsharp
=
3
"#line 1 \"libavfilter/opencl/unsharp.cl\"\n"
4
"/*\n"
5
" * This file is part of FFmpeg.\n"
6
" *\n"
7
" * FFmpeg is free software; you can redistribute it and/or\n"
8
" * modify it under the terms of the GNU Lesser General Public\n"
9
" * License as published by the Free Software Foundation; either\n"
10
" * version 2.1 of the License, or (at your option) any later version.\n"
11
" *\n"
12
" * FFmpeg is distributed in the hope that it will be useful,\n"
13
" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
14
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
15
" * Lesser General Public License for more details.\n"
16
" *\n"
17
" * You should have received a copy of the GNU Lesser General Public\n"
18
" * License along with FFmpeg; if not, write to the Free Software\n"
19
" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
20
" */\n"
21
"\n"
22
"__kernel void unsharp_global(__write_only image2d_t dst,\n"
23
" __read_only image2d_t src,\n"
24
" int size_x,\n"
25
" int size_y,\n"
26
" float amount,\n"
27
" __constant float *coef_matrix)\n"
28
"{\n"
29
" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
30
" CLK_FILTER_NEAREST);\n"
31
" int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
32
" int2 centre = (int2)(size_x / 2, size_y / 2);\n"
33
"\n"
34
" float4 val = read_imagef(src, sampler, loc);\n"
35
" float4 sum = 0.0f;\n"
36
" int x, y;\n"
37
"\n"
38
" for (y = 0; y < size_y; y++) {\n"
39
" for (x = 0; x < size_x; x++) {\n"
40
" int2 pos = loc + (int2)(x, y) - centre;\n"
41
" sum += coef_matrix[y * size_x + x] *\n"
42
" read_imagef(src, sampler, pos);\n"
43
" }\n"
44
" }\n"
45
"\n"
46
" write_imagef(dst, loc, val + (val - sum) * amount);\n"
47
"}\n"
48
"\n"
49
"__kernel void unsharp_local(__write_only image2d_t dst,\n"
50
" __read_only image2d_t src,\n"
51
" int size_x,\n"
52
" int size_y,\n"
53
" float amount,\n"
54
" __constant float *coef_x,\n"
55
" __constant float *coef_y)\n"
56
"{\n"
57
" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
58
" CLK_ADDRESS_CLAMP_TO_EDGE |\n"
59
" CLK_FILTER_NEAREST);\n"
60
" int2 block = (int2)(get_group_id(0), get_group_id(1)) * 16;\n"
61
" int2 pos = (int2)(get_local_id(0), get_local_id(1));\n"
62
"\n"
63
" __local float4 tmp[32][32];\n"
64
"\n"
65
" int rad_x = size_x / 2;\n"
66
" int rad_y = size_y / 2;\n"
67
" int x, y;\n"
68
"\n"
69
" for (y = 0; y <= 1; y++) {\n"
70
" for (x = 0; x <= 1; x++) {\n"
71
" tmp[pos.y + 16 * y][pos.x + 16 * x] =\n"
72
" read_imagef(src, sampler, block + pos + (int2)(16 * x - 8, 16 * y - 8));\n"
73
" }\n"
74
" }\n"
75
"\n"
76
" barrier(CLK_LOCAL_MEM_FENCE);\n"
77
"\n"
78
" float4 val = tmp[pos.y + 8][pos.x + 8];\n"
79
"\n"
80
" float4 horiz[2];\n"
81
" for (y = 0; y <= 1; y++) {\n"
82
" horiz[y] = 0.0f;\n"
83
" for (x = 0; x < size_x; x++)\n"
84
" horiz[y] += coef_x[x] * tmp[pos.y + y * 16][pos.x + 8 + x - rad_x];\n"
85
" }\n"
86
"\n"
87
" barrier(CLK_LOCAL_MEM_FENCE);\n"
88
"\n"
89
" for (y = 0; y <= 1; y++) {\n"
90
" tmp[pos.y + y * 16][pos.x + 8] = horiz[y];\n"
91
" }\n"
92
"\n"
93
" barrier(CLK_LOCAL_MEM_FENCE);\n"
94
"\n"
95
" float4 sum = 0.0f;\n"
96
" for (y = 0; y < size_y; y++)\n"
97
" sum += coef_y[y] * tmp[pos.y + 8 + y - rad_y][pos.x + 8];\n"
98
"\n"
99
" if (block.x + pos.x < get_image_width(dst) &&\n"
100
" block.y + pos.y < get_image_height(dst))\n"
101
" write_imagef(dst, block + pos, val + (val - sum) * amount);\n"
102
"}\n"
103
;
ff_opencl_source_unsharp
const char * ff_opencl_source_unsharp
Definition:
unsharp.c:2
Generated on Tue Jun 16 2020 16:50:00 for FFmpeg by
1.8.17