vf_fspp.asm 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. ;*****************************************************************************
  2. ;* x86-optimized functions for fspp filter
  3. ;*
  4. ;* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
  5. ;* Copyright (C) 2005 Nikolaj Poroshin <porosh3@psu.ru>
  6. ;*
  7. ;* This file is part of FFmpeg.
  8. ;*
  9. ;* FFmpeg is free software; you can redistribute it and/or modify
  10. ;* it under the terms of the GNU General Public License as published by
  11. ;* the Free Software Foundation; either version 2 of the License, or
  12. ;* (at your option) any later version.
  13. ;*
  14. ;* FFmpeg is distributed in the hope that it will be useful,
  15. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;* GNU General Public License for more details.
  18. ;*
  19. ;* You should have received a copy of the GNU General Public License along
  20. ;* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  21. ;* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. ;******************************************************************************
  23. %include "libavutil/x86/x86util.asm"
  24. SECTION_RODATA
  25. pb_dither: db 0, 48, 12, 60, 3, 51, 15, 63, 32, 16, 44, 28, 35, 19, 47, 31, \
  26. 8, 56, 4, 52, 11, 59, 7, 55, 40, 24, 36, 20, 43, 27, 39, 23, \
  27. 2, 50, 14, 62, 1, 49, 13, 61, 34, 18, 46, 30, 33, 17, 45, 29, \
  28. 10, 58, 6, 54, 9, 57, 5, 53, 42, 26, 38, 22, 41, 25, 37, 21
  29. pw_187E: times 4 dw 0x187E ; FIX64(0.382683433, 14)
  30. pw_22A3: times 4 dw 0x22A3 ; FIX64(1.082392200, 13)
  31. pw_2D41: times 4 dw 0x2D41 ; FIX64(1.414213562, 13)
  32. pw_539F: times 4 dw 0x539F ; FIX64(1.306562965, 14)
  33. pw_5A82: times 4 dw 0x5A82 ; FIX64(1.414213562, 14)
  34. pw_3B21: times 4 dw 0x3B21 ; FIX64(1.847759065, 13)
  35. pw_AC62: times 4 dw 0xAC62 ; FIX64(-2.613125930, 13)
  36. pw_3642: times 4 dw 0x3642 ; FIX64(0.847759065, 14)
  37. pw_2441: times 4 dw 0x2441 ; FIX64(0.566454497, 14)
  38. pw_0CBB: times 4 dw 0x0CBB ; FIX64(0.198912367, 14)
  39. pw_4: times 4 dw 4
  40. pw_2: times 4 dw 2
  41. SECTION .text
  42. %define DCTSIZE 8
  43. INIT_MMX mmx
  44. ;void ff_store_slice_mmx(uint8_t *dst, int16_t *src,
  45. ; ptrdiff_t dst_stride, ptrdiff_t src_stride,
  46. ; ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale)
  47. %if ARCH_X86_64
  48. cglobal store_slice, 7, 9, 0, dst, src, dst_stride, src_stride, width, dither_height, dither, tmp, tmp2
  49. %else
  50. cglobal store_slice, 2, 7, 0, dst, src, width, dither_height, dither, tmp, tmp2
  51. %define dst_strideq r2m
  52. %define src_strideq r3m
  53. mov widthq, r4m
  54. mov dither_heightq, r5m
  55. mov ditherq, r6m ; log2_scale
  56. %endif
  57. add widthq, 7
  58. mov tmpq, src_strideq
  59. and widthq, ~7
  60. sub dst_strideq, widthq
  61. movd m5, ditherd ; log2_scale
  62. xor ditherq, -1 ; log2_scale
  63. mov tmp2q, tmpq
  64. add ditherq, 7 ; log2_scale
  65. neg tmpq
  66. sub tmp2q, widthq
  67. movd m2, ditherd ; log2_scale
  68. add tmp2q, tmp2q
  69. lea ditherq, [pb_dither]
  70. mov src_strideq, tmp2q
  71. shl tmpq, 4
  72. lea dither_heightq, [ditherq+dither_heightq*8]
  73. pxor m7, m7
  74. .loop_height:
  75. movq m3, [ditherq]
  76. movq m4, m3
  77. punpcklbw m3, m7
  78. punpckhbw m4, m7
  79. mov tmp2q, widthq
  80. psraw m3, m5
  81. psraw m4, m5
  82. .loop_width:
  83. movq [srcq+tmpq], m7
  84. movq m0, [srcq]
  85. movq m1, [srcq+8]
  86. movq [srcq+tmpq+8], m7
  87. paddw m0, m3
  88. paddw m1, m4
  89. movq [srcq], m7
  90. psraw m0, m2
  91. psraw m1, m2
  92. movq [srcq+8], m7
  93. packuswb m0, m1
  94. add srcq, 16
  95. movq [dstq], m0
  96. add dstq, 8
  97. sub tmp2q, 8
  98. jg .loop_width
  99. add srcq, src_strideq
  100. add ditherq, 8
  101. add dstq, dst_strideq
  102. cmp ditherq, dither_heightq
  103. jl .loop_height
  104. RET
  105. ;void ff_store_slice2_mmx(uint8_t *dst, int16_t *src,
  106. ; ptrdiff_t dst_stride, ptrdiff_t src_stride,
  107. ; ptrdiff_t width, ptrdiff_t height, ptrdiff_t log2_scale)
  108. %if ARCH_X86_64
  109. cglobal store_slice2, 7, 9, 0, dst, src, dst_stride, src_stride, width, dither_height, dither, tmp, tmp2
  110. %else
  111. cglobal store_slice2, 0, 7, 0, dst, src, width, dither_height, dither, tmp, tmp2
  112. %define dst_strideq r2m
  113. %define src_strideq r3m
  114. mov dstq, dstm
  115. mov srcq, srcm
  116. mov widthq, r4m
  117. mov dither_heightq, r5m
  118. mov ditherq, r6m ; log2_scale
  119. %endif
  120. add widthq, 7
  121. mov tmpq, src_strideq
  122. and widthq, ~7
  123. sub dst_strideq, widthq
  124. movd m5, ditherd ; log2_scale
  125. xor ditherq, -1 ; log2_scale
  126. mov tmp2q, tmpq
  127. add ditherq, 7 ; log2_scale
  128. sub tmp2q, widthq
  129. movd m2, ditherd ; log2_scale
  130. add tmp2q, tmp2q
  131. lea ditherq, [pb_dither]
  132. mov src_strideq, tmp2q
  133. shl tmpq, 5
  134. lea dither_heightq, [ditherq+dither_heightq*8]
  135. pxor m7, m7
  136. .loop_height:
  137. movq m3, [ditherq]
  138. movq m4, m3
  139. punpcklbw m3, m7
  140. punpckhbw m4, m7
  141. mov tmp2q,widthq
  142. psraw m3, m5
  143. psraw m4, m5
  144. .loop_width:
  145. movq m0, [srcq]
  146. movq m1, [srcq+8]
  147. paddw m0, m3
  148. paddw m0, [srcq+tmpq]
  149. paddw m1, m4
  150. movq m6, [srcq+tmpq+8]
  151. movq [srcq+tmpq], m7
  152. psraw m0, m2
  153. paddw m1, m6
  154. movq [srcq+tmpq+8], m7
  155. psraw m1, m2
  156. packuswb m0, m1
  157. movq [dstq], m0
  158. add srcq, 16
  159. add dstq, 8
  160. sub tmp2q, 8
  161. jg .loop_width
  162. add srcq, src_strideq
  163. add ditherq, 8
  164. add dstq, dst_strideq
  165. cmp ditherq, dither_heightq
  166. jl .loop_height
  167. RET
  168. ;void ff_mul_thrmat_mmx(int16_t *thr_adr_noq, int16_t *thr_adr, int q);
  169. cglobal mul_thrmat, 3, 3, 0, thrn, thr, q
  170. movd m7, qd
  171. movq m0, [thrnq]
  172. punpcklwd m7, m7
  173. movq m1, [thrnq+8]
  174. punpckldq m7, m7
  175. pmullw m0, m7
  176. movq m2, [thrnq+8*2]
  177. pmullw m1, m7
  178. movq m3, [thrnq+8*3]
  179. pmullw m2, m7
  180. movq [thrq], m0
  181. movq m4, [thrnq+8*4]
  182. pmullw m3, m7
  183. movq [thrq+8], m1
  184. movq m5, [thrnq+8*5]
  185. pmullw m4, m7
  186. movq [thrq+8*2], m2
  187. movq m6, [thrnq+8*6]
  188. pmullw m5, m7
  189. movq [thrq+8*3], m3
  190. movq m0, [thrnq+8*7]
  191. pmullw m6, m7
  192. movq [thrq+8*4], m4
  193. movq m1, [thrnq+8*7+8]
  194. pmullw m0, m7
  195. movq [thrq+8*5], m5
  196. movq m2, [thrnq+8*7+8*2]
  197. pmullw m1, m7
  198. movq [thrq+8*6], m6
  199. movq m3, [thrnq+8*7+8*3]
  200. pmullw m2, m7
  201. movq [thrq+8*7], m0
  202. movq m4, [thrnq+8*7+8*4]
  203. pmullw m3, m7
  204. movq [thrq+8*7+8], m1
  205. movq m5, [thrnq+8*7+8*5]
  206. pmullw m4, m7
  207. movq [thrq+8*7+8*2], m2
  208. movq m6, [thrnq+8*7+8*6]
  209. pmullw m5, m7
  210. movq [thrq+8*7+8*3], m3
  211. movq m0, [thrnq+14*8]
  212. pmullw m6, m7
  213. movq [thrq+8*7+8*4], m4
  214. movq m1, [thrnq+14*8+8]
  215. pmullw m0, m7
  216. movq [thrq+8*7+8*5], m5
  217. pmullw m1, m7
  218. movq [thrq+8*7+8*6], m6
  219. movq [thrq+14*8], m0
  220. movq [thrq+14*8+8], m1
  221. RET
  222. %macro COLUMN_FDCT 1-3 0, 0
  223. movq m1, [srcq+DCTSIZE*0*2]
  224. movq m7, [srcq+DCTSIZE*3*2]
  225. movq m0, m1
  226. paddw m1, [srcq+DCTSIZE*7*2]
  227. movq m3, m7
  228. paddw m7, [srcq+DCTSIZE*4*2]
  229. movq m5, m1
  230. movq m6, [srcq+DCTSIZE*1*2]
  231. psubw m1, m7
  232. movq m2, [srcq+DCTSIZE*2*2]
  233. movq m4, m6
  234. paddw m6, [srcq+DCTSIZE*6*2]
  235. paddw m5, m7
  236. paddw m2, [srcq+DCTSIZE*5*2]
  237. movq m7, m6
  238. paddw m6, m2
  239. psubw m7, m2
  240. movq m2, m5
  241. paddw m5, m6
  242. psubw m2, m6
  243. paddw m7, m1
  244. movq m6, [thrq+4*16+%2]
  245. psllw m7, 2
  246. psubw m5, [thrq+%2]
  247. psubw m2, m6
  248. paddusw m5, [thrq+%2]
  249. paddusw m2, m6
  250. pmulhw m7, [pw_2D41]
  251. paddw m5, [thrq+%2]
  252. paddw m2, m6
  253. psubusw m5, [thrq+%2]
  254. psubusw m2, m6
  255. paddw m5, [pw_2]
  256. movq m6, m2
  257. paddw m2, m5
  258. psubw m5, m6
  259. movq m6, m1
  260. paddw m1, m7
  261. psubw m1, [thrq+2*16+%2]
  262. psubw m6, m7
  263. movq m7, [thrq+6*16+%2]
  264. psraw m5, 2
  265. paddusw m1, [thrq+2*16+%2]
  266. psubw m6, m7
  267. paddw m1, [thrq+2*16+%2]
  268. paddusw m6, m7
  269. psubusw m1, [thrq+2*16+%2]
  270. paddw m6, m7
  271. psubw m3, [srcq+DCTSIZE*4*2]
  272. psubusw m6, m7
  273. movq m7, m1
  274. psraw m2, 2
  275. psubw m4, [srcq+DCTSIZE*6*2]
  276. psubw m1, m6
  277. psubw m0, [srcq+DCTSIZE*7*2]
  278. paddw m6, m7
  279. psraw m6, 2
  280. movq m7, m2
  281. pmulhw m1, [pw_5A82]
  282. paddw m2, m6
  283. movq [rsp], m2
  284. psubw m7, m6
  285. movq m2, [srcq+DCTSIZE*2*2]
  286. psubw m1, m6
  287. psubw m2, [srcq+DCTSIZE*5*2]
  288. movq m6, m5
  289. movq [rsp+8*3], m7
  290. paddw m3, m2
  291. paddw m2, m4
  292. paddw m4, m0
  293. movq m7, m3
  294. psubw m3, m4
  295. psllw m3, 2
  296. psllw m7, 2
  297. pmulhw m3, [pw_187E]
  298. psllw m4, 2
  299. pmulhw m7, [pw_22A3]
  300. psllw m2, 2
  301. pmulhw m4, [pw_539F]
  302. paddw m5, m1
  303. pmulhw m2, [pw_2D41]
  304. psubw m6, m1
  305. paddw m7, m3
  306. movq [rsp+8], m5
  307. paddw m4, m3
  308. movq m3, [thrq+3*16+%2]
  309. movq m1, m0
  310. movq [rsp+8*2], m6
  311. psubw m1, m2
  312. paddw m0, m2
  313. movq m5, m1
  314. movq m2, [thrq+5*16+%2]
  315. psubw m1, m7
  316. paddw m5, m7
  317. psubw m1, m3
  318. movq m7, [thrq+16+%2]
  319. psubw m5, m2
  320. movq m6, m0
  321. paddw m0, m4
  322. paddusw m1, m3
  323. psubw m6, m4
  324. movq m4, [thrq+7*16+%2]
  325. psubw m0, m7
  326. psubw m6, m4
  327. paddusw m5, m2
  328. paddusw m6, m4
  329. paddw m1, m3
  330. paddw m5, m2
  331. paddw m6, m4
  332. psubusw m1, m3
  333. psubusw m5, m2
  334. psubusw m6, m4
  335. movq m4, m1
  336. por m4, m5
  337. paddusw m0, m7
  338. por m4, m6
  339. paddw m0, m7
  340. packssdw m4, m4
  341. psubusw m0, m7
  342. movd tmpd, m4
  343. or tmpd, tmpd
  344. jnz %1
  345. movq m4, [rsp]
  346. movq m1, m0
  347. pmulhw m0, [pw_3642]
  348. movq m2, m1
  349. movq m5, [outq+DCTSIZE*0*2]
  350. movq m3, m2
  351. pmulhw m1, [pw_2441]
  352. paddw m5, m4
  353. movq m6, [rsp+8]
  354. psraw m3, 2
  355. pmulhw m2, [pw_0CBB]
  356. psubw m4, m3
  357. movq m7, [outq+DCTSIZE*1*2]
  358. paddw m5, m3
  359. movq [outq+DCTSIZE*7*2], m4
  360. paddw m7, m6
  361. movq m3, [rsp+8*2]
  362. psubw m6, m0
  363. movq m4, [outq+DCTSIZE*2*2]
  364. paddw m7, m0
  365. movq [outq], m5
  366. paddw m4, m3
  367. movq [outq+DCTSIZE*6*2], m6
  368. psubw m3, m1
  369. movq m5, [outq+DCTSIZE*5*2]
  370. paddw m4, m1
  371. movq m6, [outq+DCTSIZE*3*2]
  372. paddw m5, m3
  373. movq m0, [rsp+8*3]
  374. add srcq, 8+%3
  375. movq [outq+DCTSIZE*1*2], m7
  376. paddw m6, m0
  377. movq [outq+DCTSIZE*2*2], m4
  378. psubw m0, m2
  379. movq m7, [outq+DCTSIZE*4*2]
  380. paddw m6, m2
  381. movq [outq+DCTSIZE*5*2], m5
  382. paddw m7, m0
  383. movq [outq+DCTSIZE*3*2], m6
  384. movq [outq+DCTSIZE*4*2], m7
  385. add outq, 8+%3
  386. %endmacro
  387. %macro COLUMN_IDCT 0-1 0
  388. movq m3, m5
  389. psubw m5, m1
  390. psllw m5, 1
  391. paddw m3, m1
  392. movq m2, m0
  393. psubw m0, m6
  394. movq m1, m5
  395. psllw m0, 1
  396. pmulhw m1, [pw_AC62]
  397. paddw m5, m0
  398. pmulhw m5, [pw_3B21]
  399. paddw m2, m6
  400. pmulhw m0, [pw_22A3]
  401. movq m7, m2
  402. movq m4, [rsp]
  403. psubw m2, m3
  404. psllw m2, 1
  405. paddw m7, m3
  406. pmulhw m2, [pw_2D41]
  407. movq m6, m4
  408. psraw m7, 2
  409. paddw m4, [outq]
  410. psubw m6, m7
  411. movq m3, [rsp+8]
  412. paddw m4, m7
  413. movq [outq+DCTSIZE*7*2], m6
  414. paddw m1, m5
  415. movq [outq], m4
  416. psubw m1, m7
  417. movq m7, [rsp+8*2]
  418. psubw m0, m5
  419. movq m6, [rsp+8*3]
  420. movq m5, m3
  421. paddw m3, [outq+DCTSIZE*1*2]
  422. psubw m5, m1
  423. psubw m2, m1
  424. paddw m3, m1
  425. movq [outq+DCTSIZE*6*2], m5
  426. movq m4, m7
  427. paddw m7, [outq+DCTSIZE*2*2]
  428. psubw m4, m2
  429. paddw m4, [outq+DCTSIZE*5*2]
  430. paddw m7, m2
  431. movq [outq+DCTSIZE*1*2], m3
  432. paddw m0, m2
  433. movq [outq+DCTSIZE*2*2], m7
  434. movq m1, m6
  435. paddw m6, [outq+DCTSIZE*4*2]
  436. psubw m1, m0
  437. paddw m1, [outq+DCTSIZE*3*2]
  438. paddw m6, m0
  439. movq [outq+DCTSIZE*5*2], m4
  440. add srcq, 8+%1
  441. movq [outq+DCTSIZE*4*2], m6
  442. movq [outq+DCTSIZE*3*2], m1
  443. add outq, 8+%1
  444. %endmacro
  445. ;void ff_column_fidct_mmx(int16_t *thr_adr, int16_t *data, int16_t *output, int cnt);
  446. cglobal column_fidct, 4, 5, 0, 32, thr, src, out, cnt, tmp
  447. .fdct1:
  448. COLUMN_FDCT .idct1
  449. jmp .fdct2
  450. .idct1:
  451. COLUMN_IDCT
  452. .fdct2:
  453. COLUMN_FDCT .idct2, 8, 16
  454. sub cntd, 2
  455. jg .fdct1
  456. RET
  457. .idct2:
  458. COLUMN_IDCT 16
  459. sub cntd, 2
  460. jg .fdct1
  461. RET
  462. ;void ff_row_idct_mmx(int16_t *workspace, int16_t *output_adr, ptrdiff_t output_stride, int cnt);
  463. cglobal row_idct, 4, 5, 0, 16, src, dst, stride, cnt, stride3
  464. add strideq, strideq
  465. lea stride3q, [strideq+strideq*2]
  466. .loop:
  467. movq m0, [srcq+DCTSIZE*0*2]
  468. movq m1, [srcq+DCTSIZE*1*2]
  469. movq m4, m0
  470. movq m2, [srcq+DCTSIZE*2*2]
  471. punpcklwd m0, m1
  472. movq m3, [srcq+DCTSIZE*3*2]
  473. punpckhwd m4, m1
  474. movq m7, m2
  475. punpcklwd m2, m3
  476. movq m6, m0
  477. punpckldq m0, m2
  478. punpckhdq m6, m2
  479. movq m5, m0
  480. punpckhwd m7, m3
  481. psubw m0, m6
  482. pmulhw m0, [pw_5A82]
  483. movq m2, m4
  484. punpckldq m4, m7
  485. paddw m5, m6
  486. punpckhdq m2, m7
  487. movq m1, m4
  488. psllw m0, 2
  489. paddw m4, m2
  490. movq m3, [srcq+DCTSIZE*0*2+8]
  491. psubw m1, m2
  492. movq m2, [srcq+DCTSIZE*1*2+8]
  493. psubw m0, m5
  494. movq m6, m4
  495. paddw m4, m5
  496. psubw m6, m5
  497. movq m7, m1
  498. movq m5, [srcq+DCTSIZE*2*2+8]
  499. paddw m1, m0
  500. movq [rsp], m4
  501. movq m4, m3
  502. movq [rsp+8], m6
  503. punpcklwd m3, m2
  504. movq m6, [srcq+DCTSIZE*3*2+8]
  505. punpckhwd m4, m2
  506. movq m2, m5
  507. punpcklwd m5, m6
  508. psubw m7, m0
  509. punpckhwd m2, m6
  510. movq m0, m3
  511. punpckldq m3, m5
  512. punpckhdq m0, m5
  513. movq m5, m4
  514. movq m6, m3
  515. punpckldq m4, m2
  516. psubw m3, m0
  517. punpckhdq m5, m2
  518. paddw m6, m0
  519. movq m2, m4
  520. movq m0, m3
  521. psubw m4, m5
  522. pmulhw m0, [pw_AC62]
  523. paddw m3, m4
  524. pmulhw m3, [pw_3B21]
  525. paddw m2, m5
  526. pmulhw m4, [pw_22A3]
  527. movq m5, m2
  528. psubw m2, m6
  529. paddw m5, m6
  530. pmulhw m2, [pw_2D41]
  531. paddw m0, m3
  532. psllw m0, 3
  533. psubw m4, m3
  534. movq m6, [rsp]
  535. movq m3, m1
  536. psllw m4, 3
  537. psubw m0, m5
  538. psllw m2, 3
  539. paddw m1, m0
  540. psubw m2, m0
  541. psubw m3, m0
  542. paddw m4, m2
  543. movq m0, m7
  544. paddw m7, m2
  545. psubw m0, m2
  546. movq m2, [pw_4]
  547. psubw m6, m5
  548. paddw m5, [rsp]
  549. paddw m1, m2
  550. paddw m5, m2
  551. psraw m1, 3
  552. paddw m7, m2
  553. psraw m5, 3
  554. paddw m5, [dstq]
  555. psraw m7, 3
  556. paddw m1, [dstq+strideq*1]
  557. paddw m0, m2
  558. paddw m7, [dstq+strideq*2]
  559. paddw m3, m2
  560. movq [dstq], m5
  561. paddw m6, m2
  562. movq [dstq+strideq*1], m1
  563. psraw m0, 3
  564. movq [dstq+strideq*2], m7
  565. add dstq, stride3q
  566. movq m5, [rsp+8]
  567. psraw m3, 3
  568. paddw m0, [dstq+strideq*2]
  569. psubw m5, m4
  570. paddw m3, [dstq+stride3q*1]
  571. psraw m6, 3
  572. paddw m4, [rsp+8]
  573. paddw m5, m2
  574. paddw m6, [dstq+strideq*4]
  575. paddw m4, m2
  576. movq [dstq+strideq*2], m0
  577. psraw m5, 3
  578. paddw m5, [dstq]
  579. psraw m4, 3
  580. paddw m4, [dstq+strideq*1]
  581. add srcq, DCTSIZE*2*4
  582. movq [dstq+stride3q*1], m3
  583. movq [dstq+strideq*4], m6
  584. movq [dstq], m5
  585. movq [dstq+strideq*1], m4
  586. sub dstq, stride3q
  587. add dstq, 8
  588. dec r3d
  589. jnz .loop
  590. RET
  591. ;void ff_row_fdct_mmx(int16_t *data, const uint8_t *pixels, ptrdiff_t line_size, int cnt);
  592. cglobal row_fdct, 4, 5, 0, 16, src, pix, stride, cnt, stride3
  593. lea stride3q, [strideq+strideq*2]
  594. .loop:
  595. movd m0, [pixq]
  596. pxor m7, m7
  597. movd m1, [pixq+strideq*1]
  598. punpcklbw m0, m7
  599. movd m2, [pixq+strideq*2]
  600. punpcklbw m1, m7
  601. punpcklbw m2, m7
  602. add pixq,stride3q
  603. movq m5, m0
  604. movd m3, [pixq+strideq*4]
  605. movq m6, m1
  606. movd m4, [pixq+stride3q*1]
  607. punpcklbw m3, m7
  608. psubw m5, m3
  609. punpcklbw m4, m7
  610. paddw m0, m3
  611. psubw m6, m4
  612. movd m3, [pixq+strideq*2]
  613. paddw m1, m4
  614. movq [rsp], m5
  615. punpcklbw m3, m7
  616. movq [rsp+8], m6
  617. movq m4, m2
  618. movd m5, [pixq]
  619. paddw m2, m3
  620. movd m6, [pixq+strideq*1]
  621. punpcklbw m5, m7
  622. psubw m4, m3
  623. punpcklbw m6, m7
  624. movq m3, m5
  625. paddw m5, m6
  626. psubw m3, m6
  627. movq m6, m0
  628. movq m7, m1
  629. psubw m0, m5
  630. psubw m1, m2
  631. paddw m7, m2
  632. paddw m1, m0
  633. movq m2, m7
  634. psllw m1, 2
  635. paddw m6, m5
  636. pmulhw m1, [pw_2D41]
  637. paddw m7, m6
  638. psubw m6, m2
  639. movq m5, m0
  640. movq m2, m7
  641. punpcklwd m7, m6
  642. paddw m0, m1
  643. punpckhwd m2, m6
  644. psubw m5, m1
  645. movq m6, m0
  646. movq m1, [rsp+8]
  647. punpcklwd m0, m5
  648. punpckhwd m6, m5
  649. movq m5, m0
  650. punpckldq m0, m7
  651. paddw m3, m4
  652. punpckhdq m5, m7
  653. movq m7, m6
  654. movq [srcq+DCTSIZE*0*2], m0
  655. punpckldq m6, m2
  656. movq [srcq+DCTSIZE*1*2], m5
  657. punpckhdq m7, m2
  658. movq [srcq+DCTSIZE*2*2], m6
  659. paddw m4, m1
  660. movq [srcq+DCTSIZE*3*2], m7
  661. psllw m3, 2
  662. movq m2, [rsp]
  663. psllw m4, 2
  664. pmulhw m4, [pw_2D41]
  665. paddw m1, m2
  666. psllw m1, 2
  667. movq m0, m3
  668. pmulhw m0, [pw_22A3]
  669. psubw m3, m1
  670. pmulhw m3, [pw_187E]
  671. movq m5, m2
  672. pmulhw m1, [pw_539F]
  673. psubw m2, m4
  674. paddw m5, m4
  675. movq m6, m2
  676. paddw m0, m3
  677. movq m7, m5
  678. paddw m2, m0
  679. psubw m6, m0
  680. movq m4, m2
  681. paddw m1, m3
  682. punpcklwd m2, m6
  683. paddw m5, m1
  684. punpckhwd m4, m6
  685. psubw m7, m1
  686. movq m6, m5
  687. punpcklwd m5, m7
  688. punpckhwd m6, m7
  689. movq m7, m2
  690. punpckldq m2, m5
  691. sub pixq, stride3q
  692. punpckhdq m7, m5
  693. movq m5, m4
  694. movq [srcq+DCTSIZE*0*2+8], m2
  695. punpckldq m4, m6
  696. movq [srcq+DCTSIZE*1*2+8], m7
  697. punpckhdq m5, m6
  698. movq [srcq+DCTSIZE*2*2+8], m4
  699. add pixq, 4
  700. movq [srcq+DCTSIZE*3*2+8], m5
  701. add srcq, DCTSIZE*4*2
  702. dec cntd
  703. jnz .loop
  704. RET