audio_convert_neon.S 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /*
  2. * Copyright (c) 2008 Mans Rullgard <mans@mansr.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 "config.h"
  21. #include "libavutil/arm/asm.S"
  22. function ff_conv_flt_to_s16_neon, export=1
  23. subs r2, r2, #8
  24. vld1.32 {q0}, [r1,:128]!
  25. vcvt.s32.f32 q8, q0, #31
  26. vld1.32 {q1}, [r1,:128]!
  27. vcvt.s32.f32 q9, q1, #31
  28. beq 3f
  29. bics r12, r2, #15
  30. beq 2f
  31. 1: subs r12, r12, #16
  32. vqrshrn.s32 d4, q8, #16
  33. vld1.32 {q0}, [r1,:128]!
  34. vcvt.s32.f32 q0, q0, #31
  35. vqrshrn.s32 d5, q9, #16
  36. vld1.32 {q1}, [r1,:128]!
  37. vcvt.s32.f32 q1, q1, #31
  38. vqrshrn.s32 d6, q0, #16
  39. vst1.16 {q2}, [r0,:128]!
  40. vqrshrn.s32 d7, q1, #16
  41. vld1.32 {q8}, [r1,:128]!
  42. vcvt.s32.f32 q8, q8, #31
  43. vld1.32 {q9}, [r1,:128]!
  44. vcvt.s32.f32 q9, q9, #31
  45. vst1.16 {q3}, [r0,:128]!
  46. bne 1b
  47. ands r2, r2, #15
  48. beq 3f
  49. 2: vld1.32 {q0}, [r1,:128]!
  50. vqrshrn.s32 d4, q8, #16
  51. vcvt.s32.f32 q0, q0, #31
  52. vld1.32 {q1}, [r1,:128]!
  53. vqrshrn.s32 d5, q9, #16
  54. vcvt.s32.f32 q1, q1, #31
  55. vqrshrn.s32 d6, q0, #16
  56. vst1.16 {q2}, [r0,:128]!
  57. vqrshrn.s32 d7, q1, #16
  58. vst1.16 {q3}, [r0,:128]!
  59. bx lr
  60. 3: vqrshrn.s32 d4, q8, #16
  61. vqrshrn.s32 d5, q9, #16
  62. vst1.16 {q2}, [r0,:128]!
  63. bx lr
  64. endfunc
  65. function ff_conv_fltp_to_s16_2ch_neon, export=1
  66. ldm r1, {r1, r3}
  67. subs r2, r2, #8
  68. vld1.32 {q0}, [r1,:128]!
  69. vcvt.s32.f32 q8, q0, #31
  70. vld1.32 {q1}, [r1,:128]!
  71. vcvt.s32.f32 q9, q1, #31
  72. vld1.32 {q10}, [r3,:128]!
  73. vcvt.s32.f32 q10, q10, #31
  74. vld1.32 {q11}, [r3,:128]!
  75. vcvt.s32.f32 q11, q11, #31
  76. beq 3f
  77. bics r12, r2, #15
  78. beq 2f
  79. 1: subs r12, r12, #16
  80. vld1.32 {q0}, [r1,:128]!
  81. vcvt.s32.f32 q0, q0, #31
  82. vsri.32 q10, q8, #16
  83. vld1.32 {q1}, [r1,:128]!
  84. vcvt.s32.f32 q1, q1, #31
  85. vld1.32 {q12}, [r3,:128]!
  86. vcvt.s32.f32 q12, q12, #31
  87. vld1.32 {q13}, [r3,:128]!
  88. vsri.32 q11, q9, #16
  89. vst1.16 {q10}, [r0,:128]!
  90. vcvt.s32.f32 q13, q13, #31
  91. vst1.16 {q11}, [r0,:128]!
  92. vsri.32 q12, q0, #16
  93. vld1.32 {q8}, [r1,:128]!
  94. vsri.32 q13, q1, #16
  95. vst1.16 {q12}, [r0,:128]!
  96. vcvt.s32.f32 q8, q8, #31
  97. vld1.32 {q9}, [r1,:128]!
  98. vcvt.s32.f32 q9, q9, #31
  99. vld1.32 {q10}, [r3,:128]!
  100. vcvt.s32.f32 q10, q10, #31
  101. vld1.32 {q11}, [r3,:128]!
  102. vcvt.s32.f32 q11, q11, #31
  103. vst1.16 {q13}, [r0,:128]!
  104. bne 1b
  105. ands r2, r2, #15
  106. beq 3f
  107. 2: vsri.32 q10, q8, #16
  108. vld1.32 {q0}, [r1,:128]!
  109. vcvt.s32.f32 q0, q0, #31
  110. vld1.32 {q1}, [r1,:128]!
  111. vcvt.s32.f32 q1, q1, #31
  112. vld1.32 {q12}, [r3,:128]!
  113. vcvt.s32.f32 q12, q12, #31
  114. vsri.32 q11, q9, #16
  115. vld1.32 {q13}, [r3,:128]!
  116. vcvt.s32.f32 q13, q13, #31
  117. vst1.16 {q10}, [r0,:128]!
  118. vsri.32 q12, q0, #16
  119. vst1.16 {q11}, [r0,:128]!
  120. vsri.32 q13, q1, #16
  121. vst1.16 {q12-q13},[r0,:128]!
  122. bx lr
  123. 3: vsri.32 q10, q8, #16
  124. vsri.32 q11, q9, #16
  125. vst1.16 {q10-q11},[r0,:128]!
  126. bx lr
  127. endfunc
  128. function ff_conv_fltp_to_s16_neon, export=1
  129. cmp r3, #2
  130. itt lt
  131. ldrlt r1, [r1]
  132. blt ff_conv_flt_to_s16_neon
  133. beq ff_conv_fltp_to_s16_2ch_neon
  134. push {r4-r8, lr}
  135. cmp r3, #4
  136. lsl r12, r3, #1
  137. blt 4f
  138. @ 4 channels
  139. 5: ldm r1!, {r4-r7}
  140. mov lr, r2
  141. mov r8, r0
  142. vld1.32 {q8}, [r4,:128]!
  143. vcvt.s32.f32 q8, q8, #31
  144. vld1.32 {q9}, [r5,:128]!
  145. vcvt.s32.f32 q9, q9, #31
  146. vld1.32 {q10}, [r6,:128]!
  147. vcvt.s32.f32 q10, q10, #31
  148. vld1.32 {q11}, [r7,:128]!
  149. vcvt.s32.f32 q11, q11, #31
  150. 6: subs lr, lr, #8
  151. vld1.32 {q0}, [r4,:128]!
  152. vcvt.s32.f32 q0, q0, #31
  153. vsri.32 q9, q8, #16
  154. vld1.32 {q1}, [r5,:128]!
  155. vcvt.s32.f32 q1, q1, #31
  156. vsri.32 q11, q10, #16
  157. vld1.32 {q2}, [r6,:128]!
  158. vcvt.s32.f32 q2, q2, #31
  159. vzip.32 d18, d22
  160. vld1.32 {q3}, [r7,:128]!
  161. vcvt.s32.f32 q3, q3, #31
  162. vzip.32 d19, d23
  163. vst1.16 {d18}, [r8], r12
  164. vsri.32 q1, q0, #16
  165. vst1.16 {d22}, [r8], r12
  166. vsri.32 q3, q2, #16
  167. vst1.16 {d19}, [r8], r12
  168. vzip.32 d2, d6
  169. vst1.16 {d23}, [r8], r12
  170. vzip.32 d3, d7
  171. beq 7f
  172. vld1.32 {q8}, [r4,:128]!
  173. vcvt.s32.f32 q8, q8, #31
  174. vst1.16 {d2}, [r8], r12
  175. vld1.32 {q9}, [r5,:128]!
  176. vcvt.s32.f32 q9, q9, #31
  177. vst1.16 {d6}, [r8], r12
  178. vld1.32 {q10}, [r6,:128]!
  179. vcvt.s32.f32 q10, q10, #31
  180. vst1.16 {d3}, [r8], r12
  181. vld1.32 {q11}, [r7,:128]!
  182. vcvt.s32.f32 q11, q11, #31
  183. vst1.16 {d7}, [r8], r12
  184. b 6b
  185. 7: vst1.16 {d2}, [r8], r12
  186. vst1.16 {d6}, [r8], r12
  187. vst1.16 {d3}, [r8], r12
  188. vst1.16 {d7}, [r8], r12
  189. subs r3, r3, #4
  190. it eq
  191. popeq {r4-r8, pc}
  192. cmp r3, #4
  193. add r0, r0, #8
  194. bge 5b
  195. @ 2 channels
  196. 4: cmp r3, #2
  197. blt 4f
  198. ldm r1!, {r4-r5}
  199. mov lr, r2
  200. mov r8, r0
  201. tst lr, #8
  202. vld1.32 {q8}, [r4,:128]!
  203. vcvt.s32.f32 q8, q8, #31
  204. vld1.32 {q9}, [r5,:128]!
  205. vcvt.s32.f32 q9, q9, #31
  206. vld1.32 {q10}, [r4,:128]!
  207. vcvt.s32.f32 q10, q10, #31
  208. vld1.32 {q11}, [r5,:128]!
  209. vcvt.s32.f32 q11, q11, #31
  210. beq 6f
  211. subs lr, lr, #8
  212. beq 7f
  213. vsri.32 d18, d16, #16
  214. vsri.32 d19, d17, #16
  215. vld1.32 {q8}, [r4,:128]!
  216. vcvt.s32.f32 q8, q8, #31
  217. vst1.32 {d18[0]}, [r8], r12
  218. vsri.32 d22, d20, #16
  219. vst1.32 {d18[1]}, [r8], r12
  220. vsri.32 d23, d21, #16
  221. vst1.32 {d19[0]}, [r8], r12
  222. vst1.32 {d19[1]}, [r8], r12
  223. vld1.32 {q9}, [r5,:128]!
  224. vcvt.s32.f32 q9, q9, #31
  225. vst1.32 {d22[0]}, [r8], r12
  226. vst1.32 {d22[1]}, [r8], r12
  227. vld1.32 {q10}, [r4,:128]!
  228. vcvt.s32.f32 q10, q10, #31
  229. vst1.32 {d23[0]}, [r8], r12
  230. vst1.32 {d23[1]}, [r8], r12
  231. vld1.32 {q11}, [r5,:128]!
  232. vcvt.s32.f32 q11, q11, #31
  233. 6: subs lr, lr, #16
  234. vld1.32 {q0}, [r4,:128]!
  235. vcvt.s32.f32 q0, q0, #31
  236. vsri.32 d18, d16, #16
  237. vld1.32 {q1}, [r5,:128]!
  238. vcvt.s32.f32 q1, q1, #31
  239. vsri.32 d19, d17, #16
  240. vld1.32 {q2}, [r4,:128]!
  241. vcvt.s32.f32 q2, q2, #31
  242. vld1.32 {q3}, [r5,:128]!
  243. vcvt.s32.f32 q3, q3, #31
  244. vst1.32 {d18[0]}, [r8], r12
  245. vsri.32 d22, d20, #16
  246. vst1.32 {d18[1]}, [r8], r12
  247. vsri.32 d23, d21, #16
  248. vst1.32 {d19[0]}, [r8], r12
  249. vsri.32 d2, d0, #16
  250. vst1.32 {d19[1]}, [r8], r12
  251. vsri.32 d3, d1, #16
  252. vst1.32 {d22[0]}, [r8], r12
  253. vsri.32 d6, d4, #16
  254. vst1.32 {d22[1]}, [r8], r12
  255. vsri.32 d7, d5, #16
  256. vst1.32 {d23[0]}, [r8], r12
  257. vst1.32 {d23[1]}, [r8], r12
  258. beq 6f
  259. vld1.32 {q8}, [r4,:128]!
  260. vcvt.s32.f32 q8, q8, #31
  261. vst1.32 {d2[0]}, [r8], r12
  262. vst1.32 {d2[1]}, [r8], r12
  263. vld1.32 {q9}, [r5,:128]!
  264. vcvt.s32.f32 q9, q9, #31
  265. vst1.32 {d3[0]}, [r8], r12
  266. vst1.32 {d3[1]}, [r8], r12
  267. vld1.32 {q10}, [r4,:128]!
  268. vcvt.s32.f32 q10, q10, #31
  269. vst1.32 {d6[0]}, [r8], r12
  270. vst1.32 {d6[1]}, [r8], r12
  271. vld1.32 {q11}, [r5,:128]!
  272. vcvt.s32.f32 q11, q11, #31
  273. vst1.32 {d7[0]}, [r8], r12
  274. vst1.32 {d7[1]}, [r8], r12
  275. bgt 6b
  276. 6: vst1.32 {d2[0]}, [r8], r12
  277. vst1.32 {d2[1]}, [r8], r12
  278. vst1.32 {d3[0]}, [r8], r12
  279. vst1.32 {d3[1]}, [r8], r12
  280. vst1.32 {d6[0]}, [r8], r12
  281. vst1.32 {d6[1]}, [r8], r12
  282. vst1.32 {d7[0]}, [r8], r12
  283. vst1.32 {d7[1]}, [r8], r12
  284. b 8f
  285. 7: vsri.32 d18, d16, #16
  286. vsri.32 d19, d17, #16
  287. vst1.32 {d18[0]}, [r8], r12
  288. vsri.32 d22, d20, #16
  289. vst1.32 {d18[1]}, [r8], r12
  290. vsri.32 d23, d21, #16
  291. vst1.32 {d19[0]}, [r8], r12
  292. vst1.32 {d19[1]}, [r8], r12
  293. vst1.32 {d22[0]}, [r8], r12
  294. vst1.32 {d22[1]}, [r8], r12
  295. vst1.32 {d23[0]}, [r8], r12
  296. vst1.32 {d23[1]}, [r8], r12
  297. 8: subs r3, r3, #2
  298. add r0, r0, #4
  299. it eq
  300. popeq {r4-r8, pc}
  301. @ 1 channel
  302. 4: ldr r4, [r1]
  303. tst r2, #8
  304. mov lr, r2
  305. mov r5, r0
  306. vld1.32 {q0}, [r4,:128]!
  307. vcvt.s32.f32 q0, q0, #31
  308. vld1.32 {q1}, [r4,:128]!
  309. vcvt.s32.f32 q1, q1, #31
  310. bne 8f
  311. 6: subs lr, lr, #16
  312. vld1.32 {q2}, [r4,:128]!
  313. vcvt.s32.f32 q2, q2, #31
  314. vld1.32 {q3}, [r4,:128]!
  315. vcvt.s32.f32 q3, q3, #31
  316. vst1.16 {d0[1]}, [r5,:16], r12
  317. vst1.16 {d0[3]}, [r5,:16], r12
  318. vst1.16 {d1[1]}, [r5,:16], r12
  319. vst1.16 {d1[3]}, [r5,:16], r12
  320. vst1.16 {d2[1]}, [r5,:16], r12
  321. vst1.16 {d2[3]}, [r5,:16], r12
  322. vst1.16 {d3[1]}, [r5,:16], r12
  323. vst1.16 {d3[3]}, [r5,:16], r12
  324. beq 7f
  325. vld1.32 {q0}, [r4,:128]!
  326. vcvt.s32.f32 q0, q0, #31
  327. vld1.32 {q1}, [r4,:128]!
  328. vcvt.s32.f32 q1, q1, #31
  329. 7: vst1.16 {d4[1]}, [r5,:16], r12
  330. vst1.16 {d4[3]}, [r5,:16], r12
  331. vst1.16 {d5[1]}, [r5,:16], r12
  332. vst1.16 {d5[3]}, [r5,:16], r12
  333. vst1.16 {d6[1]}, [r5,:16], r12
  334. vst1.16 {d6[3]}, [r5,:16], r12
  335. vst1.16 {d7[1]}, [r5,:16], r12
  336. vst1.16 {d7[3]}, [r5,:16], r12
  337. bgt 6b
  338. pop {r4-r8, pc}
  339. 8: subs lr, lr, #8
  340. vst1.16 {d0[1]}, [r5,:16], r12
  341. vst1.16 {d0[3]}, [r5,:16], r12
  342. vst1.16 {d1[1]}, [r5,:16], r12
  343. vst1.16 {d1[3]}, [r5,:16], r12
  344. vst1.16 {d2[1]}, [r5,:16], r12
  345. vst1.16 {d2[3]}, [r5,:16], r12
  346. vst1.16 {d3[1]}, [r5,:16], r12
  347. vst1.16 {d3[3]}, [r5,:16], r12
  348. it eq
  349. popeq {r4-r8, pc}
  350. vld1.32 {q0}, [r4,:128]!
  351. vcvt.s32.f32 q0, q0, #31
  352. vld1.32 {q1}, [r4,:128]!
  353. vcvt.s32.f32 q1, q1, #31
  354. b 6b
  355. endfunc