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.

59 lines
2.2KB

  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * Libav is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "libavutil/x86/asm.h"
  20. #include "audiodsp.h"
  21. #if HAVE_INLINE_ASM
  22. void ff_vector_clipf_sse(float *dst, const float *src,
  23. float min, float max, int len)
  24. {
  25. x86_reg i = (len - 16) * 4;
  26. __asm__ volatile (
  27. "movss %3, %%xmm4 \n\t"
  28. "movss %4, %%xmm5 \n\t"
  29. "shufps $0, %%xmm4, %%xmm4 \n\t"
  30. "shufps $0, %%xmm5, %%xmm5 \n\t"
  31. "1: \n\t"
  32. "movaps (%2, %0), %%xmm0 \n\t" // 3/1 on intel
  33. "movaps 16(%2, %0), %%xmm1 \n\t"
  34. "movaps 32(%2, %0), %%xmm2 \n\t"
  35. "movaps 48(%2, %0), %%xmm3 \n\t"
  36. "maxps %%xmm4, %%xmm0 \n\t"
  37. "maxps %%xmm4, %%xmm1 \n\t"
  38. "maxps %%xmm4, %%xmm2 \n\t"
  39. "maxps %%xmm4, %%xmm3 \n\t"
  40. "minps %%xmm5, %%xmm0 \n\t"
  41. "minps %%xmm5, %%xmm1 \n\t"
  42. "minps %%xmm5, %%xmm2 \n\t"
  43. "minps %%xmm5, %%xmm3 \n\t"
  44. "movaps %%xmm0, (%1, %0) \n\t"
  45. "movaps %%xmm1, 16(%1, %0) \n\t"
  46. "movaps %%xmm2, 32(%1, %0) \n\t"
  47. "movaps %%xmm3, 48(%1, %0) \n\t"
  48. "sub $64, %0 \n\t"
  49. "jge 1b \n\t"
  50. : "+&r" (i)
  51. : "r" (dst), "r" (src), "m" (min), "m" (max)
  52. : "memory");
  53. }
  54. #endif /* HAVE_INLINE_ASM */