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.

61 lines
2.1KB

  1. /*
  2. * Copyright (c) 2012-2014 Christophe Gisquet <christophe.gisquet@gmail.com>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_X86_DCA_H
  21. #define AVCODEC_X86_DCA_H
  22. #include "config.h"
  23. #if ARCH_X86_64 && HAVE_SSE2_INLINE
  24. # include "libavutil/x86/asm.h"
  25. # include "libavutil/mem.h"
  26. #include "libavcodec/dcadsp.h"
  27. # define int8x8_fmul_int32 int8x8_fmul_int32
  28. static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
  29. float *dst, const int8_t *src, int scale)
  30. {
  31. DECLARE_ALIGNED(16, static const uint32_t, inverse16) = 0x3D800000;
  32. __asm__ volatile (
  33. "cvtsi2ss %2, %%xmm0 \n\t"
  34. "mulss %3, %%xmm0 \n\t"
  35. "movq (%1), %%xmm1 \n\t"
  36. "punpcklbw %%xmm1, %%xmm1 \n\t"
  37. "movaps %%xmm1, %%xmm2 \n\t"
  38. "punpcklwd %%xmm1, %%xmm1 \n\t"
  39. "punpckhwd %%xmm2, %%xmm2 \n\t"
  40. "psrad $24, %%xmm1 \n\t"
  41. "psrad $24, %%xmm2 \n\t"
  42. "shufps $0, %%xmm0, %%xmm0 \n\t"
  43. "cvtdq2ps %%xmm1, %%xmm1 \n\t"
  44. "cvtdq2ps %%xmm2, %%xmm2 \n\t"
  45. "mulps %%xmm0, %%xmm1 \n\t"
  46. "mulps %%xmm0, %%xmm2 \n\t"
  47. "movaps %%xmm1, 0(%0) \n\t"
  48. "movaps %%xmm2, 16(%0) \n\t"
  49. :: "r"(dst), "r"(src), "m"(scale), "m"(inverse16)
  50. XMM_CLOBBERS_ONLY("xmm0", "xmm1", "xmm2")
  51. );
  52. }
  53. #endif /* ARCH_X86_64 && HAVE_SSE2_INLINE */
  54. #endif /* AVCODEC_X86_DCA_H */