float_dsp.asm 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ;*****************************************************************************
  2. ;* x86-optimized Float DSP functions
  3. ;*
  4. ;* Copyright 2006 Loren Merritt
  5. ;*
  6. ;* This file is part of FFmpeg.
  7. ;*
  8. ;* FFmpeg 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. ;* FFmpeg 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 FFmpeg; 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. SECTION .text
  25. ;-----------------------------------------------------------------------------
  26. ; void vector_fmul(float *dst, const float *src0, const float *src1, int len)
  27. ;-----------------------------------------------------------------------------
  28. %macro VECTOR_FMUL 0
  29. cglobal vector_fmul, 4,4,2, dst, src0, src1, len
  30. lea lenq, [lend*4 - 2*mmsize]
  31. ALIGN 16
  32. .loop:
  33. mova m0, [src0q + lenq]
  34. mova m1, [src0q + lenq + mmsize]
  35. mulps m0, m0, [src1q + lenq]
  36. mulps m1, m1, [src1q + lenq + mmsize]
  37. mova [dstq + lenq], m0
  38. mova [dstq + lenq + mmsize], m1
  39. sub lenq, 2*mmsize
  40. jge .loop
  41. REP_RET
  42. %endmacro
  43. INIT_XMM sse
  44. VECTOR_FMUL
  45. %if HAVE_AVX_EXTERNAL
  46. INIT_YMM avx
  47. VECTOR_FMUL
  48. %endif
  49. ;------------------------------------------------------------------------------
  50. ; void ff_vector_fmac_scalar(float *dst, const float *src, float mul, int len)
  51. ;------------------------------------------------------------------------------
  52. %macro VECTOR_FMAC_SCALAR 0
  53. %if UNIX64
  54. cglobal vector_fmac_scalar, 3,3,3, dst, src, len
  55. %else
  56. cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len
  57. %endif
  58. %if ARCH_X86_32
  59. VBROADCASTSS m0, mulm
  60. %else
  61. %if WIN64
  62. mova xmm0, xmm2
  63. %endif
  64. shufps xmm0, xmm0, 0
  65. %if cpuflag(avx)
  66. vinsertf128 m0, m0, xmm0, 1
  67. %endif
  68. %endif
  69. lea lenq, [lend*4-2*mmsize]
  70. .loop:
  71. mulps m1, m0, [srcq+lenq ]
  72. mulps m2, m0, [srcq+lenq+mmsize]
  73. addps m1, m1, [dstq+lenq ]
  74. addps m2, m2, [dstq+lenq+mmsize]
  75. mova [dstq+lenq ], m1
  76. mova [dstq+lenq+mmsize], m2
  77. sub lenq, 2*mmsize
  78. jge .loop
  79. REP_RET
  80. %endmacro
  81. INIT_XMM sse
  82. VECTOR_FMAC_SCALAR
  83. %if HAVE_AVX_EXTERNAL
  84. INIT_YMM avx
  85. VECTOR_FMAC_SCALAR
  86. %endif