4" * This file is part of FFmpeg.\n"
6" * FFmpeg is free software; you can redistribute it and/or\n"
7" * modify it under the terms of the GNU Lesser General Public\n"
8" * License as published by the Free Software Foundation; either\n"
9" * version 2.1 of the License, or (at your option) any later version.\n"
11" * FFmpeg is distributed in the hope that it will be useful,\n"
12" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
13" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
14" * Lesser General Public License for more details.\n"
16" * You should have received a copy of the GNU Lesser General Public\n"
17" * License along with FFmpeg; if not, write to the Free Software\n"
18" * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
21"__kernel void unsharp_global(__write_only image2d_t dst,\n"
22" __read_only image2d_t src,\n"
26" __constant float *coef_matrix)\n"
28" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
29" CLK_FILTER_NEAREST);\n"
30" int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
31" int2 centre = (int2)(size_x / 2, size_y / 2);\n"
33" float4 val = read_imagef(src, sampler, loc);\n"
34" float4 sum = 0.0f;\n"
37" for (y = 0; y < size_y; y++) {\n"
38" for (x = 0; x < size_x; x++) {\n"
39" int2 pos = loc + (int2)(x, y) - centre;\n"
40" sum += coef_matrix[y * size_x + x] *\n"
41" read_imagef(src, sampler, pos);\n"
45" write_imagef(dst, loc, val + (val - sum) * amount);\n"
48"__kernel void unsharp_local(__write_only image2d_t dst,\n"
49" __read_only image2d_t src,\n"
53" __constant float *coef_x,\n"
54" __constant float *coef_y)\n"
56" const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
57" CLK_ADDRESS_CLAMP_TO_EDGE |\n"
58" CLK_FILTER_NEAREST);\n"
59" int2 block = (int2)(get_group_id(0), get_group_id(1)) * 16;\n"
60" int2 pos = (int2)(get_local_id(0), get_local_id(1));\n"
62" __local float4 tmp[32][32];\n"
64" int rad_x = size_x / 2;\n"
65" int rad_y = size_y / 2;\n"
68" for (y = 0; y <= 1; y++) {\n"
69" for (x = 0; x <= 1; x++) {\n"
70" tmp[pos.y + 16 * y][pos.x + 16 * x] =\n"
71" read_imagef(src, sampler, block + pos + (int2)(16 * x - 8, 16 * y - 8));\n"
75" barrier(CLK_LOCAL_MEM_FENCE);\n"
77" float4 val = tmp[pos.y + 8][pos.x + 8];\n"
80" for (y = 0; y <= 1; y++) {\n"
82" for (x = 0; x < size_x; x++)\n"
83" horiz[y] += coef_x[x] * tmp[pos.y + y * 16][pos.x + 8 + x - rad_x];\n"
86" barrier(CLK_LOCAL_MEM_FENCE);\n"
88" for (y = 0; y <= 1; y++) {\n"
89" tmp[pos.y + y * 16][pos.x + 8] = horiz[y];\n"
92" barrier(CLK_LOCAL_MEM_FENCE);\n"
94" float4 sum = 0.0f;\n"
95" for (y = 0; y < size_y; y++)\n"
96" sum += coef_y[y] * tmp[pos.y + 8 + y - rad_y][pos.x + 8];\n"
98" if (block.x + pos.x < get_image_width(dst) &&\n"
99" block.y + pos.y < get_image_height(dst))\n"
100" write_imagef(dst, block + pos, val + (val - sum) * amount);\n"
const char * ff_source_unsharp_cl