[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.18, Wed Jun 12 20:38:40 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    
76          __asm {          __asm {
77                  rdtsc          rdtsc mov ts1, eax mov ts2, edx}
                 mov  ts1, eax  
                 mov  ts2, edx  
         }  
78    
79          ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);          ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
80    
81          return ts;          return ts;
82  }  }
83    
84  #elif defined(LINUX) || defined(DJGPP)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
85    
86    #ifdef _DEBUG
87    
88  #include <stdio.h>  #include <stdio.h>
89  #define DEBUG_WHERE             stdout  #define DEBUG_WHERE             stdout
# Line 59  Line 92 
92  #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))
93  #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))
94  #define DEBUG8(S,A,B,C,D,E,F,G,H)  #define DEBUG8(S,A,B,C,D,E,F,G,H)
95    #define DEBUGCBR(A,B,C)           fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C))
96    #else
97    #define DEBUG(S)
98    #define DEBUG1(S,I)
99    #define DEBUG2(X,A,B)
100    #define DEBUG3(X,A,B,C)
101    #define DEBUG8(X,A,B,C,D,E,F,G,H)
102    #define DEBUGCBR(A,B,C)
103    #endif
104    
105    #define CACHE_LINE  16
106    
107  #if defined(LINUX)  #if defined(LINUX)
108    
109  #include <stdint.h>  #include <stdint.h>
110    
111    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
112            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
113            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
114    
115  #else  #else
116    
117    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
118            __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]
119    
120  #define int8_t char  #define int8_t char
121  #define uint8_t unsigned char  #define uint8_t unsigned char
122  #define int16_t short  #define int16_t short
# Line 77  Line 128 
128    
129  #endif  #endif
130    
 #define EMMS() __asm__("emms\n\t")  
131    
132  // needed for bitstream.h  // needed for bitstream.h
133    #ifdef ARCH_PPC
134    #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \
135                    "r" (&(a)), "m" (a));
136    #define EMMS()
137    
138    static __inline unsigned long
139    get_tbl(void)
140    {
141            unsigned long tbl;
142            asm volatile ("mftb %0":"=r" (tbl));
143    
144            return tbl;
145    }
146    static __inline unsigned long
147    get_tbu(void)
148    {
149            unsigned long tbl;
150            asm volatile ("mftbu %0":"=r" (tbl));
151    
152            return tbl;
153    }
154    static __inline int64_t
155    read_counter()
156    {
157            unsigned long tb, tu;
158    
159            do {
160                    tu = get_tbu();
161                    tb = get_tbl();
162            } while (tb != get_tbl());
163            return (((int64_t) tu) << 32) | (int64_t) tb;
164    }
165    #else
166  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
167    #define EMMS() __asm__("emms\n\t")
168    
169    
170  // needed for timer.c  // needed for timer.c
171  static __inline int64_t read_counter() {  static __inline int64_t
172    read_counter()
173    {
174      int64_t ts;      int64_t ts;
175      uint32_t ts1, ts2;      uint32_t ts1, ts2;
176    
177      __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2));          __asm__ __volatile__("rdtsc\n\t":"=a"(ts1),
178                                                     "=d"(ts2));
179    
180      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
181    
182      return ts;      return ts;
183  }  }
184    
185    #endif
186    
187  #else // OTHER OS  #else // OTHER OS
188    
189  #define DEBUG(S)  #define DEBUG(S)
# Line 101  Line 191 
191  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
192  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
193  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
194    #define DEBUGCBR(A,B,C)
195    
196  #include <inttypes.h>  #include <inttypes.h>
197    
# Line 112  Line 203 
203    
204  // rdtsc command most likely not supported,  // rdtsc command most likely not supported,
205  // so just dummy code here  // so just dummy code here
206  static __inline int64_t read_counter() {  static __inline int64_t
207    read_counter()
208    {
209          return 0;          return 0;
210  }  }
211    
212    #define CACHE_LINE  16
213    #define CACHE_ALIGN
214    
215  #endif  #endif
216    
217  #endif // _PORTAB_H_  #endif // _PORTAB_H_
   

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

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