3 "#line 1 \"libavfilter/opencl/xfade.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 "const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |\n"
23 " CLK_FILTER_NEAREST);\n"
25 "__kernel void fade(__write_only image2d_t dst,\n"
26 " __read_only image2d_t src1,\n"
27 " __read_only image2d_t src2,\n"
30 " int2 p = (int2)(get_global_id(0), get_global_id(1));\n"
32 " float4 val1 = read_imagef(src1, sampler, p);\n"
33 " float4 val2 = read_imagef(src2, sampler, p);\n"
35 " write_imagef(dst, p, mix(val2, val1, progress));\n"
38 "__kernel void wipeleft(__write_only image2d_t dst,\n"
39 " __read_only image2d_t src1,\n"
40 " __read_only image2d_t src2,\n"
43 " int s = (int)(get_image_dim(src1).x * progress);\n"
44 " int2 p = (int2)(get_global_id(0), get_global_id(1));\n"
46 " float4 val1 = read_imagef(src1, sampler, p);\n"
47 " float4 val2 = read_imagef(src2, sampler, p);\n"
49 " write_imagef(dst, p, p.x > s ? val2 : val1);\n"
52 "__kernel void wiperight(__write_only image2d_t dst,\n"
53 " __read_only image2d_t src1,\n"
54 " __read_only image2d_t src2,\n"
57 " int s = (int)(get_image_dim(src1).x * (1.f - progress));\n"
58 " int2 p = (int2)(get_global_id(0), get_global_id(1));\n"
60 " float4 val1 = read_imagef(src1, sampler, p);\n"
61 " float4 val2 = read_imagef(src2, sampler, p);\n"
63 " write_imagef(dst, p, p.x > s ? val1 : val2);\n"
66 "__kernel void wipeup(__write_only image2d_t dst,\n"
67 " __read_only image2d_t src1,\n"
68 " __read_only image2d_t src2,\n"
71 " int s = (int)(get_image_dim(src1).y * progress);\n"
72 " int2 p = (int2)(get_global_id(0), get_global_id(1));\n"
74 " float4 val1 = read_imagef(src1, sampler, p);\n"
75 " float4 val2 = read_imagef(src2, sampler, p);\n"
77 " write_imagef(dst, p, p.y > s ? val2 : val1);\n"
80 "__kernel void wipedown(__write_only image2d_t dst,\n"
81 " __read_only image2d_t src1,\n"
82 " __read_only image2d_t src2,\n"
85 " int s = (int)(get_image_dim(src1).y * (1.f - progress));\n"
86 " int2 p = (int2)(get_global_id(0), get_global_id(1));\n"
88 " float4 val1 = read_imagef(src1, sampler, p);\n"
89 " float4 val2 = read_imagef(src2, sampler, p);\n"
91 " write_imagef(dst, p, p.y > s ? val1 : val2);\n"
94 "void slide(__write_only image2d_t dst,\n"
95 " __read_only image2d_t src1,\n"
96 " __read_only image2d_t src2,\n"
100 " int w = get_image_dim(src1).x;\n"
101 " int h = get_image_dim(src1).y;\n"
102 " int2 wh = (int2)(w, h);\n"
103 " int2 uv = (int2)(get_global_id(0), get_global_id(1));\n"
104 " int2 pi = (int2)(progress * w, progress * h);\n"
105 " int2 p = uv + pi * direction;\n"
106 " int2 f = p % wh;\n"
108 " f = f + (int2)(w, h) * (int2)(f.x < 0, f.y < 0);\n"
109 " float4 val1 = read_imagef(src1, sampler, f);\n"
110 " float4 val2 = read_imagef(src2, sampler, f);\n"
111 " write_imagef(dst, uv, mix(val1, val2, (p.y >= 0) * (h > p.y) * (p.x >= 0) * (w > p.x)));\n"
114 "__kernel void slidedown(__write_only image2d_t dst,\n"
115 " __read_only image2d_t src1,\n"
116 " __read_only image2d_t src2,\n"
119 " int2 direction = (int2)(0, 1);\n"
120 " slide(dst, src1, src2, progress, direction);\n"
123 "__kernel void slideup(__write_only image2d_t dst,\n"
124 " __read_only image2d_t src1,\n"
125 " __read_only image2d_t src2,\n"
128 " int2 direction = (int2)(0, -1);\n"
129 " slide(dst, src1, src2, progress, direction);\n"
132 "__kernel void slideleft(__write_only image2d_t dst,\n"
133 " __read_only image2d_t src1,\n"
134 " __read_only image2d_t src2,\n"
137 " int2 direction = (int2)(-1, 0);\n"
138 " slide(dst, src1, src2, progress, direction);\n"
141 "__kernel void slideright(__write_only image2d_t dst,\n"
142 " __read_only image2d_t src1,\n"
143 " __read_only image2d_t src2,\n"
146 " int2 direction = (int2)(1, 0);\n"
147 " slide(dst, src1, src2, progress, direction);\n"
const char * ff_opencl_source_xfade