Commit | Line | Data |
---|---|---|
72b9787e JB |
1 | /***************************************************************************** |
2 | * Copyright (C) 2013 x265 project | |
3 | * | |
4 | * Authors: Steve Borho <steve@borho.org> | |
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 02111, USA. | |
19 | * | |
20 | * This program is also available under a commercial proprietary license. | |
21 | * For more information, contact us at license @ x265.com. | |
22 | *****************************************************************************/ | |
23 | ||
24 | #include "primitives.h" | |
25 | #include "x265.h" | |
26 | ||
27 | /* The #if logic here must match the file lists in CMakeLists.txt */ | |
28 | #if X265_ARCH_X86 | |
29 | #if defined(__INTEL_COMPILER) | |
30 | #define HAVE_SSE3 | |
31 | #define HAVE_SSSE3 | |
32 | #define HAVE_SSE4 | |
33 | #define HAVE_AVX2 | |
34 | #elif defined(__GNUC__) | |
35 | #if __clang__ || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3) | |
36 | #define HAVE_SSE3 | |
37 | #define HAVE_SSSE3 | |
38 | #define HAVE_SSE4 | |
39 | #endif | |
40 | #if __clang__ || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 7) | |
41 | #define HAVE_AVX2 | |
42 | #endif | |
43 | #elif defined(_MSC_VER) | |
44 | #define HAVE_SSE3 | |
45 | #define HAVE_SSSE3 | |
46 | #define HAVE_SSE4 | |
47 | #if _MSC_VER >= 1700 // VC11 | |
48 | #define HAVE_AVX2 | |
49 | #endif | |
50 | #endif // compiler checks | |
51 | #endif // if X265_ARCH_X86 | |
52 | ||
53 | namespace x265 { | |
54 | // private x265 namespace | |
55 | ||
56 | void Setup_Vec_DCTPrimitives_sse3(EncoderPrimitives&); | |
57 | void Setup_Vec_DCTPrimitives_ssse3(EncoderPrimitives&); | |
58 | void Setup_Vec_DCTPrimitives_sse41(EncoderPrimitives&); | |
59 | ||
60 | /* Use primitives for the best available vector architecture */ | |
61 | void Setup_Instrinsic_Primitives(EncoderPrimitives &p, int cpuMask) | |
62 | { | |
63 | #ifdef HAVE_SSE3 | |
64 | if (cpuMask & X265_CPU_SSE3) | |
65 | { | |
66 | Setup_Vec_DCTPrimitives_sse3(p); | |
67 | } | |
68 | #endif | |
69 | #ifdef HAVE_SSSE3 | |
70 | if (cpuMask & X265_CPU_SSSE3) | |
71 | { | |
72 | Setup_Vec_DCTPrimitives_ssse3(p); | |
73 | } | |
74 | #endif | |
75 | #ifdef HAVE_SSE4 | |
76 | if (cpuMask & X265_CPU_SSE4) | |
77 | { | |
78 | Setup_Vec_DCTPrimitives_sse41(p); | |
79 | } | |
80 | #endif | |
81 | (void)p; | |
82 | (void)cpuMask; | |
83 | } | |
84 | } |