cpu.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This file is part of Libav.
  3. *
  4. * Libav is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * Libav is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with Libav; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "cpu.h"
  19. #include "config.h"
  20. int av_get_cpu_flags(void)
  21. {
  22. static int flags, checked;
  23. if (checked)
  24. return flags;
  25. if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
  26. if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
  27. if (ARCH_X86) flags = ff_get_cpu_flags_x86();
  28. checked = 1;
  29. return flags;
  30. }
  31. #ifdef TEST
  32. #undef printf
  33. #include <stdio.h>
  34. int main(void)
  35. {
  36. int cpu_flags = av_get_cpu_flags();
  37. printf("cpu_flags = 0x%08X\n", cpu_flags);
  38. printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
  39. #if ARCH_ARM
  40. cpu_flags & AV_CPU_FLAG_IWMMXT ? "IWMMXT " : "",
  41. #elif ARCH_PPC
  42. cpu_flags & AV_CPU_FLAG_ALTIVEC ? "ALTIVEC " : "",
  43. #elif ARCH_X86
  44. cpu_flags & AV_CPU_FLAG_MMX ? "MMX " : "",
  45. cpu_flags & AV_CPU_FLAG_MMX2 ? "MMX2 " : "",
  46. cpu_flags & AV_CPU_FLAG_SSE ? "SSE " : "",
  47. cpu_flags & AV_CPU_FLAG_SSE2 ? "SSE2 " : "",
  48. cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "",
  49. cpu_flags & AV_CPU_FLAG_SSE3 ? "SSE3 " : "",
  50. cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "",
  51. cpu_flags & AV_CPU_FLAG_SSSE3 ? "SSSE3 " : "",
  52. cpu_flags & AV_CPU_FLAG_ATOM ? "Atom " : "",
  53. cpu_flags & AV_CPU_FLAG_SSE4 ? "SSE4.1 " : "",
  54. cpu_flags & AV_CPU_FLAG_SSE42 ? "SSE4.2 " : "",
  55. cpu_flags & AV_CPU_FLAG_AVX ? "AVX " : "",
  56. cpu_flags & AV_CPU_FLAG_3DNOW ? "3DNow " : "",
  57. cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt " : "");
  58. #endif
  59. return 0;
  60. }
  61. #endif