You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
7.3KB

  1. /*
  2. * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; 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. #define FRAC_BITS 23 // fractional bits for sb_samples and dct
  22. #define WFRAC_BITS 16 // fractional bits for window
  23. #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
  24. const tbl_rev128_s, align=4
  25. .byte 12, 13, 14, 15
  26. .byte 8, 9, 10, 11
  27. .byte 4, 5, 6, 7
  28. .byte 0, 1, 2, 3
  29. endconst
  30. .macro apply_window type, st
  31. function ff_mpadsp_apply_window_\type\()_neon, export=1
  32. mov x7, x0
  33. add x8, x0, #512<<2
  34. ld1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x7], #64
  35. ld1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x7], #64
  36. st1 {v0.4s,v1.4s,v2.4s,v3.4s}, [x8], #64
  37. st1 {v4.4s,v5.4s,v6.4s,v7.4s}, [x8], #64
  38. movrel x15, tbl_rev128_s
  39. ld1 {v27.4s}, [x15]
  40. .ifc \type, fixed
  41. lsl x4, x4, #1
  42. .else
  43. lsl x4, x4, #2
  44. .endif
  45. add x10, x0, #45<<2
  46. add x0, x0, #16<<2
  47. add x1, x1, #16<<2
  48. add x5, x3, x4, lsl #5
  49. sub x5, x5, x4 // samples2
  50. neg x13, x4 // -incr
  51. mov x9, #64<<2
  52. .ifc \type, fixed
  53. ld1r {v16.2s}, [x2] // dither_state
  54. sxtl v16.2d, v16.2s
  55. movi v29.2d, #0
  56. movi v30.2d, #(1<<OUT_SHIFT)-1
  57. trn1 v31.2d, v29.2d, v30.2d
  58. trn2 v30.2d, v30.2d, v29.2d
  59. trn1 v16.2d, v16.2d, v29.2d
  60. .else
  61. movi v16.4s, #0
  62. movi v28.4s, #0
  63. .endif
  64. mov x14, #4
  65. 1:
  66. mov x8, x0
  67. sub x7, x1, #3<<2
  68. sub x6, x1, x14, lsl #4
  69. add x7, x7, x14, lsl #4
  70. add x11, x6, #(32)<<2 // w + 32
  71. add x12, x7, #(32)<<2 // w2 + 32
  72. mov x15, #8
  73. movi v17.2d, #0
  74. movi v18.2d, #0
  75. movi v19.2d, #0
  76. 2:
  77. subs x15, x15, #1
  78. ld1 {v0.4s}, [x8], x9
  79. ld1 {v1.4s}, [x10], x9
  80. ld1 {v2.4s}, [x6], x9
  81. ld1 {v3.4s}, [x7], x9
  82. tbl v6.16b, {v0.16b}, v27.16b
  83. tbl v7.16b, {v1.16b}, v27.16b
  84. ld1 {v4.4s}, [x11], x9
  85. ld1 {v5.4s}, [x12], x9
  86. MLA v16, v2, v0
  87. MLA2 v17, v2, v0
  88. MLS v18, v3, v6
  89. MLS2 v19, v3, v6
  90. MLS v16, v4, v7
  91. MLS2 v17, v4, v7
  92. MLS v18, v5, v1
  93. MLS2 v19, v5, v1
  94. b.gt 2b
  95. cmp x14, #4
  96. sub x10, x10, #64<<5 // 64 * 8 * sizeof(int32_t)
  97. .ifc \type, fixed
  98. and v28.16b, v16.16b, v30.16b
  99. ext v28.16b, v29.16b, v28.16b, #8
  100. b.eq 4f
  101. round_sample v19, 1, 1
  102. 4:
  103. round_sample v16, 1, 0
  104. shrn v16.2s, v16.2d, #OUT_SHIFT
  105. round_sample v19, 0, 0
  106. shrn v19.2s, v19.2d, #OUT_SHIFT
  107. round_sample v17, 0, 1
  108. round_sample v18, 1, 1
  109. round_sample v17, 1, 0
  110. shrn2 v16.4s, v17.2d, #OUT_SHIFT
  111. round_sample v18, 0, 0
  112. shrn2 v19.4s, v18.2d, #OUT_SHIFT
  113. sqxtn v16.4h, v16.4s
  114. sqxtn v18.4h, v19.4s
  115. .else
  116. ext v18.16b, v18.16b, v18.16b, #8
  117. .endif
  118. st1 {v16.\st\()}[0], [x3], x4
  119. b.eq 4f
  120. st1 {v18.\st\()}[1], [x5], x13
  121. 4:
  122. st1 {v16.\st\()}[1], [x3], x4
  123. st1 {v18.\st\()}[0], [x5], x13
  124. st1 {v16.\st\()}[2], [x3], x4
  125. st1 {v18.\st\()}[3], [x5], x13
  126. st1 {v16.\st\()}[3], [x3], x4
  127. st1 {v18.\st\()}[2], [x5], x13
  128. mov v16.16b, v28.16b
  129. subs x14, x14, #1
  130. add x0, x0, #4<<2
  131. sub x10, x10, #4<<2
  132. b.gt 1b
  133. // computing samples[16]
  134. add x6, x1, #32<<2
  135. ld1 {v0.2s}, [x6], x9
  136. ld1 {v1.2s}, [x0], x9
  137. .rept 3
  138. ld1 {v2.2s}, [x6], x9
  139. ld1 {v3.2s}, [x0], x9
  140. MLS v16, v0, v1
  141. ld1 {v0.2s}, [x6], x9
  142. ld1 {v1.2s}, [x0], x9
  143. MLS v16, v2, v3
  144. .endr
  145. ld1 {v2.2s}, [x6], x9
  146. ld1 {v3.2s}, [x0], x9
  147. MLS v16, v0, v1
  148. MLS v16, v2, v3
  149. .ifc \type, fixed
  150. and v28.16b, v16.16b, v30.16b
  151. shrn v20.2s, v16.2d, #OUT_SHIFT
  152. xtn v28.2s, v28.2d
  153. sqxtn v20.4h, v20.4s
  154. st1 {v28.s}[0], [x2] // save dither_state
  155. st1 {v20.h}[0], [x3]
  156. .else
  157. st1 {v16.s}[0], [x3]
  158. .endif
  159. ret
  160. endfunc
  161. .purgem round_sample
  162. .purgem MLA
  163. .purgem MLA2
  164. .purgem MLS
  165. .purgem MLS2
  166. .endm
  167. .macro round_sample r, idx, next
  168. add \r\().2d, \r\().2d, v28.2d
  169. .if \idx == 0
  170. and v28.16b, \r\().16b, v30.16b
  171. .else // \idx == 1
  172. and v28.16b, \r\().16b, v31.16b
  173. .endif
  174. .if \idx != \next
  175. .if \next == 0
  176. ext v28.16b, v28.16b, v29.16b, #8
  177. .else
  178. ext v28.16b, v29.16b, v28.16b, #8
  179. .endif
  180. .endif
  181. .endm
  182. .macro MLA d, s1, s2
  183. smlal \d\().2d, \s1\().2s, \s2\().2s
  184. .endm
  185. .macro MLA2 d, s1, s2
  186. smlal2 \d\().2d, \s1\().4s, \s2\().4s
  187. .endm
  188. .macro MLS d, s1, s2
  189. smlsl \d\().2d, \s1\().2s, \s2\().2s
  190. .endm
  191. .macro MLS2 d, s1, s2
  192. smlsl2 \d\().2d, \s1\().4s, \s2\().4s
  193. .endm
  194. apply_window fixed, h
  195. // nothing to do for round_sample and ML{A,S}2
  196. .macro round_sample r, idx, next
  197. .endm
  198. .macro MLA2 d, s1, s2
  199. .endm
  200. .macro MLS2 d, s1, s2
  201. .endm
  202. .macro MLA d, s1, s2
  203. fmla \d\().4s, \s1\().4s, \s2\().4s
  204. .endm
  205. .macro MLS d, s1, s2
  206. fmls \d\().4s, \s1\().4s, \s2\().4s
  207. .endm
  208. apply_window float, s