resample_init.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "libavutil/x86/cpu.h"
  27. #include "libswresample/resample.h"
  28. #define RESAMPLE_FUNCS(type, opt) \
  29. int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
  30. const void *src, int sz, int upd); \
  31. int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
  32. const void *src, int sz, int upd)
  33. RESAMPLE_FUNCS(int16, mmxext);
  34. RESAMPLE_FUNCS(int16, sse2);
  35. RESAMPLE_FUNCS(int16, xop);
  36. RESAMPLE_FUNCS(float, sse);
  37. RESAMPLE_FUNCS(float, avx);
  38. RESAMPLE_FUNCS(float, fma3);
  39. RESAMPLE_FUNCS(float, fma4);
  40. RESAMPLE_FUNCS(double, sse2);
  41. RESAMPLE_FUNCS(double, avx);
  42. RESAMPLE_FUNCS(double, fma3);
  43. av_cold void swri_resample_dsp_x86_init(ResampleContext *c)
  44. {
  45. int av_unused mm_flags = av_get_cpu_flags();
  46. switch(c->format){
  47. case AV_SAMPLE_FMT_S16P:
  48. if (ARCH_X86_32 && EXTERNAL_MMXEXT(mm_flags)) {
  49. c->dsp.resample_linear = ff_resample_linear_int16_mmxext;
  50. c->dsp.resample_common = ff_resample_common_int16_mmxext;
  51. }
  52. if (EXTERNAL_SSE2(mm_flags)) {
  53. c->dsp.resample_linear = ff_resample_linear_int16_sse2;
  54. c->dsp.resample_common = ff_resample_common_int16_sse2;
  55. }
  56. if (EXTERNAL_XOP(mm_flags)) {
  57. c->dsp.resample_linear = ff_resample_linear_int16_xop;
  58. c->dsp.resample_common = ff_resample_common_int16_xop;
  59. }
  60. break;
  61. case AV_SAMPLE_FMT_FLTP:
  62. if (EXTERNAL_SSE(mm_flags)) {
  63. c->dsp.resample_linear = ff_resample_linear_float_sse;
  64. c->dsp.resample_common = ff_resample_common_float_sse;
  65. }
  66. if (EXTERNAL_AVX_FAST(mm_flags)) {
  67. c->dsp.resample_linear = ff_resample_linear_float_avx;
  68. c->dsp.resample_common = ff_resample_common_float_avx;
  69. }
  70. if (EXTERNAL_FMA3_FAST(mm_flags)) {
  71. c->dsp.resample_linear = ff_resample_linear_float_fma3;
  72. c->dsp.resample_common = ff_resample_common_float_fma3;
  73. }
  74. if (EXTERNAL_FMA4(mm_flags)) {
  75. c->dsp.resample_linear = ff_resample_linear_float_fma4;
  76. c->dsp.resample_common = ff_resample_common_float_fma4;
  77. }
  78. break;
  79. case AV_SAMPLE_FMT_DBLP:
  80. if (EXTERNAL_SSE2(mm_flags)) {
  81. c->dsp.resample_linear = ff_resample_linear_double_sse2;
  82. c->dsp.resample_common = ff_resample_common_double_sse2;
  83. }
  84. if (EXTERNAL_AVX_FAST(mm_flags)) {
  85. c->dsp.resample_linear = ff_resample_linear_double_avx;
  86. c->dsp.resample_common = ff_resample_common_double_avx;
  87. }
  88. if (EXTERNAL_FMA3_FAST(mm_flags)) {
  89. c->dsp.resample_linear = ff_resample_linear_double_fma3;
  90. c->dsp.resample_common = ff_resample_common_double_fma3;
  91. }
  92. break;
  93. }
  94. }