diff options
author | Ruiling Song <ruiling.song@intel.com> | 2018-11-28 10:27:38 +0800 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2018-12-02 23:39:37 +0000 |
commit | 416dc9a5e81729e3313bcc13aebc5faa082c63a3 (patch) | |
tree | 05014f89f5bcb948d7dc4645344e134adcbfcb35 /libavfilter/opencl | |
parent | 21608bc30303b221db8f3e2fb0952e7e7f2bd270 (diff) | |
download | ffmpeg-streaming-416dc9a5e81729e3313bcc13aebc5faa082c63a3.zip ffmpeg-streaming-416dc9a5e81729e3313bcc13aebc5faa082c63a3.tar.gz |
lavf: add transpose_opencl filter
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
Diffstat (limited to 'libavfilter/opencl')
-rw-r--r-- | libavfilter/opencl/transpose.cl | 35 |
1 files changed, 35 insertions, 0 deletions
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); +} |