00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "cpu.h"
00020 #include "config.h"
00021
00022 static int flags, checked;
00023
00024 void av_force_cpu_flags(int arg){
00025 flags = arg;
00026 checked = 1;
00027 }
00028
00029 int av_get_cpu_flags(void)
00030 {
00031 if (checked)
00032 return flags;
00033
00034 if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
00035 if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
00036 if (ARCH_X86) flags = ff_get_cpu_flags_x86();
00037
00038 checked = 1;
00039 return flags;
00040 }
00041
00042 #ifdef TEST
00043
00044 #undef printf
00045 #include <stdio.h>
00046
00047 static const struct {
00048 int flag;
00049 const char *name;
00050 } cpu_flag_tab[] = {
00051 #if ARCH_ARM
00052 { AV_CPU_FLAG_IWMMXT, "iwmmxt" },
00053 #elif ARCH_PPC
00054 { AV_CPU_FLAG_ALTIVEC, "altivec" },
00055 #elif ARCH_X86
00056 { AV_CPU_FLAG_MMX, "mmx" },
00057 { AV_CPU_FLAG_MMX2, "mmx2" },
00058 { AV_CPU_FLAG_SSE, "sse" },
00059 { AV_CPU_FLAG_SSE2, "sse2" },
00060 { AV_CPU_FLAG_SSE2SLOW, "sse2(slow)" },
00061 { AV_CPU_FLAG_SSE3, "sse3" },
00062 { AV_CPU_FLAG_SSE3SLOW, "sse3(slow)" },
00063 { AV_CPU_FLAG_SSSE3, "ssse3" },
00064 { AV_CPU_FLAG_ATOM, "atom" },
00065 { AV_CPU_FLAG_SSE4, "sse4.1" },
00066 { AV_CPU_FLAG_SSE42, "sse4.2" },
00067 { AV_CPU_FLAG_AVX, "avx" },
00068 { AV_CPU_FLAG_XOP, "xop" },
00069 { AV_CPU_FLAG_FMA4, "fma4" },
00070 { AV_CPU_FLAG_3DNOW, "3dnow" },
00071 { AV_CPU_FLAG_3DNOWEXT, "3dnowext" },
00072 #endif
00073 { 0 }
00074 };
00075
00076 int main(void)
00077 {
00078 int cpu_flags = av_get_cpu_flags();
00079 int i;
00080
00081 printf("cpu_flags = 0x%08X\n", cpu_flags);
00082 printf("cpu_flags =");
00083 for (i = 0; cpu_flag_tab[i].flag; i++)
00084 if (cpu_flags & cpu_flag_tab[i].flag)
00085 printf(" %s", cpu_flag_tab[i].name);
00086 printf("\n");
00087
00088 return 0;
00089 }
00090
00091 #endif