FFmpeg  4.1
overlay.c
Go to the documentation of this file.
1 // Generated from libavfilter/opencl/overlay.cl
3 "#line 1 \"libavfilter/opencl/overlay.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 overlay_no_alpha(__write_only image2d_t dst,\n"
23 " __read_only image2d_t main,\n"
24 " __read_only image2d_t overlay,\n"
25 " int x_position,\n"
26 " int y_position)\n"
27 "{\n"
28 " const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
29 " CLK_FILTER_NEAREST);\n"
30 "\n"
31 " int2 overlay_size = get_image_dim(overlay);\n"
32 " int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
33 "\n"
34 " if (loc.x < x_position ||\n"
35 " loc.y < y_position ||\n"
36 " loc.x >= overlay_size.x + x_position ||\n"
37 " loc.y >= overlay_size.y + y_position) {\n"
38 " float4 val = read_imagef(main, sampler, loc);\n"
39 " write_imagef(dst, loc, val);\n"
40 " } else {\n"
41 " int2 loc_overlay = (int2)(x_position, y_position);\n"
42 " float4 val = read_imagef(overlay, sampler, loc - loc_overlay);\n"
43 " write_imagef(dst, loc, val);\n"
44 " }\n"
45 "}\n"
46 "\n"
47 "__kernel void overlay_internal_alpha(__write_only image2d_t dst,\n"
48 " __read_only image2d_t main,\n"
49 " __read_only image2d_t overlay,\n"
50 " int x_position,\n"
51 " int y_position)\n"
52 "{\n"
53 " const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
54 " CLK_FILTER_NEAREST);\n"
55 "\n"
56 " int2 overlay_size = get_image_dim(overlay);\n"
57 " int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
58 "\n"
59 " if (loc.x < x_position ||\n"
60 " loc.y < y_position ||\n"
61 " loc.x >= overlay_size.x + x_position ||\n"
62 " loc.y >= overlay_size.y + y_position) {\n"
63 " float4 val = read_imagef(main, sampler, loc);\n"
64 " write_imagef(dst, loc, val);\n"
65 " } else {\n"
66 " int2 loc_overlay = (int2)(x_position, y_position);\n"
67 " float4 in_main = read_imagef(main, sampler, loc);\n"
68 " float4 in_overlay = read_imagef(overlay, sampler, loc - loc_overlay);\n"
69 " float4 val = in_overlay * in_overlay.w + in_main * (1.0f - in_overlay.w);\n"
70 " write_imagef(dst, loc, val);\n"
71 " }\n"
72 "}\n"
73 "\n"
74 "__kernel void overlay_external_alpha(__write_only image2d_t dst,\n"
75 " __read_only image2d_t main,\n"
76 " __read_only image2d_t overlay,\n"
77 " __read_only image2d_t alpha,\n"
78 " int x_position,\n"
79 " int y_position,\n"
80 " int alpha_adj_x,\n"
81 " int alpha_adj_y)\n"
82 "{\n"
83 " const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
84 " CLK_FILTER_NEAREST);\n"
85 "\n"
86 " int2 overlay_size = get_image_dim(overlay);\n"
87 " int2 loc = (int2)(get_global_id(0), get_global_id(1));\n"
88 "\n"
89 " if (loc.x < x_position ||\n"
90 " loc.y < y_position ||\n"
91 " loc.x >= overlay_size.x + x_position ||\n"
92 " loc.y >= overlay_size.y + y_position) {\n"
93 " float4 val = read_imagef(main, sampler, loc);\n"
94 " write_imagef(dst, loc, val);\n"
95 " } else {\n"
96 " int2 loc_overlay = (int2)(x_position, y_position);\n"
97 " float4 in_main = read_imagef(main, sampler, loc);\n"
98 " float4 in_overlay = read_imagef(overlay, sampler, loc - loc_overlay);\n"
99 "\n"
100 " int2 loc_alpha = (int2)(loc.x * alpha_adj_x,\n"
101 " loc.y * alpha_adj_y) - loc_overlay;\n"
102 " float4 in_alpha = read_imagef(alpha, sampler, loc_alpha);\n"
103 "\n"
104 " float4 val = in_overlay * in_alpha.x + in_main * (1.0f - in_alpha.x);\n"
105 " write_imagef(dst, loc, val);\n"
106 " }\n"
107 "}\n"
108 ;
const char * ff_opencl_source_overlay
Definition: overlay.c:2