rgb2rgb_rvv.S 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 "libavutil/riscv/asm.S"
  21. func ff_shuffle_bytes_0321_rvv, zve32x
  22. addi t1, a0, 3
  23. addi t2, a0, 2
  24. addi t3, a0, 1
  25. 1:
  26. srai a2, a2, 2
  27. li t4, 4
  28. 2:
  29. vsetvli t0, a2, e8, m1, ta, ma
  30. sub a2, a2, t0
  31. vlse8.v v8, (a0), t4
  32. sh2add a0, t0, a0
  33. vlse8.v v9, (t1), t4
  34. sh2add t1, t0, t1
  35. vlse8.v v10, (t2), t4
  36. sh2add t2, t0, t2
  37. vlse8.v v11, (t3), t4
  38. sh2add t3, t0, t3
  39. vsseg4e8.v v8, (a1)
  40. sh2add a1, t0, a1
  41. bnez a2, 2b
  42. ret
  43. endfunc
  44. func ff_shuffle_bytes_2103_rvv, zve32x
  45. addi t1, a0, 1
  46. addi t2, a0, 0
  47. addi t3, a0, 3
  48. addi a0, a0, 2
  49. j 1b
  50. endfunc
  51. func ff_shuffle_bytes_1230_rvv, zve32x
  52. addi t1, a0, 2
  53. addi t2, a0, 3
  54. addi t3, a0, 0
  55. addi a0, a0, 1
  56. j 1b
  57. endfunc
  58. func ff_shuffle_bytes_3012_rvv, zve32x
  59. addi t1, a0, 0
  60. addi t2, a0, 1
  61. addi t3, a0, 2
  62. addi a0, a0, 3
  63. j 1b
  64. endfunc
  65. func ff_shuffle_bytes_3210_rvv, zve32x
  66. addi t1, a0, 2
  67. addi t2, a0, 1
  68. addi t3, a0, 0
  69. addi a0, a0, 3
  70. j 1b
  71. endfunc
  72. func ff_interleave_bytes_rvv, zve32x
  73. 1:
  74. mv t0, a0
  75. mv t1, a1
  76. mv t2, a2
  77. mv t3, a3
  78. addi a4, a4, -1
  79. 2:
  80. vsetvli t4, t3, e8, ta, ma
  81. sub t3, t3, t4
  82. vle8.v v8, (t0)
  83. add t0, t4, t0
  84. vle8.v v9, (t1)
  85. add t1, t4, t1
  86. vsseg2e8.v v8, (t2)
  87. sh1add t2, t4, t2
  88. bnez t4, 2b
  89. add a0, a0, a5
  90. add a1, a1, a6
  91. add a2, a2, a7
  92. bnez a4, 1b
  93. ret
  94. endfunc
  95. #if (__riscv_xlen == 64)
  96. .macro yuy2_to_i422p v_y0, v_y1, v_u, v_v
  97. addi sp, sp, -16
  98. sd s0, (sp)
  99. sd s1, 8(sp)
  100. addi a4, a4, 1
  101. lw s0, 16(sp)
  102. srai a4, a4, 1 // pixel width -> chroma width
  103. li s1, 2
  104. 1:
  105. mv t4, a4
  106. mv t3, a3
  107. mv t0, a0
  108. addi t6, a0, 1
  109. mv t1, a1
  110. mv t2, a2
  111. addi a5, a5, -1
  112. 2:
  113. vsetvli t5, t4, e8, m1, ta, ma
  114. sub t4, t4, t5
  115. vlseg4e8.v v8, (t3)
  116. sh2add t3, t5, t3
  117. vsse8.v \v_y0, (t0), s1
  118. sh1add t0, t5, t0
  119. vsse8.v \v_y1, (t6), s1
  120. sh1add t6, t5, t6
  121. vse8.v \v_u, (t1)
  122. add t1, t5, t1
  123. vse8.v \v_v, (t2)
  124. add t2, t5, t2
  125. bnez t4, 2b
  126. add a3, a3, s0
  127. add a0, a0, a6
  128. add a1, a1, a7
  129. add a2, a2, a7
  130. bnez a5, 1b
  131. ld s1, 8(sp)
  132. ld s0, (sp)
  133. addi sp, sp, 16
  134. ret
  135. .endm
  136. func ff_uyvytoyuv422_rvv, zve32x
  137. yuy2_to_i422p v9, v11, v8, v10
  138. endfunc
  139. func ff_yuyvtoyuv422_rvv, zve32x
  140. yuy2_to_i422p v8, v10, v9, v11
  141. endfunc
  142. #endif