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