dequantize_mmx.asm 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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_dequantize_b_impl_mmx(short *sq, short *dq, short *q)
  13. global sym(vp8_dequantize_b_impl_mmx) PRIVATE
  14. sym(vp8_dequantize_b_impl_mmx):
  15. push rbp
  16. mov rbp, rsp
  17. SHADOW_ARGS_TO_STACK 3
  18. push rsi
  19. push rdi
  20. ; end prolog
  21. mov rsi, arg(0) ;sq
  22. mov rdi, arg(1) ;dq
  23. mov rax, arg(2) ;q
  24. movq mm1, [rsi]
  25. pmullw mm1, [rax+0] ; mm4 *= kernel 0 modifiers.
  26. movq [rdi], mm1
  27. movq mm1, [rsi+8]
  28. pmullw mm1, [rax+8] ; mm4 *= kernel 0 modifiers.
  29. movq [rdi+8], mm1
  30. movq mm1, [rsi+16]
  31. pmullw mm1, [rax+16] ; mm4 *= kernel 0 modifiers.
  32. movq [rdi+16], mm1
  33. movq mm1, [rsi+24]
  34. pmullw mm1, [rax+24] ; mm4 *= kernel 0 modifiers.
  35. movq [rdi+24], mm1
  36. ; begin epilog
  37. pop rdi
  38. pop rsi
  39. UNSHADOW_ARGS
  40. pop rbp
  41. ret
  42. ;void dequant_idct_add_mmx(
  43. ;short *input, 0
  44. ;short *dq, 1
  45. ;unsigned char *dest, 2
  46. ;int stride) 3
  47. global sym(vp8_dequant_idct_add_mmx) PRIVATE
  48. sym(vp8_dequant_idct_add_mmx):
  49. push rbp
  50. mov rbp, rsp
  51. SHADOW_ARGS_TO_STACK 4
  52. GET_GOT rbx
  53. push rdi
  54. ; end prolog
  55. mov rax, arg(0) ;input
  56. mov rdx, arg(1) ;dq
  57. movq mm0, [rax ]
  58. pmullw mm0, [rdx]
  59. movq mm1, [rax +8]
  60. pmullw mm1, [rdx +8]
  61. movq mm2, [rax+16]
  62. pmullw mm2, [rdx+16]
  63. movq mm3, [rax+24]
  64. pmullw mm3, [rdx+24]
  65. mov rdx, arg(2) ;dest
  66. pxor mm7, mm7
  67. movq [rax], mm7
  68. movq [rax+8], mm7
  69. movq [rax+16],mm7
  70. movq [rax+24],mm7
  71. movsxd rdi, dword ptr arg(3) ;stride
  72. psubw mm0, mm2 ; b1= 0-2
  73. paddw mm2, mm2 ;
  74. movq mm5, mm1
  75. paddw mm2, mm0 ; a1 =0+2
  76. pmulhw mm5, [GLOBAL(x_s1sqr2)];
  77. paddw mm5, mm1 ; ip1 * sin(pi/8) * sqrt(2)
  78. movq mm7, mm3 ;
  79. pmulhw mm7, [GLOBAL(x_c1sqr2less1)];
  80. paddw mm7, mm3 ; ip3 * cos(pi/8) * sqrt(2)
  81. psubw mm7, mm5 ; c1
  82. movq mm5, mm1
  83. movq mm4, mm3
  84. pmulhw mm5, [GLOBAL(x_c1sqr2less1)]
  85. paddw mm5, mm1
  86. pmulhw mm3, [GLOBAL(x_s1sqr2)]
  87. paddw mm3, mm4
  88. paddw mm3, mm5 ; d1
  89. movq mm6, mm2 ; a1
  90. movq mm4, mm0 ; b1
  91. paddw mm2, mm3 ;0
  92. paddw mm4, mm7 ;1
  93. psubw mm0, mm7 ;2
  94. psubw mm6, mm3 ;3
  95. movq mm1, mm2 ; 03 02 01 00
  96. movq mm3, mm4 ; 23 22 21 20
  97. punpcklwd mm1, mm0 ; 11 01 10 00
  98. punpckhwd mm2, mm0 ; 13 03 12 02
  99. punpcklwd mm3, mm6 ; 31 21 30 20
  100. punpckhwd mm4, mm6 ; 33 23 32 22
  101. movq mm0, mm1 ; 11 01 10 00
  102. movq mm5, mm2 ; 13 03 12 02
  103. punpckldq mm0, mm3 ; 30 20 10 00
  104. punpckhdq mm1, mm3 ; 31 21 11 01
  105. punpckldq mm2, mm4 ; 32 22 12 02
  106. punpckhdq mm5, mm4 ; 33 23 13 03
  107. movq mm3, mm5 ; 33 23 13 03
  108. psubw mm0, mm2 ; b1= 0-2
  109. paddw mm2, mm2 ;
  110. movq mm5, mm1
  111. paddw mm2, mm0 ; a1 =0+2
  112. pmulhw mm5, [GLOBAL(x_s1sqr2)];
  113. paddw mm5, mm1 ; ip1 * sin(pi/8) * sqrt(2)
  114. movq mm7, mm3 ;
  115. pmulhw mm7, [GLOBAL(x_c1sqr2less1)];
  116. paddw mm7, mm3 ; ip3 * cos(pi/8) * sqrt(2)
  117. psubw mm7, mm5 ; c1
  118. movq mm5, mm1
  119. movq mm4, mm3
  120. pmulhw mm5, [GLOBAL(x_c1sqr2less1)]
  121. paddw mm5, mm1
  122. pmulhw mm3, [GLOBAL(x_s1sqr2)]
  123. paddw mm3, mm4
  124. paddw mm3, mm5 ; d1
  125. paddw mm0, [GLOBAL(fours)]
  126. paddw mm2, [GLOBAL(fours)]
  127. movq mm6, mm2 ; a1
  128. movq mm4, mm0 ; b1
  129. paddw mm2, mm3 ;0
  130. paddw mm4, mm7 ;1
  131. psubw mm0, mm7 ;2
  132. psubw mm6, mm3 ;3
  133. psraw mm2, 3
  134. psraw mm0, 3
  135. psraw mm4, 3
  136. psraw mm6, 3
  137. movq mm1, mm2 ; 03 02 01 00
  138. movq mm3, mm4 ; 23 22 21 20
  139. punpcklwd mm1, mm0 ; 11 01 10 00
  140. punpckhwd mm2, mm0 ; 13 03 12 02
  141. punpcklwd mm3, mm6 ; 31 21 30 20
  142. punpckhwd mm4, mm6 ; 33 23 32 22
  143. movq mm0, mm1 ; 11 01 10 00
  144. movq mm5, mm2 ; 13 03 12 02
  145. punpckldq mm0, mm3 ; 30 20 10 00
  146. punpckhdq mm1, mm3 ; 31 21 11 01
  147. punpckldq mm2, mm4 ; 32 22 12 02
  148. punpckhdq mm5, mm4 ; 33 23 13 03
  149. pxor mm7, mm7
  150. movd mm4, [rdx]
  151. punpcklbw mm4, mm7
  152. paddsw mm0, mm4
  153. packuswb mm0, mm7
  154. movd [rdx], mm0
  155. movd mm4, [rdx+rdi]
  156. punpcklbw mm4, mm7
  157. paddsw mm1, mm4
  158. packuswb mm1, mm7
  159. movd [rdx+rdi], mm1
  160. movd mm4, [rdx+2*rdi]
  161. punpcklbw mm4, mm7
  162. paddsw mm2, mm4
  163. packuswb mm2, mm7
  164. movd [rdx+rdi*2], mm2
  165. add rdx, rdi
  166. movd mm4, [rdx+2*rdi]
  167. punpcklbw mm4, mm7
  168. paddsw mm5, mm4
  169. packuswb mm5, mm7
  170. movd [rdx+rdi*2], mm5
  171. ; begin epilog
  172. pop rdi
  173. RESTORE_GOT
  174. UNSHADOW_ARGS
  175. pop rbp
  176. ret
  177. SECTION_RODATA
  178. align 16
  179. x_s1sqr2:
  180. times 4 dw 0x8A8C
  181. align 16
  182. x_c1sqr2less1:
  183. times 4 dw 0x4E7B
  184. align 16
  185. fours:
  186. times 4 dw 0x0004