dequantize_mmx.asm 7.9 KB

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