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