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.

168 lines
4.7KB

  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 "libavutil/x86/x86util.asm"
  23. cextern pw_64
  24. SECTION .text
  25. %macro DIAG4 6
  26. %if mmsize == 8
  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. %else ; mmsize == 16
  64. movq m0, [%1+%2]
  65. movq m1, [%1+%3]
  66. punpcklbw m0, m7
  67. punpcklbw m1, m7
  68. pmullw m0, m4 ; src[x-8 ] * biweight [0]
  69. pmullw m1, m5 ; src[x ] * biweight [1]
  70. paddw m0, m1
  71. movq m1, [%1+%4]
  72. movq m2, [%1+%5]
  73. punpcklbw m1, m7
  74. punpcklbw m2, m7
  75. pmullw m1, m6 ; src[x+8 ] * biweight [2]
  76. pmullw m2, m3 ; src[x+16] * biweight [3]
  77. paddw m1, m2
  78. paddsw m0, m1
  79. paddsw m0, [pw_64] ; Add 64
  80. psraw m0, 7
  81. packuswb m0, m0
  82. movq [%6], m0
  83. %endif ; mmsize == 8/16
  84. %endmacro
  85. %macro SPLAT4REGS 0
  86. %if mmsize == 8
  87. movq m5, m3
  88. punpcklwd m3, m3
  89. movq m4, m3
  90. punpckldq m3, m3
  91. punpckhdq m4, m4
  92. punpckhwd m5, m5
  93. movq m2, m5
  94. punpckhdq m2, m2
  95. punpckldq m5, m5
  96. movq [rsp+8*11], m3
  97. movq [rsp+8*12], m4
  98. movq [rsp+8*13], m5
  99. movq [rsp+8*14], m2
  100. %else ; mmsize == 16
  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. %endif ; mmsize == 8/16
  110. %endmacro
  111. %macro vp6_filter_diag4 0
  112. ; void ff_vp6_filter_diag4_<opt>(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
  113. ; const int16_t h_weight[4], const int16_t v_weights[4])
  114. cglobal vp6_filter_diag4, 5, 7, 8
  115. mov r5, rsp ; backup stack pointer
  116. and rsp, ~(mmsize-1) ; align stack
  117. %if mmsize == 16
  118. sub rsp, 8*11
  119. %else
  120. sub rsp, 8*15
  121. movq m6, [pw_64]
  122. %endif
  123. sub r1, r2
  124. pxor m7, m7
  125. movq m3, [r3]
  126. SPLAT4REGS
  127. mov r3, rsp
  128. mov r6, 11
  129. .nextrow:
  130. DIAG4 r1, -1, 0, 1, 2, r3
  131. add r3, 8
  132. add r1, r2
  133. dec r6
  134. jnz .nextrow
  135. movq m3, [r4]
  136. SPLAT4REGS
  137. lea r3, [rsp+8]
  138. mov r6, 8
  139. .nextcol:
  140. DIAG4 r3, -8, 0, 8, 16, r0
  141. add r3, 8
  142. add r0, r2
  143. dec r6
  144. jnz .nextcol
  145. mov rsp, r5 ; restore stack pointer
  146. RET
  147. %endmacro
  148. %if ARCH_X86_32
  149. INIT_MMX mmx
  150. vp6_filter_diag4
  151. %endif
  152. INIT_XMM sse2
  153. vp6_filter_diag4