2
0

copy_sse3.asm 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 STACK_FRAME_CREATE_X3 0
  12. %if ABI_IS_32BIT
  13. %define src_ptr rsi
  14. %define src_stride rax
  15. %define ref_ptr rdi
  16. %define ref_stride rdx
  17. %define end_ptr rcx
  18. %define ret_var rbx
  19. %define result_ptr arg(4)
  20. %define max_sad arg(4)
  21. %define height dword ptr arg(4)
  22. push rbp
  23. mov rbp, rsp
  24. push rsi
  25. push rdi
  26. push rbx
  27. mov rsi, arg(0) ; src_ptr
  28. mov rdi, arg(2) ; ref_ptr
  29. movsxd rax, dword ptr arg(1) ; src_stride
  30. movsxd rdx, dword ptr arg(3) ; ref_stride
  31. %else
  32. %if LIBVPX_YASM_WIN64
  33. SAVE_XMM 7, u
  34. %define src_ptr rcx
  35. %define src_stride rdx
  36. %define ref_ptr r8
  37. %define ref_stride r9
  38. %define end_ptr r10
  39. %define ret_var r11
  40. %define result_ptr [rsp+xmm_stack_space+8+4*8]
  41. %define max_sad [rsp+xmm_stack_space+8+4*8]
  42. %define height dword ptr [rsp+xmm_stack_space+8+4*8]
  43. %else
  44. %define src_ptr rdi
  45. %define src_stride rsi
  46. %define ref_ptr rdx
  47. %define ref_stride rcx
  48. %define end_ptr r9
  49. %define ret_var r10
  50. %define result_ptr r8
  51. %define max_sad r8
  52. %define height r8
  53. %endif
  54. %endif
  55. %endmacro
  56. %macro STACK_FRAME_DESTROY_X3 0
  57. %define src_ptr
  58. %define src_stride
  59. %define ref_ptr
  60. %define ref_stride
  61. %define end_ptr
  62. %define ret_var
  63. %define result_ptr
  64. %define max_sad
  65. %define height
  66. %if ABI_IS_32BIT
  67. pop rbx
  68. pop rdi
  69. pop rsi
  70. pop rbp
  71. %else
  72. %if LIBVPX_YASM_WIN64
  73. RESTORE_XMM
  74. %endif
  75. %endif
  76. ret
  77. %endmacro
  78. ;void vp8_copy32xn_sse3(
  79. ; unsigned char *src_ptr,
  80. ; int src_stride,
  81. ; unsigned char *dst_ptr,
  82. ; int dst_stride,
  83. ; int height);
  84. global sym(vp8_copy32xn_sse3) PRIVATE
  85. sym(vp8_copy32xn_sse3):
  86. STACK_FRAME_CREATE_X3
  87. .block_copy_sse3_loopx4:
  88. lea end_ptr, [src_ptr+src_stride*2]
  89. movdqu xmm0, XMMWORD PTR [src_ptr]
  90. movdqu xmm1, XMMWORD PTR [src_ptr + 16]
  91. movdqu xmm2, XMMWORD PTR [src_ptr + src_stride]
  92. movdqu xmm3, XMMWORD PTR [src_ptr + src_stride + 16]
  93. movdqu xmm4, XMMWORD PTR [end_ptr]
  94. movdqu xmm5, XMMWORD PTR [end_ptr + 16]
  95. movdqu xmm6, XMMWORD PTR [end_ptr + src_stride]
  96. movdqu xmm7, XMMWORD PTR [end_ptr + src_stride + 16]
  97. lea src_ptr, [src_ptr+src_stride*4]
  98. lea end_ptr, [ref_ptr+ref_stride*2]
  99. movdqa XMMWORD PTR [ref_ptr], xmm0
  100. movdqa XMMWORD PTR [ref_ptr + 16], xmm1
  101. movdqa XMMWORD PTR [ref_ptr + ref_stride], xmm2
  102. movdqa XMMWORD PTR [ref_ptr + ref_stride + 16], xmm3
  103. movdqa XMMWORD PTR [end_ptr], xmm4
  104. movdqa XMMWORD PTR [end_ptr + 16], xmm5
  105. movdqa XMMWORD PTR [end_ptr + ref_stride], xmm6
  106. movdqa XMMWORD PTR [end_ptr + ref_stride + 16], xmm7
  107. lea ref_ptr, [ref_ptr+ref_stride*4]
  108. sub height, 4
  109. cmp height, 4
  110. jge .block_copy_sse3_loopx4
  111. ;Check to see if there is more rows need to be copied.
  112. cmp height, 0
  113. je .copy_is_done
  114. .block_copy_sse3_loop:
  115. movdqu xmm0, XMMWORD PTR [src_ptr]
  116. movdqu xmm1, XMMWORD PTR [src_ptr + 16]
  117. lea src_ptr, [src_ptr+src_stride]
  118. movdqa XMMWORD PTR [ref_ptr], xmm0
  119. movdqa XMMWORD PTR [ref_ptr + 16], xmm1
  120. lea ref_ptr, [ref_ptr+ref_stride]
  121. sub height, 1
  122. jne .block_copy_sse3_loop
  123. .copy_is_done:
  124. STACK_FRAME_DESTROY_X3