[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.3, Sat Mar 16 22:28:37 2002 UTC revision 1.15, Sun Apr 21 02:30:24 2002 UTC
# Line 5  Line 5 
5    
6  #include <windows.h>  #include <windows.h>
7    
8    #define DEBUGCBR(A,B,C) { char tmp[100]; wsprintf(tmp, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)); OutputDebugString(tmp); }
9    
10  #ifdef _DEBUG  #ifdef _DEBUG
11  #define DEBUG(S) OutputDebugString((S));  #define DEBUG(S) OutputDebugString((S));
12  #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); }
# Line 31  Line 33 
33    
34  #define EMMS() __asm {emms}  #define EMMS() __asm {emms}
35    
36    #define CACHE_LINE  16
37    
38    #if _MSC_VER <= 1200
39    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
40            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
41            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
42    #else
43    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
44            __declspec(align(alignment)) type name[(sizex)*(sizey)]
45    #endif
46    
47  // needed for bitstream.h  // needed for bitstream.h
48  #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
49    
# Line 50  Line 63 
63          return ts;          return ts;
64  }  }
65    
66  #elif defined(LINUX) || defined(DJGPP)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
   
67    
68  #ifdef _DEBUG  #ifdef _DEBUG
69    
# Line 62  Line 74 
74  #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))
75  #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))
76  #define DEBUG8(S,A,B,C,D,E,F,G,H)  #define DEBUG8(S,A,B,C,D,E,F,G,H)
77    #define DEBUGCBR(A,B,C)           fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C))
78  #else  #else
79  #define DEBUG(S)  #define DEBUG(S)
80  #define DEBUG1(S,I)  #define DEBUG1(S,I)
81  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
82  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
83  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
84    #define DEBUGCBR(A,B,C)
85  #endif  #endif
86    
87    #define CACHE_LINE  16
88    
89  #if defined(LINUX)  #if defined(LINUX)
90    
91  #include <stdint.h>  #include <stdint.h>
92    
93    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
94            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
95            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
96    
97  #else  #else
98    
99    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
100            __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]
101    
102  #define int8_t char  #define int8_t char
103  #define uint8_t unsigned char  #define uint8_t unsigned char
104  #define int16_t short  #define int16_t short
# Line 87  Line 110 
110    
111  #endif  #endif
112    
 #define EMMS() __asm__("emms\n\t")  
113    
114  // needed for bitstream.h  // needed for bitstream.h
115    #ifdef ARCH_PPC
116            #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \
117                    "r" (&(a)), "m" (a));
118            #define EMMS()
119    
120            static __inline unsigned long get_tbl(void) {
121                    unsigned long tbl;
122                    asm volatile("mftb %0" : "=r" (tbl));
123                    return tbl;
124            }
125            static __inline unsigned long get_tbu(void) {
126                    unsigned long tbl;
127                    asm volatile("mftbu %0" : "=r" (tbl));
128                    return tbl;
129            }
130            static __inline int64_t read_counter() {
131                    unsigned long tb, tu;
132                    do {
133                            tu = get_tbu();
134                            tb = get_tbl();
135                    } while(tb != get_tbl());
136                    return (((int64_t)tu) << 32) | (int64_t)tb;
137            }
138    #else
139  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
140            #define EMMS() __asm__("emms\n\t")
141    
142    
143  // needed for timer.c  // needed for timer.c
144  static __inline int64_t read_counter() {  static __inline int64_t read_counter() {
# Line 104  Line 152 
152      return ts;      return ts;
153  }  }
154    
155    #endif
156    
157  #else // OTHER OS  #else // OTHER OS
158    
159  #define DEBUG(S)  #define DEBUG(S)
# Line 111  Line 161 
161  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
162  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
163  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
164    #define DEBUGCBR(A,B,C)
165    
166  #include <inttypes.h>  #include <inttypes.h>
167    
# Line 126  Line 177 
177          return 0;          return 0;
178  }  }
179    
180    #define CACHE_LINE  16
181    #define CACHE_ALIGN
182    
183  #endif  #endif
184    
185  #endif // _PORTAB_H_  #endif // _PORTAB_H_

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.15

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