You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
3.4KB

  1. /*
  2. * Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
  3. *
  4. * This file is part of libswresample
  5. *
  6. * libswresample 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. * libswresample 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 libswresample; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libswresample/swresample_internal.h"
  21. #include "libswresample/audioconvert.h"
  22. #define MULTI_CAPS_FUNC_DECL(cap) \
  23. void ff_int16_to_int32_a_ ## cap(uint8_t **dst, const uint8_t **src, int len);\
  24. void ff_int32_to_int16_a_ ## cap(uint8_t **dst, const uint8_t **src, int len);\
  25. MULTI_CAPS_FUNC_DECL(mmx)
  26. MULTI_CAPS_FUNC_DECL(sse)
  27. void ff_int32_to_float_a_sse2(uint8_t **dst, const uint8_t **src, int len);
  28. void ff_int16_to_float_a_sse2(uint8_t **dst, const uint8_t **src, int len);
  29. void ff_float_to_int32_a_sse2(uint8_t **dst, const uint8_t **src, int len);
  30. void ff_float_to_int16_a_sse2(uint8_t **dst, const uint8_t **src, int len);
  31. void ff_int32_to_float_a_avx(uint8_t **dst, const uint8_t **src, int len);
  32. void swri_audio_convert_init_x86(struct AudioConvert *ac,
  33. enum AVSampleFormat out_fmt,
  34. enum AVSampleFormat in_fmt,
  35. int channels){
  36. int mm_flags = av_get_cpu_flags();
  37. ac->simd_f= NULL;
  38. //FIXME add memcpy case
  39. #define MULTI_CAPS_FUNC(flag, cap) \
  40. if (mm_flags & flag) {\
  41. if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
  42. ac->simd_f = ff_int16_to_int32_a_ ## cap;\
  43. if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
  44. ac->simd_f = ff_int32_to_int16_a_ ## cap;\
  45. }
  46. MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
  47. MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE, sse)
  48. if(mm_flags & AV_CPU_FLAG_SSE2) {
  49. if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
  50. ac->simd_f = ff_int32_to_float_a_sse2;
  51. if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
  52. ac->simd_f = ff_int16_to_float_a_sse2;
  53. if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
  54. ac->simd_f = ff_float_to_int32_a_sse2;
  55. if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
  56. ac->simd_f = ff_float_to_int16_a_sse2;
  57. }
  58. if(HAVE_AVX && mm_flags & AV_CPU_FLAG_AVX) {
  59. if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
  60. ac->simd_f = ff_int32_to_float_a_avx;
  61. }
  62. }