output.S 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2016 Clément Bœsch <clement stupeflix.com>
  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. function ff_yuv2planeX_8_neon, export=1
  22. ld1 {v0.8B}, [x5] // load 8x8-bit dither
  23. cbz w6, 1f // check if offsetting present
  24. ext v0.8B, v0.8B, v0.8B, #3 // honor offsetting which can be 0 or 3 only
  25. 1: uxtl v0.8H, v0.8B // extend dither to 16-bit
  26. ushll v1.4S, v0.4H, #12 // extend dither to 32-bit with left shift by 12 (part 1)
  27. ushll2 v2.4S, v0.8H, #12 // extend dither to 32-bit with left shift by 12 (part 2)
  28. mov x7, #0 // i = 0
  29. 2: mov v3.16B, v1.16B // initialize accumulator part 1 with dithering value
  30. mov v4.16B, v2.16B // initialize accumulator part 2 with dithering value
  31. mov w8, w1 // tmpfilterSize = filterSize
  32. mov x9, x2 // srcp = src
  33. mov x10, x0 // filterp = filter
  34. 3: ldp x11, x12, [x9], #16 // get 2 pointers: src[j] and src[j+1]
  35. add x11, x11, x7, lsl #1 // &src[j ][i]
  36. add x12, x12, x7, lsl #1 // &src[j+1][i]
  37. ld1 {v5.8H}, [x11] // read 8x16-bit @ src[j ][i + {0..7}]: A,B,C,D,E,F,G,H
  38. ld1 {v6.8H}, [x12] // read 8x16-bit @ src[j+1][i + {0..7}]: I,J,K,L,M,N,O,P
  39. ld1r {v7.8H}, [x10], #2 // read 1x16-bit coeff X at filter[j ] and duplicate across lanes
  40. ld1r {v16.8H}, [x10], #2 // read 1x16-bit coeff Y at filter[j+1] and duplicate across lanes
  41. smlal v3.4S, v5.4H, v7.4H // val0 += {A,B,C,D} * X
  42. smlal2 v4.4S, v5.8H, v7.8H // val1 += {E,F,G,H} * X
  43. smlal v3.4S, v6.4H, v16.4H // val0 += {I,J,K,L} * Y
  44. smlal2 v4.4S, v6.8H, v16.8H // val1 += {M,N,O,P} * Y
  45. subs w8, w8, #2 // tmpfilterSize -= 2
  46. b.gt 3b // loop until filterSize consumed
  47. sqshrun v3.4h, v3.4s, #16 // clip16(val0>>16)
  48. sqshrun2 v3.8h, v4.4s, #16 // clip16(val1>>16)
  49. uqshrn v3.8b, v3.8h, #3 // clip8(val>>19)
  50. st1 {v3.8b}, [x3], #8 // write to destination
  51. subs w4, w4, #8 // dstW -= 8
  52. add x7, x7, #8 // i += 8
  53. b.gt 2b // loop until width consumed
  54. ret
  55. endfunc