resample_init.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. void swri_resample_dsp_x86_init(ResampleContext *c)
  42. {
  43. int av_unused mm_flags = av_get_cpu_flags();
  44. switch(c->format){
  45. case AV_SAMPLE_FMT_S16P:
  46. if (ARCH_X86_32 && EXTERNAL_MMXEXT(mm_flags)) {
  47. c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
  48. : ff_resample_common_int16_mmxext;
  49. }
  50. if (EXTERNAL_SSE2(mm_flags)) {
  51. c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
  52. : ff_resample_common_int16_sse2;
  53. }
  54. if (EXTERNAL_XOP(mm_flags)) {
  55. c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
  56. : ff_resample_common_int16_xop;
  57. }
  58. break;
  59. case AV_SAMPLE_FMT_FLTP:
  60. if (EXTERNAL_SSE(mm_flags)) {
  61. c->dsp.resample = c->linear ? ff_resample_linear_float_sse
  62. : ff_resample_common_float_sse;
  63. }
  64. if (EXTERNAL_AVX(mm_flags)) {
  65. c->dsp.resample = c->linear ? ff_resample_linear_float_avx
  66. : ff_resample_common_float_avx;
  67. }
  68. if (EXTERNAL_FMA3(mm_flags)) {
  69. c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
  70. : ff_resample_common_float_fma3;
  71. }
  72. if (EXTERNAL_FMA4(mm_flags)) {
  73. c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
  74. : ff_resample_common_float_fma4;
  75. }
  76. break;
  77. case AV_SAMPLE_FMT_DBLP:
  78. if (EXTERNAL_SSE2(mm_flags)) {
  79. c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
  80. : ff_resample_common_double_sse2;
  81. }
  82. break;
  83. }
  84. }