[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.16, Thu Apr 25 06:55:00 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 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    
23    #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  #ifdef _DEBUG  #ifdef _DEBUG
26  #define DEBUG(S) OutputDebugString((S));  #define DEBUG(S) OutputDebugString((S));
# Line 31  Line 48 
48    
49  #define EMMS() __asm {emms}  #define EMMS() __asm {emms}
50    
51    #define CACHE_LINE  16
52    
53    #if _MSC_VER <= 1200
54    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
55            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
56            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
57    #else
58    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
59            __declspec(align(alignment)) type name[(sizex)*(sizey)]
60    #endif
61    
62  // needed for bitstream.h  // needed for bitstream.h
63  #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
64    
# Line 50  Line 78 
78          return ts;          return ts;
79  }  }
80    
81  #elif defined(LINUX) || defined(DJGPP)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
82    
83    #ifdef _DEBUG
84    
85  #include <stdio.h>  #include <stdio.h>
86  #define DEBUG_WHERE             stdout  #define DEBUG_WHERE             stdout
# Line 59  Line 89 
89  #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))
90  #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))
91  #define DEBUG8(S,A,B,C,D,E,F,G,H)  #define DEBUG8(S,A,B,C,D,E,F,G,H)
92    #define DEBUGCBR(A,B,C)           fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C))
93    #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    #define DEBUGCBR(A,B,C)
100    #endif
101    
102    #define CACHE_LINE  16
103    
104  #if defined(LINUX)  #if defined(LINUX)
105    
106  #include <stdint.h>  #include <stdint.h>
107    
108    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
109            type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
110            type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))
111    
112  #else  #else
113    
114    #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
115            __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]
116    
117  #define int8_t char  #define int8_t char
118  #define uint8_t unsigned char  #define uint8_t unsigned char
119  #define int16_t short  #define int16_t short
# Line 77  Line 125 
125    
126  #endif  #endif
127    
 #define EMMS() __asm__("emms\n\t")  
128    
129  // needed for bitstream.h  // needed for bitstream.h
130    #ifdef ARCH_PPC
131            #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \
132                    "r" (&(a)), "m" (a));
133            #define EMMS()
134    
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                            tu = get_tbu();
149                            tb = get_tbl();
150                    } while(tb != get_tbl());
151                    return (((int64_t)tu) << 32) | (int64_t)tb;
152            }
153    #else
154  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
155            #define EMMS() __asm__("emms\n\t")
156    
157    
158  // needed for timer.c  // needed for timer.c
159  static __inline int64_t read_counter() {  static __inline int64_t read_counter() {
# Line 94  Line 167 
167      return ts;      return ts;
168  }  }
169    
170    #endif
171    
172  #else // OTHER OS  #else // OTHER OS
173    
174  #define DEBUG(S)  #define DEBUG(S)
# Line 101  Line 176 
176  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
177  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
178  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
179    #define DEBUGCBR(A,B,C)
180    
181  #include <inttypes.h>  #include <inttypes.h>
182    
# Line 116  Line 192 
192          return 0;          return 0;
193  }  }
194    
195    #define CACHE_LINE  16
196    #define CACHE_ALIGN
197    
198  #endif  #endif
199    
200  #endif // _PORTAB_H_  #endif // _PORTAB_H_

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

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