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