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

Diff of /xvidcore/src/portab.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Sat Mar 16 14:15:10 2002 UTC revision 1.21, Fri Jun 14 13:29:07 2002 UTC
# Line 4  Line 4 
4  #if defined(WIN32)  #if defined(WIN32)
5    
6  #include <windows.h>  #include <windows.h>
7    #include <stdio.h>
8    
9    
10    #define DPRINTF_BUF_SZ  1024
11    static void
12    dprintf(char *fmt,
13                    ...)
14    {
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    
25    #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  #ifdef _DEBUG  #ifdef _DEBUG
28  #define DEBUG(S) OutputDebugString((S));  #define DEBUG(S) OutputDebugString((S));
29  #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); }  #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); }  #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); }  #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); }
32    #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  #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); }  #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  #else  #else
35  #define DEBUG(S)  #define DEBUG(S)
36  #define DEBUG1(S,I)  #define DEBUG1(S,I)
37  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
38  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
39    #define DEBUG4(X,A,B,C,D)
40  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
41  #endif  #endif
42    
# Line 28  Line 49 
49  #define uint32_t unsigned int  #define uint32_t unsigned int
50  #define int64_t __int64  #define int64_t __int64
51  #define uint64_t unsigned __int64  #define uint64_t unsigned __int64
52    #define ptr_t uint32_t
53    
54  #define EMMS() __asm {emms}  #define EMMS() __asm {emms}
55    
56    #define CACHE_LINE  16
57    
58    #if _MSC_VER <= 1200
59    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
60            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
61            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
62    #else
63    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
64            __declspec(align(alignment)) type name[(sizex)*(sizey)]
65    #endif
66    
67  // needed for bitstream.h  // needed for bitstream.h
68  #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax  #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
69    
70  // needed for timer.c  // needed for timer.c
71  static __inline int64_t read_counter() {  static __inline int64_t
72    read_counter()
73    {
74          int64_t ts;          int64_t ts;
75          uint32_t ts1, ts2;          uint32_t ts1, ts2;
76    
# Line 50  Line 85 
85          return ts;          return ts;
86  }  }
87    
88  #elif defined(LINUX) || defined(DJGPP)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
89    
90    #ifdef _DEBUG
91    
92  #include <stdio.h>  #include <stdio.h>
93  #define DEBUG_WHERE             stdout  #define DEBUG_WHERE             stdout
# Line 59  Line 96 
96  #define DEBUG2(S,A,B)   fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B))  #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))  #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C))
98  #define DEBUG8(S,A,B,C,D,E,F,G,H)  #define DEBUG8(S,A,B,C,D,E,F,G,H)
99    #define DEBUGCBR(A,B,C)           fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C))
100    #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    #define DEBUGCBR(A,B,C)
107    #endif
108    
109  #if defined(LINUX)  #if defined(LINUX)
110    
111  #include <stdint.h>  #include <stdint.h>
112    
113    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
114            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
115            type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1))
116    
117  #else  #else
118    
119    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
120            __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]
121    
122  #define int8_t char  #define int8_t char
123  #define uint8_t unsigned char  #define uint8_t unsigned char
124  #define int16_t short  #define int16_t short
# Line 77  Line 130 
130    
131  #endif  #endif
132    
 #define EMMS() __asm__("emms\n\t")  
133    
134  // needed for bitstream.h  // needed for bitstream.h
135    #ifdef ARCH_PPC
136    #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \
137                    "r" (&(a)), "m" (a));
138    #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    
161            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    
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    #else
191  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
192    #define EMMS() __asm__("emms\n\t")
193    
194    
195  // needed for timer.c  // needed for timer.c
196  static __inline int64_t read_counter() {  static __inline int64_t
197    read_counter()
198    {
199      int64_t ts;      int64_t ts;
200      uint32_t ts1, ts2;      uint32_t ts1, ts2;
201    
202      __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2));          __asm__ __volatile__("rdtsc\n\t":"=a"(ts1),
203                                                     "=d"(ts2));
204    
205      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
206    
207      return ts;      return ts;
208  }  }
209    
210    #define ptr_t   uint32_t
211    
212    #define CACHE_LINE 16
213    
214    #endif
215    
216  #else // OTHER OS  #else // OTHER OS
217    
218  #define DEBUG(S)  #define DEBUG(S)
# Line 101  Line 220 
220  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
221  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
222  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
223    #define DEBUGCBR(A,B,C)
224    
225  #include <inttypes.h>  #include <inttypes.h>
226    
# Line 112  Line 232 
232    
233  // rdtsc command most likely not supported,  // rdtsc command most likely not supported,
234  // so just dummy code here  // so just dummy code here
235  static __inline int64_t read_counter() {  static __inline int64_t
236    read_counter()
237    {
238          return 0;          return 0;
239  }  }
240    
241    #define ptr_t uint32_t
242    
243    #define CACHE_LINE  16
244    #define CACHE_ALIGN
245    
246  #endif  #endif
247    
248  #endif // _PORTAB_H_  #endif // _PORTAB_H_
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.21

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