resample_init.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #include "libavutil/cpu.h"
  22. #include "libavutil/arm/cpu.h"
  23. #include "libavutil/internal.h"
  24. #include "libavutil/samplefmt.h"
  25. #include "libavresample/resample.h"
  26. #include "asm-offsets.h"
  27. AV_CHECK_OFFSET(struct ResampleContext, filter_bank, FILTER_BANK);
  28. AV_CHECK_OFFSET(struct ResampleContext, filter_length, FILTER_LENGTH);
  29. AV_CHECK_OFFSET(struct ResampleContext, src_incr, SRC_INCR);
  30. AV_CHECK_OFFSET(struct ResampleContext, phase_shift, PHASE_SHIFT);
  31. AV_CHECK_OFFSET(struct ResampleContext, phase_mask, PHASE_MASK);
  32. void ff_resample_one_flt_neon(struct ResampleContext *c, void *dst0,
  33. int dst_index, const void *src0,
  34. unsigned int index, int frac);
  35. void ff_resample_one_s16_neon(struct ResampleContext *c, void *dst0,
  36. int dst_index, const void *src0,
  37. unsigned int index, int frac);
  38. void ff_resample_one_s32_neon(struct ResampleContext *c, void *dst0,
  39. int dst_index, const void *src0,
  40. unsigned int index, int frac);
  41. void ff_resample_linear_flt_neon(struct ResampleContext *c, void *dst0,
  42. int dst_index, const void *src0,
  43. unsigned int index, int frac);
  44. av_cold void ff_audio_resample_init_arm(ResampleContext *c,
  45. enum AVSampleFormat sample_fmt)
  46. {
  47. int cpu_flags = av_get_cpu_flags();
  48. if (have_neon(cpu_flags)) {
  49. switch (sample_fmt) {
  50. case AV_SAMPLE_FMT_FLTP:
  51. if (c->linear)
  52. c->resample_one = ff_resample_linear_flt_neon;
  53. else
  54. c->resample_one = ff_resample_one_flt_neon;
  55. break;
  56. case AV_SAMPLE_FMT_S16P:
  57. if (!c->linear)
  58. c->resample_one = ff_resample_one_s16_neon;
  59. break;
  60. case AV_SAMPLE_FMT_S32P:
  61. if (!c->linear)
  62. c->resample_one = ff_resample_one_s32_neon;
  63. break;
  64. }
  65. }
  66. }