Parent Directory | Revision Log
Revision 229 - (view) (download)
1 : | Isibaar | 3 | #ifndef _PORTAB_H_ |
2 : | #define _PORTAB_H_ | ||
3 : | |||
4 : | #if defined(WIN32) | ||
5 : | |||
6 : | #include <windows.h> | ||
7 : | suxen_drol | 136 | #include <stdio.h> |
8 : | Isibaar | 3 | |
9 : | suxen_drol | 136 | |
10 : | #define DPRINTF_BUF_SZ 1024 | ||
11 : | edgomez | 195 | static void |
12 : | suxen_drol | 229 | DPRINTF(char *fmt, |
13 : | edgomez | 195 | ...) |
14 : | suxen_drol | 136 | { |
15 : | va_list args; | ||
16 : | char buf[DPRINTF_BUF_SZ]; | ||
17 : | |||
18 : | va_start(args, fmt); | ||
19 : | vsprintf(buf, fmt, args); | ||
20 : | OutputDebugString(buf); | ||
21 : | fprintf(stdout, "%s\n", buf); | ||
22 : | } | ||
23 : | |||
24 : | |||
25 : | h | 108 | #define DEBUGCBR(A,B,C) { char tmp[100]; wsprintf(tmp, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)); OutputDebugString(tmp); } |
26 : | |||
27 : | h | 34 | #ifdef _DEBUG |
28 : | Isibaar | 3 | #define DEBUG(S) OutputDebugString((S)); |
29 : | #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); } | ||
30 : | #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); } | ||
31 : | #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); } | ||
32 : | chenm001 | 161 | #define DEBUG4(X,A,B,C,D){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i %i",(X),(A), (B), (C), (D)); OutputDebugString(tmp); } |
33 : | Isibaar | 3 | #define DEBUG8(X,A,B,C,D,E,F,G,H){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i %i %i %i %i %i",(X),(A),(B),(C),(D),(E),(F),(G),(H)); OutputDebugString(tmp); } |
34 : | h | 34 | #else |
35 : | #define DEBUG(S) | ||
36 : | #define DEBUG1(S,I) | ||
37 : | #define DEBUG2(X,A,B) | ||
38 : | #define DEBUG3(X,A,B,C) | ||
39 : | chenm001 | 161 | #define DEBUG4(X,A,B,C,D) |
40 : | h | 34 | #define DEBUG8(X,A,B,C,D,E,F,G,H) |
41 : | #endif | ||
42 : | Isibaar | 3 | |
43 : | |||
44 : | #define int8_t char | ||
45 : | #define uint8_t unsigned char | ||
46 : | #define int16_t short | ||
47 : | #define uint16_t unsigned short | ||
48 : | #define int32_t int | ||
49 : | #define uint32_t unsigned int | ||
50 : | #define int64_t __int64 | ||
51 : | #define uint64_t unsigned __int64 | ||
52 : | Isibaar | 209 | #define ptr_t uint32_t |
53 : | Isibaar | 3 | |
54 : | #define EMMS() __asm {emms} | ||
55 : | |||
56 : | Isibaar | 42 | #define CACHE_LINE 16 |
57 : | edgomez | 78 | |
58 : | suxen_drol | 68 | #if _MSC_VER <= 1200 |
59 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
60 : | edgomez | 78 | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
61 : | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) | ||
62 : | suxen_drol | 68 | #else |
63 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
64 : | edgomez | 88 | __declspec(align(alignment)) type name[(sizex)*(sizey)] |
65 : | suxen_drol | 68 | #endif |
66 : | Isibaar | 42 | |
67 : | Isibaar | 3 | // needed for bitstream.h |
68 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
69 : | |||
70 : | // needed for timer.c | ||
71 : | edgomez | 195 | static __inline int64_t |
72 : | read_counter() | ||
73 : | { | ||
74 : | Isibaar | 3 | int64_t ts; |
75 : | uint32_t ts1, ts2; | ||
76 : | |||
77 : | __asm { | ||
78 : | Isibaar | 209 | rdtsc |
79 : | mov ts1, eax | ||
80 : | suxen_drol | 206 | mov ts2, edx |
81 : | } | ||
82 : | edgomez | 195 | |
83 : | Isibaar | 3 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
84 : | edgomez | 195 | |
85 : | Isibaar | 3 | return ts; |
86 : | } | ||
87 : | |||
88 : | knhor | 129 | #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) |
89 : | Isibaar | 3 | |
90 : | suxen_drol | 229 | #include <stdio.h> |
91 : | #include <stdarg.h> | ||
92 : | #define DPRINTF_BUF_SZ 1024 | ||
93 : | static void | ||
94 : | DPRINTF(char *fmt, | ||
95 : | ...) | ||
96 : | { | ||
97 : | va_list args; | ||
98 : | char buf[DPRINTF_BUF_SZ]; | ||
99 : | |||
100 : | va_start(args, fmt); | ||
101 : | vsprintf(buf, fmt, args); | ||
102 : | fprintf(stdout, "%s\n", buf); | ||
103 : | } | ||
104 : | |||
105 : | chl | 37 | #ifdef _DEBUG |
106 : | |||
107 : | Isibaar | 3 | #include <stdio.h> |
108 : | edgomez | 78 | #define DEBUG_WHERE stdout |
109 : | #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); | ||
110 : | #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I)) | ||
111 : | #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) | ||
112 : | #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) | ||
113 : | Isibaar | 3 | #define DEBUG8(S,A,B,C,D,E,F,G,H) |
114 : | h | 108 | #define DEBUGCBR(A,B,C) fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)) |
115 : | chl | 37 | #else |
116 : | #define DEBUG(S) | ||
117 : | #define DEBUG1(S,I) | ||
118 : | #define DEBUG2(X,A,B) | ||
119 : | #define DEBUG3(X,A,B,C) | ||
120 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
121 : | h | 108 | #define DEBUGCBR(A,B,C) |
122 : | chl | 37 | #endif |
123 : | Isibaar | 3 | |
124 : | #if defined(LINUX) | ||
125 : | |||
126 : | #include <stdint.h> | ||
127 : | |||
128 : | canard | 73 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
129 : | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ | ||
130 : | Isibaar | 209 | type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1)) |
131 : | canard | 73 | |
132 : | Isibaar | 3 | #else |
133 : | |||
134 : | knhor | 129 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
135 : | edgomez | 78 | __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)] |
136 : | |||
137 : | #define int8_t char | ||
138 : | #define uint8_t unsigned char | ||
139 : | #define int16_t short | ||
140 : | Isibaar | 3 | #define uint16_t unsigned short |
141 : | edgomez | 78 | #define int32_t int |
142 : | Isibaar | 3 | #define uint32_t unsigned int |
143 : | edgomez | 78 | #define int64_t long long |
144 : | Isibaar | 3 | #define uint64_t unsigned long long |
145 : | |||
146 : | #endif | ||
147 : | |||
148 : | |||
149 : | // needed for bitstream.h | ||
150 : | canard | 45 | #ifdef ARCH_PPC |
151 : | edgomez | 195 | #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
152 : | canard | 45 | "r" (&(a)), "m" (a)); |
153 : | edgomez | 195 | #define EMMS() |
154 : | canard | 89 | |
155 : | edgomez | 195 | static __inline unsigned long |
156 : | get_tbl(void) | ||
157 : | { | ||
158 : | unsigned long tbl; | ||
159 : | asm volatile ("mftb %0":"=r" (tbl)); | ||
160 : | |||
161 : | return tbl; | ||
162 : | } | ||
163 : | static __inline unsigned long | ||
164 : | get_tbu(void) | ||
165 : | { | ||
166 : | unsigned long tbl; | ||
167 : | asm volatile ("mftbu %0":"=r" (tbl)); | ||
168 : | |||
169 : | return tbl; | ||
170 : | } | ||
171 : | static __inline int64_t | ||
172 : | read_counter() | ||
173 : | { | ||
174 : | unsigned long tb, tu; | ||
175 : | |||
176 : | do { | ||
177 : | tu = get_tbu(); | ||
178 : | tb = get_tbl(); | ||
179 : | } while (tb != get_tbl()); | ||
180 : | return (((int64_t) tu) << 32) | (int64_t) tb; | ||
181 : | } | ||
182 : | Isibaar | 209 | |
183 : | #define ptr_t uint32_t | ||
184 : | |||
185 : | #define CACHE_LINE 16 | ||
186 : | |||
187 : | #elif defined(ARCH_IA64) | ||
188 : | |||
189 : | #define ptr_t uint64_t | ||
190 : | |||
191 : | #define CACHE_LINE 32 | ||
192 : | |||
193 : | #define EMMS() | ||
194 : | |||
195 : | // needed for bitstream.h | ||
196 : | #define BSWAP(a) \ | ||
197 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
198 : | |||
199 : | // rdtsc command most likely not supported, | ||
200 : | // so just dummy code here | ||
201 : | static __inline int64_t read_counter() { | ||
202 : | return 0; | ||
203 : | } | ||
204 : | |||
205 : | canard | 45 | #else |
206 : | edgomez | 195 | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
207 : | #define EMMS() __asm__("emms\n\t") | ||
208 : | Isibaar | 3 | |
209 : | edgomez | 78 | |
210 : | Isibaar | 3 | // needed for timer.c |
211 : | edgomez | 195 | static __inline int64_t |
212 : | read_counter() | ||
213 : | { | ||
214 : | int64_t ts; | ||
215 : | uint32_t ts1, ts2; | ||
216 : | Isibaar | 3 | |
217 : | edgomez | 195 | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), |
218 : | "=d"(ts2)); | ||
219 : | Isibaar | 3 | |
220 : | edgomez | 195 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
221 : | Isibaar | 3 | |
222 : | edgomez | 195 | return ts; |
223 : | Isibaar | 3 | } |
224 : | |||
225 : | Isibaar | 209 | #define ptr_t uint32_t |
226 : | |||
227 : | #define CACHE_LINE 16 | ||
228 : | |||
229 : | edgomez | 78 | #endif |
230 : | |||
231 : | edgomez | 195 | #else // OTHER OS |
232 : | Isibaar | 3 | |
233 : | suxen_drol | 229 | |
234 : | #include <stdio.h> | ||
235 : | #include <stdarg.h> | ||
236 : | #define DPRINTF_BUF_SZ 1024 | ||
237 : | static void | ||
238 : | DPRINTF(char *fmt, | ||
239 : | ...) | ||
240 : | { | ||
241 : | va_list args; | ||
242 : | char buf[DPRINTF_BUF_SZ]; | ||
243 : | |||
244 : | va_start(args, fmt); | ||
245 : | vsprintf(buf, fmt, args); | ||
246 : | fprintf(stdout, "%s\n", buf); | ||
247 : | } | ||
248 : | |||
249 : | |||
250 : | Isibaar | 3 | #define DEBUG(S) |
251 : | #define DEBUG1(S,I) | ||
252 : | #define DEBUG2(X,A,B) | ||
253 : | #define DEBUG3(X,A,B,C) | ||
254 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
255 : | h | 108 | #define DEBUGCBR(A,B,C) |
256 : | Isibaar | 3 | |
257 : | #include <inttypes.h> | ||
258 : | |||
259 : | #define EMMS() | ||
260 : | |||
261 : | // needed for bitstream.h | ||
262 : | #define BSWAP(a) \ | ||
263 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
264 : | |||
265 : | // rdtsc command most likely not supported, | ||
266 : | // so just dummy code here | ||
267 : | edgomez | 195 | static __inline int64_t |
268 : | read_counter() | ||
269 : | { | ||
270 : | Isibaar | 3 | return 0; |
271 : | } | ||
272 : | |||
273 : | Isibaar | 209 | #define ptr_t uint32_t |
274 : | |||
275 : | Isibaar | 42 | #define CACHE_LINE 16 |
276 : | #define CACHE_ALIGN | ||
277 : | |||
278 : | Isibaar | 3 | #endif |
279 : | |||
280 : | edgomez | 195 | #endif // _PORTAB_H_ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |