rgb2rgb_lasx.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2022 Loongson Technology Corporation Limited
  3. * Contributed by Hao Chen(chenhao@loongson.cn)
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "swscale_loongarch.h"
  22. #include "libavutil/loongarch/loongson_intrinsics.h"
  23. void ff_interleave_bytes_lasx(const uint8_t *src1, const uint8_t *src2,
  24. uint8_t *dest, int width, int height,
  25. int src1Stride, int src2Stride, int dstStride)
  26. {
  27. int h;
  28. int len = width & (0xFFFFFFF0);
  29. for (h = 0; h < height; h++) {
  30. int w, index = 0;
  31. __m256i src_1, src_2, dst;
  32. for (w = 0; w < len; w += 16) {
  33. DUP2_ARG2(__lasx_xvld, src1 + w, 0, src2 + w, 0, src_1, src_2);
  34. src_1 = __lasx_xvpermi_d(src_1, 0xD8);
  35. src_2 = __lasx_xvpermi_d(src_2, 0xD8);
  36. dst = __lasx_xvilvl_b(src_2, src_1);
  37. __lasx_xvst(dst, dest + index, 0);
  38. index += 32;
  39. }
  40. for (; w < width; w++) {
  41. dest[(w << 1) + 0] = src1[w];
  42. dest[(w << 1) + 1] = src2[w];
  43. }
  44. dest += dstStride;
  45. src1 += src1Stride;
  46. src2 += src2Stride;
  47. }
  48. }