• 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 FFmpeg.
00003  *
00004  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 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 int main(void)
00048 {
00049     int cpu_flags = av_get_cpu_flags();
00050 
00051     printf("cpu_flags = 0x%08X\n", cpu_flags);
00052     printf("cpu_flags = %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
00053 #if   ARCH_ARM
00054            cpu_flags & AV_CPU_FLAG_IWMMXT   ? "IWMMXT "     : "",
00055 #elif ARCH_PPC
00056            cpu_flags & AV_CPU_FLAG_ALTIVEC  ? "ALTIVEC "    : "",
00057 #elif ARCH_X86
00058            cpu_flags & AV_CPU_FLAG_MMX      ? "MMX "        : "",
00059            cpu_flags & AV_CPU_FLAG_MMX2     ? "MMX2 "       : "",
00060            cpu_flags & AV_CPU_FLAG_SSE      ? "SSE "        : "",
00061            cpu_flags & AV_CPU_FLAG_SSE2     ? "SSE2 "       : "",
00062            cpu_flags & AV_CPU_FLAG_SSE2SLOW ? "SSE2(slow) " : "",
00063            cpu_flags & AV_CPU_FLAG_SSE3     ? "SSE3 "       : "",
00064            cpu_flags & AV_CPU_FLAG_SSE3SLOW ? "SSE3(slow) " : "",
00065            cpu_flags & AV_CPU_FLAG_SSSE3    ? "SSSE3 "      : "",
00066            cpu_flags & AV_CPU_FLAG_ATOM     ? "Atom "       : "",
00067            cpu_flags & AV_CPU_FLAG_SSE4     ? "SSE4.1 "     : "",
00068            cpu_flags & AV_CPU_FLAG_SSE42    ? "SSE4.2 "     : "",
00069            cpu_flags & AV_CPU_FLAG_AVX      ? "AVX "        : "",
00070            cpu_flags & AV_CPU_FLAG_3DNOW    ? "3DNow "      : "",
00071            cpu_flags & AV_CPU_FLAG_3DNOWEXT ? "3DNowExt "   : "");
00072 #endif
00073     return 0;
00074 }
00075 
00076 #endif

Generated on Wed Apr 11 2012 07:31:37 for FFmpeg by  doxygen 1.7.1