rgb2rgb_neon.S 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2020 Martin Storsjo
  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/aarch64/asm.S"
  21. // void ff_interleave_bytes_neon(const uint8_t *src1, const uint8_t *src2,
  22. // uint8_t *dest, int width, int height,
  23. // int src1Stride, int src2Stride, int dstStride);
  24. function ff_interleave_bytes_neon, export=1
  25. sub w5, w5, w3
  26. sub w6, w6, w3
  27. sub w7, w7, w3, lsl #1
  28. 1:
  29. ands w8, w3, #0xfffffff0 // & ~15
  30. b.eq 3f
  31. 2:
  32. ld1 {v0.16b}, [x0], #16
  33. ld1 {v1.16b}, [x1], #16
  34. subs w8, w8, #16
  35. st2 {v0.16b, v1.16b}, [x2], #32
  36. b.gt 2b
  37. tst w3, #15
  38. b.eq 9f
  39. 3:
  40. tst w3, #8
  41. b.eq 4f
  42. ld1 {v0.8b}, [x0], #8
  43. ld1 {v1.8b}, [x1], #8
  44. st2 {v0.8b, v1.8b}, [x2], #16
  45. 4:
  46. tst w3, #4
  47. b.eq 5f
  48. ld1 {v0.s}[0], [x0], #4
  49. ld1 {v1.s}[0], [x1], #4
  50. zip1 v0.8b, v0.8b, v1.8b
  51. st1 {v0.8b}, [x2], #8
  52. 5:
  53. ands w8, w3, #3
  54. b.eq 9f
  55. 6:
  56. ldrb w9, [x0], #1
  57. ldrb w10, [x1], #1
  58. subs w8, w8, #1
  59. bfi w9, w10, #8, #8
  60. strh w9, [x2], #2
  61. b.gt 6b
  62. 9:
  63. subs w4, w4, #1
  64. b.eq 0f
  65. add x0, x0, w5, sxtw
  66. add x1, x1, w6, sxtw
  67. add x2, x2, w7, sxtw
  68. b 1b
  69. 0:
  70. ret
  71. endfunc