Document lmin and lmax lavcopts; mpeg vrc_buf_size values
[mplayer/greg.git] / libvo / aclib.c
blob5959b7326aa5fe731c5001169a5bbb544290c270
1 #include "../config.h"
2 #ifdef USE_FASTMEMCPY
4 /*
5 aclib - advanced C library ;)
6 This file contains functions which improve and expand standard C-library
7 see aclib_template.c ... this file only contains runtime cpu detection and config options stuff
8 runtime cpu detection by michael niedermayer (michaelni@gmx.at) is under GPL
9 */
10 #include <stddef.h>
11 #include "../cpudetect.h"
12 #include "fastmemcpy.h"
14 #define BLOCK_SIZE 4096
15 #define CONFUSION_FACTOR 0
16 //Feel free to fine-tune the above 2, it might be possible to get some speedup with them :)
18 //#define STATISTICS
19 #ifdef ARCH_X86
20 #define CAN_COMPILE_X86_ASM
21 #endif
23 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
24 //Plain C versions
25 //#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT)
26 //#define COMPILE_C
27 //#endif
29 #ifdef CAN_COMPILE_X86_ASM
31 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
32 #define COMPILE_MMX
33 #endif
35 #if (defined (HAVE_MMX2) && !defined (HAVE_SSE2)) || defined (RUNTIME_CPUDETECT)
36 #define COMPILE_MMX2
37 #endif
39 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT)
40 #define COMPILE_3DNOW
41 #endif
43 #if defined (HAVE_SSE2) || defined (RUNTIME_CPUDETECT)
44 #define COMPILE_SSE
45 #endif
47 #undef HAVE_MMX
48 #undef HAVE_MMX2
49 #undef HAVE_3DNOW
50 #undef HAVE_SSE
51 #undef HAVE_SSE2
52 #undef ARCH_X86
54 #ifdef COMPILE_C
55 #undef HAVE_MMX
56 #undef HAVE_MMX2
57 #undef HAVE_3DNOW
58 #undef ARCH_X86
59 #define RENAME(a) a ## _C
60 #include "aclib_template.c"
61 #endif
63 //MMX versions
64 #ifdef COMPILE_MMX
65 #undef RENAME
66 #define HAVE_MMX
67 #undef HAVE_MMX2
68 #undef HAVE_3DNOW
69 #undef HAVE_SSE
70 #undef HAVE_SSE2
71 #define ARCH_X86
72 #define RENAME(a) a ## _MMX
73 #include "aclib_template.c"
74 #endif
76 //MMX2 versions
77 #ifdef COMPILE_MMX2
78 #undef RENAME
79 #define HAVE_MMX
80 #define HAVE_MMX2
81 #undef HAVE_3DNOW
82 #undef HAVE_SSE
83 #undef HAVE_SSE2
84 #define ARCH_X86
85 #define RENAME(a) a ## _MMX2
86 #include "aclib_template.c"
87 #endif
89 //3DNOW versions
90 #ifdef COMPILE_3DNOW
91 #undef RENAME
92 #define HAVE_MMX
93 #undef HAVE_MMX2
94 #define HAVE_3DNOW
95 #undef HAVE_SSE
96 #undef HAVE_SSE2
97 #define ARCH_X86
98 #define RENAME(a) a ## _3DNow
99 #include "aclib_template.c"
100 #endif
102 //SSE versions (only used on SSE2 cpus)
103 #ifdef COMPILE_SSE
104 #undef RENAME
105 #define HAVE_MMX
106 #define HAVE_MMX2
107 #undef HAVE_3DNOW
108 #define HAVE_SSE
109 #define HAVE_SSE2
110 #define ARCH_X86
111 #define RENAME(a) a ## _SSE
112 #include "aclib_template.c"
113 #endif
115 #endif // CAN_COMPILE_X86_ASM
118 void * fast_memcpy(void * to, const void * from, size_t len)
120 #ifdef RUNTIME_CPUDETECT
121 #ifdef CAN_COMPILE_X86_ASM
122 // ordered per speed fasterst first
123 if(gCpuCaps.hasSSE2)
124 fast_memcpy_SSE(to, from, len);
125 else if(gCpuCaps.hasMMX2)
126 fast_memcpy_MMX2(to, from, len);
127 else if(gCpuCaps.has3DNow)
128 fast_memcpy_3DNow(to, from, len);
129 else if(gCpuCaps.hasMMX)
130 fast_memcpy_MMX(to, from, len);
131 else
132 #endif //CAN_COMPILE_X86_ASM
133 memcpy(to, from, len); // prior to mmx we use the standart memcpy
134 #else
135 #ifdef HAVE_SSE2
136 fast_memcpy_SSE(to, from, len);
137 #elif defined (HAVE_MMX2)
138 fast_memcpy_MMX2(to, from, len);
139 #elif defined (HAVE_3DNOW)
140 fast_memcpy_3DNow(to, from, len);
141 #elif defined (HAVE_MMX)
142 fast_memcpy_MMX(to, from, len);
143 #else
144 memcpy(to, from, len); // prior to mmx we use the standart memcpy
145 #endif
147 #endif //!RUNTIME_CPUDETECT
148 return to;
151 #undef mem2agpcpy
152 void * mem2agpcpy(void * to, const void * from, size_t len)
154 #ifdef RUNTIME_CPUDETECT
155 #ifdef CAN_COMPILE_X86_ASM
156 // ordered per speed fasterst first
157 if(gCpuCaps.hasSSE2)
158 mem2agpcpy_SSE(to, from, len);
159 else if(gCpuCaps.hasMMX2)
160 mem2agpcpy_MMX2(to, from, len);
161 else if(gCpuCaps.has3DNow)
162 mem2agpcpy_3DNow(to, from, len);
163 else if(gCpuCaps.hasMMX)
164 mem2agpcpy_MMX(to, from, len);
165 else
166 #endif //CAN_COMPILE_X86_ASM
167 memcpy(to, from, len); // prior to mmx we use the standart memcpy
168 #else
169 #ifdef HAVE_SSE2
170 mem2agpcpy_SSE(to, from, len);
171 #elif defined (HAVE_MMX2)
172 mem2agpcpy_MMX2(to, from, len);
173 #elif defined (HAVE_3DNOW)
174 mem2agpcpy_3DNow(to, from, len);
175 #elif defined (HAVE_MMX)
176 mem2agpcpy_MMX(to, from, len);
177 #else
178 memcpy(to, from, len); // prior to mmx we use the standart memcpy
179 #endif
181 #endif //!RUNTIME_CPUDETECT
182 return to;
185 #endif /* use fastmemcpy */