sad_sse4.asm 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. ;void vpx_sad16x16x8_sse4_1(
  135. ; const unsigned char *src_ptr,
  136. ; int src_stride,
  137. ; const unsigned char *ref_ptr,
  138. ; int ref_stride,
  139. ; unsigned short *sad_array);
  140. global sym(vpx_sad16x16x8_sse4_1) PRIVATE
  141. sym(vpx_sad16x16x8_sse4_1):
  142. push rbp
  143. mov rbp, rsp
  144. SHADOW_ARGS_TO_STACK 5
  145. push rsi
  146. push rdi
  147. ; end prolog
  148. mov rsi, arg(0) ;src_ptr
  149. mov rdi, arg(2) ;ref_ptr
  150. movsxd rax, dword ptr arg(1) ;src_stride
  151. movsxd rdx, dword ptr arg(3) ;ref_stride
  152. PROCESS_16X2X8 1
  153. PROCESS_16X2X8 0
  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. WRITE_AS_INTS
  161. ; begin epilog
  162. pop rdi
  163. pop rsi
  164. UNSHADOW_ARGS
  165. pop rbp
  166. ret
  167. ;void vpx_sad16x8x8_sse4_1(
  168. ; const unsigned char *src_ptr,
  169. ; int src_stride,
  170. ; const unsigned char *ref_ptr,
  171. ; int ref_stride,
  172. ; unsigned short *sad_array
  173. ;);
  174. global sym(vpx_sad16x8x8_sse4_1) PRIVATE
  175. sym(vpx_sad16x8x8_sse4_1):
  176. push rbp
  177. mov rbp, rsp
  178. SHADOW_ARGS_TO_STACK 5
  179. push rsi
  180. push rdi
  181. ; end prolog
  182. mov rsi, arg(0) ;src_ptr
  183. mov rdi, arg(2) ;ref_ptr
  184. movsxd rax, dword ptr arg(1) ;src_stride
  185. movsxd rdx, dword ptr arg(3) ;ref_stride
  186. PROCESS_16X2X8 1
  187. PROCESS_16X2X8 0
  188. PROCESS_16X2X8 0
  189. PROCESS_16X2X8 0
  190. WRITE_AS_INTS
  191. ; begin epilog
  192. pop rdi
  193. pop rsi
  194. UNSHADOW_ARGS
  195. pop rbp
  196. ret
  197. ;void vpx_sad8x8x8_sse4_1(
  198. ; const unsigned char *src_ptr,
  199. ; int src_stride,
  200. ; const unsigned char *ref_ptr,
  201. ; int ref_stride,
  202. ; unsigned short *sad_array
  203. ;);
  204. global sym(vpx_sad8x8x8_sse4_1) PRIVATE
  205. sym(vpx_sad8x8x8_sse4_1):
  206. push rbp
  207. mov rbp, rsp
  208. SHADOW_ARGS_TO_STACK 5
  209. push rsi
  210. push rdi
  211. ; end prolog
  212. mov rsi, arg(0) ;src_ptr
  213. mov rdi, arg(2) ;ref_ptr
  214. movsxd rax, dword ptr arg(1) ;src_stride
  215. movsxd rdx, dword ptr arg(3) ;ref_stride
  216. PROCESS_8X2X8 1
  217. PROCESS_8X2X8 0
  218. PROCESS_8X2X8 0
  219. PROCESS_8X2X8 0
  220. WRITE_AS_INTS
  221. ; begin epilog
  222. pop rdi
  223. pop rsi
  224. UNSHADOW_ARGS
  225. pop rbp
  226. ret
  227. ;void vpx_sad8x16x8_sse4_1(
  228. ; const unsigned char *src_ptr,
  229. ; int src_stride,
  230. ; const unsigned char *ref_ptr,
  231. ; int ref_stride,
  232. ; unsigned short *sad_array
  233. ;);
  234. global sym(vpx_sad8x16x8_sse4_1) PRIVATE
  235. sym(vpx_sad8x16x8_sse4_1):
  236. push rbp
  237. mov rbp, rsp
  238. SHADOW_ARGS_TO_STACK 5
  239. push rsi
  240. push rdi
  241. ; end prolog
  242. mov rsi, arg(0) ;src_ptr
  243. mov rdi, arg(2) ;ref_ptr
  244. movsxd rax, dword ptr arg(1) ;src_stride
  245. movsxd rdx, dword ptr arg(3) ;ref_stride
  246. PROCESS_8X2X8 1
  247. PROCESS_8X2X8 0
  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. WRITE_AS_INTS
  255. ; begin epilog
  256. pop rdi
  257. pop rsi
  258. UNSHADOW_ARGS
  259. pop rbp
  260. ret
  261. ;void vpx_sad4x4x8_sse4_1(
  262. ; const unsigned char *src_ptr,
  263. ; int src_stride,
  264. ; const unsigned char *ref_ptr,
  265. ; int ref_stride,
  266. ; unsigned short *sad_array
  267. ;);
  268. global sym(vpx_sad4x4x8_sse4_1) PRIVATE
  269. sym(vpx_sad4x4x8_sse4_1):
  270. push rbp
  271. mov rbp, rsp
  272. SHADOW_ARGS_TO_STACK 5
  273. push rsi
  274. push rdi
  275. ; end prolog
  276. mov rsi, arg(0) ;src_ptr
  277. mov rdi, arg(2) ;ref_ptr
  278. movsxd rax, dword ptr arg(1) ;src_stride
  279. movsxd rdx, dword ptr arg(3) ;ref_stride
  280. PROCESS_4X2X8 1
  281. PROCESS_4X2X8 0
  282. WRITE_AS_INTS
  283. ; begin epilog
  284. pop rdi
  285. pop rsi
  286. UNSHADOW_ARGS
  287. pop rbp
  288. ret