1 /*****************************************************************************
2 * cpu.c: CPU capabilities for libavcodec
3 *****************************************************************************
4 * Copyright (C) 1999-2012 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
25 #include <vlc_common.h>
29 #include <libavcodec/avcodec.h>
33 * Maps CPU capabilities computed by VLC to libav DSP mask.
35 unsigned GetVlcDspMask( void )
39 #if defined (__i386__) || defined (__x86_64__)
41 mask |= AV_CPU_FLAG_MMX;
42 if( !vlc_CPU_MMXEXT() )
43 mask |= AV_CPU_FLAG_MMXEXT;
44 if( !vlc_CPU_3dNOW() )
45 mask |= AV_CPU_FLAG_3DNOW;
47 mask |= AV_CPU_FLAG_SSE;
49 mask |= AV_CPU_FLAG_SSE2;
50 # ifdef AV_CPU_FLAG_SSE3
52 mask |= AV_CPU_FLAG_SSE3;
54 # ifdef AV_CPU_FLAG_SSSE3
55 if( !vlc_CPU_SSSE3() )
56 mask |= AV_CPU_FLAG_SSSE3;
58 # ifdef AV_CPU_FLAG_SSE4
59 if( !vlc_CPU_SSE4_1() )
60 mask |= AV_CPU_FLAG_SSE4;
62 # ifdef AV_CPU_FLAG_SSE42
63 if( !vlc_CPU_SSE4_2() )
64 mask |= AV_CPU_FLAG_SSE42;
66 # ifdef AV_CPU_FLAG_AVX
68 mask |= AV_CPU_FLAG_AVX;
70 # ifdef AV_CPU_FLAG_XOP
72 mask |= AV_CPU_FLAG_XOP;
74 # ifdef AV_CPU_FLAG_FMA4
76 mask |= AV_CPU_FLAG_FMA4;
80 #if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
81 if( !vlc_CPU_ALTIVEC() )
82 mask |= AV_CPU_FLAG_ALTIVEC;
85 #if defined ( __arm__)
86 #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 29, 0)
87 if( !vlc_CPU_ARM_NEON() )
88 mask |= AV_CPU_FLAG_NEON;