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