3 "#line 1 \"libavfilter/opencl/unsharp.cl\"\n" 5 " * This file is part of FFmpeg.\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" 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" 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" 22 "__kernel void unsharp_global(__write_only image2d_t dst,\n" 23 " __read_only image2d_t src,\n" 27 " __constant float *coef_matrix)\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" 34 " float4 val = read_imagef(src, sampler, loc);\n" 35 " float4 sum = 0.0f;\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" 46 " write_imagef(dst, loc, val + (val - sum) * amount);\n" 49 "__kernel void unsharp_local(__write_only image2d_t dst,\n" 50 " __read_only image2d_t src,\n" 54 " __constant float *coef_x,\n" 55 " __constant float *coef_y)\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" 63 " __local float4 tmp[32][32];\n" 65 " int rad_x = size_x / 2;\n" 66 " int rad_y = size_y / 2;\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" 76 " barrier(CLK_LOCAL_MEM_FENCE);\n" 78 " float4 val = tmp[pos.y + 8][pos.x + 8];\n" 81 " for (y = 0; y <= 1; y++) {\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" 87 " barrier(CLK_LOCAL_MEM_FENCE);\n" 89 " for (y = 0; y <= 1; y++) {\n" 90 " tmp[pos.y + y * 16][pos.x + 8] = horiz[y];\n" 93 " barrier(CLK_LOCAL_MEM_FENCE);\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" 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" const char * ff_opencl_source_unsharp