2 * Copyright (c) 2018 Dylan Fernando
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 __kernel void avgblur_horiz(__write_only image2d_t dst,
23 __read_only image2d_t src,
26 const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
28 int2 loc = (int2)(get_global_id(0), get_global_id(1));
29 int2 size = (int2)(get_global_size(0), get_global_size(1));
32 float4 acc = (float4)(0,0,0,0);
34 for (int xx = max(0, loc.x - rad); xx < min(loc.x + rad + 1, size.x); xx++) {
36 acc += read_imagef(src, sampler, (int2)(xx, loc.y));
39 write_imagef(dst, loc, acc / count);
42 __kernel void avgblur_vert(__write_only image2d_t dst,
43 __read_only image2d_t src,
46 const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
48 int2 loc = (int2)(get_global_id(0), get_global_id(1));
49 int2 size = (int2)(get_global_size(0), get_global_size(1));
52 float4 acc = (float4)(0,0,0,0);
54 for (int yy = max(0, loc.y - radv); yy < min(loc.y + radv + 1, size.y); yy++) {
56 acc += read_imagef(src, sampler, (int2)(loc.x, yy));
59 write_imagef(dst, loc, acc / count);