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.

58 lines
2.3KB

  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. MULTI_CAPS_FUNC_DECL(mmx)
  25. MULTI_CAPS_FUNC_DECL(sse)
  26. void ff_int32_to_float_a_sse2(uint8_t **dst, const uint8_t **src, int len);
  27. void ff_int16_to_float_a_sse2(uint8_t **dst, const uint8_t **src, int len);
  28. void swri_audio_convert_init_x86(struct AudioConvert *ac,
  29. enum AVSampleFormat out_fmt,
  30. enum AVSampleFormat in_fmt,
  31. int channels){
  32. int mm_flags = av_get_cpu_flags();
  33. ac->simd_f= NULL;
  34. //FIXME add memcpy case
  35. #define MULTI_CAPS_FUNC(flag, cap) \
  36. if (mm_flags & flag) {\
  37. 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)\
  38. ac->simd_f = ff_int16_to_int32_a_ ## cap;\
  39. }
  40. MULTI_CAPS_FUNC(AV_CPU_FLAG_MMX, mmx)
  41. MULTI_CAPS_FUNC(AV_CPU_FLAG_SSE, sse)
  42. if(mm_flags & AV_CPU_FLAG_SSE2) {
  43. 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)
  44. ac->simd_f = ff_int32_to_float_a_sse2;
  45. 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)
  46. ac->simd_f = ff_int16_to_float_a_sse2;
  47. }
  48. }