2
0

idctllm_mmx.asm 9.2 KB

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