hscale.S 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_hscale_8_to_15_neon, export=1
  22. add x10, x4, w6, UXTW #1 // filter2 = filter + filterSize*2 (x2 because int16)
  23. 1: ldr w8, [x5], #4 // filterPos[0]
  24. ldr w9, [x5], #4 // filterPos[1]
  25. movi v4.4S, #0 // val sum part 1 (for dst[0])
  26. movi v5.4S, #0 // val sum part 2 (for dst[1])
  27. mov w7, w6 // filterSize counter
  28. mov x13, x3 // srcp = src
  29. 2: add x11, x13, w8, UXTW // srcp + filterPos[0]
  30. add x12, x13, w9, UXTW // srcp + filterPos[1]
  31. ld1 {v0.8B}, [x11] // srcp[filterPos[0] + {0..7}]
  32. ld1 {v1.8B}, [x12] // srcp[filterPos[1] + {0..7}]
  33. ld1 {v2.8H}, [x4], #16 // load 8x16-bit filter values, part 1
  34. ld1 {v3.8H}, [x10], #16 // ditto at filter+filterSize for part 2
  35. uxtl v0.8H, v0.8B // unpack part 1 to 16-bit
  36. uxtl v1.8H, v1.8B // unpack part 2 to 16-bit
  37. smull v16.4S, v0.4H, v2.4H // v16.i32{0..3} = part 1 of: srcp[filterPos[0] + {0..7}] * filter[{0..7}]
  38. smull v18.4S, v1.4H, v3.4H // v18.i32{0..3} = part 1 of: srcp[filterPos[1] + {0..7}] * filter[{0..7}]
  39. smull2 v17.4S, v0.8H, v2.8H // v17.i32{0..3} = part 2 of: srcp[filterPos[0] + {0..7}] * filter[{0..7}]
  40. smull2 v19.4S, v1.8H, v3.8H // v19.i32{0..3} = part 2 of: srcp[filterPos[1] + {0..7}] * filter[{0..7}]
  41. addp v16.4S, v16.4S, v17.4S // horizontal pair adding of the 8x32-bit multiplied values for part 1 into 4x32-bit
  42. addp v18.4S, v18.4S, v19.4S // horizontal pair adding of the 8x32-bit multiplied values for part 2 into 4x32-bit
  43. add v4.4S, v4.4S, v16.4S // update val accumulator for part 1
  44. add v5.4S, v5.4S, v18.4S // update val accumulator for part 2
  45. add x13, x13, #8 // srcp += 8
  46. subs w7, w7, #8 // processed 8/filterSize
  47. b.gt 2b // inner loop if filterSize not consumed completely
  48. mov x4, x10 // filter = filter2
  49. add x10, x10, w6, UXTW #1 // filter2 += filterSize*2
  50. addp v4.4S, v4.4S, v5.4S // horizontal pair adding of the 8x32-bit sums into 4x32-bit
  51. addp v4.4S, v4.4S, v4.4S // horizontal pair adding of the 4x32-bit sums into 2x32-bit
  52. sqshrn v4.4H, v4.4S, #7 // shift and clip the 2x16-bit final values
  53. st1 {v4.S}[0], [x1], #4 // write to destination
  54. subs w2, w2, #2 // dstW -= 2
  55. b.gt 1b // loop until end of line
  56. ret
  57. endfunc