Parent Directory
|
Revision Log
Revision 252 - (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 : | // debug level | ||
16 : | #define DPRINTF_LEVEL 0 | ||
17 : | |||
18 : | |||
19 : | #define DPRINTF_BUF_SZ 1024 | ||
20 : | |||
21 : | |||
22 : | Isibaar | 3 | #if defined(WIN32) |
23 : | |||
24 : | #include <windows.h> | ||
25 : | suxen_drol | 136 | #include <stdio.h> |
26 : | Isibaar | 3 | |
27 : | suxen_drol | 252 | static __inline void |
28 : | DPRINTF(int level, char *fmt, | ||
29 : | edgomez | 195 | ...) |
30 : | suxen_drol | 136 | { |
31 : | suxen_drol | 252 | if ((DPRINTF_LEVEL & level)) |
32 : | { | ||
33 : | va_list args; | ||
34 : | char buf[DPRINTF_BUF_SZ]; | ||
35 : | suxen_drol | 136 | |
36 : | suxen_drol | 252 | 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 | 136 | } |
43 : | |||
44 : | |||
45 : | 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); } |
46 : | |||
47 : | h | 34 | #ifdef _DEBUG |
48 : | Isibaar | 3 | #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 | 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); } |
53 : | 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); } |
54 : | h | 34 | #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 | 161 | #define DEBUG4(X,A,B,C,D) |
60 : | h | 34 | #define DEBUG8(X,A,B,C,D,E,F,G,H) |
61 : | #endif | ||
62 : | Isibaar | 3 | |
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 | 209 | #define ptr_t uint32_t |
73 : | Isibaar | 3 | |
74 : | #define EMMS() __asm {emms} | ||
75 : | |||
76 : | Isibaar | 42 | #define CACHE_LINE 16 |
77 : | edgomez | 78 | |
78 : | suxen_drol | 68 | #if _MSC_VER <= 1200 |
79 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
80 : | edgomez | 78 | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
81 : | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) | ||
82 : | suxen_drol | 68 | #else |
83 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
84 : | edgomez | 88 | __declspec(align(alignment)) type name[(sizex)*(sizey)] |
85 : | suxen_drol | 68 | #endif |
86 : | Isibaar | 42 | |
87 : | Isibaar | 3 | // 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 | 195 | static __inline int64_t |
92 : | read_counter() | ||
93 : | { | ||
94 : | Isibaar | 3 | int64_t ts; |
95 : | uint32_t ts1, ts2; | ||
96 : | |||
97 : | __asm { | ||
98 : | Isibaar | 209 | rdtsc |
99 : | mov ts1, eax | ||
100 : | suxen_drol | 206 | mov ts2, edx |
101 : | } | ||
102 : | edgomez | 195 | |
103 : | Isibaar | 3 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
104 : | edgomez | 195 | |
105 : | Isibaar | 3 | return ts; |
106 : | } | ||
107 : | |||
108 : | knhor | 129 | #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) |
109 : | Isibaar | 3 | |
110 : | suxen_drol | 229 | #include <stdio.h> |
111 : | #include <stdarg.h> | ||
112 : | suxen_drol | 252 | |
113 : | static __inline void | ||
114 : | DPRINTF(int level, char *fmt, | ||
115 : | suxen_drol | 229 | ...) |
116 : | { | ||
117 : | suxen_drol | 252 | if ((DPRINTF_LEVEL & level)) { |
118 : | va_list args; | ||
119 : | char buf[DPRINTF_BUF_SZ]; | ||
120 : | suxen_drol | 229 | |
121 : | suxen_drol | 252 | va_start(args, fmt); |
122 : | vsprintf(buf, fmt, args); | ||
123 : | fprintf(stdout, "%s\n", buf); | ||
124 : | } | ||
125 : | suxen_drol | 229 | } |
126 : | |||
127 : | chl | 37 | #ifdef _DEBUG |
128 : | |||
129 : | Isibaar | 3 | #include <stdio.h> |
130 : | edgomez | 78 | #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 | 3 | #define DEBUG8(S,A,B,C,D,E,F,G,H) |
136 : | h | 108 | #define DEBUGCBR(A,B,C) fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)) |
137 : | chl | 37 | #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 | 108 | #define DEBUGCBR(A,B,C) |
144 : | chl | 37 | #endif |
145 : | Isibaar | 3 | |
146 : | #if defined(LINUX) | ||
147 : | |||
148 : | #include <stdint.h> | ||
149 : | |||
150 : | canard | 73 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
151 : | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ | ||
152 : | Isibaar | 209 | type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1)) |
153 : | canard | 73 | |
154 : | Isibaar | 3 | #else |
155 : | |||
156 : | knhor | 129 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
157 : | edgomez | 78 | __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)] |
158 : | |||
159 : | #define int8_t char | ||
160 : | #define uint8_t unsigned char | ||
161 : | #define int16_t short | ||
162 : | Isibaar | 3 | #define uint16_t unsigned short |
163 : | edgomez | 78 | #define int32_t int |
164 : | Isibaar | 3 | #define uint32_t unsigned int |
165 : | edgomez | 78 | #define int64_t long long |
166 : | Isibaar | 3 | #define uint64_t unsigned long long |
167 : | |||
168 : | #endif | ||
169 : | |||
170 : | |||
171 : | // needed for bitstream.h | ||
172 : | canard | 45 | #ifdef ARCH_PPC |
173 : | edgomez | 195 | #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
174 : | canard | 45 | "r" (&(a)), "m" (a)); |
175 : | edgomez | 195 | #define EMMS() |
176 : | canard | 89 | |
177 : | edgomez | 195 | static __inline unsigned long |
178 : | get_tbl(void) | ||
179 : | { | ||
180 : | unsigned long tbl; | ||
181 : | asm volatile ("mftb %0":"=r" (tbl)); | ||
182 : | |||
183 : | return tbl; | ||
184 : | } | ||
185 : | static __inline unsigned long | ||
186 : | get_tbu(void) | ||
187 : | { | ||
188 : | unsigned long tbl; | ||
189 : | asm volatile ("mftbu %0":"=r" (tbl)); | ||
190 : | |||
191 : | return tbl; | ||
192 : | } | ||
193 : | static __inline int64_t | ||
194 : | read_counter() | ||
195 : | { | ||
196 : | unsigned long tb, tu; | ||
197 : | |||
198 : | do { | ||
199 : | tu = get_tbu(); | ||
200 : | tb = get_tbl(); | ||
201 : | } while (tb != get_tbl()); | ||
202 : | return (((int64_t) tu) << 32) | (int64_t) tb; | ||
203 : | } | ||
204 : | Isibaar | 209 | |
205 : | #define ptr_t uint32_t | ||
206 : | |||
207 : | #define CACHE_LINE 16 | ||
208 : | |||
209 : | #elif defined(ARCH_IA64) | ||
210 : | |||
211 : | #define ptr_t uint64_t | ||
212 : | |||
213 : | #define CACHE_LINE 32 | ||
214 : | |||
215 : | #define EMMS() | ||
216 : | |||
217 : | // needed for bitstream.h | ||
218 : | #define BSWAP(a) \ | ||
219 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
220 : | |||
221 : | // rdtsc command most likely not supported, | ||
222 : | // so just dummy code here | ||
223 : | static __inline int64_t read_counter() { | ||
224 : | return 0; | ||
225 : | } | ||
226 : | |||
227 : | canard | 45 | #else |
228 : | edgomez | 195 | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
229 : | #define EMMS() __asm__("emms\n\t") | ||
230 : | Isibaar | 3 | |
231 : | edgomez | 78 | |
232 : | Isibaar | 3 | // needed for timer.c |
233 : | edgomez | 195 | static __inline int64_t |
234 : | read_counter() | ||
235 : | { | ||
236 : | int64_t ts; | ||
237 : | uint32_t ts1, ts2; | ||
238 : | Isibaar | 3 | |
239 : | edgomez | 195 | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), |
240 : | "=d"(ts2)); | ||
241 : | Isibaar | 3 | |
242 : | edgomez | 195 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
243 : | Isibaar | 3 | |
244 : | edgomez | 195 | return ts; |
245 : | Isibaar | 3 | } |
246 : | |||
247 : | Isibaar | 209 | #define ptr_t uint32_t |
248 : | |||
249 : | #define CACHE_LINE 16 | ||
250 : | |||
251 : | edgomez | 78 | #endif |
252 : | |||
253 : | edgomez | 195 | #else // OTHER OS |
254 : | Isibaar | 3 | |
255 : | suxen_drol | 229 | |
256 : | #include <stdio.h> | ||
257 : | #include <stdarg.h> | ||
258 : | suxen_drol | 252 | |
259 : | static __inline void | ||
260 : | DPRINTF(int level, char *fmt, ...) | ||
261 : | suxen_drol | 229 | { |
262 : | suxen_drol | 252 | if ((DPRINTF_LEVEL & level)) { |
263 : | suxen_drol | 229 | |
264 : | suxen_drol | 252 | va_list args; |
265 : | char buf[DPRINTF_BUF_SZ]; | ||
266 : | |||
267 : | va_start(args, fmt); | ||
268 : | vsprintf(buf, fmt, args); | ||
269 : | fprintf(stdout, "%s\n", buf); | ||
270 : | } | ||
271 : | suxen_drol | 229 | } |
272 : | |||
273 : | |||
274 : | Isibaar | 3 | #define DEBUG(S) |
275 : | #define DEBUG1(S,I) | ||
276 : | #define DEBUG2(X,A,B) | ||
277 : | #define DEBUG3(X,A,B,C) | ||
278 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
279 : | h | 108 | #define DEBUGCBR(A,B,C) |
280 : | Isibaar | 3 | |
281 : | #include <inttypes.h> | ||
282 : | |||
283 : | #define EMMS() | ||
284 : | |||
285 : | // needed for bitstream.h | ||
286 : | #define BSWAP(a) \ | ||
287 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
288 : | |||
289 : | // rdtsc command most likely not supported, | ||
290 : | // so just dummy code here | ||
291 : | edgomez | 195 | static __inline int64_t |
292 : | read_counter() | ||
293 : | { | ||
294 : | Isibaar | 3 | return 0; |
295 : | } | ||
296 : | |||
297 : | Isibaar | 209 | #define ptr_t uint32_t |
298 : | |||
299 : | Isibaar | 42 | #define CACHE_LINE 16 |
300 : | #define CACHE_ALIGN | ||
301 : | |||
302 : | Isibaar | 3 | #endif |
303 : | |||
304 : | edgomez | 195 | #endif // _PORTAB_H_ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |