rgb2rgb.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_deinterleave_bytes_rvv(const uint8_t *src, uint8_t *dst1,
  34. uint8_t *dst2, int width, int height,
  35. int srcStride, int dst1Stride, int dst2Stride);
  36. void ff_uyvytoyuv422_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. void ff_yuyvtoyuv422_rvv(uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
  40. const uint8_t *src, int width, int height,
  41. int ystride, int uvstride, int src_stride);
  42. av_cold void rgb2rgb_init_riscv(void)
  43. {
  44. #if HAVE_RV
  45. int flags = av_get_cpu_flags();
  46. #if (__riscv_xlen == 64)
  47. if (flags & AV_CPU_FLAG_RVB_BASIC)
  48. shuffle_bytes_3210 = ff_shuffle_bytes_3210_rvb;
  49. #endif
  50. #if HAVE_RVV
  51. if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB)) {
  52. shuffle_bytes_0321 = ff_shuffle_bytes_0321_rvv;
  53. shuffle_bytes_2103 = ff_shuffle_bytes_2103_rvv;
  54. shuffle_bytes_1230 = ff_shuffle_bytes_1230_rvv;
  55. shuffle_bytes_3012 = ff_shuffle_bytes_3012_rvv;
  56. interleaveBytes = ff_interleave_bytes_rvv;
  57. deinterleaveBytes = ff_deinterleave_bytes_rvv;
  58. uyvytoyuv422 = ff_uyvytoyuv422_rvv;
  59. yuyvtoyuv422 = ff_yuyvtoyuv422_rvv;
  60. }
  61. #endif
  62. #endif
  63. }