2
0

idctllm_mmx.asm 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. ; /****************************************************************************
  12. ; * Notes:
  13. ; *
  14. ; * This implementation makes use of 16 bit fixed point version of two multiply
  15. ; * constants:
  16. ; * 1. sqrt(2) * cos (pi/8)
  17. ; * 2. sqrt(2) * sin (pi/8)
  18. ; * Because the first constant is bigger than 1, to maintain the same 16 bit
  19. ; * fixed point precision as the second one, we use a trick of
  20. ; * x * a = x + x*(a-1)
  21. ; * so
  22. ; * x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
  23. ; *
  24. ; * For the second constant, because of the 16bit version is 35468, which
  25. ; * is bigger than 32768, in signed 16 bit multiply, it becomes a negative
  26. ; * number.
  27. ; * (x * (unsigned)35468 >> 16) = x * (signed)35468 >> 16 + x
  28. ; *
  29. ; **************************************************************************/
  30. ;void vp8_short_idct4x4llm_mmx(short *input, unsigned char *pred,
  31. ;int pitch, unsigned char *dest,int stride)
  32. global sym(vp8_short_idct4x4llm_mmx) PRIVATE
  33. sym(vp8_short_idct4x4llm_mmx):
  34. push rbp
  35. mov rbp, rsp
  36. SHADOW_ARGS_TO_STACK 5
  37. GET_GOT rbx
  38. push rsi
  39. push rdi
  40. ; end prolog
  41. mov rax, arg(0) ;input
  42. mov rsi, arg(1) ;pred
  43. movq mm0, [rax ]
  44. movq mm1, [rax+ 8]
  45. movq mm2, [rax+16]
  46. movq mm3, [rax+24]
  47. %if 0
  48. pxor mm7, mm7
  49. movq [rax], mm7
  50. movq [rax+8], mm7
  51. movq [rax+16],mm7
  52. movq [rax+24],mm7
  53. %endif
  54. movsxd rax, dword ptr arg(2) ;pitch
  55. mov rdx, arg(3) ;dest
  56. movsxd rdi, dword ptr arg(4) ;stride
  57. psubw mm0, mm2 ; b1= 0-2
  58. paddw mm2, mm2 ;
  59. movq mm5, mm1
  60. paddw mm2, mm0 ; a1 =0+2
  61. pmulhw mm5, [GLOBAL(x_s1sqr2)];
  62. paddw mm5, mm1 ; ip1 * sin(pi/8) * sqrt(2)
  63. movq mm7, mm3 ;
  64. pmulhw mm7, [GLOBAL(x_c1sqr2less1)];
  65. paddw mm7, mm3 ; ip3 * cos(pi/8) * sqrt(2)
  66. psubw mm7, mm5 ; c1
  67. movq mm5, mm1
  68. movq mm4, mm3
  69. pmulhw mm5, [GLOBAL(x_c1sqr2less1)]
  70. paddw mm5, mm1
  71. pmulhw mm3, [GLOBAL(x_s1sqr2)]
  72. paddw mm3, mm4
  73. paddw mm3, mm5 ; d1
  74. movq mm6, mm2 ; a1
  75. movq mm4, mm0 ; b1
  76. paddw mm2, mm3 ;0
  77. paddw mm4, mm7 ;1
  78. psubw mm0, mm7 ;2
  79. psubw mm6, mm3 ;3
  80. movq mm1, mm2 ; 03 02 01 00
  81. movq mm3, mm4 ; 23 22 21 20
  82. punpcklwd mm1, mm0 ; 11 01 10 00
  83. punpckhwd mm2, mm0 ; 13 03 12 02
  84. punpcklwd mm3, mm6 ; 31 21 30 20
  85. punpckhwd mm4, mm6 ; 33 23 32 22
  86. movq mm0, mm1 ; 11 01 10 00
  87. movq mm5, mm2 ; 13 03 12 02
  88. punpckldq mm0, mm3 ; 30 20 10 00
  89. punpckhdq mm1, mm3 ; 31 21 11 01
  90. punpckldq mm2, mm4 ; 32 22 12 02
  91. punpckhdq mm5, mm4 ; 33 23 13 03
  92. movq mm3, mm5 ; 33 23 13 03
  93. psubw mm0, mm2 ; b1= 0-2
  94. paddw mm2, mm2 ;
  95. movq mm5, mm1
  96. paddw mm2, mm0 ; a1 =0+2
  97. pmulhw mm5, [GLOBAL(x_s1sqr2)];
  98. paddw mm5, mm1 ; ip1 * sin(pi/8) * sqrt(2)
  99. movq mm7, mm3 ;
  100. pmulhw mm7, [GLOBAL(x_c1sqr2less1)];
  101. paddw mm7, mm3 ; ip3 * cos(pi/8) * sqrt(2)
  102. psubw mm7, mm5 ; c1
  103. movq mm5, mm1
  104. movq mm4, mm3
  105. pmulhw mm5, [GLOBAL(x_c1sqr2less1)]
  106. paddw mm5, mm1
  107. pmulhw mm3, [GLOBAL(x_s1sqr2)]
  108. paddw mm3, mm4
  109. paddw mm3, mm5 ; d1
  110. paddw mm0, [GLOBAL(fours)]
  111. paddw mm2, [GLOBAL(fours)]
  112. movq mm6, mm2 ; a1
  113. movq mm4, mm0 ; b1
  114. paddw mm2, mm3 ;0
  115. paddw mm4, mm7 ;1
  116. psubw mm0, mm7 ;2
  117. psubw mm6, mm3 ;3
  118. psraw mm2, 3
  119. psraw mm0, 3
  120. psraw mm4, 3
  121. psraw mm6, 3
  122. movq mm1, mm2 ; 03 02 01 00
  123. movq mm3, mm4 ; 23 22 21 20
  124. punpcklwd mm1, mm0 ; 11 01 10 00
  125. punpckhwd mm2, mm0 ; 13 03 12 02
  126. punpcklwd mm3, mm6 ; 31 21 30 20
  127. punpckhwd mm4, mm6 ; 33 23 32 22
  128. movq mm0, mm1 ; 11 01 10 00
  129. movq mm5, mm2 ; 13 03 12 02
  130. punpckldq mm0, mm3 ; 30 20 10 00
  131. punpckhdq mm1, mm3 ; 31 21 11 01
  132. punpckldq mm2, mm4 ; 32 22 12 02
  133. punpckhdq mm5, mm4 ; 33 23 13 03
  134. pxor mm7, mm7
  135. movd mm4, [rsi]
  136. punpcklbw mm4, mm7
  137. paddsw mm0, mm4
  138. packuswb mm0, mm7
  139. movd [rdx], mm0
  140. movd mm4, [rsi+rax]
  141. punpcklbw mm4, mm7
  142. paddsw mm1, mm4
  143. packuswb mm1, mm7
  144. movd [rdx+rdi], mm1
  145. movd mm4, [rsi+2*rax]
  146. punpcklbw mm4, mm7
  147. paddsw mm2, mm4
  148. packuswb mm2, mm7
  149. movd [rdx+rdi*2], mm2
  150. add rdx, rdi
  151. add rsi, rax
  152. movd mm4, [rsi+2*rax]
  153. punpcklbw mm4, mm7
  154. paddsw mm5, mm4
  155. packuswb mm5, mm7
  156. movd [rdx+rdi*2], mm5
  157. ; begin epilog
  158. pop rdi
  159. pop rsi
  160. RESTORE_GOT
  161. UNSHADOW_ARGS
  162. pop rbp
  163. ret
  164. ;void vp8_dc_only_idct_add_mmx(
  165. ;short input_dc,
  166. ;unsigned char *pred_ptr,
  167. ;int pred_stride,
  168. ;unsigned char *dst_ptr,
  169. ;int stride)
  170. global sym(vp8_dc_only_idct_add_mmx) PRIVATE
  171. sym(vp8_dc_only_idct_add_mmx):
  172. push rbp
  173. mov rbp, rsp
  174. SHADOW_ARGS_TO_STACK 5
  175. GET_GOT rbx
  176. ; end prolog
  177. movd mm5, arg(0) ;input_dc
  178. mov rax, arg(1) ;pred_ptr
  179. movsxd rdx, dword ptr arg(2) ;pred_stride
  180. pxor mm0, mm0
  181. paddw mm5, [GLOBAL(fours)]
  182. lea rcx, [rdx + rdx*2]
  183. psraw mm5, 3
  184. punpcklwd mm5, mm5
  185. punpckldq mm5, mm5
  186. movd mm1, [rax]
  187. movd mm2, [rax+rdx]
  188. movd mm3, [rax+2*rdx]
  189. movd mm4, [rax+rcx]
  190. mov rax, arg(3) ;d -- destination
  191. movsxd rdx, dword ptr arg(4) ;dst_stride
  192. punpcklbw mm1, mm0
  193. paddsw mm1, mm5
  194. packuswb mm1, mm0 ; pack and unpack to saturate
  195. lea rcx, [rdx + rdx*2]
  196. punpcklbw mm2, mm0
  197. paddsw mm2, mm5
  198. packuswb mm2, mm0 ; pack and unpack to saturate
  199. punpcklbw mm3, mm0
  200. paddsw mm3, mm5
  201. packuswb mm3, mm0 ; pack and unpack to saturate
  202. punpcklbw mm4, mm0
  203. paddsw mm4, mm5
  204. packuswb mm4, mm0 ; pack and unpack to saturate
  205. movd [rax], mm1
  206. movd [rax+rdx], mm2
  207. movd [rax+2*rdx], mm3
  208. movd [rax+rcx], mm4
  209. ; begin epilog
  210. RESTORE_GOT
  211. UNSHADOW_ARGS
  212. pop rbp
  213. ret
  214. SECTION_RODATA
  215. align 16
  216. x_s1sqr2:
  217. times 4 dw 0x8A8C
  218. align 16
  219. x_c1sqr2less1:
  220. times 4 dw 0x4E7B
  221. align 16
  222. fours:
  223. times 4 dw 0x0004