[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.18, Wed Jun 12 20:38:40 2002 UTC revision 1.24, Wed Jul 10 14:05:08 2002 UTC
# Line 1  Line 1 
1  #ifndef _PORTAB_H_  #ifndef _PORTAB_H_
2  #define _PORTAB_H_  #define _PORTAB_H_
3    
4    
5    // debug level masks
6    #define DPRINTF_ERROR           0x00000001
7    #define DPRINTF_STARTCODE       0x00000002
8    #define DPRINTF_HEADER          0x00000004
9    #define DPRINTF_TIMECODE        0x00000008
10    #define DPRINTF_MB                      0x00000010
11    #define DPRINTF_COEFF           0x00000020
12    #define DPRINTF_MV                      0x00000040
13    #define DPRINTF_DEBUG           0x80000000
14    
15    // debug level
16    #define DPRINTF_LEVEL           0
17    
18    
19    #define DPRINTF_BUF_SZ  1024
20    
21    
22  #if defined(WIN32)  #if defined(WIN32)
23    
24  #include <windows.h>  #include <windows.h>
25  #include <stdio.h>  #include <stdio.h>
26    
27    static __inline void
28  #define DPRINTF_BUF_SZ  1024  DPRINTF(int level, char *fmt,
 static void  
 dprintf(char *fmt,  
29                  ...)                  ...)
30  {  {
31            if ((DPRINTF_LEVEL & level))
32            {
33          va_list args;          va_list args;
34          char buf[DPRINTF_BUF_SZ];          char buf[DPRINTF_BUF_SZ];
35    
# Line 19  Line 37 
37          vsprintf(buf, fmt, args);          vsprintf(buf, fmt, args);
38          OutputDebugString(buf);          OutputDebugString(buf);
39          fprintf(stdout, "%s\n", buf);          fprintf(stdout, "%s\n", buf);
40                    fflush(stdout);
41            }
42  }  }
43    
44    
# Line 49  Line 69 
69  #define uint32_t unsigned int  #define uint32_t unsigned int
70  #define int64_t __int64  #define int64_t __int64
71  #define uint64_t unsigned __int64  #define uint64_t unsigned __int64
72    #define ptr_t uint32_t
73    
74  #define EMMS() __asm {emms}  #define EMMS() __asm {emms}
75    
# Line 74  Line 95 
95          uint32_t ts1, ts2;          uint32_t ts1, ts2;
96    
97          __asm {          __asm {
98          rdtsc mov ts1, eax mov ts2, edx}                  rdtsc
99                    mov ts1, eax
100                    mov ts2, edx
101            }
102    
103          ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);          ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
104    
# Line 83  Line 107 
107    
108  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
109    
110    #include <stdio.h>
111    #include <stdarg.h>
112    
113    static __inline void
114    DPRINTF(int level, char *fmt,
115                    ...)
116    {
117            if ((DPRINTF_LEVEL & level)) {
118                    va_list args;
119                    char buf[DPRINTF_BUF_SZ];
120    
121                    va_start(args, fmt);
122                    vsprintf(buf, fmt, args);
123                    fprintf(stdout, "%s\n", buf);
124            }
125    }
126    
127  #ifdef _DEBUG  #ifdef _DEBUG
128    
129  #include <stdio.h>  #include <stdio.h>
# Line 102  Line 143 
143  #define DEBUGCBR(A,B,C)  #define DEBUGCBR(A,B,C)
144  #endif  #endif
145    
 #define CACHE_LINE  16  
   
146  #if defined(LINUX)  #if defined(LINUX)
147    
148  #include <stdint.h>  #include <stdint.h>
149    
150  #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \  #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
151          type name##_storage[(sizex)*(sizey)+(alignment)-1]; \          type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
152          type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))          type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1))
153    
154  #else  #else
155    
# Line 162  Line 201 
201          } while (tb != get_tbl());          } while (tb != get_tbl());
202          return (((int64_t) tu) << 32) | (int64_t) tb;          return (((int64_t) tu) << 32) | (int64_t) tb;
203  }  }
204    
205    #define ptr_t   uint32_t
206    
207    #define CACHE_LINE 16
208    
209    #elif defined(ARCH_IA64)
210    
211    #define ptr_t   uint64_t
212    
213    #define CACHE_LINE 32
214    
215    #define EMMS()
216    
217    // needed for bitstream.h
218    #define BSWAP(a)  __asm__ __volatile__ ("mux1 %1 = %0, @rev" \
219                            ";;" \
220                            "shr.u %1 = %1, 32" : "=r" (a) : "r" (a));
221    
222    // rdtsc replacement for ia64
223    static __inline int64_t read_counter() {
224            unsigned long result;
225    
226    //      __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
227    //      while (__builtin_expect ((int) result == -1, 0))
228                    __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
229            return result;
230    
231    }
232    
233  #else  #else
234  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )  #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
235  #define EMMS() __asm__("emms\n\t")  #define EMMS() __asm__("emms\n\t")
# Line 182  Line 250 
250          return ts;          return ts;
251  }  }
252    
253    #define ptr_t   uint32_t
254    
255    #define CACHE_LINE 16
256    
257  #endif  #endif
258    
259  #else                                                   // OTHER OS  #else                                                   // OTHER OS
260    
261    
262    #include <stdio.h>
263    #include <stdarg.h>
264    
265    static __inline void
266    DPRINTF(int level, char *fmt, ...)
267    {
268            if ((DPRINTF_LEVEL & level)) {
269    
270                    va_list args;
271                    char buf[DPRINTF_BUF_SZ];
272    
273                    va_start(args, fmt);
274                    vsprintf(buf, fmt, args);
275                    fprintf(stdout, "%s\n", buf);
276            }
277    }
278    
279    
280  #define DEBUG(S)  #define DEBUG(S)
281  #define DEBUG1(S,I)  #define DEBUG1(S,I)
282  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
# Line 209  Line 300 
300          return 0;          return 0;
301  }  }
302    
303    #define ptr_t uint32_t
304    
305  #define CACHE_LINE  16  #define CACHE_LINE  16
306  #define CACHE_ALIGN  #define CACHE_ALIGN
307    

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

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