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.

199 lines
7.9KB

  1. /*
  2. * DSP utils mmx functions are compiled twice for rnd/no_rnd
  3. * Copyright (c) 2000, 2001 Fabrice Bellard
  4. * Copyright (c) 2003-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
  7. * mostly rewritten by Michael Niedermayer <michaelni@gmx.at>
  8. * and improved by Zdenek Kabelac <kabi@users.sf.net>
  9. *
  10. * This file is part of Libav.
  11. *
  12. * Libav is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * Libav is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Lesser General Public
  23. * License along with Libav; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  25. */
  26. // put_pixels
  27. static void DEF(put, pixels8_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  28. {
  29. MOVQ_BFE(mm6);
  30. __asm__ volatile(
  31. "lea (%3, %3), %%"REG_a" \n\t"
  32. ".p2align 3 \n\t"
  33. "1: \n\t"
  34. "movq (%1), %%mm0 \n\t"
  35. "movq 1(%1), %%mm1 \n\t"
  36. "movq (%1, %3), %%mm2 \n\t"
  37. "movq 1(%1, %3), %%mm3 \n\t"
  38. PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
  39. "movq %%mm4, (%2) \n\t"
  40. "movq %%mm5, (%2, %3) \n\t"
  41. "add %%"REG_a", %1 \n\t"
  42. "add %%"REG_a", %2 \n\t"
  43. "movq (%1), %%mm0 \n\t"
  44. "movq 1(%1), %%mm1 \n\t"
  45. "movq (%1, %3), %%mm2 \n\t"
  46. "movq 1(%1, %3), %%mm3 \n\t"
  47. PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
  48. "movq %%mm4, (%2) \n\t"
  49. "movq %%mm5, (%2, %3) \n\t"
  50. "add %%"REG_a", %1 \n\t"
  51. "add %%"REG_a", %2 \n\t"
  52. "subl $4, %0 \n\t"
  53. "jnz 1b \n\t"
  54. :"+g"(h), "+S"(pixels), "+D"(block)
  55. :"r"((x86_reg)line_size)
  56. :REG_a, "memory");
  57. }
  58. static void DEF(put, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  59. {
  60. MOVQ_BFE(mm6);
  61. __asm__ volatile(
  62. "lea (%3, %3), %%"REG_a" \n\t"
  63. ".p2align 3 \n\t"
  64. "1: \n\t"
  65. "movq (%1), %%mm0 \n\t"
  66. "movq 1(%1), %%mm1 \n\t"
  67. "movq (%1, %3), %%mm2 \n\t"
  68. "movq 1(%1, %3), %%mm3 \n\t"
  69. PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
  70. "movq %%mm4, (%2) \n\t"
  71. "movq %%mm5, (%2, %3) \n\t"
  72. "movq 8(%1), %%mm0 \n\t"
  73. "movq 9(%1), %%mm1 \n\t"
  74. "movq 8(%1, %3), %%mm2 \n\t"
  75. "movq 9(%1, %3), %%mm3 \n\t"
  76. PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
  77. "movq %%mm4, 8(%2) \n\t"
  78. "movq %%mm5, 8(%2, %3) \n\t"
  79. "add %%"REG_a", %1 \n\t"
  80. "add %%"REG_a", %2 \n\t"
  81. "movq (%1), %%mm0 \n\t"
  82. "movq 1(%1), %%mm1 \n\t"
  83. "movq (%1, %3), %%mm2 \n\t"
  84. "movq 1(%1, %3), %%mm3 \n\t"
  85. PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
  86. "movq %%mm4, (%2) \n\t"
  87. "movq %%mm5, (%2, %3) \n\t"
  88. "movq 8(%1), %%mm0 \n\t"
  89. "movq 9(%1), %%mm1 \n\t"
  90. "movq 8(%1, %3), %%mm2 \n\t"
  91. "movq 9(%1, %3), %%mm3 \n\t"
  92. PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
  93. "movq %%mm4, 8(%2) \n\t"
  94. "movq %%mm5, 8(%2, %3) \n\t"
  95. "add %%"REG_a", %1 \n\t"
  96. "add %%"REG_a", %2 \n\t"
  97. "subl $4, %0 \n\t"
  98. "jnz 1b \n\t"
  99. :"+g"(h), "+S"(pixels), "+D"(block)
  100. :"r"((x86_reg)line_size)
  101. :REG_a, "memory");
  102. }
  103. static void DEF(put, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  104. {
  105. MOVQ_BFE(mm6);
  106. __asm__ volatile(
  107. "lea (%3, %3), %%"REG_a" \n\t"
  108. "movq (%1), %%mm0 \n\t"
  109. ".p2align 3 \n\t"
  110. "1: \n\t"
  111. "movq (%1, %3), %%mm1 \n\t"
  112. "movq (%1, %%"REG_a"),%%mm2 \n\t"
  113. PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5)
  114. "movq %%mm4, (%2) \n\t"
  115. "movq %%mm5, (%2, %3) \n\t"
  116. "add %%"REG_a", %1 \n\t"
  117. "add %%"REG_a", %2 \n\t"
  118. "movq (%1, %3), %%mm1 \n\t"
  119. "movq (%1, %%"REG_a"),%%mm0 \n\t"
  120. PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5)
  121. "movq %%mm4, (%2) \n\t"
  122. "movq %%mm5, (%2, %3) \n\t"
  123. "add %%"REG_a", %1 \n\t"
  124. "add %%"REG_a", %2 \n\t"
  125. "subl $4, %0 \n\t"
  126. "jnz 1b \n\t"
  127. :"+g"(h), "+S"(pixels), "+D"(block)
  128. :"r"((x86_reg)line_size)
  129. :REG_a, "memory");
  130. }
  131. static void DEF(avg, pixels16_x2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  132. {
  133. MOVQ_BFE(mm6);
  134. JUMPALIGN();
  135. do {
  136. __asm__ volatile(
  137. "movq %1, %%mm0 \n\t"
  138. "movq 1%1, %%mm1 \n\t"
  139. "movq %0, %%mm3 \n\t"
  140. PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
  141. PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
  142. "movq %%mm0, %0 \n\t"
  143. "movq 8%1, %%mm0 \n\t"
  144. "movq 9%1, %%mm1 \n\t"
  145. "movq 8%0, %%mm3 \n\t"
  146. PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
  147. PAVGB_MMX(%%mm3, %%mm2, %%mm0, %%mm6)
  148. "movq %%mm0, 8%0 \n\t"
  149. :"+m"(*block)
  150. :"m"(*pixels)
  151. :"memory");
  152. pixels += line_size;
  153. block += line_size;
  154. } while (--h);
  155. }
  156. static void DEF(avg, pixels8_y2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  157. {
  158. MOVQ_BFE(mm6);
  159. __asm__ volatile(
  160. "lea (%3, %3), %%"REG_a" \n\t"
  161. "movq (%1), %%mm0 \n\t"
  162. ".p2align 3 \n\t"
  163. "1: \n\t"
  164. "movq (%1, %3), %%mm1 \n\t"
  165. "movq (%1, %%"REG_a"), %%mm2 \n\t"
  166. PAVGBP(%%mm1, %%mm0, %%mm4, %%mm2, %%mm1, %%mm5)
  167. "movq (%2), %%mm3 \n\t"
  168. PAVGB_MMX(%%mm3, %%mm4, %%mm0, %%mm6)
  169. "movq (%2, %3), %%mm3 \n\t"
  170. PAVGB_MMX(%%mm3, %%mm5, %%mm1, %%mm6)
  171. "movq %%mm0, (%2) \n\t"
  172. "movq %%mm1, (%2, %3) \n\t"
  173. "add %%"REG_a", %1 \n\t"
  174. "add %%"REG_a", %2 \n\t"
  175. "movq (%1, %3), %%mm1 \n\t"
  176. "movq (%1, %%"REG_a"), %%mm0 \n\t"
  177. PAVGBP(%%mm1, %%mm2, %%mm4, %%mm0, %%mm1, %%mm5)
  178. "movq (%2), %%mm3 \n\t"
  179. PAVGB_MMX(%%mm3, %%mm4, %%mm2, %%mm6)
  180. "movq (%2, %3), %%mm3 \n\t"
  181. PAVGB_MMX(%%mm3, %%mm5, %%mm1, %%mm6)
  182. "movq %%mm2, (%2) \n\t"
  183. "movq %%mm1, (%2, %3) \n\t"
  184. "add %%"REG_a", %1 \n\t"
  185. "add %%"REG_a", %2 \n\t"
  186. "subl $4, %0 \n\t"
  187. "jnz 1b \n\t"
  188. :"+g"(h), "+S"(pixels), "+D"(block)
  189. :"r"((x86_reg)line_size)
  190. :REG_a, "memory");
  191. }