]> git.sesse.net Git - ffmpeg/blob - libavfilter/opencl/transpose.cl
avfilter/vf_psnr: remove unnecessary check
[ffmpeg] / libavfilter / opencl / transpose.cl
1 /*
2  * This file is part of FFmpeg.
3  *
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.
8  *
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.
13  *
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
17  */
18 kernel void transpose(__write_only image2d_t dst,
19                       __read_only image2d_t src,
20                       int dir) {
21     const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
22                                CLK_ADDRESS_CLAMP_TO_EDGE   |
23                                CLK_FILTER_NEAREST);
24
25     int2 size = get_image_dim(dst);
26     int x = get_global_id(0);
27     int y = get_global_id(1);
28
29     int xin = (dir & 2) ? (size.y - 1 - y) : y;
30     int yin = (dir & 1) ? (size.x - 1 - x) : x;
31     float4 data = read_imagef(src, sampler, (int2)(xin, yin));
32
33     if (x < size.x && y < size.y)
34         write_imagef(dst, (int2)(x, y), data);
35 }