1 |
#ifndef _PORTAB_H_ |
#ifndef _PORTAB_H_ |
2 |
#define _PORTAB_H_ |
#define _PORTAB_H_ |
3 |
|
|
4 |
|
|
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 |
#if defined(WIN32) |
#if defined(WIN32) |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
25 |
#include <stdio.h> |
#include <stdio.h> |
26 |
|
|
27 |
|
static __inline void |
28 |
#define DPRINTF_BUF_SZ 1024 |
DPRINTF(int level, char *fmt, |
|
static void |
|
|
dprintf(char *fmt, |
|
29 |
...) |
...) |
30 |
{ |
{ |
31 |
|
if ((DPRINTF_LEVEL & level)) |
32 |
|
{ |
33 |
va_list args; |
va_list args; |
34 |
char buf[DPRINTF_BUF_SZ]; |
char buf[DPRINTF_BUF_SZ]; |
35 |
|
|
37 |
vsprintf(buf, fmt, args); |
vsprintf(buf, fmt, args); |
38 |
OutputDebugString(buf); |
OutputDebugString(buf); |
39 |
fprintf(stdout, "%s\n", buf); |
fprintf(stdout, "%s\n", buf); |
40 |
|
fflush(stdout); |
41 |
|
} |
42 |
} |
} |
43 |
|
|
44 |
|
|
69 |
#define uint32_t unsigned int |
#define uint32_t unsigned int |
70 |
#define int64_t __int64 |
#define int64_t __int64 |
71 |
#define uint64_t unsigned __int64 |
#define uint64_t unsigned __int64 |
72 |
|
#define ptr_t uint32_t |
73 |
|
|
74 |
#define EMMS() __asm {emms} |
#define EMMS() __asm {emms} |
75 |
|
|
105 |
return ts; |
return ts; |
106 |
} |
} |
107 |
|
|
108 |
#elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) |
#elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) || defined(BEOS) |
109 |
|
|
110 |
|
#include <stdio.h> |
111 |
|
#include <stdarg.h> |
112 |
|
|
113 |
|
static __inline void |
114 |
|
DPRINTF(int level, char *fmt, |
115 |
|
...) |
116 |
|
{ |
117 |
|
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 |
|
} |
126 |
|
|
127 |
#ifdef _DEBUG |
#ifdef _DEBUG |
128 |
|
|
143 |
#define DEBUGCBR(A,B,C) |
#define DEBUGCBR(A,B,C) |
144 |
#endif |
#endif |
145 |
|
|
146 |
#define CACHE_LINE 16 |
#if defined(LINUX) || defined(BEOS) |
|
|
|
|
#if defined(LINUX) |
|
147 |
|
|
148 |
|
#if defined(BEOS) |
149 |
|
#include <inttypes.h> |
150 |
|
#else |
151 |
#include <stdint.h> |
#include <stdint.h> |
152 |
|
#endif |
153 |
|
|
154 |
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
155 |
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
156 |
type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1)) |
157 |
|
|
158 |
#else |
#else |
159 |
|
|
205 |
} while (tb != get_tbl()); |
} while (tb != get_tbl()); |
206 |
return (((int64_t) tu) << 32) | (int64_t) tb; |
return (((int64_t) tu) << 32) | (int64_t) tb; |
207 |
} |
} |
208 |
|
|
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 |
|
#ifdef __GNUC__ |
222 |
|
|
223 |
|
// needed for bitstream.h |
224 |
|
#define BSWAP(a) __asm__ __volatile__ ("mux1 %1 = %0, @rev" \ |
225 |
|
";;" \ |
226 |
|
"shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); |
227 |
|
|
228 |
|
// rdtsc replacement for ia64 |
229 |
|
static __inline int64_t read_counter() { |
230 |
|
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 |
|
} |
238 |
|
|
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 |
|
|
270 |
#else |
#else |
271 |
#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
272 |
#define EMMS() __asm__("emms\n\t") |
#define EMMS() __asm__("emms\n\t") |
287 |
return ts; |
return ts; |
288 |
} |
} |
289 |
|
|
290 |
|
#define ptr_t uint32_t |
291 |
|
|
292 |
|
#define CACHE_LINE 16 |
293 |
|
|
294 |
#endif |
#endif |
295 |
|
|
296 |
#else // OTHER OS |
#else // OTHER OS |
297 |
|
|
298 |
|
|
299 |
|
#include <stdio.h> |
300 |
|
#include <stdarg.h> |
301 |
|
|
302 |
|
static __inline void |
303 |
|
DPRINTF(int level, char *fmt, ...) |
304 |
|
{ |
305 |
|
if ((DPRINTF_LEVEL & level)) { |
306 |
|
|
307 |
|
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 |
|
} |
315 |
|
|
316 |
|
|
317 |
#define DEBUG(S) |
#define DEBUG(S) |
318 |
#define DEBUG1(S,I) |
#define DEBUG1(S,I) |
319 |
#define DEBUG2(X,A,B) |
#define DEBUG2(X,A,B) |
337 |
return 0; |
return 0; |
338 |
} |
} |
339 |
|
|
340 |
|
#define ptr_t uint32_t |
341 |
|
|
342 |
#define CACHE_LINE 16 |
#define CACHE_LINE 16 |
343 |
#define CACHE_ALIGN |
#define CACHE_ALIGN |
344 |
|
|