From 416dc9a5e81729e3313bcc13aebc5faa082c63a3 Mon Sep 17 00:00:00 2001 From: Ruiling Song Date: Wed, 28 Nov 2018 10:27:38 +0800 Subject: lavf: add transpose_opencl filter Signed-off-by: Ruiling Song Signed-off-by: Mark Thompson --- libavfilter/opencl/transpose.cl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 libavfilter/opencl/transpose.cl (limited to 'libavfilter/opencl') diff --git a/libavfilter/opencl/transpose.cl b/libavfilter/opencl/transpose.cl new file mode 100644 index 0000000..e6388ab --- /dev/null +++ b/libavfilter/opencl/transpose.cl @@ -0,0 +1,35 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +kernel void transpose(__write_only image2d_t dst, + __read_only image2d_t src, + int dir) { + const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE | + CLK_ADDRESS_CLAMP_TO_EDGE | + CLK_FILTER_NEAREST); + + int2 size = get_image_dim(dst); + int x = get_global_id(0); + int y = get_global_id(1); + + int xin = (dir & 2) ? (size.y - 1 - y) : y; + int yin = (dir & 1) ? (size.x - 1 - x) : x; + float4 data = read_imagef(src, sampler, (int2)(xin, yin)); + + if (x < size.x && y < size.y) + write_imagef(dst, (int2)(x, y), data); +} -- cgit v1.1