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.

172 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 6
  27. %if mmsize == 8
  28. movq m0, [%1+%2]
  29. movq m1, [%1+%3]
  30. movq m3, m0
  31. movq m4, m1
  32. punpcklbw m0, m7
  33. punpcklbw m1, m7
  34. punpckhbw m3, m7
  35. punpckhbw m4, m7
  36. pmullw m0, [rsp+8*11] ; src[x-8 ] * biweight [0]
  37. pmullw m1, [rsp+8*12] ; src[x ] * biweight [1]
  38. pmullw m3, [rsp+8*11] ; src[x-8 ] * biweight [0]
  39. pmullw m4, [rsp+8*12] ; src[x ] * biweight [1]
  40. paddw m0, m1
  41. paddw m3, m4
  42. movq m1, [%1+%4]
  43. movq m2, [%1+%5]
  44. movq m4, m1
  45. movq m5, m2
  46. punpcklbw m1, m7
  47. punpcklbw m2, m7
  48. punpckhbw m4, m7
  49. punpckhbw m5, m7
  50. pmullw m1, [rsp+8*13] ; src[x+8 ] * biweight [2]
  51. pmullw m2, [rsp+8*14] ; src[x+16] * biweight [3]
  52. pmullw m4, [rsp+8*13] ; src[x+8 ] * biweight [2]
  53. pmullw m5, [rsp+8*14] ; src[x+16] * biweight [3]
  54. paddw m1, m2
  55. paddw m4, m5
  56. paddsw m0, m1
  57. paddsw m3, m4
  58. paddsw m0, m6 ; Add 64
  59. paddsw m3, m6 ; Add 64
  60. psraw m0, 7
  61. psraw m3, 7
  62. packuswb m0, m3
  63. movq [%6], m0
  64. %else ; mmsize == 16
  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. %endif ; mmsize == 8/16
  85. %endmacro
  86. %macro SPLAT4REGS 0
  87. %if mmsize == 8
  88. movq m5, m3
  89. punpcklwd m3, m3
  90. movq m4, m3
  91. punpckldq m3, m3
  92. punpckhdq m4, m4
  93. punpckhwd m5, m5
  94. movq m2, m5
  95. punpckhdq m2, m2
  96. punpckldq m5, m5
  97. movq [rsp+8*11], m3
  98. movq [rsp+8*12], m4
  99. movq [rsp+8*13], m5
  100. movq [rsp+8*14], m2
  101. %else ; mmsize == 16
  102. pshuflw m4, m3, 0x0
  103. pshuflw m5, m3, 0x55
  104. pshuflw m6, m3, 0xAA
  105. pshuflw m3, m3, 0xFF
  106. punpcklqdq m4, m4
  107. punpcklqdq m5, m5
  108. punpcklqdq m6, m6
  109. punpcklqdq m3, m3
  110. %endif ; mmsize == 8/16
  111. %endmacro
  112. %macro vp6_filter_diag4 0
  113. ; void ff_vp6_filter_diag4_<opt>(uint8_t *dst, uint8_t *src, int stride,
  114. ; const int16_t h_weight[4], const int16_t v_weights[4])
  115. cglobal vp6_filter_diag4, 5, 7, 8
  116. mov r5, rsp ; backup stack pointer
  117. and rsp, ~(mmsize-1) ; align stack
  118. %if mmsize == 16
  119. sub rsp, 8*11
  120. %else
  121. sub rsp, 8*15
  122. movq m6, [pw_64]
  123. %endif
  124. %if ARCH_X86_64
  125. movsxd r2, r2d
  126. %endif
  127. sub r1, r2
  128. pxor m7, m7
  129. movq m3, [r3]
  130. SPLAT4REGS
  131. mov r3, rsp
  132. mov r6, 11
  133. .nextrow:
  134. DIAG4 r1, -1, 0, 1, 2, r3
  135. add r3, 8
  136. add r1, r2
  137. dec r6
  138. jnz .nextrow
  139. movq m3, [r4]
  140. SPLAT4REGS
  141. lea r3, [rsp+8]
  142. mov r6, 8
  143. .nextcol:
  144. DIAG4 r3, -8, 0, 8, 16, r0
  145. add r3, 8
  146. add r0, r2
  147. dec r6
  148. jnz .nextcol
  149. mov rsp, r5 ; restore stack pointer
  150. RET
  151. %endmacro
  152. %if ARCH_X86_32
  153. INIT_MMX mmx
  154. vp6_filter_diag4
  155. %endif
  156. INIT_XMM sse2
  157. vp6_filter_diag4