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.

107 lines
2.9KB

  1. ;******************************************************************************
  2. ;* MMX optimized DSP utils
  3. ;* Copyright (c) 2008 Loren Merritt
  4. ;* Copyright (c) 2003-2013 Michael Niedermayer
  5. ;* Copyright (c) 2013 Daniel Kang
  6. ;*
  7. ;* This file is part of Libav.
  8. ;*
  9. ;* Libav 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. ;* Libav 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 Libav; if not, write to the Free Software
  21. ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. ;******************************************************************************
  23. %include "libavutil/x86/x86util.asm"
  24. SECTION .text
  25. INIT_MMX mmxext
  26. ; void pixels(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  27. %macro PIXELS48 2
  28. %if %2 == 4
  29. %define OP movh
  30. %else
  31. %define OP mova
  32. %endif
  33. cglobal %1_pixels%2, 4,5
  34. movsxdifnidn r2, r2d
  35. lea r4, [r2*3]
  36. .loop:
  37. OP m0, [r1]
  38. OP m1, [r1+r2]
  39. OP m2, [r1+r2*2]
  40. OP m3, [r1+r4]
  41. lea r1, [r1+r2*4]
  42. %ifidn %1, avg
  43. pavgb m0, [r0]
  44. pavgb m1, [r0+r2]
  45. pavgb m2, [r0+r2*2]
  46. pavgb m3, [r0+r4]
  47. %endif
  48. OP [r0], m0
  49. OP [r0+r2], m1
  50. OP [r0+r2*2], m2
  51. OP [r0+r4], m3
  52. sub r3d, 4
  53. lea r0, [r0+r2*4]
  54. jne .loop
  55. RET
  56. %endmacro
  57. PIXELS48 put, 4
  58. PIXELS48 avg, 4
  59. PIXELS48 put, 8
  60. PIXELS48 avg, 8
  61. INIT_XMM sse2
  62. ; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  63. cglobal put_pixels16, 4,5,4
  64. lea r4, [r2*3]
  65. .loop:
  66. movu m0, [r1]
  67. movu m1, [r1+r2]
  68. movu m2, [r1+r2*2]
  69. movu m3, [r1+r4]
  70. lea r1, [r1+r2*4]
  71. mova [r0], m0
  72. mova [r0+r2], m1
  73. mova [r0+r2*2], m2
  74. mova [r0+r4], m3
  75. sub r3d, 4
  76. lea r0, [r0+r2*4]
  77. jnz .loop
  78. REP_RET
  79. ; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
  80. cglobal avg_pixels16, 4,5,4
  81. lea r4, [r2*3]
  82. .loop:
  83. movu m0, [r1]
  84. movu m1, [r1+r2]
  85. movu m2, [r1+r2*2]
  86. movu m3, [r1+r4]
  87. lea r1, [r1+r2*4]
  88. pavgb m0, [r0]
  89. pavgb m1, [r0+r2]
  90. pavgb m2, [r0+r2*2]
  91. pavgb m3, [r0+r4]
  92. mova [r0], m0
  93. mova [r0+r2], m1
  94. mova [r0+r2*2], m2
  95. mova [r0+r4], m3
  96. sub r3d, 4
  97. lea r0, [r0+r2*4]
  98. jnz .loop
  99. REP_RET