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.

68 lines
3.1KB

  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 swri_audio_convert_init_x86(struct AudioConvert *ac,
  32. enum AVSampleFormat out_fmt,
  33. enum AVSampleFormat in_fmt,
  34. int channels){
  35. int mm_flags = av_get_cpu_flags();
  36. ac->simd_f= NULL;
  37. //FIXME add memcpy case
  38. #define MULTI_CAPS_FUNC(flag, cap) \
  39. if (mm_flags & flag) {\
  40. 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)\
  41. ac->simd_f = ff_int16_to_int32_a_ ## cap;\
  42. 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)\
  43. ac->simd_f = ff_int32_to_int16_a_ ## cap;\
  44. }
  45. MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
  46. MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE, sse)
  47. if(mm_flags & AV_CPU_FLAG_SSE2) {
  48. 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)
  49. ac->simd_f = ff_int32_to_float_a_sse2;
  50. 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)
  51. ac->simd_f = ff_int16_to_float_a_sse2;
  52. 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)
  53. ac->simd_f = ff_float_to_int32_a_sse2;
  54. 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)
  55. ac->simd_f = ff_float_to_int16_a_sse2;
  56. }
  57. }