[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.26.2.8, Sat Feb 15 08:39:17 2003 UTC revision 1.34, Sat Oct 19 12:20:33 2002 UTC
# Line 7  Line 7 
7   *               2002 Peter Ross <pross@xvid.org>   *               2002 Peter Ross <pross@xvid.org>
8   *               2002 Edouard Gomez <ed.gomez@wanadoo.fr>   *               2002 Edouard Gomez <ed.gomez@wanadoo.fr>
9   *   *
10   *  This file is part of XviD, a free MPEG-4 video encoder/decoder   *  This program is an implementation of a part of one or more MPEG-4
11     *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending
12     *  to use this software module in hardware or software products are
13     *  advised that its use may infringe existing patents or copyrights, and
14     *  any such use would be at such party's own risk.  The original
15     *  developer of this software module and his/her company, and subsequent
16     *  editors and their companies, will have no liability for use of this
17     *  software or modifications or derivatives thereof.
18   *   *
19   *  XviD is free software; you can redistribute it and/or modify it   *  This program is free software ; you can redistribute it and/or modify
20   *  under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
21   *  the Free Software Foundation; either version 2 of the License, or   *  the Free Software Foundation; either version 2 of the License, or
22   *  (at your option) any later version.   *  (at your option) any later version.
23   *   *
# Line 23  Line 30 
30   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
31   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
32   *   *
  *  Under section 8 of the GNU General Public License, the copyright  
  *  holders of XVID explicitly forbid distribution in the following  
  *  countries:  
  *  
  *    - Japan  
  *    - United States of America  
  *  
  *  Linking XviD statically or dynamically with other modules is making a  
  *  combined work based on XviD.  Thus, the terms and conditions of the  
  *  GNU General Public License cover the whole combination.  
  *  
  *  As a special exception, the copyright holders of XviD give you  
  *  permission to link XviD with independent modules that communicate with  
  *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the  
  *  license terms of these independent modules, and to copy and distribute  
  *  the resulting combined work under terms of your choice, provided that  
  *  every copy of the combined work is accompanied by a complete copy of  
  *  the source code of XviD (the version of XviD used to produce the  
  *  combined work), being distributed under the terms of the GNU General  
  *  Public License plus this exception.  An independent module is a module  
  *  which is not derived from or based on XviD.  
  *  
  *  Note that people who make modified versions of XviD are not obligated  
  *  to grant this special exception for their modified versions; it is  
  *  their choice whether to do so.  The GNU General Public License gives  
  *  permission to release a modified version without this exception; this  
  *  exception also makes it possible to release a modified version which  
  *  carries forward this exception.  
  *  
33   * $Id$   * $Id$
34   *   *
35   ****************************************************************************/   ****************************************************************************/
# Line 71  Line 49 
49  #define DPRINTF_MB                      0x00000010  #define DPRINTF_MB                      0x00000010
50  #define DPRINTF_COEFF           0x00000020  #define DPRINTF_COEFF           0x00000020
51  #define DPRINTF_MV                      0x00000040  #define DPRINTF_MV                      0x00000040
 #define DPRINTF_RC                      0x00000080  
52  #define DPRINTF_DEBUG           0x80000000  #define DPRINTF_DEBUG           0x80000000
53    
54  /* debug level for this library */  /* debug level for this library */
55  #ifdef _DEBUG  #define DPRINTF_LEVEL           0
 #define DPRINTF_LEVEL           (DPRINTF_RC|0x0000007F)  
 #else  
 #define DPRINTF_LEVEL           DPRINTF_RC  
 #endif  
56    
57  /* Buffer size for non C99 compliant compilers (msvc) */  /* Buffer size for non C99 compliant compilers (msvc) */
58  #define DPRINTF_BUF_SZ  1024  #define DPRINTF_BUF_SZ  1024
# Line 101  Line 74 
74   | msvc (lacks such a header file)   | msvc (lacks such a header file)
75   *---------------------------------------------------------------------------*/   *---------------------------------------------------------------------------*/
76    
77  #elif defined(_MSC_VER) || defined (__WATCOMC__)  #elif defined(_MSC_VER)
78  #    define int8_t   char  #    define int8_t   char
79  #    define uint8_t  unsigned char  #    define uint8_t  unsigned char
80  #    define int16_t  short  #    define int16_t  short
# Line 115  Line 88 
88   | Fallback when using gcc   | Fallback when using gcc
89   *---------------------------------------------------------------------------*/   *---------------------------------------------------------------------------*/
90    
91  #elif defined(__GNUC__) || defined(__ICC)  #elif defined(__GNUC__)
92    
93  #    define int8_t   char  #    define int8_t   char
94  #    define uint8_t  unsigned char  #    define uint8_t  unsigned char
# Line 145  Line 118 
118  #    define CACHE_LINE  32  #    define CACHE_LINE  32
119  #    define ptr_t uint64_t  #    define ptr_t uint64_t
120  #else  #else
121  /* todo: fix cache_line 0 operation */  #    error Architecture not supported.
 #    define CACHE_LINE  16  
 #    define ptr_t uint32_t  
122  #endif  #endif
123    
124  /*****************************************************************************  /*****************************************************************************
# Line 167  Line 138 
138  #include <windows.h>  #include <windows.h>
139  #include <stdio.h>  #include <stdio.h>
140    
         /* non-ansi function mapping */  
 #       define snprintf _snprintf  
 #       define vsnprintf _vsnprintf  
   
141      /*      /*
142       * This function must be declared/defined all the time because MSVC does       * This function must be declared/defined all the time because MSVC does
143       * not support C99 variable arguments macros       * not support C99 variable arguments macros
# Line 202  Line 169 
169   *---------------------------------------------------------------------------*/   *---------------------------------------------------------------------------*/
170  #    if defined(ARCH_X86)  #    if defined(ARCH_X86)
171  #        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
172    #        define EMMS() __asm {emms}
173    
174               static __inline int64_t read_counter(void)               static __inline int64_t read_counter(void)
175               {               {
# Line 220  Line 188 
188   | msvc unknown architecture   | msvc unknown architecture
189   *---------------------------------------------------------------------------*/   *---------------------------------------------------------------------------*/
190  #    else  #    else
191  /* ANSI C version of BSWAP */  #        error Architecture not supported.
 #define BSWAP(x) \  
  x = ((((x) & 0xff000000) >> 24) | \  
      (((x) & 0x00ff0000) >>  8) | \  
      (((x) & 0x0000ff00) <<  8) | \  
      (((x) & 0x000000ff) << 24))  
   
192  #    endif  #    endif
193    
194    
# Line 236  Line 198 
198   *  GNU CC compiler stuff   *  GNU CC compiler stuff
199   ****************************************************************************/   ****************************************************************************/
200    
201  #elif defined(__GNUC__) || defined(__ICC) /* Compiler test */  #elif defined(__GNUC__) /* Compiler test */
202    
203  /*----------------------------------------------------------------------------  /*----------------------------------------------------------------------------
204   | Common gcc stuff   | Common gcc stuff
# Line 272  Line 234 
234   *---------------------------------------------------------------------------*/   *---------------------------------------------------------------------------*/
235  #    if defined(ARCH_X86)  #    if defined(ARCH_X86)
236  #        define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) );  #        define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) );
237    #        define EMMS() __asm__ ("emms\n\t");
238    
239           static __inline int64_t read_counter(void)           static __inline int64_t read_counter(void)
240           {           {
# Line 288  Line 251 
251  #    elif defined(ARCH_PPC)  #    elif defined(ARCH_PPC)
252  #        define BSWAP(a) __asm__ __volatile__ \  #        define BSWAP(a) __asm__ __volatile__ \
253                  ( "lwbrx %0,0,%1; eieio" : "=r" (a) : "r" (&(a)), "m" (a));                  ( "lwbrx %0,0,%1; eieio" : "=r" (a) : "r" (&(a)), "m" (a));
254    #        define EMMS()
255    
256           static __inline unsigned long get_tbl(void)           static __inline unsigned long get_tbl(void)
257           {           {
# Line 320  Line 284 
284  #        define BSWAP(a)  __asm__ __volatile__ \  #        define BSWAP(a)  __asm__ __volatile__ \
285                  ("mux1 %1 = %0, @rev" ";;" \                  ("mux1 %1 = %0, @rev" ";;" \
286                   "shr.u %1 = %1, 32" : "=r" (a) : "r" (a));                   "shr.u %1 = %1, 32" : "=r" (a) : "r" (a));
287    #        define EMMS()
288    
289           static __inline int64_t read_counter(void) {           static __inline int64_t read_counter(void) {
290               unsigned long result;               unsigned long result;
# Line 334  Line 299 
299  #        define BSWAP(a) \  #        define BSWAP(a) \
300                  ((a) = (((a) & 0xff) << 24)  | (((a) & 0xff00) << 8) | \                  ((a) = (((a) & 0xff) << 24)  | (((a) & 0xff00) << 8) | \
301                         (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))                         (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))
302    #        define EMMS()
303    
304           static __inline int64_t read_counter(void)           static __inline int64_t read_counter(void)
305           {           {
# Line 347  Line 313 
313  #        define BSWAP(a) \  #        define BSWAP(a) \
314                  ((a) = (((a) & 0xff) << 24)  | (((a) & 0xff00) << 8) | \                  ((a) = (((a) & 0xff) << 24)  | (((a) & 0xff00) << 8) | \
315                         (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))                         (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))
316    #        define EMMS()
317    
318           static __inline int64_t read_counter(void)           static __inline int64_t read_counter(void)
319           {           {
# Line 357  Line 324 
324   | XviD + gcc unsupported Architecture   | XviD + gcc unsupported Architecture
325   *---------------------------------------------------------------------------*/   *---------------------------------------------------------------------------*/
326  #    else  #    else
327  /* ANSI C version of BSWAP */  #        error Architecture not supported.
 #define BSWAP(x) \  
  x = ((((x) & 0xff000000) >> 24) | \  
      (((x) & 0x00ff0000) >>  8) | \  
      (((x) & 0x0000ff00) <<  8) | \  
      (((x) & 0x000000ff) << 24))  
   
328  #    endif /* Architecture checking */  #    endif /* Architecture checking */
329    
330  /*****************************************************************************  /*****************************************************************************
  *  OPEN WATCOM C/C++ compiler  
  ****************************************************************************/  
 #elif defined(__WATCOMC__)  
   
 #       include <stdio.h>  
 #       include <stdarg.h>  
   
     static __inline void DPRINTF(int level, char *fmt, ...)  
     {  
                 if (DPRINTF_LEVEL & level) {  
             va_list args;  
             char buf[DPRINTF_BUF_SZ];  
             va_start(args, fmt);  
             vsprintf(buf, fmt, args);  
                         fprintf(stderr, "%s\n", buf);  
                 }  
         }  
   
 #       define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \  
                 type name##_storage[(sizex)*(sizey)+(alignment)-1]; \  
                 type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))  
   
 /*----------------------------------------------------------------------------  
  | watcom x86 specific macros/functions  
  *---------------------------------------------------------------------------*/  
 #       if defined(ARCH_X86)  
   
 #               define BSWAP(a)  __asm mov eax,a __asm bswap eax __asm mov a, eax  
   
                 static __inline int64_t read_counter(void)  
                 {  
                         int64_t ts;  
                         uint32_t ts1, ts2;  
                         __asm {  
                                 rdtsc  
                                 mov ts1, eax  
                                 mov ts2, edx  
                         }  
                         ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);  
                         return ts;  
                 }  
   
 /*----------------------------------------------------------------------------  
  | watcom unsupported architecture  
  *---------------------------------------------------------------------------*/  
 #       else  
   
 #               define BSWAP(x) \  
                         x = ((((x) & 0xff000000) >> 24) | \  
                                 (((x) & 0x00ff0000) >>  8) | \  
                                 (((x) & 0x0000ff00) <<  8) | \  
                                 (((x) & 0x000000ff) << 24))  
   
                 static int64_t read_counter() { return 0; }  
   
 #       endif  
 /*****************************************************************************  
331   *  Unknown compiler   *  Unknown compiler
332   ****************************************************************************/   ****************************************************************************/
333  #else /* Compiler test */  #else /* Compiler test */

Legend:
Removed from v.1.26.2.8  
changed lines
  Added in v.1.34

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