2 * aclib - advanced C library ;)
3 * Functions which improve and expand the standard C library, see aclib_template.c.
4 * This file only contains runtime CPU detection and config option stuff.
5 * runtime CPU detection by Michael Niedermayer (michaelni@gmx.at)
7 * This file is part of MPlayer.
9 * MPlayer is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * MPlayer is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "cpudetect.h"
29 #include "fastmemcpy.h"
30 #include "ffmpeg_files/x86_cpu.h"
33 #define BLOCK_SIZE 4096
34 #define CONFUSION_FACTOR 0
35 //Feel free to fine-tune the above 2, it might be possible to get some speedup with them :)
39 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
41 //#if !HAVE_MMX || CONFIG_RUNTIME_CPUDETECT
47 #if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT
51 #if (HAVE_MMX2 && !HAVE_SSE2) || CONFIG_RUNTIME_CPUDETECT
55 #if (HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT
59 #if HAVE_SSE2 || CONFIG_RUNTIME_CPUDETECT
70 #define HAVE_AMD3DNOW 0
82 #define HAVE_AMD3DNOW 0
85 #define RENAME(a) a ## _C
86 #include "aclib_template.c"
99 #define HAVE_AMD3DNOW 0
102 #define RENAME(a) a ## _MMX
103 #include "aclib_template.c"
116 #define HAVE_AMD3DNOW 0
119 #define RENAME(a) a ## _MMX2
120 #include "aclib_template.c"
133 #define HAVE_AMD3DNOW 1
136 #define RENAME(a) a ## _3DNow
137 #include "aclib_template.c"
140 //SSE versions (only used on SSE2 cpus)
150 #define HAVE_AMD3DNOW 0
153 #define RENAME(a) a ## _SSE
154 #include "aclib_template.c"
157 #endif /* ARCH_X86 */
161 void * fast_memcpy(void * to
, const void * from
, size_t len
)
163 #if CONFIG_RUNTIME_CPUDETECT
165 // ordered per speed fasterst first
167 fast_memcpy_SSE(to
, from
, len
);
168 else if(gCpuCaps
.hasMMX2
)
169 fast_memcpy_MMX2(to
, from
, len
);
170 else if(gCpuCaps
.has3DNow
)
171 fast_memcpy_3DNow(to
, from
, len
);
172 else if(gCpuCaps
.hasMMX
)
173 fast_memcpy_MMX(to
, from
, len
);
176 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
179 fast_memcpy_SSE(to
, from
, len
);
181 fast_memcpy_MMX2(to
, from
, len
);
183 fast_memcpy_3DNow(to
, from
, len
);
185 fast_memcpy_MMX(to
, from
, len
);
187 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
190 #endif //!CONFIG_RUNTIME_CPUDETECT
195 void * mem2agpcpy(void * to
, const void * from
, size_t len
)
197 #if CONFIG_RUNTIME_CPUDETECT
199 // ordered per speed fasterst first
201 mem2agpcpy_SSE(to
, from
, len
);
202 else if(gCpuCaps
.hasMMX2
)
203 mem2agpcpy_MMX2(to
, from
, len
);
204 else if(gCpuCaps
.has3DNow
)
205 mem2agpcpy_3DNow(to
, from
, len
);
206 else if(gCpuCaps
.hasMMX
)
207 mem2agpcpy_MMX(to
, from
, len
);
210 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
213 mem2agpcpy_SSE(to
, from
, len
);
215 mem2agpcpy_MMX2(to
, from
, len
);
217 mem2agpcpy_3DNow(to
, from
, len
);
219 mem2agpcpy_MMX(to
, from
, len
);
221 memcpy(to
, from
, len
); // prior to mmx we use the standart memcpy
224 #endif //!CONFIG_RUNTIME_CPUDETECT