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 |
|
|
16 |
|
#ifdef _DEBUG |
17 |
|
// debug level |
18 |
|
#define DPRINTF_LEVEL 0x0000000f |
19 |
|
#else |
20 |
|
#define DPRINTF_LEVEL 0x0 |
21 |
|
#endif |
22 |
|
|
23 |
|
|
24 |
|
#define DPRINTF_BUF_SZ 1024 |
25 |
|
|
26 |
|
|
27 |
#if defined(WIN32) |
#if defined(WIN32) |
28 |
|
|
29 |
#include <windows.h> |
#include <windows.h> |
30 |
#include <stdio.h> |
#include <stdio.h> |
31 |
|
|
32 |
|
static __inline void |
33 |
#define DPRINTF_BUF_SZ 1024 |
DPRINTF(int level, char *fmt, |
|
static void |
|
|
dprintf(char *fmt, |
|
34 |
...) |
...) |
35 |
{ |
{ |
36 |
|
if ((DPRINTF_LEVEL & level)) |
37 |
|
{ |
38 |
va_list args; |
va_list args; |
39 |
char buf[DPRINTF_BUF_SZ]; |
char buf[DPRINTF_BUF_SZ]; |
40 |
|
|
42 |
vsprintf(buf, fmt, args); |
vsprintf(buf, fmt, args); |
43 |
OutputDebugString(buf); |
OutputDebugString(buf); |
44 |
fprintf(stdout, "%s\n", buf); |
fprintf(stdout, "%s\n", buf); |
45 |
|
fflush(stdout); |
46 |
|
} |
47 |
} |
} |
48 |
|
|
49 |
|
|
74 |
#define uint32_t unsigned int |
#define uint32_t unsigned int |
75 |
#define int64_t __int64 |
#define int64_t __int64 |
76 |
#define uint64_t unsigned __int64 |
#define uint64_t unsigned __int64 |
77 |
|
#define ptr_t uint32_t |
78 |
|
|
79 |
#define EMMS() __asm {emms} |
#define EMMS() __asm {emms} |
80 |
|
|
110 |
return ts; |
return ts; |
111 |
} |
} |
112 |
|
|
113 |
#elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) |
#elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) || defined(BEOS) |
114 |
|
|
115 |
|
#include <stdio.h> |
116 |
|
#include <stdarg.h> |
117 |
|
|
118 |
|
static __inline void |
119 |
|
DPRINTF(int level, char *fmt, |
120 |
|
...) |
121 |
|
{ |
122 |
|
if ((DPRINTF_LEVEL & level)) { |
123 |
|
va_list args; |
124 |
|
char buf[DPRINTF_BUF_SZ]; |
125 |
|
|
126 |
|
va_start(args, fmt); |
127 |
|
vsprintf(buf, fmt, args); |
128 |
|
fprintf(stdout, "%s\n", buf); |
129 |
|
} |
130 |
|
} |
131 |
|
|
132 |
#ifdef _DEBUG |
#ifdef _DEBUG |
133 |
|
|
148 |
#define DEBUGCBR(A,B,C) |
#define DEBUGCBR(A,B,C) |
149 |
#endif |
#endif |
150 |
|
|
151 |
#define CACHE_LINE 16 |
#if defined(LINUX) || defined(BEOS) |
|
|
|
|
#if defined(LINUX) |
|
152 |
|
|
153 |
|
#if defined(BEOS) |
154 |
|
#include <inttypes.h> |
155 |
|
#else |
156 |
#include <stdint.h> |
#include <stdint.h> |
157 |
|
#endif |
158 |
|
|
159 |
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
160 |
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
161 |
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)) |
162 |
|
|
163 |
#else |
#else |
164 |
|
|
210 |
} while (tb != get_tbl()); |
} while (tb != get_tbl()); |
211 |
return (((int64_t) tu) << 32) | (int64_t) tb; |
return (((int64_t) tu) << 32) | (int64_t) tb; |
212 |
} |
} |
213 |
|
|
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 |
|
#ifdef __GNUC__ |
227 |
|
|
228 |
|
// needed for bitstream.h |
229 |
|
#define BSWAP(a) __asm__ __volatile__ ("mux1 %1 = %0, @rev" \ |
230 |
|
";;" \ |
231 |
|
"shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); |
232 |
|
|
233 |
|
// rdtsc replacement for ia64 |
234 |
|
static __inline int64_t read_counter() { |
235 |
|
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 |
|
} |
243 |
|
|
244 |
|
/* 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 |
#else |
#else |
276 |
#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
277 |
#define EMMS() __asm__("emms\n\t") |
#define EMMS() __asm__("emms\n\t") |
292 |
return ts; |
return ts; |
293 |
} |
} |
294 |
|
|
295 |
|
#define ptr_t uint32_t |
296 |
|
|
297 |
|
#define CACHE_LINE 16 |
298 |
|
|
299 |
#endif |
#endif |
300 |
|
|
301 |
#else // OTHER OS |
#else // OTHER OS |
302 |
|
|
303 |
|
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
304 |
|
__declspec(align(alignment)) type name[(sizex)*(sizey)] |
305 |
|
|
306 |
|
#include <stdio.h> |
307 |
|
#include <stdarg.h> |
308 |
|
|
309 |
|
static __inline void |
310 |
|
DPRINTF(int level, char *fmt, ...) |
311 |
|
{ |
312 |
|
if ((DPRINTF_LEVEL & level)) { |
313 |
|
|
314 |
|
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 |
|
} |
322 |
|
|
323 |
|
|
324 |
#define DEBUG(S) |
#define DEBUG(S) |
325 |
#define DEBUG1(S,I) |
#define DEBUG1(S,I) |
326 |
#define DEBUG2(X,A,B) |
#define DEBUG2(X,A,B) |
344 |
return 0; |
return 0; |
345 |
} |
} |
346 |
|
|
347 |
|
#define ptr_t uint32_t |
348 |
|
|
349 |
#define CACHE_LINE 16 |
#define CACHE_LINE 16 |
350 |
#define CACHE_ALIGN |
#define CACHE_ALIGN |
|
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
|
|
type name[(sizex)*(sizey)] |
|
351 |
|
|
352 |
#endif |
#endif |
353 |
|
|