resample_init.c 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #define RESAMPLE_FUNCS(type, opt) \
  28. int ff_resample_common_##type##_##opt(ResampleContext *c, void *dst, \
  29. const void *src, int sz, int upd); \
  30. int ff_resample_linear_##type##_##opt(ResampleContext *c, void *dst, \
  31. const void *src, int sz, int upd)
  32. RESAMPLE_FUNCS(int16, mmxext);
  33. RESAMPLE_FUNCS(int16, sse2);
  34. RESAMPLE_FUNCS(int16, xop);
  35. RESAMPLE_FUNCS(float, sse);
  36. RESAMPLE_FUNCS(float, avx);
  37. RESAMPLE_FUNCS(float, fma3);
  38. RESAMPLE_FUNCS(float, fma4);
  39. RESAMPLE_FUNCS(double, sse2);
  40. void swri_resample_dsp_x86_init(ResampleContext *c)
  41. {
  42. int av_unused mm_flags = av_get_cpu_flags();
  43. switch(c->format){
  44. case AV_SAMPLE_FMT_S16P:
  45. if (ARCH_X86_32 && HAVE_MMXEXT_EXTERNAL && mm_flags & AV_CPU_FLAG_MMX2) {
  46. c->dsp.resample = c->linear ? ff_resample_linear_int16_mmxext
  47. : ff_resample_common_int16_mmxext;
  48. }
  49. if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
  50. c->dsp.resample = c->linear ? ff_resample_linear_int16_sse2
  51. : ff_resample_common_int16_sse2;
  52. }
  53. if (HAVE_XOP_EXTERNAL && mm_flags & AV_CPU_FLAG_XOP) {
  54. c->dsp.resample = c->linear ? ff_resample_linear_int16_xop
  55. : ff_resample_common_int16_xop;
  56. }
  57. break;
  58. case AV_SAMPLE_FMT_FLTP:
  59. if (HAVE_SSE_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE) {
  60. c->dsp.resample = c->linear ? ff_resample_linear_float_sse
  61. : ff_resample_common_float_sse;
  62. }
  63. if (HAVE_AVX_EXTERNAL && mm_flags & AV_CPU_FLAG_AVX) {
  64. c->dsp.resample = c->linear ? ff_resample_linear_float_avx
  65. : ff_resample_common_float_avx;
  66. }
  67. if (HAVE_FMA3_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA3) {
  68. c->dsp.resample = c->linear ? ff_resample_linear_float_fma3
  69. : ff_resample_common_float_fma3;
  70. }
  71. if (HAVE_FMA4_EXTERNAL && mm_flags & AV_CPU_FLAG_FMA4) {
  72. c->dsp.resample = c->linear ? ff_resample_linear_float_fma4
  73. : ff_resample_common_float_fma4;
  74. }
  75. break;
  76. case AV_SAMPLE_FMT_DBLP:
  77. if (HAVE_SSE2_EXTERNAL && mm_flags & AV_CPU_FLAG_SSE2) {
  78. c->dsp.resample = c->linear ? ff_resample_linear_double_sse2
  79. : ff_resample_common_double_sse2;
  80. }
  81. break;
  82. }
  83. }