resample_init.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/attributes.h"
  27. #include "libavutil/x86/cpu.h"
  28. #include "libswresample/resample.h"
  29. #define RESAMPLE_FUNCS(type, opt) \
  30. int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
  31. const void *src, int sz, int upd); \
  32. int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
  33. const void *src, int sz, int upd)
  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 (EXTERNAL_SSE2(mm_flags)) {
  49. c->dsp.resample_linear = ff_resample_linear_int16_sse2;
  50. c->dsp.resample_common = ff_resample_common_int16_sse2;
  51. }
  52. if (EXTERNAL_XOP(mm_flags)) {
  53. c->dsp.resample_linear = ff_resample_linear_int16_xop;
  54. c->dsp.resample_common = ff_resample_common_int16_xop;
  55. }
  56. break;
  57. case AV_SAMPLE_FMT_FLTP:
  58. if (EXTERNAL_SSE(mm_flags)) {
  59. c->dsp.resample_linear = ff_resample_linear_float_sse;
  60. c->dsp.resample_common = ff_resample_common_float_sse;
  61. }
  62. if (EXTERNAL_AVX_FAST(mm_flags)) {
  63. c->dsp.resample_linear = ff_resample_linear_float_avx;
  64. c->dsp.resample_common = ff_resample_common_float_avx;
  65. }
  66. if (EXTERNAL_FMA3_FAST(mm_flags)) {
  67. c->dsp.resample_linear = ff_resample_linear_float_fma3;
  68. c->dsp.resample_common = ff_resample_common_float_fma3;
  69. }
  70. if (EXTERNAL_FMA4(mm_flags)) {
  71. c->dsp.resample_linear = ff_resample_linear_float_fma4;
  72. c->dsp.resample_common = ff_resample_common_float_fma4;
  73. }
  74. break;
  75. case AV_SAMPLE_FMT_DBLP:
  76. if (EXTERNAL_SSE2(mm_flags)) {
  77. c->dsp.resample_linear = ff_resample_linear_double_sse2;
  78. c->dsp.resample_common = ff_resample_common_double_sse2;
  79. }
  80. if (EXTERNAL_AVX_FAST(mm_flags)) {
  81. c->dsp.resample_linear = ff_resample_linear_double_avx;
  82. c->dsp.resample_common = ff_resample_common_double_avx;
  83. }
  84. if (EXTERNAL_FMA3_FAST(mm_flags)) {
  85. c->dsp.resample_linear = ff_resample_linear_double_fma3;
  86. c->dsp.resample_common = ff_resample_common_double_fma3;
  87. }
  88. break;
  89. }
  90. }