[cvs] / xvidcore / src / portab.h Repository:
ViewVC logotype

Annotation of /xvidcore/src/portab.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (view) (download)

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

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4