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.

103 lines
4.2KB

  1. /*
  2. * audio resampling
  3. * Copyright (c) 2004-2012 Michael Niedermayer <michaelni@gmx.at>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * audio resampling
  24. * @author Michael Niedermayer <michaelni@gmx.at>
  25. */
  26. #include "libswresample/resample.h"
  27. int swri_resample_common_int16_mmx2 (ResampleContext *c, int16_t *dst, const int16_t *src, int n, int update_ctx);
  28. int swri_resample_linear_int16_mmx2 (ResampleContext *c, int16_t *dst, const int16_t *src, int n, int update_ctx);
  29. int swri_resample_common_int16_sse2 (ResampleContext *c, int16_t *dst, const int16_t *src, int n, int update_ctx);
  30. int swri_resample_linear_int16_sse2 (ResampleContext *c, int16_t *dst, const int16_t *src, int n, int update_ctx);
  31. int swri_resample_common_float_sse (ResampleContext *c, float *dst, const float *src, int n, int update_ctx);
  32. int swri_resample_linear_float_sse (ResampleContext *c, float *dst, const float *src, int n, int update_ctx);
  33. int swri_resample_common_float_avx (ResampleContext *c, float *dst, const float *src, int n, int update_ctx);
  34. int swri_resample_linear_float_avx (ResampleContext *c, float *dst, const float *src, int n, int update_ctx);
  35. int swri_resample_common_double_sse2(ResampleContext *c, double *dst, const double *src, int n, int update_ctx);
  36. int swri_resample_linear_double_sse2(ResampleContext *c, double *dst, const double *src, int n, int update_ctx);
  37. #if HAVE_MMXEXT_INLINE
  38. #define DO_RESAMPLE_ONE 0
  39. #include "resample_mmx.h"
  40. #if ARCH_X86_32
  41. #define TEMPLATE_RESAMPLE_S16_MMX2
  42. #include "libswresample/resample_template.c"
  43. #undef TEMPLATE_RESAMPLE_S16_MMX2
  44. #endif
  45. #if HAVE_SSE_INLINE
  46. #define TEMPLATE_RESAMPLE_FLT_SSE
  47. #include "libswresample/resample_template.c"
  48. #undef TEMPLATE_RESAMPLE_FLT_SSE
  49. #endif
  50. #if HAVE_SSE2_INLINE
  51. #define TEMPLATE_RESAMPLE_S16_SSE2
  52. #include "libswresample/resample_template.c"
  53. #undef TEMPLATE_RESAMPLE_S16_SSE2
  54. #define TEMPLATE_RESAMPLE_DBL_SSE2
  55. #include "libswresample/resample_template.c"
  56. #undef TEMPLATE_RESAMPLE_DBL_SSE2
  57. #endif
  58. #if HAVE_AVX_INLINE
  59. #define TEMPLATE_RESAMPLE_FLT_AVX
  60. #include "libswresample/resample_template.c"
  61. #undef TEMPLATE_RESAMPLE_FLT_AVX
  62. #endif
  63. #undef DO_RESAMPLE_ONE
  64. #endif // HAVE_MMXEXT_INLINE
  65. void swresample_dsp_x86_init(ResampleContext *c)
  66. {
  67. int av_unused mm_flags = av_get_cpu_flags();
  68. #define FNIDX(fmt) (AV_SAMPLE_FMT_##fmt - AV_SAMPLE_FMT_S16P)
  69. if (ARCH_X86_32 && HAVE_MMXEXT_INLINE && mm_flags & AV_CPU_FLAG_MMX2) {
  70. c->dsp.resample_common[FNIDX(S16P)] = (resample_fn) swri_resample_common_int16_mmx2;
  71. c->dsp.resample_linear[FNIDX(S16P)] = (resample_fn) swri_resample_linear_int16_mmx2;
  72. }
  73. if (HAVE_SSE_INLINE && mm_flags & AV_CPU_FLAG_SSE) {
  74. c->dsp.resample_common[FNIDX(FLTP)] = (resample_fn) swri_resample_common_float_sse;
  75. c->dsp.resample_linear[FNIDX(FLTP)] = (resample_fn) swri_resample_linear_float_sse;
  76. }
  77. if (HAVE_SSE2_INLINE && mm_flags & AV_CPU_FLAG_SSE2) {
  78. c->dsp.resample_common[FNIDX(S16P)] = (resample_fn) swri_resample_common_int16_sse2;
  79. c->dsp.resample_linear[FNIDX(S16P)] = (resample_fn) swri_resample_linear_int16_sse2;
  80. c->dsp.resample_common[FNIDX(DBLP)] = (resample_fn) swri_resample_common_double_sse2;
  81. c->dsp.resample_linear[FNIDX(DBLP)] = (resample_fn) swri_resample_linear_double_sse2;
  82. }
  83. if (HAVE_AVX_INLINE && mm_flags & AV_CPU_FLAG_AVX) {
  84. c->dsp.resample_common[FNIDX(FLTP)] = (resample_fn) swri_resample_common_float_avx;
  85. c->dsp.resample_linear[FNIDX(FLTP)] = (resample_fn) swri_resample_linear_float_avx;
  86. }
  87. }