2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
22 __kernel void fade(__write_only image2d_t dst,
23 __read_only image2d_t src1,
24 __read_only image2d_t src2,
27 int2 p = (int2)(get_global_id(0), get_global_id(1));
29 float4 val1 = read_imagef(src1, sampler, p);
30 float4 val2 = read_imagef(src2, sampler, p);
32 write_imagef(dst, p, mix(val2, val1, progress));
35 __kernel void wipeleft(__write_only image2d_t dst,
36 __read_only image2d_t src1,
37 __read_only image2d_t src2,
40 int s = (int)(get_image_dim(src1).x * progress);
41 int2 p = (int2)(get_global_id(0), get_global_id(1));
43 float4 val1 = read_imagef(src1, sampler, p);
44 float4 val2 = read_imagef(src2, sampler, p);
46 write_imagef(dst, p, p.x > s ? val2 : val1);
49 __kernel void wiperight(__write_only image2d_t dst,
50 __read_only image2d_t src1,
51 __read_only image2d_t src2,
54 int s = (int)(get_image_dim(src1).x * (1.f - progress));
55 int2 p = (int2)(get_global_id(0), get_global_id(1));
57 float4 val1 = read_imagef(src1, sampler, p);
58 float4 val2 = read_imagef(src2, sampler, p);
60 write_imagef(dst, p, p.x > s ? val1 : val2);
63 __kernel void wipeup(__write_only image2d_t dst,
64 __read_only image2d_t src1,
65 __read_only image2d_t src2,
68 int s = (int)(get_image_dim(src1).y * progress);
69 int2 p = (int2)(get_global_id(0), get_global_id(1));
71 float4 val1 = read_imagef(src1, sampler, p);
72 float4 val2 = read_imagef(src2, sampler, p);
74 write_imagef(dst, p, p.y > s ? val2 : val1);
77 __kernel void wipedown(__write_only image2d_t dst,
78 __read_only image2d_t src1,
79 __read_only image2d_t src2,
82 int s = (int)(get_image_dim(src1).y * (1.f - progress));
83 int2 p = (int2)(get_global_id(0), get_global_id(1));
85 float4 val1 = read_imagef(src1, sampler, p);
86 float4 val2 = read_imagef(src2, sampler, p);
88 write_imagef(dst, p, p.y > s ? val1 : val2);
91 void slide(__write_only image2d_t dst,
92 __read_only image2d_t src1,
93 __read_only image2d_t src2,
97 int w = get_image_dim(src1).x;
98 int h = get_image_dim(src1).y;
99 int2 wh = (int2)(w, h);
100 int2 uv = (int2)(get_global_id(0), get_global_id(1));
101 int2 pi = (int2)(progress * w, progress * h);
102 int2 p = uv + pi * direction;
105 f = f + (int2)(w, h) * (int2)(f.x < 0, f.y < 0);
106 float4 val1 = read_imagef(src1, sampler, f);
107 float4 val2 = read_imagef(src2, sampler, f);
108 write_imagef(dst, uv, mix(val1, val2, (p.y >= 0) * (h > p.y) * (p.x >= 0) * (w > p.x)));
111 __kernel void slidedown(__write_only image2d_t dst,
112 __read_only image2d_t src1,
113 __read_only image2d_t src2,
116 int2 direction = (int2)(0, 1);
117 slide(dst, src1, src2, progress, direction);
120 __kernel void slideup(__write_only image2d_t dst,
121 __read_only image2d_t src1,
122 __read_only image2d_t src2,
125 int2 direction = (int2)(0, -1);
126 slide(dst, src1, src2, progress, direction);
129 __kernel void slideleft(__write_only image2d_t dst,
130 __read_only image2d_t src1,
131 __read_only image2d_t src2,
134 int2 direction = (int2)(-1, 0);
135 slide(dst, src1, src2, progress, direction);
138 __kernel void slideright(__write_only image2d_t dst,
139 __read_only image2d_t src1,
140 __read_only image2d_t src2,
143 int2 direction = (int2)(1, 0);
144 slide(dst, src1, src2, progress, direction);