]> git.sesse.net Git - vlc/blob - modules/codec/avcodec/cpu.c
5efbce7f03f23605668589a95fae49ca8c73ada4
[vlc] / modules / codec / avcodec / cpu.c
1 /*****************************************************************************
2  * cpu.c: CPU capabilities for libavcodec
3  *****************************************************************************
4  * Copyright (C) 1999-2012 the VideoLAN team
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
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 General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
24
25 #include <vlc_common.h>
26 #include <vlc_cpu.h>
27
28 #define HAVE_MMX 1
29 #include <libavcodec/avcodec.h>
30 #include "avcommon.h"
31
32 /**
33  * Maps CPU capabilities computed by VLC to libav DSP mask.
34  */
35 unsigned GetVlcDspMask( void )
36 {
37     unsigned mask = 0;
38
39 #if defined (__i386__) || defined (__x86_64__)
40     if( !vlc_CPU_MMX() )
41         mask |= AV_CPU_FLAG_MMX;
42     if( !vlc_CPU_MMXEXT() )
43         mask |= AV_CPU_FLAG_MMX2;
44     if( !vlc_CPU_3dNOW() )
45         mask |= AV_CPU_FLAG_3DNOW;
46     if( !vlc_CPU_SSE() )
47         mask |= AV_CPU_FLAG_SSE;
48     if( !vlc_CPU_SSE2() )
49         mask |= AV_CPU_FLAG_SSE2;
50 # ifdef AV_CPU_FLAG_SSE3
51     if( !vlc_CPU_SSE3() )
52         mask |= AV_CPU_FLAG_SSE3;
53 # endif
54 # ifdef AV_CPU_FLAG_SSSE3
55     if( !vlc_CPU_SSSE3() )
56         mask |= AV_CPU_FLAG_SSSE3;
57 # endif
58 # ifdef AV_CPU_FLAG_SSE4
59     if( !vlc_CPU_SSE4_1() )
60         mask |= AV_CPU_FLAG_SSE4;
61 # endif
62 # ifdef AV_CPU_FLAG_SSE42
63     if( !vlc_CPU_SSE4_2() )
64         mask |= AV_CPU_FLAG_SSE42;
65 # endif
66 # ifdef AV_CPU_FLAG_AVX
67     if( !vlc_CPU_AVX() )
68         mask |= AV_CPU_FLAG_AVX;
69 # endif
70 # ifdef AV_CPU_FLAG_XOP
71     if( !vlc_CPU_XOP() )
72         mask |= AV_CPU_FLAG_XOP;
73 # endif
74 # ifdef AV_CPU_FLAG_FMA4
75     if( !vlc_CPU_FMA4() )
76         mask |= AV_CPU_FLAG_FMA4;
77 # endif
78 #endif
79
80 #if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
81     if( !vlc_CPU_ALTIVEC() )
82         mask |= AV_CPU_FLAG_ALTIVEC;
83 #endif
84
85 #if defined ( __arm__)
86 #if LIBAVUTIL_VERSION_INT >= ((51<<16)+(29<<8)+0)
87     if( !vlc_CPU_ARM_NEON() )
88         mask |= AV_CPU_FLAG_NEON;
89 #endif
90 #endif
91
92     return mask;
93 }