Mercurial > mplayer.hg
annotate libvo/aclib.c @ 13593:e2dca00374f2
add new control message, that is send after end of stream, to flush all remaining frames in the video system
required by xvid4 encoder.
author | iive |
---|---|
date | Sat, 09 Oct 2004 13:07:18 +0000 |
parents | ac3fd2ff2561 |
children | 821f464b4d90 |
rev | line source |
---|---|
12650
ac3fd2ff2561
Unify the config.h #include, use "config.h" instead of "../config.h"
diego
parents:
12492
diff
changeset
|
1 #include "config.h" |
3393 | 2 #ifdef USE_FASTMEMCPY |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
3 |
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
|
4 /* |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
5 aclib - advanced C library ;) |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
6 This file contains functions which improve and expand standard C-library |
3393 | 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 | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
9 */ |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
10 #include <stddef.h> |
3393 | 11 #include "../cpudetect.h" |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7072
diff
changeset
|
12 #include "fastmemcpy.h" |
12492
4b8417674f1c
fix crash due to fast_memcpy calling itself instead of libc memcpy
reimar
parents:
8127
diff
changeset
|
13 #undef memcpy |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
14 |
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
|
15 #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
|
16 #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
|
17 //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
|
18 |
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
|
19 //#define STATISTICS |
3393 | 20 #ifdef ARCH_X86 |
21 #define CAN_COMPILE_X86_ASM | |
22 #endif | |
23 | |
24 //Note: we have MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one | |
25 //Plain C versions | |
26 //#if !defined (HAVE_MMX) || defined (RUNTIME_CPUDETECT) | |
27 //#define COMPILE_C | |
28 //#endif | |
29 | |
30 #ifdef CAN_COMPILE_X86_ASM | |
31 | |
32 #if (defined (HAVE_MMX) && !defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) | |
33 #define COMPILE_MMX | |
34 #endif | |
35 | |
5208 | 36 #if (defined (HAVE_MMX2) && !defined (HAVE_SSE2)) || defined (RUNTIME_CPUDETECT) |
3393 | 37 #define COMPILE_MMX2 |
38 #endif | |
39 | |
40 #if (defined (HAVE_3DNOW) && !defined (HAVE_MMX2)) || defined (RUNTIME_CPUDETECT) | |
41 #define COMPILE_3DNOW | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
42 #endif |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
43 |
5208 | 44 #if defined (HAVE_SSE2) || defined (RUNTIME_CPUDETECT) |
45 #define COMPILE_SSE | |
46 #endif | |
47 | |
3393 | 48 #undef HAVE_MMX |
49 #undef HAVE_MMX2 | |
50 #undef HAVE_3DNOW | |
5208 | 51 #undef HAVE_SSE |
52 #undef HAVE_SSE2 | |
3393 | 53 #undef ARCH_X86 |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
54 /* |
3393 | 55 #ifdef COMPILE_C |
56 #undef HAVE_MMX | |
57 #undef HAVE_MMX2 | |
58 #undef HAVE_3DNOW | |
59 #undef ARCH_X86 | |
60 #define RENAME(a) a ## _C | |
61 #include "aclib_template.c" | |
62 #endif | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
63 */ |
3393 | 64 //MMX versions |
65 #ifdef COMPILE_MMX | |
66 #undef RENAME | |
67 #define HAVE_MMX | |
68 #undef HAVE_MMX2 | |
69 #undef HAVE_3DNOW | |
5208 | 70 #undef HAVE_SSE |
71 #undef HAVE_SSE2 | |
3393 | 72 #define ARCH_X86 |
73 #define RENAME(a) a ## _MMX | |
74 #include "aclib_template.c" | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
75 #endif |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
76 |
3393 | 77 //MMX2 versions |
78 #ifdef COMPILE_MMX2 | |
79 #undef RENAME | |
80 #define HAVE_MMX | |
81 #define HAVE_MMX2 | |
82 #undef HAVE_3DNOW | |
5208 | 83 #undef HAVE_SSE |
84 #undef HAVE_SSE2 | |
3393 | 85 #define ARCH_X86 |
86 #define RENAME(a) a ## _MMX2 | |
87 #include "aclib_template.c" | |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
88 #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
|
89 |
3393 | 90 //3DNOW versions |
91 #ifdef COMPILE_3DNOW | |
92 #undef RENAME | |
93 #define HAVE_MMX | |
94 #undef HAVE_MMX2 | |
95 #define HAVE_3DNOW | |
5208 | 96 #undef HAVE_SSE |
97 #undef HAVE_SSE2 | |
3393 | 98 #define ARCH_X86 |
99 #define RENAME(a) a ## _3DNow | |
100 #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
|
101 #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
|
102 |
5208 | 103 //SSE versions (only used on SSE2 cpus) |
104 #ifdef COMPILE_SSE | |
105 #undef RENAME | |
106 #define HAVE_MMX | |
107 #define HAVE_MMX2 | |
108 #undef HAVE_3DNOW | |
109 #define HAVE_SSE | |
110 #define HAVE_SSE2 | |
111 #define ARCH_X86 | |
112 #define RENAME(a) a ## _SSE | |
113 #include "aclib_template.c" | |
114 #endif | |
115 | |
3393 | 116 #endif // CAN_COMPILE_X86_ASM |
117 | |
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
|
118 |
7072 | 119 void * fast_memcpy(void * to, const void * from, size_t len) |
3393 | 120 { |
121 #ifdef RUNTIME_CPUDETECT | |
122 #ifdef CAN_COMPILE_X86_ASM | |
123 // ordered per speed fasterst first | |
5208 | 124 if(gCpuCaps.hasSSE2) |
125 fast_memcpy_SSE(to, from, len); | |
126 else if(gCpuCaps.hasMMX2) | |
3393 | 127 fast_memcpy_MMX2(to, from, len); |
128 else if(gCpuCaps.has3DNow) | |
129 fast_memcpy_3DNow(to, from, len); | |
130 else if(gCpuCaps.hasMMX) | |
131 fast_memcpy_MMX(to, from, len); | |
132 else | |
133 #endif //CAN_COMPILE_X86_ASM | |
134 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
135 #else | |
5208 | 136 #ifdef HAVE_SSE2 |
137 fast_memcpy_SSE(to, from, len); | |
138 #elif defined (HAVE_MMX2) | |
3393 | 139 fast_memcpy_MMX2(to, from, len); |
140 #elif defined (HAVE_3DNOW) | |
141 fast_memcpy_3DNow(to, from, len); | |
142 #elif defined (HAVE_MMX) | |
143 fast_memcpy_MMX(to, from, len); | |
144 #else | |
145 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
|
146 #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
|
147 |
3393 | 148 #endif //!RUNTIME_CPUDETECT |
5543
c75f75806af1
memcpy must return destination ptr patch by Adam <adam@cfar.umd.edu>
michael
parents:
5208
diff
changeset
|
149 return to; |
698
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
150 } |
f0fbf1a9bf31
Moving fast_memcpy to separate file (Size optimization)
nickols_k
parents:
diff
changeset
|
151 |
8127
e7153e62a7f4
On non-x86 platforms, memcpy was re-implemented in mplayer and was called
jkeil
parents:
8123
diff
changeset
|
152 #undef mem2agpcpy |
7072 | 153 void * mem2agpcpy(void * to, const void * from, size_t len) |
4681 | 154 { |
155 #ifdef RUNTIME_CPUDETECT | |
156 #ifdef CAN_COMPILE_X86_ASM | |
157 // ordered per speed fasterst first | |
5208 | 158 if(gCpuCaps.hasSSE2) |
159 mem2agpcpy_SSE(to, from, len); | |
160 else if(gCpuCaps.hasMMX2) | |
4681 | 161 mem2agpcpy_MMX2(to, from, len); |
162 else if(gCpuCaps.has3DNow) | |
163 mem2agpcpy_3DNow(to, from, len); | |
164 else if(gCpuCaps.hasMMX) | |
165 mem2agpcpy_MMX(to, from, len); | |
166 else | |
167 #endif //CAN_COMPILE_X86_ASM | |
168 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
169 #else | |
5208 | 170 #ifdef HAVE_SSE2 |
171 mem2agpcpy_SSE(to, from, len); | |
172 #elif defined (HAVE_MMX2) | |
4681 | 173 mem2agpcpy_MMX2(to, from, len); |
174 #elif defined (HAVE_3DNOW) | |
175 mem2agpcpy_3DNow(to, from, len); | |
176 #elif defined (HAVE_MMX) | |
177 mem2agpcpy_MMX(to, from, len); | |
178 #else | |
179 memcpy(to, from, len); // prior to mmx we use the standart memcpy | |
180 #endif | |
181 | |
182 #endif //!RUNTIME_CPUDETECT | |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7072
diff
changeset
|
183 return to; |
4681 | 184 } |
185 | |
186 #endif /* use fastmemcpy */ | |
187 |