Mercurial > mplayer.hg
annotate libvo/aclib.c @ 29439:02dec439f717
100l, av_fifo_generic_read does not return anything useful, so ignore its
return value and return len instead.
author | reimar |
---|---|
date | Sat, 08 Aug 2009 08:17:35 +0000 |
parents | 06540eb5ef6a |
children | 807fce7a4bb3 |
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 |
3393 | 36 |
37 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one | |
38 //Plain C versions | |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
39 //#if !HAVE_MMX || CONFIG_RUNTIME_CPUDETECT |
3393 | 40 //#define COMPILE_C |
41 //#endif | |
42 | |
28921
62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
diego
parents:
28448
diff
changeset
|
43 #if ARCH_X86 |
3393 | 44 |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
45 #if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT |
3393 | 46 #define COMPILE_MMX |
47 #endif | |
48 | |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
49 #if (HAVE_MMX2 && !HAVE_SSE2) || CONFIG_RUNTIME_CPUDETECT |
3393 | 50 #define COMPILE_MMX2 |
51 #endif | |
52 | |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
53 #if (HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT |
3393 | 54 #define COMPILE_3DNOW |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
55 #endif |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
56 |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
57 #if HAVE_SSE2 || CONFIG_RUNTIME_CPUDETECT |
5208 | 58 #define COMPILE_SSE |
59 #endif | |
60 | |
3393 | 61 #undef HAVE_MMX |
62 #undef HAVE_MMX2 | |
28335 | 63 #undef HAVE_AMD3DNOW |
5208 | 64 #undef HAVE_SSE |
65 #undef HAVE_SSE2 | |
28290 | 66 #define HAVE_MMX 0 |
67 #define HAVE_MMX2 0 | |
28335 | 68 #define HAVE_AMD3DNOW 0 |
28290 | 69 #define HAVE_SSE 0 |
70 #define HAVE_SSE2 0 | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
71 /* |
3393 | 72 #ifdef COMPILE_C |
73 #undef HAVE_MMX | |
74 #undef HAVE_MMX2 | |
28335 | 75 #undef HAVE_AMD3DNOW |
28290 | 76 #undef HAVE_SSE |
77 #undef HAVE_SSE2 | |
78 #define HAVE_MMX 0 | |
79 #define HAVE_MMX2 0 | |
28335 | 80 #define HAVE_AMD3DNOW 0 |
28290 | 81 #define HAVE_SSE 0 |
82 #define HAVE_SSE2 0 | |
3393 | 83 #define RENAME(a) a ## _C |
84 #include "aclib_template.c" | |
85 #endif | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
86 */ |
3393 | 87 //MMX versions |
88 #ifdef COMPILE_MMX | |
89 #undef RENAME | |
28290 | 90 #undef HAVE_MMX |
3393 | 91 #undef HAVE_MMX2 |
28335 | 92 #undef HAVE_AMD3DNOW |
5208 | 93 #undef HAVE_SSE |
94 #undef HAVE_SSE2 | |
28290 | 95 #define HAVE_MMX 1 |
96 #define HAVE_MMX2 0 | |
28335 | 97 #define HAVE_AMD3DNOW 0 |
28290 | 98 #define HAVE_SSE 0 |
99 #define HAVE_SSE2 0 | |
3393 | 100 #define RENAME(a) a ## _MMX |
101 #include "aclib_template.c" | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
102 #endif |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
103 |
3393 | 104 //MMX2 versions |
105 #ifdef COMPILE_MMX2 | |
106 #undef RENAME | |
28290 | 107 #undef HAVE_MMX |
108 #undef HAVE_MMX2 | |
28335 | 109 #undef HAVE_AMD3DNOW |
5208 | 110 #undef HAVE_SSE |
111 #undef HAVE_SSE2 | |
28290 | 112 #define HAVE_MMX 1 |
113 #define HAVE_MMX2 1 | |
28335 | 114 #define HAVE_AMD3DNOW 0 |
28290 | 115 #define HAVE_SSE 0 |
116 #define HAVE_SSE2 0 | |
3393 | 117 #define RENAME(a) a ## _MMX2 |
118 #include "aclib_template.c" | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
119 #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
|
120 |
3393 | 121 //3DNOW versions |
122 #ifdef COMPILE_3DNOW | |
123 #undef RENAME | |
28290 | 124 #undef HAVE_MMX |
3393 | 125 #undef HAVE_MMX2 |
28335 | 126 #undef HAVE_AMD3DNOW |
5208 | 127 #undef HAVE_SSE |
128 #undef HAVE_SSE2 | |
28290 | 129 #define HAVE_MMX 1 |
130 #define HAVE_MMX2 0 | |
28335 | 131 #define HAVE_AMD3DNOW 1 |
28290 | 132 #define HAVE_SSE 0 |
133 #define HAVE_SSE2 0 | |
3393 | 134 #define RENAME(a) a ## _3DNow |
135 #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
|
136 #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
|
137 |
5208 | 138 //SSE versions (only used on SSE2 cpus) |
139 #ifdef COMPILE_SSE | |
140 #undef RENAME | |
28290 | 141 #undef HAVE_MMX |
142 #undef HAVE_MMX2 | |
28335 | 143 #undef HAVE_AMD3DNOW |
28290 | 144 #undef HAVE_SSE |
145 #undef HAVE_SSE2 | |
146 #define HAVE_MMX 1 | |
147 #define HAVE_MMX2 1 | |
28335 | 148 #define HAVE_AMD3DNOW 0 |
28290 | 149 #define HAVE_SSE 1 |
150 #define HAVE_SSE2 1 | |
5208 | 151 #define RENAME(a) a ## _SSE |
152 #include "aclib_template.c" | |
153 #endif | |
154 | |
28921
62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
diego
parents:
28448
diff
changeset
|
155 #endif /* ARCH_X86 */ |
3393 | 156 |
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
|
157 |
23523
273aa6124f66
avoid utter breakage on non-x86, patch from Chris Roccati <roccati@at@pobox.dot.com>
lu_zero
parents:
21982
diff
changeset
|
158 #undef fast_memcpy |
7072 | 159 void * fast_memcpy(void * to, const void * from, size_t len) |
3393 | 160 { |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
161 #if CONFIG_RUNTIME_CPUDETECT |
28921
62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
diego
parents:
28448
diff
changeset
|
162 #if ARCH_X86 |
3393 | 163 // ordered per speed fasterst first |
5208 | 164 if(gCpuCaps.hasSSE2) |
165 fast_memcpy_SSE(to, from, len); | |
166 else if(gCpuCaps.hasMMX2) | |
3393 | 167 fast_memcpy_MMX2(to, from, len); |
168 else if(gCpuCaps.has3DNow) | |
169 fast_memcpy_3DNow(to, from, len); | |
170 else if(gCpuCaps.hasMMX) | |
171 fast_memcpy_MMX(to, from, len); | |
172 else | |
28921
62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
diego
parents:
28448
diff
changeset
|
173 #endif |
3393 | 174 memcpy(to, from, len); // prior to mmx we use the standart memcpy |
175 #else | |
28290 | 176 #if HAVE_SSE2 |
5208 | 177 fast_memcpy_SSE(to, from, len); |
28290 | 178 #elif HAVE_MMX2 |
3393 | 179 fast_memcpy_MMX2(to, from, len); |
28335 | 180 #elif HAVE_AMD3DNOW |
3393 | 181 fast_memcpy_3DNow(to, from, len); |
28290 | 182 #elif HAVE_MMX |
3393 | 183 fast_memcpy_MMX(to, from, len); |
184 #else | |
185 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
|
186 #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
|
187 |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
188 #endif //!CONFIG_RUNTIME_CPUDETECT |
5543
c75f75806af1
memcpy must return destination ptr patch by Adam <adam@cfar.umd.edu>
michael
parents:
5208
diff
changeset
|
189 return to; |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
190 } |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
191 |
8127
e7153e62a7f4
On non-x86 platforms, memcpy was re-implemented in mplayer and was called
jkeil
parents:
8123
diff
changeset
|
192 #undef mem2agpcpy |
7072 | 193 void * mem2agpcpy(void * to, const void * from, size_t len) |
4681 | 194 { |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
195 #if CONFIG_RUNTIME_CPUDETECT |
28921
62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
diego
parents:
28448
diff
changeset
|
196 #if ARCH_X86 |
4681 | 197 // ordered per speed fasterst first |
5208 | 198 if(gCpuCaps.hasSSE2) |
199 mem2agpcpy_SSE(to, from, len); | |
200 else if(gCpuCaps.hasMMX2) | |
4681 | 201 mem2agpcpy_MMX2(to, from, len); |
202 else if(gCpuCaps.has3DNow) | |
203 mem2agpcpy_3DNow(to, from, len); | |
204 else if(gCpuCaps.hasMMX) | |
205 mem2agpcpy_MMX(to, from, len); | |
206 else | |
28921
62f0032e736a
Get rid of pointless preprocessor condition indirection and use ARCH_X86
diego
parents:
28448
diff
changeset
|
207 #endif |
4681 | 208 memcpy(to, from, len); // prior to mmx we use the standart memcpy |
209 #else | |
28290 | 210 #if HAVE_SSE2 |
5208 | 211 mem2agpcpy_SSE(to, from, len); |
28290 | 212 #elif HAVE_MMX2 |
4681 | 213 mem2agpcpy_MMX2(to, from, len); |
28335 | 214 #elif HAVE_AMD3DNOW |
4681 | 215 mem2agpcpy_3DNow(to, from, len); |
28290 | 216 #elif HAVE_MMX |
4681 | 217 mem2agpcpy_MMX(to, from, len); |
218 #else | |
219 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
220 #endif | |
221 | |
29114
06540eb5ef6a
Rename RUNTIME_CPUDETECT to CONFIG_RUNTIME_CPUDETECT and always define it.
ramiro
parents:
28921
diff
changeset
|
222 #endif //!CONFIG_RUNTIME_CPUDETECT |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7072
diff
changeset
|
223 return to; |
4681 | 224 } |