fwalsh_sse2.asm 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. SECTION .text
  12. ;void vp8_short_walsh4x4_sse2(short *input, short *output, int pitch)
  13. global sym(vp8_short_walsh4x4_sse2) PRIVATE
  14. sym(vp8_short_walsh4x4_sse2):
  15. push rbp
  16. mov rbp, rsp
  17. SHADOW_ARGS_TO_STACK 3
  18. SAVE_XMM 7
  19. GET_GOT rbx
  20. push rsi
  21. push rdi
  22. ; end prolog
  23. mov rsi, arg(0) ; input
  24. mov rdi, arg(1) ; output
  25. movsxd rdx, dword ptr arg(2) ; pitch
  26. ; first for loop
  27. movq xmm0, MMWORD PTR [rsi] ; load input
  28. movq xmm1, MMWORD PTR [rsi + rdx]
  29. lea rsi, [rsi + rdx*2]
  30. movq xmm2, MMWORD PTR [rsi]
  31. movq xmm3, MMWORD PTR [rsi + rdx]
  32. punpcklwd xmm0, xmm1
  33. punpcklwd xmm2, xmm3
  34. movdqa xmm1, xmm0
  35. punpckldq xmm0, xmm2 ; ip[1] ip[0]
  36. punpckhdq xmm1, xmm2 ; ip[3] ip[2]
  37. movdqa xmm2, xmm0
  38. paddw xmm0, xmm1
  39. psubw xmm2, xmm1
  40. psllw xmm0, 2 ; d1 a1
  41. psllw xmm2, 2 ; c1 b1
  42. movdqa xmm1, xmm0
  43. punpcklqdq xmm0, xmm2 ; b1 a1
  44. punpckhqdq xmm1, xmm2 ; c1 d1
  45. pxor xmm6, xmm6
  46. movq xmm6, xmm0
  47. pxor xmm7, xmm7
  48. pcmpeqw xmm7, xmm6
  49. paddw xmm7, [GLOBAL(c1)]
  50. movdqa xmm2, xmm0
  51. paddw xmm0, xmm1 ; b1+c1 a1+d1
  52. psubw xmm2, xmm1 ; b1-c1 a1-d1
  53. paddw xmm0, xmm7 ; b1+c1 a1+d1+(a1!=0)
  54. ; second for loop
  55. ; input: 13 9 5 1 12 8 4 0 (xmm0)
  56. ; 14 10 6 2 15 11 7 3 (xmm2)
  57. ; after shuffle:
  58. ; 13 5 9 1 12 4 8 0 (xmm0)
  59. ; 14 6 10 2 15 7 11 3 (xmm1)
  60. pshuflw xmm3, xmm0, 0xd8
  61. pshufhw xmm0, xmm3, 0xd8
  62. pshuflw xmm3, xmm2, 0xd8
  63. pshufhw xmm1, xmm3, 0xd8
  64. movdqa xmm2, xmm0
  65. pmaddwd xmm0, [GLOBAL(c1)] ; d11 a11 d10 a10
  66. pmaddwd xmm2, [GLOBAL(cn1)] ; c11 b11 c10 b10
  67. movdqa xmm3, xmm1
  68. pmaddwd xmm1, [GLOBAL(c1)] ; d12 a12 d13 a13
  69. pmaddwd xmm3, [GLOBAL(cn1)] ; c12 b12 c13 b13
  70. pshufd xmm4, xmm0, 0xd8 ; d11 d10 a11 a10
  71. pshufd xmm5, xmm2, 0xd8 ; c11 c10 b11 b10
  72. pshufd xmm6, xmm1, 0x72 ; d13 d12 a13 a12
  73. pshufd xmm7, xmm3, 0x72 ; c13 c12 b13 b12
  74. movdqa xmm0, xmm4
  75. punpcklqdq xmm0, xmm5 ; b11 b10 a11 a10
  76. punpckhqdq xmm4, xmm5 ; c11 c10 d11 d10
  77. movdqa xmm1, xmm6
  78. punpcklqdq xmm1, xmm7 ; b13 b12 a13 a12
  79. punpckhqdq xmm6, xmm7 ; c13 c12 d13 d12
  80. movdqa xmm2, xmm0
  81. paddd xmm0, xmm4 ; b21 b20 a21 a20
  82. psubd xmm2, xmm4 ; c21 c20 d21 d20
  83. movdqa xmm3, xmm1
  84. paddd xmm1, xmm6 ; b23 b22 a23 a22
  85. psubd xmm3, xmm6 ; c23 c22 d23 d22
  86. pxor xmm4, xmm4
  87. movdqa xmm5, xmm4
  88. pcmpgtd xmm4, xmm0
  89. pcmpgtd xmm5, xmm2
  90. pand xmm4, [GLOBAL(cd1)]
  91. pand xmm5, [GLOBAL(cd1)]
  92. pxor xmm6, xmm6
  93. movdqa xmm7, xmm6
  94. pcmpgtd xmm6, xmm1
  95. pcmpgtd xmm7, xmm3
  96. pand xmm6, [GLOBAL(cd1)]
  97. pand xmm7, [GLOBAL(cd1)]
  98. paddd xmm0, xmm4
  99. paddd xmm2, xmm5
  100. paddd xmm0, [GLOBAL(cd3)]
  101. paddd xmm2, [GLOBAL(cd3)]
  102. paddd xmm1, xmm6
  103. paddd xmm3, xmm7
  104. paddd xmm1, [GLOBAL(cd3)]
  105. paddd xmm3, [GLOBAL(cd3)]
  106. psrad xmm0, 3
  107. psrad xmm1, 3
  108. psrad xmm2, 3
  109. psrad xmm3, 3
  110. movdqa xmm4, xmm0
  111. punpcklqdq xmm0, xmm1 ; a23 a22 a21 a20
  112. punpckhqdq xmm4, xmm1 ; b23 b22 b21 b20
  113. movdqa xmm5, xmm2
  114. punpckhqdq xmm2, xmm3 ; c23 c22 c21 c20
  115. punpcklqdq xmm5, xmm3 ; d23 d22 d21 d20
  116. packssdw xmm0, xmm4 ; b23 b22 b21 b20 a23 a22 a21 a20
  117. packssdw xmm2, xmm5 ; d23 d22 d21 d20 c23 c22 c21 c20
  118. movdqa XMMWORD PTR [rdi], xmm0
  119. movdqa XMMWORD PTR [rdi + 16], xmm2
  120. ; begin epilog
  121. pop rdi
  122. pop rsi
  123. RESTORE_GOT
  124. RESTORE_XMM
  125. UNSHADOW_ARGS
  126. pop rbp
  127. ret
  128. SECTION_RODATA
  129. align 16
  130. c1:
  131. dw 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001
  132. align 16
  133. cn1:
  134. dw 0x0001, 0xffff, 0x0001, 0xffff, 0x0001, 0xffff, 0x0001, 0xffff
  135. align 16
  136. cd1:
  137. dd 0x00000001, 0x00000001, 0x00000001, 0x00000001
  138. align 16
  139. cd3:
  140. dd 0x00000003, 0x00000003, 0x00000003, 0x00000003