Parent Directory | Revision Log
Revision 631 - (view) (download)
1 : | Isibaar | 3 | #ifndef _PORTAB_H_ |
2 : | #define _PORTAB_H_ | ||
3 : | |||
4 : | suxen_drol | 252 | |
5 : | // debug level masks | ||
6 : | #define DPRINTF_ERROR 0x00000001 | ||
7 : | #define DPRINTF_STARTCODE 0x00000002 | ||
8 : | #define DPRINTF_HEADER 0x00000004 | ||
9 : | #define DPRINTF_TIMECODE 0x00000008 | ||
10 : | #define DPRINTF_MB 0x00000010 | ||
11 : | #define DPRINTF_COEFF 0x00000020 | ||
12 : | #define DPRINTF_MV 0x00000040 | ||
13 : | #define DPRINTF_DEBUG 0x80000000 | ||
14 : | |||
15 : | suxen_drol | 630 | |
16 : | #ifdef _DEBUG | ||
17 : | suxen_drol | 252 | // debug level |
18 : | suxen_drol | 631 | #define DPRINTF_LEVEL 0x0000000f |
19 : | suxen_drol | 630 | #else |
20 : | #define DPRINTF_LEVEL 0x0 | ||
21 : | #endif | ||
22 : | suxen_drol | 252 | |
23 : | |||
24 : | #define DPRINTF_BUF_SZ 1024 | ||
25 : | |||
26 : | |||
27 : | Isibaar | 3 | #if defined(WIN32) |
28 : | |||
29 : | #include <windows.h> | ||
30 : | suxen_drol | 136 | #include <stdio.h> |
31 : | Isibaar | 3 | |
32 : | suxen_drol | 252 | static __inline void |
33 : | DPRINTF(int level, char *fmt, | ||
34 : | edgomez | 195 | ...) |
35 : | suxen_drol | 136 | { |
36 : | suxen_drol | 252 | if ((DPRINTF_LEVEL & level)) |
37 : | { | ||
38 : | va_list args; | ||
39 : | char buf[DPRINTF_BUF_SZ]; | ||
40 : | suxen_drol | 136 | |
41 : | suxen_drol | 252 | va_start(args, fmt); |
42 : | vsprintf(buf, fmt, args); | ||
43 : | OutputDebugString(buf); | ||
44 : | fprintf(stdout, "%s\n", buf); | ||
45 : | fflush(stdout); | ||
46 : | } | ||
47 : | suxen_drol | 136 | } |
48 : | |||
49 : | |||
50 : | 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); } |
51 : | |||
52 : | h | 34 | #ifdef _DEBUG |
53 : | Isibaar | 3 | #define DEBUG(S) OutputDebugString((S)); |
54 : | #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); } | ||
55 : | #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); } | ||
56 : | #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); } | ||
57 : | 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); } |
58 : | 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); } |
59 : | h | 34 | #else |
60 : | #define DEBUG(S) | ||
61 : | #define DEBUG1(S,I) | ||
62 : | #define DEBUG2(X,A,B) | ||
63 : | #define DEBUG3(X,A,B,C) | ||
64 : | chenm001 | 161 | #define DEBUG4(X,A,B,C,D) |
65 : | h | 34 | #define DEBUG8(X,A,B,C,D,E,F,G,H) |
66 : | #endif | ||
67 : | Isibaar | 3 | |
68 : | |||
69 : | #define int8_t char | ||
70 : | #define uint8_t unsigned char | ||
71 : | #define int16_t short | ||
72 : | #define uint16_t unsigned short | ||
73 : | #define int32_t int | ||
74 : | #define uint32_t unsigned int | ||
75 : | #define int64_t __int64 | ||
76 : | #define uint64_t unsigned __int64 | ||
77 : | Isibaar | 209 | #define ptr_t uint32_t |
78 : | Isibaar | 3 | |
79 : | #define EMMS() __asm {emms} | ||
80 : | |||
81 : | Isibaar | 42 | #define CACHE_LINE 16 |
82 : | edgomez | 78 | |
83 : | suxen_drol | 68 | #if _MSC_VER <= 1200 |
84 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
85 : | edgomez | 78 | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
86 : | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) | ||
87 : | suxen_drol | 68 | #else |
88 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
89 : | edgomez | 88 | __declspec(align(alignment)) type name[(sizex)*(sizey)] |
90 : | suxen_drol | 68 | #endif |
91 : | Isibaar | 42 | |
92 : | Isibaar | 3 | // needed for bitstream.h |
93 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
94 : | |||
95 : | // needed for timer.c | ||
96 : | edgomez | 195 | static __inline int64_t |
97 : | read_counter() | ||
98 : | { | ||
99 : | Isibaar | 3 | int64_t ts; |
100 : | uint32_t ts1, ts2; | ||
101 : | |||
102 : | __asm { | ||
103 : | Isibaar | 209 | rdtsc |
104 : | mov ts1, eax | ||
105 : | suxen_drol | 206 | mov ts2, edx |
106 : | } | ||
107 : | edgomez | 195 | |
108 : | Isibaar | 3 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
109 : | edgomez | 195 | |
110 : | Isibaar | 3 | return ts; |
111 : | } | ||
112 : | |||
113 : | Isibaar | 381 | #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) || defined(BEOS) |
114 : | Isibaar | 3 | |
115 : | suxen_drol | 229 | #include <stdio.h> |
116 : | #include <stdarg.h> | ||
117 : | suxen_drol | 252 | |
118 : | static __inline void | ||
119 : | DPRINTF(int level, char *fmt, | ||
120 : | suxen_drol | 229 | ...) |
121 : | { | ||
122 : | suxen_drol | 252 | if ((DPRINTF_LEVEL & level)) { |
123 : | va_list args; | ||
124 : | char buf[DPRINTF_BUF_SZ]; | ||
125 : | suxen_drol | 229 | |
126 : | suxen_drol | 252 | va_start(args, fmt); |
127 : | vsprintf(buf, fmt, args); | ||
128 : | fprintf(stdout, "%s\n", buf); | ||
129 : | } | ||
130 : | suxen_drol | 229 | } |
131 : | |||
132 : | chl | 37 | #ifdef _DEBUG |
133 : | |||
134 : | Isibaar | 3 | #include <stdio.h> |
135 : | edgomez | 78 | #define DEBUG_WHERE stdout |
136 : | #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); | ||
137 : | #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I)) | ||
138 : | #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) | ||
139 : | #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) | ||
140 : | Isibaar | 3 | #define DEBUG8(S,A,B,C,D,E,F,G,H) |
141 : | h | 108 | #define DEBUGCBR(A,B,C) fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)) |
142 : | chl | 37 | #else |
143 : | #define DEBUG(S) | ||
144 : | #define DEBUG1(S,I) | ||
145 : | #define DEBUG2(X,A,B) | ||
146 : | #define DEBUG3(X,A,B,C) | ||
147 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
148 : | h | 108 | #define DEBUGCBR(A,B,C) |
149 : | chl | 37 | #endif |
150 : | Isibaar | 3 | |
151 : | Isibaar | 381 | #if defined(LINUX) || defined(BEOS) |
152 : | Isibaar | 3 | |
153 : | Isibaar | 381 | #if defined(BEOS) |
154 : | #include <inttypes.h> | ||
155 : | #else | ||
156 : | Isibaar | 3 | #include <stdint.h> |
157 : | Isibaar | 381 | #endif |
158 : | Isibaar | 3 | |
159 : | canard | 73 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
160 : | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ | ||
161 : | Isibaar | 209 | type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1)) |
162 : | canard | 73 | |
163 : | Isibaar | 3 | #else |
164 : | |||
165 : | knhor | 129 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
166 : | edgomez | 78 | __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)] |
167 : | |||
168 : | #define int8_t char | ||
169 : | #define uint8_t unsigned char | ||
170 : | #define int16_t short | ||
171 : | Isibaar | 3 | #define uint16_t unsigned short |
172 : | edgomez | 78 | #define int32_t int |
173 : | Isibaar | 3 | #define uint32_t unsigned int |
174 : | edgomez | 78 | #define int64_t long long |
175 : | Isibaar | 3 | #define uint64_t unsigned long long |
176 : | |||
177 : | #endif | ||
178 : | |||
179 : | |||
180 : | // needed for bitstream.h | ||
181 : | canard | 45 | #ifdef ARCH_PPC |
182 : | edgomez | 195 | #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
183 : | canard | 45 | "r" (&(a)), "m" (a)); |
184 : | edgomez | 195 | #define EMMS() |
185 : | canard | 89 | |
186 : | edgomez | 195 | static __inline unsigned long |
187 : | get_tbl(void) | ||
188 : | { | ||
189 : | unsigned long tbl; | ||
190 : | asm volatile ("mftb %0":"=r" (tbl)); | ||
191 : | |||
192 : | return tbl; | ||
193 : | } | ||
194 : | static __inline unsigned long | ||
195 : | get_tbu(void) | ||
196 : | { | ||
197 : | unsigned long tbl; | ||
198 : | asm volatile ("mftbu %0":"=r" (tbl)); | ||
199 : | |||
200 : | return tbl; | ||
201 : | } | ||
202 : | static __inline int64_t | ||
203 : | read_counter() | ||
204 : | { | ||
205 : | unsigned long tb, tu; | ||
206 : | |||
207 : | do { | ||
208 : | tu = get_tbu(); | ||
209 : | tb = get_tbl(); | ||
210 : | } while (tb != get_tbl()); | ||
211 : | return (((int64_t) tu) << 32) | (int64_t) tb; | ||
212 : | } | ||
213 : | Isibaar | 209 | |
214 : | #define ptr_t uint32_t | ||
215 : | |||
216 : | #define CACHE_LINE 16 | ||
217 : | |||
218 : | #elif defined(ARCH_IA64) | ||
219 : | |||
220 : | #define ptr_t uint64_t | ||
221 : | |||
222 : | #define CACHE_LINE 32 | ||
223 : | |||
224 : | #define EMMS() | ||
225 : | |||
226 : | ia64p | 283 | #ifdef __GNUC__ |
227 : | |||
228 : | Isibaar | 209 | // needed for bitstream.h |
229 : | ia64p | 280 | #define BSWAP(a) __asm__ __volatile__ ("mux1 %1 = %0, @rev" \ |
230 : | ";;" \ | ||
231 : | "shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); | ||
232 : | Isibaar | 209 | |
233 : | ia64p | 280 | // rdtsc replacement for ia64 |
234 : | Isibaar | 209 | static __inline int64_t read_counter() { |
235 : | ia64p | 280 | unsigned long result; |
236 : | |||
237 : | // __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); | ||
238 : | // while (__builtin_expect ((int) result == -1, 0)) | ||
239 : | __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); | ||
240 : | return result; | ||
241 : | |||
242 : | Isibaar | 209 | } |
243 : | |||
244 : | ia64p | 283 | /* we are missing our ia64intrin.h file, but according to the |
245 : | Intel's ecc manual, this should be the right way ... | ||
246 : | this | ||
247 : | |||
248 : | #elif defined(__INTEL_COMPILER) | ||
249 : | |||
250 : | #include <ia64intrin.h> | ||
251 : | |||
252 : | static __inline int64_t read_counter() { | ||
253 : | return __getReg(44); | ||
254 : | } | ||
255 : | |||
256 : | #define BSWAP(a) ((unsigned int) (_m64_mux1(a, 0xb) >> 32)) | ||
257 : | */ | ||
258 : | |||
259 : | #else | ||
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 : | static __inline int64_t | ||
268 : | read_counter() | ||
269 : | { | ||
270 : | return 0; | ||
271 : | } | ||
272 : | |||
273 : | #endif // gcc or ecc | ||
274 : | |||
275 : | canard | 45 | #else |
276 : | edgomez | 195 | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
277 : | #define EMMS() __asm__("emms\n\t") | ||
278 : | Isibaar | 3 | |
279 : | edgomez | 78 | |
280 : | Isibaar | 3 | // needed for timer.c |
281 : | edgomez | 195 | static __inline int64_t |
282 : | read_counter() | ||
283 : | { | ||
284 : | int64_t ts; | ||
285 : | uint32_t ts1, ts2; | ||
286 : | Isibaar | 3 | |
287 : | edgomez | 195 | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), |
288 : | "=d"(ts2)); | ||
289 : | Isibaar | 3 | |
290 : | edgomez | 195 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
291 : | Isibaar | 3 | |
292 : | edgomez | 195 | return ts; |
293 : | Isibaar | 3 | } |
294 : | |||
295 : | Isibaar | 209 | #define ptr_t uint32_t |
296 : | |||
297 : | #define CACHE_LINE 16 | ||
298 : | |||
299 : | edgomez | 78 | #endif |
300 : | |||
301 : | edgomez | 195 | #else // OTHER OS |
302 : | Isibaar | 3 | |
303 : | suxen_drol | 630 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
304 : | __declspec(align(alignment)) type name[(sizex)*(sizey)] | ||
305 : | suxen_drol | 229 | |
306 : | #include <stdio.h> | ||
307 : | #include <stdarg.h> | ||
308 : | suxen_drol | 252 | |
309 : | static __inline void | ||
310 : | DPRINTF(int level, char *fmt, ...) | ||
311 : | suxen_drol | 229 | { |
312 : | suxen_drol | 252 | if ((DPRINTF_LEVEL & level)) { |
313 : | suxen_drol | 229 | |
314 : | suxen_drol | 252 | va_list args; |
315 : | char buf[DPRINTF_BUF_SZ]; | ||
316 : | |||
317 : | va_start(args, fmt); | ||
318 : | vsprintf(buf, fmt, args); | ||
319 : | fprintf(stdout, "%s\n", buf); | ||
320 : | } | ||
321 : | suxen_drol | 229 | } |
322 : | |||
323 : | |||
324 : | Isibaar | 3 | #define DEBUG(S) |
325 : | #define DEBUG1(S,I) | ||
326 : | #define DEBUG2(X,A,B) | ||
327 : | #define DEBUG3(X,A,B,C) | ||
328 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
329 : | h | 108 | #define DEBUGCBR(A,B,C) |
330 : | Isibaar | 3 | |
331 : | #include <inttypes.h> | ||
332 : | |||
333 : | #define EMMS() | ||
334 : | |||
335 : | // needed for bitstream.h | ||
336 : | #define BSWAP(a) \ | ||
337 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
338 : | |||
339 : | // rdtsc command most likely not supported, | ||
340 : | // so just dummy code here | ||
341 : | edgomez | 195 | static __inline int64_t |
342 : | read_counter() | ||
343 : | { | ||
344 : | Isibaar | 3 | return 0; |
345 : | } | ||
346 : | |||
347 : | Isibaar | 209 | #define ptr_t uint32_t |
348 : | |||
349 : | Isibaar | 42 | #define CACHE_LINE 16 |
350 : | #define CACHE_ALIGN | ||
351 : | |||
352 : | Isibaar | 3 | #endif |
353 : | |||
354 : | edgomez | 195 | #endif // _PORTAB_H_ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |