FFmpeg  4.0.2
convolution.c
Go to the documentation of this file.
1 // Generated from libavfilter/opencl/convolution.cl
3 "#line 1 \"libavfilter/opencl/convolution.cl\"\n"
4 "/*\n"
5 " * Copyright (c) 2018 Danil Iashchenko\n"
6 " *\n"
7 " * This file is part of FFmpeg.\n"
8 " *\n"
9 " * FFmpeg is free software; you can redistribute it and/or\n"
10 " * modify it under the terms of the GNU Lesser General Public\n"
11 " * License as published by the Free Software Foundation; either\n"
12 " * version 2.1 of the License, or (at your option) any later version.\n"
13 " *\n"
14 " * FFmpeg is distributed in the hope that it will be useful,\n"
15 " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
16 " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
17 " * Lesser General Public License for more details.\n"
18 " *\n"
19 " * You should have received a copy of the GNU Lesser General Public\n"
20 " * License along with FFmpeg; if not, write to the Free Software\n"
21 " * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
22 " */\n"
23 "\n"
24 "__kernel void convolution_global(__write_only image2d_t dst,\n"
25 " __read_only image2d_t src,\n"
26 " int coef_matrix_dim,\n"
27 " __constant float *coef_matrix,\n"
28 " float div,\n"
29 " float bias)\n"
30 "{\n"
31 " const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
32 " CLK_ADDRESS_CLAMP_TO_EDGE |\n"
33 " CLK_FILTER_NEAREST);\n"
34 "\n"
35 " const int half_matrix_dim = (coef_matrix_dim / 2);\n"
36 " int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
37 " float4 convPix = (float4)(0.0f, 0.0f, 0.0f, 0.0f);\n"
38 "\n"
39 " for (int conv_i = -half_matrix_dim; conv_i <= half_matrix_dim; conv_i++) {\n"
40 " for (int conv_j = -half_matrix_dim; conv_j <= half_matrix_dim; conv_j++) {\n"
41 " float4 px = read_imagef(src, sampler, loc + (int2)(conv_j, conv_i));\n"
42 " convPix += px * coef_matrix[(conv_i + half_matrix_dim) * coef_matrix_dim +\n"
43 " (conv_j + half_matrix_dim)];\n"
44 " }\n"
45 " }\n"
46 " float4 dstPix = convPix * div + bias;\n"
47 " write_imagef(dst, loc, dstPix);\n"
48 "}\n"
49 ;
const char * ff_opencl_source_convolution
Definition: convolution.c:2