[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.19, Fri Jun 14 12:26:06 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 31  Line 52 
52    
53  #define EMMS() __asm {emms}  #define EMMS() __asm {emms}
54    
55    #define CACHE_LINE  16
56    
57    #if _MSC_VER <= 1200
58    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
59            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
60            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
61    #else
62    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
63            __declspec(align(alignment)) type name[(sizex)*(sizey)]
64    #endif
65    
66  // needed for bitstream.h  // needed for bitstream.h
67  #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
68    
69  // needed for timer.c  // needed for timer.c
70  static __inline int64_t read_counter() {  static __inline int64_t
71    read_counter()
72    {
73          int64_t ts;          int64_t ts;
74          uint32_t ts1, ts2;          uint32_t ts1, ts2;
75    
# Line 50  Line 84 
84          return ts;          return ts;
85  }  }
86    
87  #elif defined(LINUX) || defined(DJGPP)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
88    
89    #ifdef _DEBUG
90    
91  #include <stdio.h>  #include <stdio.h>
92  #define DEBUG_WHERE             stdout  #define DEBUG_WHERE             stdout
# Line 59  Line 95 
95  #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))
96  #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))
97  #define DEBUG8(S,A,B,C,D,E,F,G,H)  #define DEBUG8(S,A,B,C,D,E,F,G,H)
98    #define DEBUGCBR(A,B,C)           fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C))
99    #else
100    #define DEBUG(S)
101    #define DEBUG1(S,I)
102    #define DEBUG2(X,A,B)
103    #define DEBUG3(X,A,B,C)
104    #define DEBUG8(X,A,B,C,D,E,F,G,H)
105    #define DEBUGCBR(A,B,C)
106    #endif
107    
108    #define CACHE_LINE  16
109    
110  #if defined(LINUX)  #if defined(LINUX)
111    
112  #include <stdint.h>  #include <stdint.h>
113    
114    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
115            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
116            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
117    
118  #else  #else
119    
120    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
121            __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]
122    
123  #define int8_t char  #define int8_t char
124  #define uint8_t unsigned char  #define uint8_t unsigned char
125  #define int16_t short  #define int16_t short
# Line 77  Line 131 
131    
132  #endif  #endif
133    
 #define EMMS() __asm__("emms\n\t")  
134    
135  // needed for bitstream.h  // needed for bitstream.h
136    #ifdef ARCH_PPC
137    #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \
138                    "r" (&(a)), "m" (a));
139    #define EMMS()
140    
141    static __inline unsigned long
142    get_tbl(void)
143    {
144            unsigned long tbl;
145            asm volatile ("mftb %0":"=r" (tbl));
146    
147            return tbl;
148    }
149    static __inline unsigned long
150    get_tbu(void)
151    {
152            unsigned long tbl;
153            asm volatile ("mftbu %0":"=r" (tbl));
154    
155            return tbl;
156    }
157    static __inline int64_t
158    read_counter()
159    {
160            unsigned long tb, tu;
161    
162            do {
163                    tu = get_tbu();
164                    tb = get_tbl();
165            } while (tb != get_tbl());
166            return (((int64_t) tu) << 32) | (int64_t) tb;
167    }
168    #else
169  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
170    #define EMMS() __asm__("emms\n\t")
171    
172    
173  // needed for timer.c  // needed for timer.c
174  static __inline int64_t read_counter() {  static __inline int64_t
175    read_counter()
176    {
177      int64_t ts;      int64_t ts;
178      uint32_t ts1, ts2;      uint32_t ts1, ts2;
179    
180      __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2));          __asm__ __volatile__("rdtsc\n\t":"=a"(ts1),
181                                                     "=d"(ts2));
182    
183      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
184    
185      return ts;      return ts;
186  }  }
187    
188    #endif
189    
190  #else // OTHER OS  #else // OTHER OS
191    
192  #define DEBUG(S)  #define DEBUG(S)
# Line 101  Line 194 
194  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
195  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
196  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
197    #define DEBUGCBR(A,B,C)
198    
199  #include <inttypes.h>  #include <inttypes.h>
200    
# Line 112  Line 206 
206    
207  // rdtsc command most likely not supported,  // rdtsc command most likely not supported,
208  // so just dummy code here  // so just dummy code here
209  static __inline int64_t read_counter() {  static __inline int64_t
210    read_counter()
211    {
212          return 0;          return 0;
213  }  }
214    
215    #define CACHE_LINE  16
216    #define CACHE_ALIGN
217    
218  #endif  #endif
219    
220  #endif // _PORTAB_H_  #endif // _PORTAB_H_
   

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

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