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

Annotation of /xvidcore/src/portab.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (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 :     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 : Isibaar 1.1
23 : 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); }
24 :    
25 : h 1.2 #ifdef _DEBUG
26 : Isibaar 1.1 #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 1.2 #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 1.1
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 1.4 #define CACHE_LINE 16
52 : edgomez 1.9
53 : suxen_drol 1.7 #if _MSC_VER <= 1200
54 : h 1.10 #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
55 : edgomez 1.9 type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
56 :     type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
57 : suxen_drol 1.7 #else
58 : h 1.10 #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
59 : edgomez 1.11 __declspec(align(alignment)) type name[(sizex)*(sizey)]
60 : suxen_drol 1.7 #endif
61 : Isibaar 1.4
62 : Isibaar 1.1 // 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 1.15 #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
82 : Isibaar 1.1
83 : chl 1.3 #ifdef _DEBUG
84 :    
85 : Isibaar 1.1 #include <stdio.h>
86 : edgomez 1.9 #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 1.1 #define DEBUG8(S,A,B,C,D,E,F,G,H)
92 : h 1.14 #define DEBUGCBR(A,B,C) fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C))
93 : chl 1.3 #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 1.14 #define DEBUGCBR(A,B,C)
100 : chl 1.3 #endif
101 : Isibaar 1.1
102 : Isibaar 1.4 #define CACHE_LINE 16
103 :    
104 : Isibaar 1.1 #if defined(LINUX)
105 :    
106 :     #include <stdint.h>
107 :    
108 : canard 1.8 #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
109 :     type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
110 : edgomez 1.9 type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
111 : canard 1.8
112 : Isibaar 1.1 #else
113 :    
114 : knhor 1.15 #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
115 : edgomez 1.9 __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 1.1 #define uint16_t unsigned short
121 : edgomez 1.9 #define int32_t int
122 : Isibaar 1.1 #define uint32_t unsigned int
123 : edgomez 1.9 #define int64_t long long
124 : Isibaar 1.1 #define uint64_t unsigned long long
125 :    
126 :     #endif
127 :    
128 :    
129 :     // needed for bitstream.h
130 : canard 1.5 #ifdef ARCH_PPC
131 : canard 1.13 #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \
132 : canard 1.5 "r" (&(a)), "m" (a));
133 :     #define EMMS()
134 : canard 1.12
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 1.13 tu = get_tbu();
149 : canard 1.12 tb = get_tbl();
150 :     } while(tb != get_tbl());
151 :     return (((int64_t)tu) << 32) | (int64_t)tb;
152 :     }
153 : canard 1.5 #else
154 :     #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
155 :     #define EMMS() __asm__("emms\n\t")
156 : edgomez 1.9
157 : Isibaar 1.1
158 :     // 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 : edgomez 1.9
170 :     #endif
171 : Isibaar 1.1
172 :     #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 1.14 #define DEBUGCBR(A,B,C)
180 : Isibaar 1.1
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 : Isibaar 1.4
195 :     #define CACHE_LINE 16
196 :     #define CACHE_ALIGN
197 : Isibaar 1.1
198 :     #endif
199 :    
200 :     #endif // _PORTAB_H_
201 :    

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