range_rvv.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright © 2024 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_range_lum_to_jpeg_16_rvv, zve32x
  22. li t1, 30189
  23. li t2, 19077
  24. li t3, -39057361
  25. 1:
  26. vsetvli t0, a1, e16, m4, ta, ma
  27. vle16.v v0, (a0)
  28. sub a1, a1, t0
  29. vmin.vx v0, v0, t1
  30. vwmul.vx v8, v0, t2
  31. vsetvli zero, zero, e32, m8, ta, ma
  32. vadd.vx v8, v8, t3
  33. vsetvli zero, zero, e16, m4, ta, ma
  34. vnsra.wi v0, v8, 14
  35. vse16.v v0, (a0)
  36. sh1add a0, t0, a0
  37. bnez a1, 1b
  38. ret
  39. endfunc
  40. func ff_range_lum_from_jpeg_16_rvv, zve32x
  41. li t1, 14071
  42. li t2, 33561947
  43. 1:
  44. vsetvli t0, a1, e16, m4, ta, ma
  45. vle16.v v0, (a0)
  46. sub a1, a1, t0
  47. vwmul.vx v8, v0, t1
  48. vsetvli zero, zero, e32, m8, ta, ma
  49. vadd.vx v8, v8, t2
  50. vsetvli zero, zero, e16, m4, ta, ma
  51. vnsra.wi v0, v8, 14
  52. vse16.v v0, (a0)
  53. sh1add a0, t0, a0
  54. bnez a1, 1b
  55. ret
  56. endfunc
  57. func ff_range_chr_to_jpeg_16_rvv, zve32x
  58. li t1, 30775
  59. li t2, 4663
  60. li t3, -9289992
  61. 1:
  62. vsetvli t0, a2, e16, m4, ta, ma
  63. vle16.v v0, (a0)
  64. sub a2, a2, t0
  65. vle16.v v4, (a1)
  66. vmin.vx v0, v0, t1
  67. vmin.vx v4, v4, t1
  68. vwmul.vx v8, v0, t2
  69. vwmul.vx v16, v4, t2
  70. vsetvli zero, zero, e32, m8, ta, ma
  71. vadd.vx v8, v8, t3
  72. vadd.vx v16, v16, t3
  73. vsetvli zero, zero, e16, m4, ta, ma
  74. vnsra.wi v0, v8, 12
  75. vnsra.wi v4, v16, 12
  76. vse16.v v0, (a0)
  77. sh1add a0, t0, a0
  78. vse16.v v4, (a1)
  79. sh1add a1, t0, a1
  80. bnez a2, 1b
  81. ret
  82. endfunc
  83. func ff_range_chr_from_jpeg_16_rvv, zve32x
  84. li t1, 1799
  85. li t2, 4081085
  86. 1:
  87. vsetvli t0, a2, e16, m4, ta, ma
  88. vle16.v v0, (a0)
  89. sub a2, a2, t0
  90. vle16.v v4, (a1)
  91. vwmul.vx v8, v0, t1
  92. vwmul.vx v16, v4, t1
  93. vsetvli zero, zero, e32, m8, ta, ma
  94. vadd.vx v8, v8, t2
  95. vadd.vx v16, v16, t2
  96. vsetvli zero, zero, e16, m4, ta, ma
  97. vnsra.wi v0, v8, 11
  98. vnsra.wi v4, v16, 11
  99. vse16.v v0, (a0)
  100. sh1add a0, t0, a0
  101. vse16.v v0, (a1)
  102. sh1add a1, t0, a1
  103. bnez a2, 1b
  104. ret
  105. endfunc