You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.8KB

  1. ;******************************************************************************
  2. ;* MMX/SSE2-optimized functions for the VP6 decoder
  3. ;* Copyright (C) 2009 Sebastien Lucas <sebastien.lucas@gmail.com>
  4. ;* Copyright (C) 2009 Zuxy Meng <zuxy.meng@gmail.com>
  5. ;*
  6. ;* This file is part of Libav.
  7. ;*
  8. ;* Libav is free software; you can redistribute it and/or
  9. ;* modify it under the terms of the GNU Lesser General Public
  10. ;* License as published by the Free Software Foundation; either
  11. ;* version 2.1 of the License, or (at your option) any later version.
  12. ;*
  13. ;* Libav is distributed in the hope that it will be useful,
  14. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. ;* Lesser General Public License for more details.
  17. ;*
  18. ;* You should have received a copy of the GNU Lesser General Public
  19. ;* License along with Libav; if not, write to the Free Software
  20. ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. ;******************************************************************************
  22. %include "x86inc.asm"
  23. %include "x86util.asm"
  24. cextern pw_64
  25. SECTION .text
  26. %macro DIAG4_MMX 6
  27. movq m0, [%1+%2]
  28. movq m1, [%1+%3]
  29. movq m3, m0
  30. movq m4, m1
  31. punpcklbw m0, m7
  32. punpcklbw m1, m7
  33. punpckhbw m3, m7
  34. punpckhbw m4, m7
  35. pmullw m0, [rsp+8*11] ; src[x-8 ] * biweight [0]
  36. pmullw m1, [rsp+8*12] ; src[x ] * biweight [1]
  37. pmullw m3, [rsp+8*11] ; src[x-8 ] * biweight [0]
  38. pmullw m4, [rsp+8*12] ; src[x ] * biweight [1]
  39. paddw m0, m1
  40. paddw m3, m4
  41. movq m1, [%1+%4]
  42. movq m2, [%1+%5]
  43. movq m4, m1
  44. movq m5, m2
  45. punpcklbw m1, m7
  46. punpcklbw m2, m7
  47. punpckhbw m4, m7
  48. punpckhbw m5, m7
  49. pmullw m1, [rsp+8*13] ; src[x+8 ] * biweight [2]
  50. pmullw m2, [rsp+8*14] ; src[x+16] * biweight [3]
  51. pmullw m4, [rsp+8*13] ; src[x+8 ] * biweight [2]
  52. pmullw m5, [rsp+8*14] ; src[x+16] * biweight [3]
  53. paddw m1, m2
  54. paddw m4, m5
  55. paddsw m0, m1
  56. paddsw m3, m4
  57. paddsw m0, m6 ; Add 64
  58. paddsw m3, m6 ; Add 64
  59. psraw m0, 7
  60. psraw m3, 7
  61. packuswb m0, m3
  62. movq [%6], m0
  63. %endmacro
  64. %macro DIAG4_SSE2 6
  65. movq m0, [%1+%2]
  66. movq m1, [%1+%3]
  67. punpcklbw m0, m7
  68. punpcklbw m1, m7
  69. pmullw m0, m4 ; src[x-8 ] * biweight [0]
  70. pmullw m1, m5 ; src[x ] * biweight [1]
  71. paddw m0, m1
  72. movq m1, [%1+%4]
  73. movq m2, [%1+%5]
  74. punpcklbw m1, m7
  75. punpcklbw m2, m7
  76. pmullw m1, m6 ; src[x+8 ] * biweight [2]
  77. pmullw m2, m3 ; src[x+16] * biweight [3]
  78. paddw m1, m2
  79. paddsw m0, m1
  80. paddsw m0, [pw_64] ; Add 64
  81. psraw m0, 7
  82. packuswb m0, m0
  83. movq [%6], m0
  84. %endmacro
  85. %macro SPLAT4REGS_MMX 0
  86. movq m5, m3
  87. punpcklwd m3, m3
  88. movq m4, m3
  89. punpckldq m3, m3
  90. punpckhdq m4, m4
  91. punpckhwd m5, m5
  92. movq m2, m5
  93. punpckhdq m2, m2
  94. punpckldq m5, m5
  95. movq [rsp+8*11], m3
  96. movq [rsp+8*12], m4
  97. movq [rsp+8*13], m5
  98. movq [rsp+8*14], m2
  99. %endmacro
  100. %macro SPLAT4REGS_SSE2 0
  101. pshuflw m4, m3, 0x0
  102. pshuflw m5, m3, 0x55
  103. pshuflw m6, m3, 0xAA
  104. pshuflw m3, m3, 0xFF
  105. punpcklqdq m4, m4
  106. punpcklqdq m5, m5
  107. punpcklqdq m6, m6
  108. punpcklqdq m3, m3
  109. %endmacro
  110. %macro vp6_filter_diag4 2
  111. ; void ff_vp6_filter_diag4_<opt>(uint8_t *dst, uint8_t *src, int stride,
  112. ; const int16_t h_weight[4], const int16_t v_weights[4])
  113. cglobal vp6_filter_diag4_%1, 5, 7, %2
  114. mov r5, rsp ; backup stack pointer
  115. and rsp, ~(mmsize-1) ; align stack
  116. %ifidn %1, sse2
  117. sub rsp, 8*11
  118. %else
  119. sub rsp, 8*15
  120. movq m6, [pw_64]
  121. %endif
  122. %if ARCH_X86_64
  123. movsxd r2, r2d
  124. %endif
  125. sub r1, r2
  126. pxor m7, m7
  127. movq m3, [r3]
  128. SPLAT4REGS
  129. mov r3, rsp
  130. mov r6, 11
  131. .nextrow
  132. DIAG4 r1, -1, 0, 1, 2, r3
  133. add r3, 8
  134. add r1, r2
  135. dec r6
  136. jnz .nextrow
  137. movq m3, [r4]
  138. SPLAT4REGS
  139. lea r3, [rsp+8]
  140. mov r6, 8
  141. .nextcol
  142. DIAG4 r3, -8, 0, 8, 16, r0
  143. add r3, 8
  144. add r0, r2
  145. dec r6
  146. jnz .nextcol
  147. mov rsp, r5 ; restore stack pointer
  148. RET
  149. %endmacro
  150. INIT_MMX
  151. %define DIAG4 DIAG4_MMX
  152. %define SPLAT4REGS SPLAT4REGS_MMX
  153. vp6_filter_diag4 mmx, 0
  154. INIT_XMM
  155. %define DIAG4 DIAG4_SSE2
  156. %define SPLAT4REGS SPLAT4REGS_SSE2
  157. vp6_filter_diag4 sse2, 8