www.pudn.com > T264-src-0.02.zip > portab.h


/***************************************************************************** 
 * 
 *  T264 AVC CODEC 
 * 
 *  Copyright(C) 2004-2005 llcc  
 *               2004-2005 visionany  
 * 
 *  This program is free software ; you can redistribute it and/or modify 
 *  it under the terms of the GNU General Public License as published by 
 *  the Free Software Foundation ; either version 2 of the License, or 
 *  (at your option) any later version. 
 * 
 *  This program is distributed in the hope that it will be useful, 
 *  but WITHOUT ANY WARRANTY ; without even the implied warranty of 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *  GNU General Public License for more details. 
 * 
 *  You should have received a copy of the GNU General Public License 
 *  along with this program ; if not, write to the Free Software 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 * 
 ****************************************************************************/ 
 
#ifndef _PORTAB_H_ 
#define _PORTAB_H_ 
 
#include "config.h" 
 
#define _RW 
#define _R 
#define _W 
#define _INPUT 
#define _OUTPUT 
 
#define TRUE 1 
#define FALSE 0 
 
#if defined(_MSC_VER) 
#define int8_t   char 
#define uint8_t  unsigned char 
#define int16_t  short 
#define uint16_t unsigned short 
#define int32_t  int 
#define uint32_t unsigned int 
#define int64_t  __int64 
#define uint64_t unsigned __int64 
#define ptr_t uint32_t 
 
#define BYTE   uint8_t 
#define INT32  int32_t 
#define INT16  int16_t 
#define UINT16 uint16_t 
#define UINT32 uint32_t 
 
#if defined(ARCH_IS_IA32) 
#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax 
 
         static __inline uint64_t read_counter(void) 
         { 
             __asm { 
                 rdtsc 
             } 
         } 
 
#define SWAP(type, x, y) { type* _tmp_; _tmp_ = x; x = y ; y = _tmp_;} 
#define CLIP1(x) (x & ~255) ? (-x >> 31) : x 
#define ABS(x) ((x) > 0 ? (x) : -(x)) 
 
#else // ARCH_IS_IA32 
#error Please port BSWAP to other platform! 
#endif// ARCH_IS_IA32 
 
#if _MSC_VER <= 1200 
#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)) 
#else //_MSC_VER <= 1200 
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ 
                __declspec(align(alignment)) type name[(sizex)*(sizey)] 
#endif//_MSC_VER <= 1200 
 
#if _MSC_VER <= 1200 
#define DECLARE_ALIGNED_MATRIX_H(name,sizex,sizey,type,alignment) \ 
    type name[(sizex)*(sizey)] 
#else //_MSC_VER <= 1200 
#define DECLARE_ALIGNED_MATRIX_H(name,sizex,sizey,type,alignment) \ 
    __declspec(align(alignment)) type name[(sizex)*(sizey)] 
#endif//_MSC_VER <= 1200 
 
#if _MSC_VER <= 1200 
#define DECLARE_ALIGNED2_MATRIX_H(name,sizex,sizey,type,alignment) \ 
    type name[(sizex)][(sizey)] 
#else //_MSC_VER <= 1200 
#define DECLARE_ALIGNED2_MATRIX_H(name,sizex,sizey,type,alignment) \ 
    __declspec(align(alignment)) type name[(sizex)][(sizey)] 
#endif//_MSC_VER <= 1200 
 
#endif // _MSC_VER 
 
static __inline int32_t 
clip3(int32_t a, int32_t low, int32_t high) 
{ 
    if (a < low) 
        return low; 
     
    if (a > high) 
        return high; 
 
    return a; 
} 
#endif // _PORTAB_H_