Mercurial > mplayer.hg
annotate libvo/aclib.c @ 28481:b78c8cb3959b
partial sync with obsolete section removal
author | diego |
---|---|
date | Tue, 10 Feb 2009 00:23:50 +0000 |
parents | b644796edd94 |
children | 62f0032e736a |
rev | line source |
---|---|
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
1 /* |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
2 * aclib - advanced C library ;) |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
3 * Functions which improve and expand the standard C library, see aclib_template.c. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
4 * This file only contains runtime CPU detection and config option stuff. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
5 * runtime CPU detection by Michael Niedermayer (michaelni@gmx.at) |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
6 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
7 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
8 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
9 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
10 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
11 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
12 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
13 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
14 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
17 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
18 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
19 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
22 */ |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28335
diff
changeset
|
23 |
12650
ac3fd2ff2561
Unify the config.h #include, use "config.h" instead of "../config.h"
diego
parents:
12492
diff
changeset
|
24 #include "config.h" |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
25 #include <stddef.h> |
21982
fa66a03e8920
Include string.h to make sure memcpy is not used without prototype
reimar
parents:
20577
diff
changeset
|
26 #include <string.h> |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13720
diff
changeset
|
27 #include "cpudetect.h" |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7072
diff
changeset
|
28 #include "fastmemcpy.h" |
12492
4b8417674f1c
fix crash due to fast_memcpy calling itself instead of libc memcpy
reimar
parents:
8127
diff
changeset
|
29 #undef memcpy |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
30 |
3077
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
31 #define BLOCK_SIZE 4096 |
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
32 #define CONFUSION_FACTOR 0 |
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
33 //Feel free to fine-tune the above 2, it might be possible to get some speedup with them :) |
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
34 |
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
35 //#define STATISTICS |
28290 | 36 #if ARCH_X86 |
3393 | 37 #define CAN_COMPILE_X86_ASM |
38 #endif | |
39 | |
40 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one | |
41 //Plain C versions | |
28292
d6001126678f
More #ifdef HAVE_MMX etc. missed by earlier search.
reimar
parents:
28290
diff
changeset
|
42 //#if !HAVE_MMX || defined (RUNTIME_CPUDETECT) |
3393 | 43 //#define COMPILE_C |
44 //#endif | |
45 | |
46 #ifdef CAN_COMPILE_X86_ASM | |
47 | |
28335 | 48 #if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT) |
3393 | 49 #define COMPILE_MMX |
50 #endif | |
51 | |
28290 | 52 #if (HAVE_MMX2 && !HAVE_SSE2) || defined (RUNTIME_CPUDETECT) |
3393 | 53 #define COMPILE_MMX2 |
54 #endif | |
55 | |
28335 | 56 #if (HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT) |
3393 | 57 #define COMPILE_3DNOW |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
58 #endif |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
59 |
28290 | 60 #if HAVE_SSE2 || defined (RUNTIME_CPUDETECT) |
5208 | 61 #define COMPILE_SSE |
62 #endif | |
63 | |
3393 | 64 #undef HAVE_MMX |
65 #undef HAVE_MMX2 | |
28335 | 66 #undef HAVE_AMD3DNOW |
5208 | 67 #undef HAVE_SSE |
68 #undef HAVE_SSE2 | |
28290 | 69 #define HAVE_MMX 0 |
70 #define HAVE_MMX2 0 | |
28335 | 71 #define HAVE_AMD3DNOW 0 |
28290 | 72 #define HAVE_SSE 0 |
73 #define HAVE_SSE2 0 | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
74 /* |
3393 | 75 #ifdef COMPILE_C |
76 #undef HAVE_MMX | |
77 #undef HAVE_MMX2 | |
28335 | 78 #undef HAVE_AMD3DNOW |
28290 | 79 #undef HAVE_SSE |
80 #undef HAVE_SSE2 | |
81 #define HAVE_MMX 0 | |
82 #define HAVE_MMX2 0 | |
28335 | 83 #define HAVE_AMD3DNOW 0 |
28290 | 84 #define HAVE_SSE 0 |
85 #define HAVE_SSE2 0 | |
3393 | 86 #define RENAME(a) a ## _C |
87 #include "aclib_template.c" | |
88 #endif | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
89 */ |
3393 | 90 //MMX versions |
91 #ifdef COMPILE_MMX | |
92 #undef RENAME | |
28290 | 93 #undef HAVE_MMX |
3393 | 94 #undef HAVE_MMX2 |
28335 | 95 #undef HAVE_AMD3DNOW |
5208 | 96 #undef HAVE_SSE |
97 #undef HAVE_SSE2 | |
28290 | 98 #define HAVE_MMX 1 |
99 #define HAVE_MMX2 0 | |
28335 | 100 #define HAVE_AMD3DNOW 0 |
28290 | 101 #define HAVE_SSE 0 |
102 #define HAVE_SSE2 0 | |
3393 | 103 #define RENAME(a) a ## _MMX |
104 #include "aclib_template.c" | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
105 #endif |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
106 |
3393 | 107 //MMX2 versions |
108 #ifdef COMPILE_MMX2 | |
109 #undef RENAME | |
28290 | 110 #undef HAVE_MMX |
111 #undef HAVE_MMX2 | |
28335 | 112 #undef HAVE_AMD3DNOW |
5208 | 113 #undef HAVE_SSE |
114 #undef HAVE_SSE2 | |
28290 | 115 #define HAVE_MMX 1 |
116 #define HAVE_MMX2 1 | |
28335 | 117 #define HAVE_AMD3DNOW 0 |
28290 | 118 #define HAVE_SSE 0 |
119 #define HAVE_SSE2 0 | |
3393 | 120 #define RENAME(a) a ## _MMX2 |
121 #include "aclib_template.c" | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
122 #endif |
3077
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
123 |
3393 | 124 //3DNOW versions |
125 #ifdef COMPILE_3DNOW | |
126 #undef RENAME | |
28290 | 127 #undef HAVE_MMX |
3393 | 128 #undef HAVE_MMX2 |
28335 | 129 #undef HAVE_AMD3DNOW |
5208 | 130 #undef HAVE_SSE |
131 #undef HAVE_SSE2 | |
28290 | 132 #define HAVE_MMX 1 |
133 #define HAVE_MMX2 0 | |
28335 | 134 #define HAVE_AMD3DNOW 1 |
28290 | 135 #define HAVE_SSE 0 |
136 #define HAVE_SSE2 0 | |
3393 | 137 #define RENAME(a) a ## _3DNow |
138 #include "aclib_template.c" | |
3077
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
139 #endif |
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
140 |
5208 | 141 //SSE versions (only used on SSE2 cpus) |
142 #ifdef COMPILE_SSE | |
143 #undef RENAME | |
28290 | 144 #undef HAVE_MMX |
145 #undef HAVE_MMX2 | |
28335 | 146 #undef HAVE_AMD3DNOW |
28290 | 147 #undef HAVE_SSE |
148 #undef HAVE_SSE2 | |
149 #define HAVE_MMX 1 | |
150 #define HAVE_MMX2 1 | |
28335 | 151 #define HAVE_AMD3DNOW 0 |
28290 | 152 #define HAVE_SSE 1 |
153 #define HAVE_SSE2 1 | |
5208 | 154 #define RENAME(a) a ## _SSE |
155 #include "aclib_template.c" | |
156 #endif | |
157 | |
3393 | 158 #endif // CAN_COMPILE_X86_ASM |
159 | |
3077
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
160 |
23523
273aa6124f66
avoid utter breakage on non-x86, patch from Chris Roccati <roccati@at@pobox.dot.com>
lu_zero
parents:
21982
diff
changeset
|
161 #undef fast_memcpy |
7072 | 162 void * fast_memcpy(void * to, const void * from, size_t len) |
3393 | 163 { |
164 #ifdef RUNTIME_CPUDETECT | |
165 #ifdef CAN_COMPILE_X86_ASM | |
166 // ordered per speed fasterst first | |
5208 | 167 if(gCpuCaps.hasSSE2) |
168 fast_memcpy_SSE(to, from, len); | |
169 else if(gCpuCaps.hasMMX2) | |
3393 | 170 fast_memcpy_MMX2(to, from, len); |
171 else if(gCpuCaps.has3DNow) | |
172 fast_memcpy_3DNow(to, from, len); | |
173 else if(gCpuCaps.hasMMX) | |
174 fast_memcpy_MMX(to, from, len); | |
175 else | |
176 #endif //CAN_COMPILE_X86_ASM | |
177 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
178 #else | |
28290 | 179 #if HAVE_SSE2 |
5208 | 180 fast_memcpy_SSE(to, from, len); |
28290 | 181 #elif HAVE_MMX2 |
3393 | 182 fast_memcpy_MMX2(to, from, len); |
28335 | 183 #elif HAVE_AMD3DNOW |
3393 | 184 fast_memcpy_3DNow(to, from, len); |
28290 | 185 #elif HAVE_MMX |
3393 | 186 fast_memcpy_MMX(to, from, len); |
187 #else | |
188 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
189 #endif |
3077
99f6db3255aa
10-20% faster fastmemcpy :) on my p3 at least but the algo is mostly from "amd athlon processor x86 code optimization guide" so it should be faster for amd chips too, but i fear it might be slower for mem->vram copies (someone should check that, i cant) ... there are 2 #defines to finetune it (BLOCK_SIZE & CONFUSION_FACTOR)
michael
parents:
1123
diff
changeset
|
190 |
3393 | 191 #endif //!RUNTIME_CPUDETECT |
5543
c75f75806af1
memcpy must return destination ptr patch by Adam <adam@cfar.umd.edu>
michael
parents:
5208
diff
changeset
|
192 return to; |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
193 } |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
194 |
8127
e7153e62a7f4
On non-x86 platforms, memcpy was re-implemented in mplayer and was called
jkeil
parents:
8123
diff
changeset
|
195 #undef mem2agpcpy |
7072 | 196 void * mem2agpcpy(void * to, const void * from, size_t len) |
4681 | 197 { |
198 #ifdef RUNTIME_CPUDETECT | |
199 #ifdef CAN_COMPILE_X86_ASM | |
200 // ordered per speed fasterst first | |
5208 | 201 if(gCpuCaps.hasSSE2) |
202 mem2agpcpy_SSE(to, from, len); | |
203 else if(gCpuCaps.hasMMX2) | |
4681 | 204 mem2agpcpy_MMX2(to, from, len); |
205 else if(gCpuCaps.has3DNow) | |
206 mem2agpcpy_3DNow(to, from, len); | |
207 else if(gCpuCaps.hasMMX) | |
208 mem2agpcpy_MMX(to, from, len); | |
209 else | |
210 #endif //CAN_COMPILE_X86_ASM | |
211 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
212 #else | |
28290 | 213 #if HAVE_SSE2 |
5208 | 214 mem2agpcpy_SSE(to, from, len); |
28290 | 215 #elif HAVE_MMX2 |
4681 | 216 mem2agpcpy_MMX2(to, from, len); |
28335 | 217 #elif HAVE_AMD3DNOW |
4681 | 218 mem2agpcpy_3DNow(to, from, len); |
28290 | 219 #elif HAVE_MMX |
4681 | 220 mem2agpcpy_MMX(to, from, len); |
221 #else | |
222 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
223 #endif | |
224 | |
225 #endif //!RUNTIME_CPUDETECT | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7072
diff
changeset
|
226 return to; |
4681 | 227 } |