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.

98 lines
3.8KB

  1. /*
  2. * Copyright (c) 2012 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg 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. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libavutil/x86/asm.h"
  21. #include "libavutil/cpu.h"
  22. #include "libswresample/swresample_internal.h"
  23. int swri_resample_int16_mmx2 (struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
  24. int swri_resample_int16_sse2 (struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
  25. int swri_resample_float_sse (struct ResampleContext *c, float *dst, const float *src, int *consumed, int src_size, int dst_size, int update_ctx);
  26. DECLARE_ALIGNED(16, const uint64_t, ff_resample_int16_rounder)[2] = { 0x0000000000004000ULL, 0x0000000000000000ULL};
  27. #define COMMON_CORE_INT16_MMX2 \
  28. x86_reg len= -2*c->filter_length;\
  29. __asm__ volatile(\
  30. "movq "MANGLE(ff_resample_int16_rounder)", %%mm0 \n\t"\
  31. "1: \n\t"\
  32. "movq (%1, %0), %%mm1 \n\t"\
  33. "pmaddwd (%2, %0), %%mm1 \n\t"\
  34. "paddd %%mm1, %%mm0 \n\t"\
  35. "add $8, %0 \n\t"\
  36. " js 1b \n\t"\
  37. "pshufw $0x0E, %%mm0, %%mm1 \n\t"\
  38. "paddd %%mm1, %%mm0 \n\t"\
  39. "psrad $15, %%mm0 \n\t"\
  40. "packssdw %%mm0, %%mm0 \n\t"\
  41. "movd %%mm0, (%3) \n\t"\
  42. : "+r" (len)\
  43. : "r" (((uint8_t*)(src+sample_index))-len),\
  44. "r" (((uint8_t*)filter)-len),\
  45. "r" (dst+dst_index)\
  46. NAMED_CONSTRAINTS_ADD(ff_resample_int16_rounder)\
  47. );
  48. #define COMMON_CORE_INT16_SSE2 \
  49. x86_reg len= -2*c->filter_length;\
  50. __asm__ volatile(\
  51. "movdqa "MANGLE(ff_resample_int16_rounder)", %%xmm0 \n\t"\
  52. "1: \n\t"\
  53. "movdqu (%1, %0), %%xmm1 \n\t"\
  54. "pmaddwd (%2, %0), %%xmm1 \n\t"\
  55. "paddd %%xmm1, %%xmm0 \n\t"\
  56. "add $16, %0 \n\t"\
  57. " js 1b \n\t"\
  58. "pshufd $0x0E, %%xmm0, %%xmm1 \n\t"\
  59. "paddd %%xmm1, %%xmm0 \n\t"\
  60. "pshufd $0x01, %%xmm0, %%xmm1 \n\t"\
  61. "paddd %%xmm1, %%xmm0 \n\t"\
  62. "psrad $15, %%xmm0 \n\t"\
  63. "packssdw %%xmm0, %%xmm0 \n\t"\
  64. "movd %%xmm0, (%3) \n\t"\
  65. : "+r" (len)\
  66. : "r" (((uint8_t*)(src+sample_index))-len),\
  67. "r" (((uint8_t*)filter)-len),\
  68. "r" (dst+dst_index)\
  69. NAMED_CONSTRAINTS_ADD(ff_resample_int16_rounder)\
  70. );
  71. #define COMMON_CORE_FLT_SSE \
  72. x86_reg len= -4*c->filter_length;\
  73. __asm__ volatile(\
  74. "xorps %%xmm0, %%xmm0 \n\t"\
  75. "1: \n\t"\
  76. "movups (%1, %0), %%xmm1 \n\t"\
  77. "mulps (%2, %0), %%xmm1 \n\t"\
  78. "addps %%xmm1, %%xmm0 \n\t"\
  79. "add $16, %0 \n\t"\
  80. " js 1b \n\t"\
  81. "movhlps %%xmm0, %%xmm1 \n\t"\
  82. "addps %%xmm1, %%xmm0 \n\t"\
  83. "movss %%xmm0, %%xmm1 \n\t"\
  84. "shufps $1, %%xmm0, %%xmm0 \n\t"\
  85. "addps %%xmm1, %%xmm0 \n\t"\
  86. "movss %%xmm0, (%3) \n\t"\
  87. : "+r" (len)\
  88. : "r" (((uint8_t*)(src+sample_index))-len),\
  89. "r" (((uint8_t*)filter)-len),\
  90. "r" (dst+dst_index)\
  91. );