• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavutil/cpu.c

Go to the documentation of this file.
00001 /*
00002  * This file is part of Libav.
00003  *
00004  * Libav is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * Libav is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with Libav; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00017  */
00018 
00019 #include "cpu.h"
00020 #include "config.h"
00021 
00022 int av_get_cpu_flags(void)
00023 {
00024     static int flags, checked;
00025 
00026     if (checked)
00027         return flags;
00028 
00029     if (ARCH_ARM) flags = ff_get_cpu_flags_arm();
00030     if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
00031     if (ARCH_X86) flags = ff_get_cpu_flags_x86();
00032 
00033     checked = 1;
00034     return flags;
00035 }
00036 
00037 #ifdef TEST
00038 
00039 #undef printf
00040 #include <stdio.h>
00041 
00042 static const struct {
00043     int flag;
00044     const char *name;
00045 } cpu_flag_tab[] = {
00046 #if   ARCH_ARM
00047     { AV_CPU_FLAG_IWMMXT,    "iwmmxt"     },
00048 #elif ARCH_PPC
00049     { AV_CPU_FLAG_ALTIVEC,   "altivec"    },
00050 #elif ARCH_X86
00051     { AV_CPU_FLAG_MMX,       "mmx"        },
00052     { AV_CPU_FLAG_MMX2,      "mmx2"       },
00053     { AV_CPU_FLAG_SSE,       "sse"        },
00054     { AV_CPU_FLAG_SSE2,      "sse2"       },
00055     { AV_CPU_FLAG_SSE2SLOW,  "sse2(slow)" },
00056     { AV_CPU_FLAG_SSE3,      "sse3"       },
00057     { AV_CPU_FLAG_SSE3SLOW,  "sse3(slow)" },
00058     { AV_CPU_FLAG_SSSE3,     "ssse3"      },
00059     { AV_CPU_FLAG_ATOM,      "atom"       },
00060     { AV_CPU_FLAG_SSE4,      "sse4.1"     },
00061     { AV_CPU_FLAG_SSE42,     "sse4.2"     },
00062     { AV_CPU_FLAG_AVX,       "avx"        },
00063     { AV_CPU_FLAG_XOP,       "xop"        },
00064     { AV_CPU_FLAG_FMA4,      "fma4"       },
00065     { AV_CPU_FLAG_3DNOW,     "3dnow"      },
00066     { AV_CPU_FLAG_3DNOWEXT,  "3dnowext"   },
00067 #endif
00068     { 0 }
00069 };
00070 
00071 int main(void)
00072 {
00073     int cpu_flags = av_get_cpu_flags();
00074     int i;
00075 
00076     printf("cpu_flags = 0x%08X\n", cpu_flags);
00077     printf("cpu_flags =");
00078     for (i = 0; cpu_flag_tab[i].flag; i++)
00079         if (cpu_flags & cpu_flag_tab[i].flag)
00080             printf(" %s", cpu_flag_tab[i].name);
00081     printf("\n");
00082 
00083     return 0;
00084 }
00085 
00086 #endif
Generated on Thu Jan 24 2013 17:08:56 for Libav by doxygen 1.7.1