rgb2rgb.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright © 2022 Rémi Denis-Courmont.
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #include "config.h"
  22. #include "libavutil/attributes.h"
  23. #include "libavutil/cpu.h"
  24. #include "libswscale/rgb2rgb.h"
  25. void ff_shuffle_bytes_0321_rvv(const uint8_t *src, uint8_t *dst, int src_len);
  26. void ff_shuffle_bytes_2103_rvv(const uint8_t *src, uint8_t *dst, int src_len);
  27. void ff_shuffle_bytes_1230_rvv(const uint8_t *src, uint8_t *dst, int src_len);
  28. void ff_shuffle_bytes_3012_rvv(const uint8_t *src, uint8_t *dst, int src_len);
  29. void ff_shuffle_bytes_3210_rvv(const uint8_t *src, uint8_t *dst, int src_len);
  30. void ff_interleave_bytes_rvv(const uint8_t *src1, const uint8_t *src2,
  31. uint8_t *dst, int width, int height, int s1stride,
  32. int s2stride, int dstride);
  33. void ff_uyvytoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
  34. const uint8_t *src, int width, int height,
  35. int ystride, int uvstride, int src_stride);
  36. void ff_yuyvtoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
  37. const uint8_t *src, int width, int height,
  38. int ystride, int uvstride, int src_stride);
  39. av_cold void rgb2rgb_init_riscv(void)
  40. {
  41. #if HAVE_RVV
  42. int flags = av_get_cpu_flags();
  43. if (flags & AV_CPU_FLAG_RVV_I32) {
  44. shuffle_bytes_0321 = ff_shuffle_bytes_0321_rvv;
  45. shuffle_bytes_2103 = ff_shuffle_bytes_2103_rvv;
  46. shuffle_bytes_1230 = ff_shuffle_bytes_1230_rvv;
  47. shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv;
  48. shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvv;
  49. interleaveBytes = ff_interleave_bytes_rvv;
  50. #if (__riscv_xlen == 64)
  51. uyvytoyuv422 = ff_uyvytoyuv422_rvv;
  52. yuyvtoyuv422 = ff_yuyvtoyuv422_rvv;
  53. #endif
  54. }
  55. #endif
  56. }