rgb2rgb.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_rvb(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_RV
  42. int flags = av_get_cpu_flags();
  43. #if (__riscv_xlen == 64)
  44. if ((flags & AV_CPU_FLAG_RVB_BASIC) && (flags & AV_CPU_FLAG_RVB_ADDR))
  45. shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvb;
  46. #endif
  47. #if HAVE_RVV
  48. if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
  49. shuffle_bytes_0321 = ff_shuffle_bytes_0321_rvv;
  50. shuffle_bytes_2103 = ff_shuffle_bytes_2103_rvv;
  51. shuffle_bytes_1230 = ff_shuffle_bytes_1230_rvv;
  52. shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv;
  53. interleaveBytes = ff_interleave_bytes_rvv;
  54. if (flags & AV_CPU_FLAG_RVB_BASIC) {
  55. uyvytoyuv422 = ff_uyvytoyuv422_rvv;
  56. yuyvtoyuv422 = ff_yuyvtoyuv422_rvv;
  57. }
  58. }
  59. #endif
  60. #endif
  61. }