audio_convert_neon.S 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /*
  2. * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
  3. * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "config.h"
  22. #include "libavutil/aarch64/asm.S"
  23. function ff_conv_flt_to_s16_neon, export=1
  24. subs x2, x2, #8
  25. ld1 {v0.4s}, [x1], #16
  26. fcvtzs v4.4s, v0.4s, #31
  27. ld1 {v1.4s}, [x1], #16
  28. fcvtzs v5.4s, v1.4s, #31
  29. b.eq 3f
  30. ands x12, x2, #~15
  31. b.eq 2f
  32. 1: subs x12, x12, #16
  33. sqrshrn v4.4h, v4.4s, #16
  34. ld1 {v2.4s}, [x1], #16
  35. fcvtzs v6.4s, v2.4s, #31
  36. sqrshrn2 v4.8h, v5.4s, #16
  37. ld1 {v3.4s}, [x1], #16
  38. fcvtzs v7.4s, v3.4s, #31
  39. sqrshrn v6.4h, v6.4s, #16
  40. st1 {v4.8h}, [x0], #16
  41. sqrshrn2 v6.8h, v7.4s, #16
  42. ld1 {v0.4s}, [x1], #16
  43. fcvtzs v4.4s, v0.4s, #31
  44. ld1 {v1.4s}, [x1], #16
  45. fcvtzs v5.4s, v1.4s, #31
  46. st1 {v6.8h}, [x0], #16
  47. b.ne 1b
  48. ands x2, x2, #15
  49. b.eq 3f
  50. 2: ld1 {v2.4s}, [x1], #16
  51. sqrshrn v4.4h, v4.4s, #16
  52. fcvtzs v6.4s, v2.4s, #31
  53. ld1 {v3.4s}, [x1], #16
  54. sqrshrn2 v4.8h, v5.4s, #16
  55. fcvtzs v7.4s, v3.4s, #31
  56. sqrshrn v6.4h, v6.4s, #16
  57. st1 {v4.8h}, [x0], #16
  58. sqrshrn2 v6.8h, v7.4s, #16
  59. st1 {v6.8h}, [x0]
  60. ret
  61. 3: sqrshrn v4.4h, v4.4s, #16
  62. sqrshrn2 v4.8h, v5.4s, #16
  63. st1 {v4.8h}, [x0]
  64. ret
  65. endfunc
  66. function ff_conv_fltp_to_s16_2ch_neon, export=1
  67. ldp x4, x5, [x1]
  68. subs x2, x2, #8
  69. ld1 {v0.4s}, [x4], #16
  70. fcvtzs v4.4s, v0.4s, #31
  71. ld1 {v1.4s}, [x4], #16
  72. fcvtzs v5.4s, v1.4s, #31
  73. ld1 {v2.4s}, [x5], #16
  74. fcvtzs v6.4s, v2.4s, #31
  75. ld1 {v3.4s}, [x5], #16
  76. fcvtzs v7.4s, v3.4s, #31
  77. b.eq 3f
  78. ands x12, x2, #~15
  79. b.eq 2f
  80. 1: subs x12, x12, #16
  81. ld1 {v16.4s}, [x4], #16
  82. fcvtzs v20.4s, v16.4s, #31
  83. sri v6.4s, v4.4s, #16
  84. ld1 {v17.4s}, [x4], #16
  85. fcvtzs v21.4s, v17.4s, #31
  86. ld1 {v18.4s}, [x5], #16
  87. fcvtzs v22.4s, v18.4s, #31
  88. ld1 {v19.4s}, [x5], #16
  89. sri v7.4s, v5.4s, #16
  90. st1 {v6.4s}, [x0], #16
  91. fcvtzs v23.4s, v19.4s, #31
  92. st1 {v7.4s}, [x0], #16
  93. sri v22.4s, v20.4s, #16
  94. ld1 {v0.4s}, [x4], #16
  95. sri v23.4s, v21.4s, #16
  96. st1 {v22.4s}, [x0], #16
  97. fcvtzs v4.4s, v0.4s, #31
  98. ld1 {v1.4s}, [x4], #16
  99. fcvtzs v5.4s, v1.4s, #31
  100. ld1 {v2.4s}, [x5], #16
  101. fcvtzs v6.4s, v2.4s, #31
  102. ld1 {v3.4s}, [x5], #16
  103. fcvtzs v7.4s, v3.4s, #31
  104. st1 {v23.4s}, [x0], #16
  105. b.ne 1b
  106. ands x2, x2, #15
  107. b.eq 3f
  108. 2: sri v6.4s, v4.4s, #16
  109. ld1 {v0.4s}, [x4], #16
  110. fcvtzs v0.4s, v0.4s, #31
  111. ld1 {v1.4s}, [x4], #16
  112. fcvtzs v1.4s, v1.4s, #31
  113. ld1 {v2.4s}, [x5], #16
  114. fcvtzs v2.4s, v2.4s, #31
  115. sri v7.4s, v5.4s, #16
  116. ld1 {v3.4s}, [x5], #16
  117. fcvtzs v3.4s, v3.4s, #31
  118. sri v2.4s, v0.4s, #16
  119. st1 {v6.4s,v7.4s}, [x0], #32
  120. sri v3.4s, v1.4s, #16
  121. st1 {v2.4s,v3.4s}, [x0], #32
  122. ret
  123. 3: sri v6.4s, v4.4s, #16
  124. sri v7.4s, v5.4s, #16
  125. st1 {v6.4s,v7.4s}, [x0]
  126. ret
  127. endfunc
  128. function ff_conv_fltp_to_s16_neon, export=1
  129. cmp w3, #2
  130. b.eq X(ff_conv_fltp_to_s16_2ch_neon)
  131. b.gt 1f
  132. ldr x1, [x1]
  133. b X(ff_conv_flt_to_s16_neon)
  134. 1:
  135. cmp w3, #4
  136. lsl x12, x3, #1
  137. b.lt 4f
  138. 5: // 4 channels
  139. ldp x4, x5, [x1], #16
  140. ldp x6, x7, [x1], #16
  141. mov w9, w2
  142. mov x8, x0
  143. ld1 {v4.4s}, [x4], #16
  144. fcvtzs v4.4s, v4.4s, #31
  145. ld1 {v5.4s}, [x5], #16
  146. fcvtzs v5.4s, v5.4s, #31
  147. ld1 {v6.4s}, [x6], #16
  148. fcvtzs v6.4s, v6.4s, #31
  149. ld1 {v7.4s}, [x7], #16
  150. fcvtzs v7.4s, v7.4s, #31
  151. 6:
  152. subs w9, w9, #8
  153. ld1 {v0.4s}, [x4], #16
  154. fcvtzs v0.4s, v0.4s, #31
  155. sri v5.4s, v4.4s, #16
  156. ld1 {v1.4s}, [x5], #16
  157. fcvtzs v1.4s, v1.4s, #31
  158. sri v7.4s, v6.4s, #16
  159. ld1 {v2.4s}, [x6], #16
  160. fcvtzs v2.4s, v2.4s, #31
  161. zip1 v16.4s, v5.4s, v7.4s
  162. ld1 {v3.4s}, [x7], #16
  163. fcvtzs v3.4s, v3.4s, #31
  164. zip2 v17.4s, v5.4s, v7.4s
  165. st1 {v16.d}[0], [x8], x12
  166. sri v1.4s, v0.4s, #16
  167. st1 {v16.d}[1], [x8], x12
  168. sri v3.4s, v2.4s, #16
  169. st1 {v17.d}[0], [x8], x12
  170. zip1 v18.4s, v1.4s, v3.4s
  171. st1 {v17.d}[1], [x8], x12
  172. zip2 v19.4s, v1.4s, v3.4s
  173. b.eq 7f
  174. ld1 {v4.4s}, [x4], #16
  175. fcvtzs v4.4s, v4.4s, #31
  176. st1 {v18.d}[0], [x8], x12
  177. ld1 {v5.4s}, [x5], #16
  178. fcvtzs v5.4s, v5.4s, #31
  179. st1 {v18.d}[1], [x8], x12
  180. ld1 {v6.4s}, [x6], #16
  181. fcvtzs v6.4s, v6.4s, #31
  182. st1 {v19.d}[0], [x8], x12
  183. ld1 {v7.4s}, [x7], #16
  184. fcvtzs v7.4s, v7.4s, #31
  185. st1 {v19.d}[1], [x8], x12
  186. b 6b
  187. 7:
  188. st1 {v18.d}[0], [x8], x12
  189. st1 {v18.d}[1], [x8], x12
  190. st1 {v19.d}[0], [x8], x12
  191. st1 {v19.d}[1], [x8], x12
  192. subs w3, w3, #4
  193. b.eq end
  194. cmp w3, #4
  195. add x0, x0, #8
  196. b.ge 5b
  197. 4: // 2 channels
  198. cmp w3, #2
  199. b.lt 4f
  200. ldp x4, x5, [x1], #16
  201. mov w9, w2
  202. mov x8, x0
  203. tst w9, #8
  204. ld1 {v4.4s}, [x4], #16
  205. fcvtzs v4.4s, v4.4s, #31
  206. ld1 {v5.4s}, [x5], #16
  207. fcvtzs v5.4s, v5.4s, #31
  208. ld1 {v6.4s}, [x4], #16
  209. fcvtzs v6.4s, v6.4s, #31
  210. ld1 {v7.4s}, [x5], #16
  211. fcvtzs v7.4s, v7.4s, #31
  212. b.eq 6f
  213. subs w9, w9, #8
  214. b.eq 7f
  215. sri v5.4s, v4.4s, #16
  216. ld1 {v4.4s}, [x4], #16
  217. fcvtzs v4.4s, v4.4s, #31
  218. st1 {v5.s}[0], [x8], x12
  219. sri v7.4s, v6.4s, #16
  220. st1 {v5.s}[1], [x8], x12
  221. ld1 {v6.4s}, [x4], #16
  222. fcvtzs v6.4s, v6.4s, #31
  223. st1 {v5.s}[2], [x8], x12
  224. st1 {v5.s}[3], [x8], x12
  225. st1 {v7.s}[0], [x8], x12
  226. st1 {v7.s}[1], [x8], x12
  227. ld1 {v5.4s}, [x5], #16
  228. fcvtzs v5.4s, v5.4s, #31
  229. st1 {v7.s}[2], [x8], x12
  230. st1 {v7.s}[3], [x8], x12
  231. ld1 {v7.4s}, [x5], #16
  232. fcvtzs v7.4s, v7.4s, #31
  233. 6:
  234. subs w9, w9, #16
  235. ld1 {v0.4s}, [x4], #16
  236. sri v5.4s, v4.4s, #16
  237. fcvtzs v0.4s, v0.4s, #31
  238. ld1 {v1.4s}, [x5], #16
  239. sri v7.4s, v6.4s, #16
  240. st1 {v5.s}[0], [x8], x12
  241. st1 {v5.s}[1], [x8], x12
  242. fcvtzs v1.4s, v1.4s, #31
  243. st1 {v5.s}[2], [x8], x12
  244. st1 {v5.s}[3], [x8], x12
  245. ld1 {v2.4s}, [x4], #16
  246. st1 {v7.s}[0], [x8], x12
  247. fcvtzs v2.4s, v2.4s, #31
  248. st1 {v7.s}[1], [x8], x12
  249. ld1 {v3.4s}, [x5], #16
  250. st1 {v7.s}[2], [x8], x12
  251. fcvtzs v3.4s, v3.4s, #31
  252. st1 {v7.s}[3], [x8], x12
  253. sri v1.4s, v0.4s, #16
  254. sri v3.4s, v2.4s, #16
  255. b.eq 6f
  256. ld1 {v4.4s}, [x4], #16
  257. st1 {v1.s}[0], [x8], x12
  258. fcvtzs v4.4s, v4.4s, #31
  259. st1 {v1.s}[1], [x8], x12
  260. ld1 {v5.4s}, [x5], #16
  261. st1 {v1.s}[2], [x8], x12
  262. fcvtzs v5.4s, v5.4s, #31
  263. st1 {v1.s}[3], [x8], x12
  264. ld1 {v6.4s}, [x4], #16
  265. st1 {v3.s}[0], [x8], x12
  266. fcvtzs v6.4s, v6.4s, #31
  267. st1 {v3.s}[1], [x8], x12
  268. ld1 {v7.4s}, [x5], #16
  269. st1 {v3.s}[2], [x8], x12
  270. fcvtzs v7.4s, v7.4s, #31
  271. st1 {v3.s}[3], [x8], x12
  272. b.gt 6b
  273. 6:
  274. st1 {v1.s}[0], [x8], x12
  275. st1 {v1.s}[1], [x8], x12
  276. st1 {v1.s}[2], [x8], x12
  277. st1 {v1.s}[3], [x8], x12
  278. st1 {v3.s}[0], [x8], x12
  279. st1 {v3.s}[1], [x8], x12
  280. st1 {v3.s}[2], [x8], x12
  281. st1 {v3.s}[3], [x8], x12
  282. b 8f
  283. 7:
  284. sri v5.4s, v4.4s, #16
  285. sri v7.4s, v6.4s, #16
  286. st1 {v5.s}[0], [x8], x12
  287. st1 {v5.s}[1], [x8], x12
  288. st1 {v5.s}[2], [x8], x12
  289. st1 {v5.s}[3], [x8], x12
  290. st1 {v7.s}[0], [x8], x12
  291. st1 {v7.s}[1], [x8], x12
  292. st1 {v7.s}[2], [x8], x12
  293. st1 {v7.s}[3], [x8], x12
  294. 8:
  295. subs w3, w3, #2
  296. add x0, x0, #4
  297. b.eq end
  298. 4: // 1 channel
  299. ldr x4, [x1]
  300. tst w2, #8
  301. mov w9, w2
  302. mov x5, x0
  303. ld1 {v0.4s}, [x4], #16
  304. fcvtzs v0.4s, v0.4s, #31
  305. ld1 {v1.4s}, [x4], #16
  306. fcvtzs v1.4s, v1.4s, #31
  307. b.ne 8f
  308. 6:
  309. subs w9, w9, #16
  310. ld1 {v2.4s}, [x4], #16
  311. fcvtzs v2.4s, v2.4s, #31
  312. ld1 {v3.4s}, [x4], #16
  313. fcvtzs v3.4s, v3.4s, #31
  314. st1 {v0.h}[1], [x5], x12
  315. st1 {v0.h}[3], [x5], x12
  316. st1 {v0.h}[5], [x5], x12
  317. st1 {v0.h}[7], [x5], x12
  318. st1 {v1.h}[1], [x5], x12
  319. st1 {v1.h}[3], [x5], x12
  320. st1 {v1.h}[5], [x5], x12
  321. st1 {v1.h}[7], [x5], x12
  322. b.eq 7f
  323. ld1 {v0.4s}, [x4], #16
  324. fcvtzs v0.4s, v0.4s, #31
  325. ld1 {v1.4s}, [x4], #16
  326. fcvtzs v1.4s, v1.4s, #31
  327. 7:
  328. st1 {v2.h}[1], [x5], x12
  329. st1 {v2.h}[3], [x5], x12
  330. st1 {v2.h}[5], [x5], x12
  331. st1 {v2.h}[7], [x5], x12
  332. st1 {v3.h}[1], [x5], x12
  333. st1 {v3.h}[3], [x5], x12
  334. st1 {v3.h}[5], [x5], x12
  335. st1 {v3.h}[7], [x5], x12
  336. b.gt 6b
  337. ret
  338. 8:
  339. subs w9, w9, #8
  340. st1 {v0.h}[1], [x5], x12
  341. st1 {v0.h}[3], [x5], x12
  342. st1 {v0.h}[5], [x5], x12
  343. st1 {v0.h}[7], [x5], x12
  344. st1 {v1.h}[1], [x5], x12
  345. st1 {v1.h}[3], [x5], x12
  346. st1 {v1.h}[5], [x5], x12
  347. st1 {v1.h}[7], [x5], x12
  348. b.eq end
  349. ld1 {v0.4s}, [x4], #16
  350. fcvtzs v0.4s, v0.4s, #31
  351. ld1 {v1.4s}, [x4], #16
  352. fcvtzs v1.4s, v1.4s, #31
  353. b 6b
  354. end:
  355. ret
  356. endfunc