Parent Directory | Revision Log
Revision 161 - (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 : | static void dprintf(char *fmt, ...) | ||
12 : | { | ||
13 : | va_list args; | ||
14 : | char buf[DPRINTF_BUF_SZ]; | ||
15 : | |||
16 : | va_start(args, fmt); | ||
17 : | vsprintf(buf, fmt, args); | ||
18 : | OutputDebugString(buf); | ||
19 : | fprintf(stdout, "%s\n", buf); | ||
20 : | } | ||
21 : | |||
22 : | |||
23 : | 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); } |
24 : | |||
25 : | h | 34 | #ifdef _DEBUG |
26 : | Isibaar | 3 | #define DEBUG(S) OutputDebugString((S)); |
27 : | #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); } | ||
28 : | #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); } | ||
29 : | #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); } | ||
30 : | 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); } |
31 : | 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); } |
32 : | h | 34 | #else |
33 : | #define DEBUG(S) | ||
34 : | #define DEBUG1(S,I) | ||
35 : | #define DEBUG2(X,A,B) | ||
36 : | #define DEBUG3(X,A,B,C) | ||
37 : | chenm001 | 161 | #define DEBUG4(X,A,B,C,D) |
38 : | h | 34 | #define DEBUG8(X,A,B,C,D,E,F,G,H) |
39 : | #endif | ||
40 : | Isibaar | 3 | |
41 : | |||
42 : | #define int8_t char | ||
43 : | #define uint8_t unsigned char | ||
44 : | #define int16_t short | ||
45 : | #define uint16_t unsigned short | ||
46 : | #define int32_t int | ||
47 : | #define uint32_t unsigned int | ||
48 : | #define int64_t __int64 | ||
49 : | #define uint64_t unsigned __int64 | ||
50 : | |||
51 : | #define EMMS() __asm {emms} | ||
52 : | |||
53 : | Isibaar | 42 | #define CACHE_LINE 16 |
54 : | edgomez | 78 | |
55 : | suxen_drol | 68 | #if _MSC_VER <= 1200 |
56 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
57 : | edgomez | 78 | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
58 : | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) | ||
59 : | suxen_drol | 68 | #else |
60 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
61 : | edgomez | 88 | __declspec(align(alignment)) type name[(sizex)*(sizey)] |
62 : | suxen_drol | 68 | #endif |
63 : | Isibaar | 42 | |
64 : | Isibaar | 3 | // needed for bitstream.h |
65 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
66 : | |||
67 : | // needed for timer.c | ||
68 : | static __inline int64_t read_counter() { | ||
69 : | int64_t ts; | ||
70 : | uint32_t ts1, ts2; | ||
71 : | |||
72 : | __asm { | ||
73 : | rdtsc | ||
74 : | mov ts1, eax | ||
75 : | mov ts2, edx | ||
76 : | } | ||
77 : | |||
78 : | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); | ||
79 : | |||
80 : | return ts; | ||
81 : | } | ||
82 : | |||
83 : | knhor | 129 | #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) |
84 : | Isibaar | 3 | |
85 : | chl | 37 | #ifdef _DEBUG |
86 : | |||
87 : | Isibaar | 3 | #include <stdio.h> |
88 : | edgomez | 78 | #define DEBUG_WHERE stdout |
89 : | #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); | ||
90 : | #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I)) | ||
91 : | #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) | ||
92 : | #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) | ||
93 : | Isibaar | 3 | #define DEBUG8(S,A,B,C,D,E,F,G,H) |
94 : | h | 108 | #define DEBUGCBR(A,B,C) fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)) |
95 : | chl | 37 | #else |
96 : | #define DEBUG(S) | ||
97 : | #define DEBUG1(S,I) | ||
98 : | #define DEBUG2(X,A,B) | ||
99 : | #define DEBUG3(X,A,B,C) | ||
100 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
101 : | h | 108 | #define DEBUGCBR(A,B,C) |
102 : | chl | 37 | #endif |
103 : | Isibaar | 3 | |
104 : | Isibaar | 42 | #define CACHE_LINE 16 |
105 : | |||
106 : | Isibaar | 3 | #if defined(LINUX) |
107 : | |||
108 : | #include <stdint.h> | ||
109 : | |||
110 : | canard | 73 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
111 : | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ | ||
112 : | edgomez | 78 | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
113 : | canard | 73 | |
114 : | Isibaar | 3 | #else |
115 : | |||
116 : | knhor | 129 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
117 : | edgomez | 78 | __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)] |
118 : | |||
119 : | #define int8_t char | ||
120 : | #define uint8_t unsigned char | ||
121 : | #define int16_t short | ||
122 : | Isibaar | 3 | #define uint16_t unsigned short |
123 : | edgomez | 78 | #define int32_t int |
124 : | Isibaar | 3 | #define uint32_t unsigned int |
125 : | edgomez | 78 | #define int64_t long long |
126 : | Isibaar | 3 | #define uint64_t unsigned long long |
127 : | |||
128 : | #endif | ||
129 : | |||
130 : | |||
131 : | // needed for bitstream.h | ||
132 : | canard | 45 | #ifdef ARCH_PPC |
133 : | canard | 92 | #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
134 : | canard | 45 | "r" (&(a)), "m" (a)); |
135 : | #define EMMS() | ||
136 : | canard | 89 | |
137 : | static __inline unsigned long get_tbl(void) { | ||
138 : | unsigned long tbl; | ||
139 : | asm volatile("mftb %0" : "=r" (tbl)); | ||
140 : | return tbl; | ||
141 : | } | ||
142 : | static __inline unsigned long get_tbu(void) { | ||
143 : | unsigned long tbl; | ||
144 : | asm volatile("mftbu %0" : "=r" (tbl)); | ||
145 : | return tbl; | ||
146 : | } | ||
147 : | static __inline int64_t read_counter() { | ||
148 : | unsigned long tb, tu; | ||
149 : | do { | ||
150 : | canard | 92 | tu = get_tbu(); |
151 : | canard | 89 | tb = get_tbl(); |
152 : | } while(tb != get_tbl()); | ||
153 : | return (((int64_t)tu) << 32) | (int64_t)tb; | ||
154 : | } | ||
155 : | canard | 45 | #else |
156 : | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) | ||
157 : | #define EMMS() __asm__("emms\n\t") | ||
158 : | Isibaar | 3 | |
159 : | edgomez | 78 | |
160 : | Isibaar | 3 | // needed for timer.c |
161 : | static __inline int64_t read_counter() { | ||
162 : | int64_t ts; | ||
163 : | uint32_t ts1, ts2; | ||
164 : | |||
165 : | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2)); | ||
166 : | |||
167 : | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); | ||
168 : | |||
169 : | return ts; | ||
170 : | } | ||
171 : | |||
172 : | edgomez | 78 | #endif |
173 : | |||
174 : | Isibaar | 3 | #else // OTHER OS |
175 : | |||
176 : | #define DEBUG(S) | ||
177 : | #define DEBUG1(S,I) | ||
178 : | #define DEBUG2(X,A,B) | ||
179 : | #define DEBUG3(X,A,B,C) | ||
180 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
181 : | h | 108 | #define DEBUGCBR(A,B,C) |
182 : | Isibaar | 3 | |
183 : | #include <inttypes.h> | ||
184 : | |||
185 : | #define EMMS() | ||
186 : | |||
187 : | // needed for bitstream.h | ||
188 : | #define BSWAP(a) \ | ||
189 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
190 : | |||
191 : | // rdtsc command most likely not supported, | ||
192 : | // so just dummy code here | ||
193 : | static __inline int64_t read_counter() { | ||
194 : | return 0; | ||
195 : | } | ||
196 : | |||
197 : | Isibaar | 42 | #define CACHE_LINE 16 |
198 : | #define CACHE_ALIGN | ||
199 : | |||
200 : | Isibaar | 3 | #endif |
201 : | |||
202 : | #endif // _PORTAB_H_ | ||
203 : |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |