audio_convert_neon.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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 swri_oldapi_conv_flt_to_s16_neon, export=1
  24. oldapi_conv_flt_to_s16_neon:
  25. subs x2, x2, #8
  26. ld1 {v0.4s}, [x1], #16
  27. fcvtzs v4.4s, v0.4s, #31
  28. ld1 {v1.4s}, [x1], #16
  29. fcvtzs v5.4s, v1.4s, #31
  30. b.eq 3f
  31. ands x12, x2, #~15
  32. b.eq 2f
  33. 1: subs x12, x12, #16
  34. sqrshrn v4.4h, v4.4s, #16
  35. ld1 {v2.4s}, [x1], #16
  36. fcvtzs v6.4s, v2.4s, #31
  37. sqrshrn2 v4.8h, v5.4s, #16
  38. ld1 {v3.4s}, [x1], #16
  39. fcvtzs v7.4s, v3.4s, #31
  40. sqrshrn v6.4h, v6.4s, #16
  41. st1 {v4.8h}, [x0], #16
  42. sqrshrn2 v6.8h, v7.4s, #16
  43. ld1 {v0.4s}, [x1], #16
  44. fcvtzs v4.4s, v0.4s, #31
  45. ld1 {v1.4s}, [x1], #16
  46. fcvtzs v5.4s, v1.4s, #31
  47. st1 {v6.8h}, [x0], #16
  48. b.ne 1b
  49. ands x2, x2, #15
  50. b.eq 3f
  51. 2: ld1 {v2.4s}, [x1], #16
  52. sqrshrn v4.4h, v4.4s, #16
  53. fcvtzs v6.4s, v2.4s, #31
  54. ld1 {v3.4s}, [x1], #16
  55. sqrshrn2 v4.8h, v5.4s, #16
  56. fcvtzs v7.4s, v3.4s, #31
  57. sqrshrn v6.4h, v6.4s, #16
  58. st1 {v4.8h}, [x0], #16
  59. sqrshrn2 v6.8h, v7.4s, #16
  60. st1 {v6.8h}, [x0]
  61. ret
  62. 3: sqrshrn v4.4h, v4.4s, #16
  63. sqrshrn2 v4.8h, v5.4s, #16
  64. st1 {v4.8h}, [x0]
  65. ret
  66. endfunc
  67. function swri_oldapi_conv_fltp_to_s16_2ch_neon, export=1
  68. oldapi_conv_fltp_to_s16_2ch_neon:
  69. ldp x4, x5, [x1]
  70. subs x2, x2, #8
  71. ld1 {v0.4s}, [x4], #16
  72. fcvtzs v4.4s, v0.4s, #31
  73. ld1 {v1.4s}, [x4], #16
  74. fcvtzs v5.4s, v1.4s, #31
  75. ld1 {v2.4s}, [x5], #16
  76. fcvtzs v6.4s, v2.4s, #31
  77. ld1 {v3.4s}, [x5], #16
  78. fcvtzs v7.4s, v3.4s, #31
  79. b.eq 3f
  80. ands x12, x2, #~15
  81. b.eq 2f
  82. 1: subs x12, x12, #16
  83. ld1 {v16.4s}, [x4], #16
  84. fcvtzs v20.4s, v16.4s, #31
  85. sri v6.4s, v4.4s, #16
  86. ld1 {v17.4s}, [x4], #16
  87. fcvtzs v21.4s, v17.4s, #31
  88. ld1 {v18.4s}, [x5], #16
  89. fcvtzs v22.4s, v18.4s, #31
  90. ld1 {v19.4s}, [x5], #16
  91. sri v7.4s, v5.4s, #16
  92. st1 {v6.4s}, [x0], #16
  93. fcvtzs v23.4s, v19.4s, #31
  94. st1 {v7.4s}, [x0], #16
  95. sri v22.4s, v20.4s, #16
  96. ld1 {v0.4s}, [x4], #16
  97. sri v23.4s, v21.4s, #16
  98. st1 {v22.4s}, [x0], #16
  99. fcvtzs v4.4s, v0.4s, #31
  100. ld1 {v1.4s}, [x4], #16
  101. fcvtzs v5.4s, v1.4s, #31
  102. ld1 {v2.4s}, [x5], #16
  103. fcvtzs v6.4s, v2.4s, #31
  104. ld1 {v3.4s}, [x5], #16
  105. fcvtzs v7.4s, v3.4s, #31
  106. st1 {v23.4s}, [x0], #16
  107. b.ne 1b
  108. ands x2, x2, #15
  109. b.eq 3f
  110. 2: sri v6.4s, v4.4s, #16
  111. ld1 {v0.4s}, [x4], #16
  112. fcvtzs v0.4s, v0.4s, #31
  113. ld1 {v1.4s}, [x4], #16
  114. fcvtzs v1.4s, v1.4s, #31
  115. ld1 {v2.4s}, [x5], #16
  116. fcvtzs v2.4s, v2.4s, #31
  117. sri v7.4s, v5.4s, #16
  118. ld1 {v3.4s}, [x5], #16
  119. fcvtzs v3.4s, v3.4s, #31
  120. sri v2.4s, v0.4s, #16
  121. st1 {v6.4s,v7.4s}, [x0], #32
  122. sri v3.4s, v1.4s, #16
  123. st1 {v2.4s,v3.4s}, [x0], #32
  124. ret
  125. 3: sri v6.4s, v4.4s, #16
  126. sri v7.4s, v5.4s, #16
  127. st1 {v6.4s,v7.4s}, [x0]
  128. ret
  129. endfunc
  130. function swri_oldapi_conv_fltp_to_s16_nch_neon, export=1
  131. cmp w3, #2
  132. b.eq oldapi_conv_fltp_to_s16_2ch_neon
  133. b.gt 1f
  134. ldr x1, [x1]
  135. b oldapi_conv_flt_to_s16_neon
  136. 1:
  137. cmp w3, #4
  138. lsl x12, x3, #1
  139. b.lt 4f
  140. 5: // 4 channels
  141. ldp x4, x5, [x1], #16
  142. ldp x6, x7, [x1], #16
  143. mov w9, w2
  144. mov x8, x0
  145. ld1 {v4.4s}, [x4], #16
  146. fcvtzs v4.4s, v4.4s, #31
  147. ld1 {v5.4s}, [x5], #16
  148. fcvtzs v5.4s, v5.4s, #31
  149. ld1 {v6.4s}, [x6], #16
  150. fcvtzs v6.4s, v6.4s, #31
  151. ld1 {v7.4s}, [x7], #16
  152. fcvtzs v7.4s, v7.4s, #31
  153. 6:
  154. subs w9, w9, #8
  155. ld1 {v0.4s}, [x4], #16
  156. fcvtzs v0.4s, v0.4s, #31
  157. sri v5.4s, v4.4s, #16
  158. ld1 {v1.4s}, [x5], #16
  159. fcvtzs v1.4s, v1.4s, #31
  160. sri v7.4s, v6.4s, #16
  161. ld1 {v2.4s}, [x6], #16
  162. fcvtzs v2.4s, v2.4s, #31
  163. zip1 v16.4s, v5.4s, v7.4s
  164. ld1 {v3.4s}, [x7], #16
  165. fcvtzs v3.4s, v3.4s, #31
  166. zip2 v17.4s, v5.4s, v7.4s
  167. st1 {v16.d}[0], [x8], x12
  168. sri v1.4s, v0.4s, #16
  169. st1 {v16.d}[1], [x8], x12
  170. sri v3.4s, v2.4s, #16
  171. st1 {v17.d}[0], [x8], x12
  172. zip1 v18.4s, v1.4s, v3.4s
  173. st1 {v17.d}[1], [x8], x12
  174. zip2 v19.4s, v1.4s, v3.4s
  175. b.eq 7f
  176. ld1 {v4.4s}, [x4], #16
  177. fcvtzs v4.4s, v4.4s, #31
  178. st1 {v18.d}[0], [x8], x12
  179. ld1 {v5.4s}, [x5], #16
  180. fcvtzs v5.4s, v5.4s, #31
  181. st1 {v18.d}[1], [x8], x12
  182. ld1 {v6.4s}, [x6], #16
  183. fcvtzs v6.4s, v6.4s, #31
  184. st1 {v19.d}[0], [x8], x12
  185. ld1 {v7.4s}, [x7], #16
  186. fcvtzs v7.4s, v7.4s, #31
  187. st1 {v19.d}[1], [x8], x12
  188. b 6b
  189. 7:
  190. st1 {v18.d}[0], [x8], x12
  191. st1 {v18.d}[1], [x8], x12
  192. st1 {v19.d}[0], [x8], x12
  193. st1 {v19.d}[1], [x8], x12
  194. subs w3, w3, #4
  195. b.eq end
  196. cmp w3, #4
  197. add x0, x0, #8
  198. b.ge 5b
  199. 4: // 2 channels
  200. cmp w3, #2
  201. b.lt 4f
  202. ldp x4, x5, [x1], #16
  203. mov w9, w2
  204. mov x8, x0
  205. tst w9, #8
  206. ld1 {v4.4s}, [x4], #16
  207. fcvtzs v4.4s, v4.4s, #31
  208. ld1 {v5.4s}, [x5], #16
  209. fcvtzs v5.4s, v5.4s, #31
  210. ld1 {v6.4s}, [x4], #16
  211. fcvtzs v6.4s, v6.4s, #31
  212. ld1 {v7.4s}, [x5], #16
  213. fcvtzs v7.4s, v7.4s, #31
  214. b.eq 6f
  215. subs w9, w9, #8
  216. b.eq 7f
  217. sri v5.4s, v4.4s, #16
  218. ld1 {v4.4s}, [x4], #16
  219. fcvtzs v4.4s, v4.4s, #31
  220. st1 {v5.s}[0], [x8], x12
  221. sri v7.4s, v6.4s, #16
  222. st1 {v5.s}[1], [x8], x12
  223. ld1 {v6.4s}, [x4], #16
  224. fcvtzs v6.4s, v6.4s, #31
  225. st1 {v5.s}[2], [x8], x12
  226. st1 {v5.s}[3], [x8], x12
  227. st1 {v7.s}[0], [x8], x12
  228. st1 {v7.s}[1], [x8], x12
  229. ld1 {v5.4s}, [x5], #16
  230. fcvtzs v5.4s, v5.4s, #31
  231. st1 {v7.s}[2], [x8], x12
  232. st1 {v7.s}[3], [x8], x12
  233. ld1 {v7.4s}, [x5], #16
  234. fcvtzs v7.4s, v7.4s, #31
  235. 6:
  236. subs w9, w9, #16
  237. ld1 {v0.4s}, [x4], #16
  238. sri v5.4s, v4.4s, #16
  239. fcvtzs v0.4s, v0.4s, #31
  240. ld1 {v1.4s}, [x5], #16
  241. sri v7.4s, v6.4s, #16
  242. st1 {v5.s}[0], [x8], x12
  243. st1 {v5.s}[1], [x8], x12
  244. fcvtzs v1.4s, v1.4s, #31
  245. st1 {v5.s}[2], [x8], x12
  246. st1 {v5.s}[3], [x8], x12
  247. ld1 {v2.4s}, [x4], #16
  248. st1 {v7.s}[0], [x8], x12
  249. fcvtzs v2.4s, v2.4s, #31
  250. st1 {v7.s}[1], [x8], x12
  251. ld1 {v3.4s}, [x5], #16
  252. st1 {v7.s}[2], [x8], x12
  253. fcvtzs v3.4s, v3.4s, #31
  254. st1 {v7.s}[3], [x8], x12
  255. sri v1.4s, v0.4s, #16
  256. sri v3.4s, v2.4s, #16
  257. b.eq 6f
  258. ld1 {v4.4s}, [x4], #16
  259. st1 {v1.s}[0], [x8], x12
  260. fcvtzs v4.4s, v4.4s, #31
  261. st1 {v1.s}[1], [x8], x12
  262. ld1 {v5.4s}, [x5], #16
  263. st1 {v1.s}[2], [x8], x12
  264. fcvtzs v5.4s, v5.4s, #31
  265. st1 {v1.s}[3], [x8], x12
  266. ld1 {v6.4s}, [x4], #16
  267. st1 {v3.s}[0], [x8], x12
  268. fcvtzs v6.4s, v6.4s, #31
  269. st1 {v3.s}[1], [x8], x12
  270. ld1 {v7.4s}, [x5], #16
  271. st1 {v3.s}[2], [x8], x12
  272. fcvtzs v7.4s, v7.4s, #31
  273. st1 {v3.s}[3], [x8], x12
  274. b.gt 6b
  275. 6:
  276. st1 {v1.s}[0], [x8], x12
  277. st1 {v1.s}[1], [x8], x12
  278. st1 {v1.s}[2], [x8], x12
  279. st1 {v1.s}[3], [x8], x12
  280. st1 {v3.s}[0], [x8], x12
  281. st1 {v3.s}[1], [x8], x12
  282. st1 {v3.s}[2], [x8], x12
  283. st1 {v3.s}[3], [x8], x12
  284. b 8f
  285. 7:
  286. sri v5.4s, v4.4s, #16
  287. sri v7.4s, v6.4s, #16
  288. st1 {v5.s}[0], [x8], x12
  289. st1 {v5.s}[1], [x8], x12
  290. st1 {v5.s}[2], [x8], x12
  291. st1 {v5.s}[3], [x8], x12
  292. st1 {v7.s}[0], [x8], x12
  293. st1 {v7.s}[1], [x8], x12
  294. st1 {v7.s}[2], [x8], x12
  295. st1 {v7.s}[3], [x8], x12
  296. 8:
  297. subs w3, w3, #2
  298. add x0, x0, #4
  299. b.eq end
  300. 4: // 1 channel
  301. ldr x4, [x1]
  302. tst w2, #8
  303. mov w9, w2
  304. mov x5, x0
  305. ld1 {v0.4s}, [x4], #16
  306. fcvtzs v0.4s, v0.4s, #31
  307. ld1 {v1.4s}, [x4], #16
  308. fcvtzs v1.4s, v1.4s, #31
  309. b.ne 8f
  310. 6:
  311. subs w9, w9, #16
  312. ld1 {v2.4s}, [x4], #16
  313. fcvtzs v2.4s, v2.4s, #31
  314. ld1 {v3.4s}, [x4], #16
  315. fcvtzs v3.4s, v3.4s, #31
  316. st1 {v0.h}[1], [x5], x12
  317. st1 {v0.h}[3], [x5], x12
  318. st1 {v0.h}[5], [x5], x12
  319. st1 {v0.h}[7], [x5], x12
  320. st1 {v1.h}[1], [x5], x12
  321. st1 {v1.h}[3], [x5], x12
  322. st1 {v1.h}[5], [x5], x12
  323. st1 {v1.h}[7], [x5], x12
  324. b.eq 7f
  325. ld1 {v0.4s}, [x4], #16
  326. fcvtzs v0.4s, v0.4s, #31
  327. ld1 {v1.4s}, [x4], #16
  328. fcvtzs v1.4s, v1.4s, #31
  329. 7:
  330. st1 {v2.h}[1], [x5], x12
  331. st1 {v2.h}[3], [x5], x12
  332. st1 {v2.h}[5], [x5], x12
  333. st1 {v2.h}[7], [x5], x12
  334. st1 {v3.h}[1], [x5], x12
  335. st1 {v3.h}[3], [x5], x12
  336. st1 {v3.h}[5], [x5], x12
  337. st1 {v3.h}[7], [x5], x12
  338. b.gt 6b
  339. ret
  340. 8:
  341. subs w9, w9, #8
  342. st1 {v0.h}[1], [x5], x12
  343. st1 {v0.h}[3], [x5], x12
  344. st1 {v0.h}[5], [x5], x12
  345. st1 {v0.h}[7], [x5], x12
  346. st1 {v1.h}[1], [x5], x12
  347. st1 {v1.h}[3], [x5], x12
  348. st1 {v1.h}[5], [x5], x12
  349. st1 {v1.h}[7], [x5], x12
  350. b.eq end
  351. ld1 {v0.4s}, [x4], #16
  352. fcvtzs v0.4s, v0.4s, #31
  353. ld1 {v1.4s}, [x4], #16
  354. fcvtzs v1.4s, v1.4s, #31
  355. b 6b
  356. end:
  357. ret
  358. endfunc