sad_sse4.asm 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. ;
  2. ; Copyright (c) 2010 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 "vpx_ports/x86_abi_support.asm"
  11. %macro PROCESS_16X2X8 1
  12. %if %1
  13. movdqa xmm0, XMMWORD PTR [rsi]
  14. movq xmm1, MMWORD PTR [rdi]
  15. movq xmm3, MMWORD PTR [rdi+8]
  16. movq xmm2, MMWORD PTR [rdi+16]
  17. punpcklqdq xmm1, xmm3
  18. punpcklqdq xmm3, xmm2
  19. movdqa xmm2, xmm1
  20. mpsadbw xmm1, xmm0, 0x0
  21. mpsadbw xmm2, xmm0, 0x5
  22. psrldq xmm0, 8
  23. movdqa xmm4, xmm3
  24. mpsadbw xmm3, xmm0, 0x0
  25. mpsadbw xmm4, xmm0, 0x5
  26. paddw xmm1, xmm2
  27. paddw xmm1, xmm3
  28. paddw xmm1, xmm4
  29. %else
  30. movdqa xmm0, XMMWORD PTR [rsi]
  31. movq xmm5, MMWORD PTR [rdi]
  32. movq xmm3, MMWORD PTR [rdi+8]
  33. movq xmm2, MMWORD PTR [rdi+16]
  34. punpcklqdq xmm5, xmm3
  35. punpcklqdq xmm3, xmm2
  36. movdqa xmm2, xmm5
  37. mpsadbw xmm5, xmm0, 0x0
  38. mpsadbw xmm2, xmm0, 0x5
  39. psrldq xmm0, 8
  40. movdqa xmm4, xmm3
  41. mpsadbw xmm3, xmm0, 0x0
  42. mpsadbw xmm4, xmm0, 0x5
  43. paddw xmm5, xmm2
  44. paddw xmm5, xmm3
  45. paddw xmm5, xmm4
  46. paddw xmm1, xmm5
  47. %endif
  48. movdqa xmm0, XMMWORD PTR [rsi + rax]
  49. movq xmm5, MMWORD PTR [rdi+ rdx]
  50. movq xmm3, MMWORD PTR [rdi+ rdx+8]
  51. movq xmm2, MMWORD PTR [rdi+ rdx+16]
  52. punpcklqdq xmm5, xmm3
  53. punpcklqdq xmm3, xmm2
  54. lea rsi, [rsi+rax*2]
  55. lea rdi, [rdi+rdx*2]
  56. movdqa xmm2, xmm5
  57. mpsadbw xmm5, xmm0, 0x0
  58. mpsadbw xmm2, xmm0, 0x5
  59. psrldq xmm0, 8
  60. movdqa xmm4, xmm3
  61. mpsadbw xmm3, xmm0, 0x0
  62. mpsadbw xmm4, xmm0, 0x5
  63. paddw xmm5, xmm2
  64. paddw xmm5, xmm3
  65. paddw xmm5, xmm4
  66. paddw xmm1, xmm5
  67. %endmacro
  68. %macro PROCESS_8X2X8 1
  69. %if %1
  70. movq xmm0, MMWORD PTR [rsi]
  71. movq xmm1, MMWORD PTR [rdi]
  72. movq xmm3, MMWORD PTR [rdi+8]
  73. punpcklqdq xmm1, xmm3
  74. movdqa xmm2, xmm1
  75. mpsadbw xmm1, xmm0, 0x0
  76. mpsadbw xmm2, xmm0, 0x5
  77. paddw xmm1, xmm2
  78. %else
  79. movq xmm0, MMWORD PTR [rsi]
  80. movq xmm5, MMWORD PTR [rdi]
  81. movq xmm3, MMWORD PTR [rdi+8]
  82. punpcklqdq xmm5, xmm3
  83. movdqa xmm2, xmm5
  84. mpsadbw xmm5, xmm0, 0x0
  85. mpsadbw xmm2, xmm0, 0x5
  86. paddw xmm5, xmm2
  87. paddw xmm1, xmm5
  88. %endif
  89. movq xmm0, MMWORD PTR [rsi + rax]
  90. movq xmm5, MMWORD PTR [rdi+ rdx]
  91. movq xmm3, MMWORD PTR [rdi+ rdx+8]
  92. punpcklqdq xmm5, xmm3
  93. lea rsi, [rsi+rax*2]
  94. lea rdi, [rdi+rdx*2]
  95. movdqa xmm2, xmm5
  96. mpsadbw xmm5, xmm0, 0x0
  97. mpsadbw xmm2, xmm0, 0x5
  98. paddw xmm5, xmm2
  99. paddw xmm1, xmm5
  100. %endmacro
  101. %macro PROCESS_4X2X8 1
  102. %if %1
  103. movd xmm0, [rsi]
  104. movq xmm1, MMWORD PTR [rdi]
  105. movq xmm3, MMWORD PTR [rdi+8]
  106. punpcklqdq xmm1, xmm3
  107. mpsadbw xmm1, xmm0, 0x0
  108. %else
  109. movd xmm0, [rsi]
  110. movq xmm5, MMWORD PTR [rdi]
  111. movq xmm3, MMWORD PTR [rdi+8]
  112. punpcklqdq xmm5, xmm3
  113. mpsadbw xmm5, xmm0, 0x0
  114. paddw xmm1, xmm5
  115. %endif
  116. movd xmm0, [rsi + rax]
  117. movq xmm5, MMWORD PTR [rdi+ rdx]
  118. movq xmm3, MMWORD PTR [rdi+ rdx+8]
  119. punpcklqdq xmm5, xmm3
  120. lea rsi, [rsi+rax*2]
  121. lea rdi, [rdi+rdx*2]
  122. mpsadbw xmm5, xmm0, 0x0
  123. paddw xmm1, xmm5
  124. %endmacro
  125. %macro WRITE_AS_INTS 0
  126. mov rdi, arg(4) ;Results
  127. pxor xmm0, xmm0
  128. movdqa xmm2, xmm1
  129. punpcklwd xmm1, xmm0
  130. punpckhwd xmm2, xmm0
  131. movdqa [rdi], xmm1
  132. movdqa [rdi + 16], xmm2
  133. %endmacro
  134. SECTION .text
  135. ;void vpx_sad16x16x8_sse4_1(
  136. ; const unsigned char *src_ptr,
  137. ; int src_stride,
  138. ; const unsigned char *ref_ptr,
  139. ; int ref_stride,
  140. ; unsigned short *sad_array);
  141. global sym(vpx_sad16x16x8_sse4_1) PRIVATE
  142. sym(vpx_sad16x16x8_sse4_1):
  143. push rbp
  144. mov rbp, rsp
  145. SHADOW_ARGS_TO_STACK 5
  146. push rsi
  147. push rdi
  148. ; end prolog
  149. mov rsi, arg(0) ;src_ptr
  150. mov rdi, arg(2) ;ref_ptr
  151. movsxd rax, dword ptr arg(1) ;src_stride
  152. movsxd rdx, dword ptr arg(3) ;ref_stride
  153. PROCESS_16X2X8 1
  154. PROCESS_16X2X8 0
  155. PROCESS_16X2X8 0
  156. PROCESS_16X2X8 0
  157. PROCESS_16X2X8 0
  158. PROCESS_16X2X8 0
  159. PROCESS_16X2X8 0
  160. PROCESS_16X2X8 0
  161. WRITE_AS_INTS
  162. ; begin epilog
  163. pop rdi
  164. pop rsi
  165. UNSHADOW_ARGS
  166. pop rbp
  167. ret
  168. ;void vpx_sad16x8x8_sse4_1(
  169. ; const unsigned char *src_ptr,
  170. ; int src_stride,
  171. ; const unsigned char *ref_ptr,
  172. ; int ref_stride,
  173. ; unsigned short *sad_array
  174. ;);
  175. global sym(vpx_sad16x8x8_sse4_1) PRIVATE
  176. sym(vpx_sad16x8x8_sse4_1):
  177. push rbp
  178. mov rbp, rsp
  179. SHADOW_ARGS_TO_STACK 5
  180. push rsi
  181. push rdi
  182. ; end prolog
  183. mov rsi, arg(0) ;src_ptr
  184. mov rdi, arg(2) ;ref_ptr
  185. movsxd rax, dword ptr arg(1) ;src_stride
  186. movsxd rdx, dword ptr arg(3) ;ref_stride
  187. PROCESS_16X2X8 1
  188. PROCESS_16X2X8 0
  189. PROCESS_16X2X8 0
  190. PROCESS_16X2X8 0
  191. WRITE_AS_INTS
  192. ; begin epilog
  193. pop rdi
  194. pop rsi
  195. UNSHADOW_ARGS
  196. pop rbp
  197. ret
  198. ;void vpx_sad8x8x8_sse4_1(
  199. ; const unsigned char *src_ptr,
  200. ; int src_stride,
  201. ; const unsigned char *ref_ptr,
  202. ; int ref_stride,
  203. ; unsigned short *sad_array
  204. ;);
  205. global sym(vpx_sad8x8x8_sse4_1) PRIVATE
  206. sym(vpx_sad8x8x8_sse4_1):
  207. push rbp
  208. mov rbp, rsp
  209. SHADOW_ARGS_TO_STACK 5
  210. push rsi
  211. push rdi
  212. ; end prolog
  213. mov rsi, arg(0) ;src_ptr
  214. mov rdi, arg(2) ;ref_ptr
  215. movsxd rax, dword ptr arg(1) ;src_stride
  216. movsxd rdx, dword ptr arg(3) ;ref_stride
  217. PROCESS_8X2X8 1
  218. PROCESS_8X2X8 0
  219. PROCESS_8X2X8 0
  220. PROCESS_8X2X8 0
  221. WRITE_AS_INTS
  222. ; begin epilog
  223. pop rdi
  224. pop rsi
  225. UNSHADOW_ARGS
  226. pop rbp
  227. ret
  228. ;void vpx_sad8x16x8_sse4_1(
  229. ; const unsigned char *src_ptr,
  230. ; int src_stride,
  231. ; const unsigned char *ref_ptr,
  232. ; int ref_stride,
  233. ; unsigned short *sad_array
  234. ;);
  235. global sym(vpx_sad8x16x8_sse4_1) PRIVATE
  236. sym(vpx_sad8x16x8_sse4_1):
  237. push rbp
  238. mov rbp, rsp
  239. SHADOW_ARGS_TO_STACK 5
  240. push rsi
  241. push rdi
  242. ; end prolog
  243. mov rsi, arg(0) ;src_ptr
  244. mov rdi, arg(2) ;ref_ptr
  245. movsxd rax, dword ptr arg(1) ;src_stride
  246. movsxd rdx, dword ptr arg(3) ;ref_stride
  247. PROCESS_8X2X8 1
  248. PROCESS_8X2X8 0
  249. PROCESS_8X2X8 0
  250. PROCESS_8X2X8 0
  251. PROCESS_8X2X8 0
  252. PROCESS_8X2X8 0
  253. PROCESS_8X2X8 0
  254. PROCESS_8X2X8 0
  255. WRITE_AS_INTS
  256. ; begin epilog
  257. pop rdi
  258. pop rsi
  259. UNSHADOW_ARGS
  260. pop rbp
  261. ret
  262. ;void vpx_sad4x4x8_sse4_1(
  263. ; const unsigned char *src_ptr,
  264. ; int src_stride,
  265. ; const unsigned char *ref_ptr,
  266. ; int ref_stride,
  267. ; unsigned short *sad_array
  268. ;);
  269. global sym(vpx_sad4x4x8_sse4_1) PRIVATE
  270. sym(vpx_sad4x4x8_sse4_1):
  271. push rbp
  272. mov rbp, rsp
  273. SHADOW_ARGS_TO_STACK 5
  274. push rsi
  275. push rdi
  276. ; end prolog
  277. mov rsi, arg(0) ;src_ptr
  278. mov rdi, arg(2) ;ref_ptr
  279. movsxd rax, dword ptr arg(1) ;src_stride
  280. movsxd rdx, dword ptr arg(3) ;ref_stride
  281. PROCESS_4X2X8 1
  282. PROCESS_4X2X8 0
  283. WRITE_AS_INTS
  284. ; begin epilog
  285. pop rdi
  286. pop rsi
  287. UNSHADOW_ARGS
  288. pop rbp
  289. ret