resample_dsp.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "resample.h"
  27. #define TEMPLATE_RESAMPLE_S16
  28. #include "resample_template.c"
  29. #undef TEMPLATE_RESAMPLE_S16
  30. #define TEMPLATE_RESAMPLE_S32
  31. #include "resample_template.c"
  32. #undef TEMPLATE_RESAMPLE_S32
  33. #define TEMPLATE_RESAMPLE_FLT
  34. #include "resample_template.c"
  35. #undef TEMPLATE_RESAMPLE_FLT
  36. #define TEMPLATE_RESAMPLE_DBL
  37. #include "resample_template.c"
  38. #undef TEMPLATE_RESAMPLE_DBL
  39. void swri_resample_dsp_init(ResampleContext *c)
  40. {
  41. switch(c->format){
  42. case AV_SAMPLE_FMT_S16P:
  43. c->dsp.resample_one = resample_one_int16;
  44. c->dsp.resample_common = resample_common_int16;
  45. c->dsp.resample_linear = resample_linear_int16;
  46. break;
  47. case AV_SAMPLE_FMT_S32P:
  48. c->dsp.resample_one = resample_one_int32;
  49. c->dsp.resample_common = resample_common_int32;
  50. c->dsp.resample_linear = resample_linear_int32;
  51. break;
  52. case AV_SAMPLE_FMT_FLTP:
  53. c->dsp.resample_one = resample_one_float;
  54. c->dsp.resample_common = resample_common_float;
  55. c->dsp.resample_linear = resample_linear_float;
  56. break;
  57. case AV_SAMPLE_FMT_DBLP:
  58. c->dsp.resample_one = resample_one_double;
  59. c->dsp.resample_common = resample_common_double;
  60. c->dsp.resample_linear = resample_linear_double;
  61. break;
  62. }
  63. #if ARCH_X86
  64. swri_resample_dsp_x86_init(c);
  65. #elif ARCH_ARM
  66. swri_resample_dsp_arm_init(c);
  67. #elif ARCH_AARCH64
  68. swri_resample_dsp_aarch64_init(c);
  69. #endif
  70. }