fwd_txfm_ssse3_x86_64.asm 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. ;
  2. ; Copyright (c) 2015 The WebM project authors. All Rights Reserved.
  3. ;
  4. ; Use of this source code is governed by a BSD-style license
  5. ; that can be found in the LICENSE file in the root of the source
  6. ; tree. An additional intellectual property rights grant can be found
  7. ; in the file PATENTS. All contributing project authors may
  8. ; be found in the AUTHORS file in the root of the source tree.
  9. ;
  10. %include "third_party/x86inc/x86inc.asm"
  11. SECTION_RODATA
  12. pw_11585x2: times 8 dw 23170
  13. pd_8192: times 4 dd 8192
  14. %macro TRANSFORM_COEFFS 2
  15. pw_%1_%2: dw %1, %2, %1, %2, %1, %2, %1, %2
  16. pw_%2_m%1: dw %2, -%1, %2, -%1, %2, -%1, %2, -%1
  17. %endmacro
  18. TRANSFORM_COEFFS 11585, 11585
  19. TRANSFORM_COEFFS 15137, 6270
  20. TRANSFORM_COEFFS 16069, 3196
  21. TRANSFORM_COEFFS 9102, 13623
  22. SECTION .text
  23. %if ARCH_X86_64
  24. INIT_XMM ssse3
  25. cglobal fdct8x8, 3, 5, 13, input, output, stride
  26. mova m8, [GLOBAL(pd_8192)]
  27. mova m12, [GLOBAL(pw_11585x2)]
  28. lea r3, [2 * strideq]
  29. lea r4, [4 * strideq]
  30. mova m0, [inputq]
  31. mova m1, [inputq + r3]
  32. lea inputq, [inputq + r4]
  33. mova m2, [inputq]
  34. mova m3, [inputq + r3]
  35. lea inputq, [inputq + r4]
  36. mova m4, [inputq]
  37. mova m5, [inputq + r3]
  38. lea inputq, [inputq + r4]
  39. mova m6, [inputq]
  40. mova m7, [inputq + r3]
  41. ; left shift by 2 to increase forward transformation precision
  42. psllw m0, 2
  43. psllw m1, 2
  44. psllw m2, 2
  45. psllw m3, 2
  46. psllw m4, 2
  47. psllw m5, 2
  48. psllw m6, 2
  49. psllw m7, 2
  50. ; column transform
  51. ; stage 1
  52. paddw m10, m0, m7
  53. psubw m0, m7
  54. paddw m9, m1, m6
  55. psubw m1, m6
  56. paddw m7, m2, m5
  57. psubw m2, m5
  58. paddw m6, m3, m4
  59. psubw m3, m4
  60. ; stage 2
  61. paddw m5, m9, m7
  62. psubw m9, m7
  63. paddw m4, m10, m6
  64. psubw m10, m6
  65. paddw m7, m1, m2
  66. psubw m1, m2
  67. ; stage 3
  68. paddw m6, m4, m5
  69. psubw m4, m5
  70. pmulhrsw m1, m12
  71. pmulhrsw m7, m12
  72. ; sin(pi / 8), cos(pi / 8)
  73. punpcklwd m2, m10, m9
  74. punpckhwd m10, m9
  75. pmaddwd m5, m2, [GLOBAL(pw_15137_6270)]
  76. pmaddwd m2, [GLOBAL(pw_6270_m15137)]
  77. pmaddwd m9, m10, [GLOBAL(pw_15137_6270)]
  78. pmaddwd m10, [GLOBAL(pw_6270_m15137)]
  79. paddd m5, m8
  80. paddd m2, m8
  81. paddd m9, m8
  82. paddd m10, m8
  83. psrad m5, 14
  84. psrad m2, 14
  85. psrad m9, 14
  86. psrad m10, 14
  87. packssdw m5, m9
  88. packssdw m2, m10
  89. pmulhrsw m6, m12
  90. pmulhrsw m4, m12
  91. paddw m9, m3, m1
  92. psubw m3, m1
  93. paddw m10, m0, m7
  94. psubw m0, m7
  95. ; stage 4
  96. ; sin(pi / 16), cos(pi / 16)
  97. punpcklwd m1, m10, m9
  98. punpckhwd m10, m9
  99. pmaddwd m7, m1, [GLOBAL(pw_16069_3196)]
  100. pmaddwd m1, [GLOBAL(pw_3196_m16069)]
  101. pmaddwd m9, m10, [GLOBAL(pw_16069_3196)]
  102. pmaddwd m10, [GLOBAL(pw_3196_m16069)]
  103. paddd m7, m8
  104. paddd m1, m8
  105. paddd m9, m8
  106. paddd m10, m8
  107. psrad m7, 14
  108. psrad m1, 14
  109. psrad m9, 14
  110. psrad m10, 14
  111. packssdw m7, m9
  112. packssdw m1, m10
  113. ; sin(3 * pi / 16), cos(3 * pi / 16)
  114. punpcklwd m11, m0, m3
  115. punpckhwd m0, m3
  116. pmaddwd m9, m11, [GLOBAL(pw_9102_13623)]
  117. pmaddwd m11, [GLOBAL(pw_13623_m9102)]
  118. pmaddwd m3, m0, [GLOBAL(pw_9102_13623)]
  119. pmaddwd m0, [GLOBAL(pw_13623_m9102)]
  120. paddd m9, m8
  121. paddd m11, m8
  122. paddd m3, m8
  123. paddd m0, m8
  124. psrad m9, 14
  125. psrad m11, 14
  126. psrad m3, 14
  127. psrad m0, 14
  128. packssdw m9, m3
  129. packssdw m11, m0
  130. ; transpose
  131. ; stage 1
  132. punpcklwd m0, m6, m7
  133. punpcklwd m3, m5, m11
  134. punpckhwd m6, m7
  135. punpckhwd m5, m11
  136. punpcklwd m7, m4, m9
  137. punpcklwd m10, m2, m1
  138. punpckhwd m4, m9
  139. punpckhwd m2, m1
  140. ; stage 2
  141. punpckldq m9, m0, m3
  142. punpckldq m1, m6, m5
  143. punpckhdq m0, m3
  144. punpckhdq m6, m5
  145. punpckldq m3, m7, m10
  146. punpckldq m5, m4, m2
  147. punpckhdq m7, m10
  148. punpckhdq m4, m2
  149. ; stage 3
  150. punpcklqdq m10, m9, m3
  151. punpckhqdq m9, m3
  152. punpcklqdq m2, m0, m7
  153. punpckhqdq m0, m7
  154. punpcklqdq m3, m1, m5
  155. punpckhqdq m1, m5
  156. punpcklqdq m7, m6, m4
  157. punpckhqdq m6, m4
  158. ; row transform
  159. ; stage 1
  160. paddw m5, m10, m6
  161. psubw m10, m6
  162. paddw m4, m9, m7
  163. psubw m9, m7
  164. paddw m6, m2, m1
  165. psubw m2, m1
  166. paddw m7, m0, m3
  167. psubw m0, m3
  168. ;stage 2
  169. paddw m1, m5, m7
  170. psubw m5, m7
  171. paddw m3, m4, m6
  172. psubw m4, m6
  173. paddw m7, m9, m2
  174. psubw m9, m2
  175. ; stage 3
  176. punpcklwd m6, m1, m3
  177. punpckhwd m1, m3
  178. pmaddwd m2, m6, [GLOBAL(pw_11585_11585)]
  179. pmaddwd m6, [GLOBAL(pw_11585_m11585)]
  180. pmaddwd m3, m1, [GLOBAL(pw_11585_11585)]
  181. pmaddwd m1, [GLOBAL(pw_11585_m11585)]
  182. paddd m2, m8
  183. paddd m6, m8
  184. paddd m3, m8
  185. paddd m1, m8
  186. psrad m2, 14
  187. psrad m6, 14
  188. psrad m3, 14
  189. psrad m1, 14
  190. packssdw m2, m3
  191. packssdw m6, m1
  192. pmulhrsw m7, m12
  193. pmulhrsw m9, m12
  194. punpcklwd m3, m5, m4
  195. punpckhwd m5, m4
  196. pmaddwd m1, m3, [GLOBAL(pw_15137_6270)]
  197. pmaddwd m3, [GLOBAL(pw_6270_m15137)]
  198. pmaddwd m4, m5, [GLOBAL(pw_15137_6270)]
  199. pmaddwd m5, [GLOBAL(pw_6270_m15137)]
  200. paddd m1, m8
  201. paddd m3, m8
  202. paddd m4, m8
  203. paddd m5, m8
  204. psrad m1, 14
  205. psrad m3, 14
  206. psrad m4, 14
  207. psrad m5, 14
  208. packssdw m1, m4
  209. packssdw m3, m5
  210. paddw m4, m0, m9
  211. psubw m0, m9
  212. paddw m5, m10, m7
  213. psubw m10, m7
  214. ; stage 4
  215. punpcklwd m9, m5, m4
  216. punpckhwd m5, m4
  217. pmaddwd m7, m9, [GLOBAL(pw_16069_3196)]
  218. pmaddwd m9, [GLOBAL(pw_3196_m16069)]
  219. pmaddwd m4, m5, [GLOBAL(pw_16069_3196)]
  220. pmaddwd m5, [GLOBAL(pw_3196_m16069)]
  221. paddd m7, m8
  222. paddd m9, m8
  223. paddd m4, m8
  224. paddd m5, m8
  225. psrad m7, 14
  226. psrad m9, 14
  227. psrad m4, 14
  228. psrad m5, 14
  229. packssdw m7, m4
  230. packssdw m9, m5
  231. punpcklwd m4, m10, m0
  232. punpckhwd m10, m0
  233. pmaddwd m5, m4, [GLOBAL(pw_9102_13623)]
  234. pmaddwd m4, [GLOBAL(pw_13623_m9102)]
  235. pmaddwd m0, m10, [GLOBAL(pw_9102_13623)]
  236. pmaddwd m10, [GLOBAL(pw_13623_m9102)]
  237. paddd m5, m8
  238. paddd m4, m8
  239. paddd m0, m8
  240. paddd m10, m8
  241. psrad m5, 14
  242. psrad m4, 14
  243. psrad m0, 14
  244. psrad m10, 14
  245. packssdw m5, m0
  246. packssdw m4, m10
  247. ; transpose
  248. ; stage 1
  249. punpcklwd m0, m2, m7
  250. punpcklwd m10, m1, m4
  251. punpckhwd m2, m7
  252. punpckhwd m1, m4
  253. punpcklwd m7, m6, m5
  254. punpcklwd m4, m3, m9
  255. punpckhwd m6, m5
  256. punpckhwd m3, m9
  257. ; stage 2
  258. punpckldq m5, m0, m10
  259. punpckldq m9, m2, m1
  260. punpckhdq m0, m10
  261. punpckhdq m2, m1
  262. punpckldq m10, m7, m4
  263. punpckldq m1, m6, m3
  264. punpckhdq m7, m4
  265. punpckhdq m6, m3
  266. ; stage 3
  267. punpcklqdq m4, m5, m10
  268. punpckhqdq m5, m10
  269. punpcklqdq m3, m0, m7
  270. punpckhqdq m0, m7
  271. punpcklqdq m10, m9, m1
  272. punpckhqdq m9, m1
  273. punpcklqdq m7, m2, m6
  274. punpckhqdq m2, m6
  275. psraw m1, m4, 15
  276. psraw m6, m5, 15
  277. psraw m8, m3, 15
  278. psraw m11, m0, 15
  279. psubw m4, m1
  280. psubw m5, m6
  281. psubw m3, m8
  282. psubw m0, m11
  283. psraw m4, 1
  284. psraw m5, 1
  285. psraw m3, 1
  286. psraw m0, 1
  287. psraw m1, m10, 15
  288. psraw m6, m9, 15
  289. psraw m8, m7, 15
  290. psraw m11, m2, 15
  291. psubw m10, m1
  292. psubw m9, m6
  293. psubw m7, m8
  294. psubw m2, m11
  295. psraw m10, 1
  296. psraw m9, 1
  297. psraw m7, 1
  298. psraw m2, 1
  299. mova [outputq + 0], m4
  300. mova [outputq + 16], m5
  301. mova [outputq + 32], m3
  302. mova [outputq + 48], m0
  303. mova [outputq + 64], m10
  304. mova [outputq + 80], m9
  305. mova [outputq + 96], m7
  306. mova [outputq + 112], m2
  307. RET
  308. %endif