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.

171 lines
4.2KB

  1. ;*****************************************************************************
  2. ;* SSE2-optimized weighted prediction code
  3. ;*****************************************************************************
  4. ;* Copyright (c) 2004-2005 Michael Niedermayer, Loren Merritt
  5. ;* Copyright (C) 2010 Eli Friedman <eli.friedman@gmail.com>
  6. ;*
  7. ;* This file is part of FFmpeg.
  8. ;*
  9. ;* FFmpeg is free software; you can redistribute it and/or
  10. ;* modify it under the terms of the GNU Lesser General Public
  11. ;* License as published by the Free Software Foundation; either
  12. ;* version 2.1 of the License, or (at your option) any later version.
  13. ;*
  14. ;* FFmpeg is distributed in the hope that it will be useful,
  15. ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. ;* Lesser General Public License for more details.
  18. ;*
  19. ;* You should have received a copy of the GNU Lesser General Public
  20. ;* License along with FFmpeg; if not, write to the Free Software
  21. ;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. ;******************************************************************************
  23. %include "x86inc.asm"
  24. SECTION .text
  25. INIT_XMM
  26. ;-----------------------------------------------------------------------------
  27. ; biweight pred:
  28. ;
  29. ; void h264_biweight_16x16_sse2(uint8_t *dst, uint8_t *src, int stride,
  30. ; int log2_denom, int weightd, int weights,
  31. ; int offset);
  32. ;-----------------------------------------------------------------------------
  33. %macro BIWEIGHT_SSE2_SETUP 0
  34. add r6, 1
  35. or r6, 1
  36. add r3, 1
  37. movd m3, r4
  38. movd m4, r5
  39. movd m5, r6
  40. movd m6, r3
  41. pslld m5, m6
  42. psrld m5, 1
  43. pshuflw m3, m3, 0
  44. pshuflw m4, m4, 0
  45. pshuflw m5, m5, 0
  46. punpcklqdq m3, m3
  47. punpcklqdq m4, m4
  48. punpcklqdq m5, m5
  49. pxor m7, m7
  50. %endmacro
  51. %macro BIWEIGHT_SSE2_STEPA 3
  52. movh m%1, [r0+%3]
  53. movh m%2, [r1+%3]
  54. punpcklbw m%1, m7
  55. punpcklbw m%2, m7
  56. pmullw m%1, m3
  57. pmullw m%2, m4
  58. paddsw m%1, m%2
  59. %endmacro
  60. %macro BIWEIGHT_SSE2_STEPB 0
  61. paddsw m0, m5
  62. paddsw m1, m5
  63. psraw m0, m6
  64. psraw m1, m6
  65. packuswb m0, m1
  66. %endmacro
  67. cglobal h264_biweight_16x16_sse2, 7, 7, 8
  68. BIWEIGHT_SSE2_SETUP
  69. mov r3, 16
  70. .nextrow
  71. BIWEIGHT_SSE2_STEPA 0, 1, 0
  72. BIWEIGHT_SSE2_STEPA 1, 2, 8
  73. BIWEIGHT_SSE2_STEPB
  74. mova [r0], m0
  75. add r0, r2
  76. add r1, r2
  77. dec r3
  78. jnz .nextrow
  79. REP_RET
  80. cglobal h264_biweight_8x8_sse2, 7, 7, 8
  81. BIWEIGHT_SSE2_SETUP
  82. mov r3, 4
  83. lea r4, [r2*2]
  84. .nextrow
  85. BIWEIGHT_SSE2_STEPA 0, 1, 0
  86. BIWEIGHT_SSE2_STEPA 1, 2, r2
  87. BIWEIGHT_SSE2_STEPB
  88. movh [r0], m0
  89. movhps [r0+r2], m0
  90. add r0, r4
  91. add r1, r4
  92. dec r3
  93. jnz .nextrow
  94. REP_RET
  95. %macro BIWEIGHT_SSSE3_SETUP 0
  96. add r6, 1
  97. or r6, 1
  98. add r3, 1
  99. movd m4, r4
  100. movd m0, r5
  101. movd m5, r6
  102. movd m6, r3
  103. pslld m5, m6
  104. psrld m5, 1
  105. punpcklbw m4, m0
  106. pshuflw m4, m4, 0
  107. pshuflw m5, m5, 0
  108. punpcklqdq m4, m4
  109. punpcklqdq m5, m5
  110. %endmacro
  111. %macro BIWEIGHT_SSSE3_OP 0
  112. pmaddubsw m0, m4
  113. pmaddubsw m2, m4
  114. paddsw m0, m5
  115. paddsw m2, m5
  116. psraw m0, m6
  117. psraw m2, m6
  118. packuswb m0, m2
  119. %endmacro
  120. cglobal h264_biweight_16x16_ssse3, 7, 7, 8
  121. BIWEIGHT_SSSE3_SETUP
  122. mov r3, 16
  123. .nextrow
  124. movh m0, [r0]
  125. movh m2, [r0+8]
  126. movh m3, [r1+8]
  127. punpcklbw m0, [r1]
  128. punpcklbw m2, m3
  129. BIWEIGHT_SSSE3_OP
  130. mova [r0], m0
  131. add r0, r2
  132. add r1, r2
  133. dec r3
  134. jnz .nextrow
  135. REP_RET
  136. cglobal h264_biweight_8x8_ssse3, 7, 7, 8
  137. BIWEIGHT_SSSE3_SETUP
  138. mov r3, 4
  139. lea r4, [r2*2]
  140. .nextrow
  141. movh m0, [r0]
  142. movh m1, [r1]
  143. movh m2, [r0+r2]
  144. movh m3, [r1+r2]
  145. punpcklbw m0, m1
  146. punpcklbw m2, m3
  147. BIWEIGHT_SSSE3_OP
  148. movh [r0], m0
  149. movhps [r0+r2], m0
  150. add r0, r4
  151. add r1, r4
  152. dec r3
  153. jnz .nextrow
  154. REP_RET