transpose.cl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  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. int2 size = get_image_dim(dst);
  25. int x = get_global_id(0);
  26. int y = get_global_id(1);
  27. int xin = (dir & 2) ? (size.y - 1 - y) : y;
  28. int yin = (dir & 1) ? (size.x - 1 - x) : x;
  29. float4 data = read_imagef(src, sampler, (int2)(xin, yin));
  30. if (x < size.x && y < size.y)
  31. write_imagef(dst, (int2)(x, y), data);
  32. }