www.pudn.com > VC_Standalone.rar > define.h


/************************************************************************* 
 AVS1-P2视频解码器源码 
 版权所有:联合信源数字音视频技术(北京)有限公司, (c) 2005-2006  
 
 AVS1-P2 Video Decoder Source Code 
 (c) Copyright, NSCC All Rights Reserved, 2005-2006 
 ************************************************************************* 
 Distributed 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 
*************************************************************************/ 
/************************************************************************* 
  文件名称:	define.h 
  描    述: 常数宏定义,结构体定义,常用函数宏定义 
*************************************************************************/ 
/************************************************************************* 
  Revision History 
  data          Modification                                    Author 
  2005-2-8      Created                                          jthou 
 *************************************************************************/ 
#ifndef _DEFINE_H_ 
#define _DEFINE_H_ 
#include "windows.h" 
 
 
//constant------------------------------------------------------ 
#define MBSIZE    16 
#define INBUFLEN  1024*1024*5 
 
#define AVS_MAX_HORIZONTAL 2000 
#define AVS_MAX_VERTICAL   2000 
 
#define MAX_MB_NUM 15625 
#define CLIPSIZE   1024 
#define TEMP_HALF_PIX_LEN 18 
#define TEMP_JPIE_PIX_LEN 9 
//return value-------------------------------------------------- 
#define AVS_NOERROR                   0x00000000 
#define AVS_FALSE                     0xffffffff 
#define AVS_ERROR                     0xffffffff 
#define AVS_CAN_NOT_OPEN_FILE         0xF0000001 
#define AVS_NOT_ENOUGH_DATA            0xF0000002 
#define AVS_NOT_ENOUGH_MEM            0xF0000003 
#define AVS_NOT_VALID_PIC_DATA        0xF0000004 
#define AVS_INVALID_PIC_START_CODE    0xF0000005 
 
#define THIS_VERSION_NOT_SUPPORT      0xF00000FF 
 
#define TRUE  1 
#define FALSE 0 
 
#define NULL  0 
 
//constant in avs video standard ------------------------------- 
#define SEQENCE_START_CODE   0X000001B0 
#define SEQENCE_END_CODE     0X000001B1 
#define USER_DATA_START_CODE 0X000001B2 
#define I_FRAME_START_CODE   0X000001B3 
#define EXTENSION_START_CODE 0X000001B5  
#define PB_FRAME_START_CODE  0X000001B6 
#define EDIT_CODE            0X000001B7 
 
#define SLICE_START_CODE_MIN 0X00000100 
#define SLICE_START_CODE_MAX 0X000001AF 
#define IS_START_CODE(data) ((data & 0x00FFFFFF) == 0x00010000) 
#define IS_SLICE_START_CODE(data)       (((data) >= SLICE_START_CODE_MIN)  \ 
                                      && ((data) <= SLICE_START_CODE_MAX)) 
 
//stream constant----------------------------------------------- 
#define BASE_PROFILE    0X20 
 
#define LEVEL40         0X20 
#define LEVEL42         0x22 
#define LEVEL60         0x40 
#define LEVEL62         0x42 
 
#define CHROMA420       0X01 
#define CHROMA422       0X10 
 
#define I_IMG           0 
#define P_IMG           1 
#define B_IMG           2 
 
// Intra Mode 
#define I_8x8           0 
 
//P Mb mode 
#define P_Skip          1 
#define P_16x16         2 
#define P_16x8          3 
#define P_8x16          4 
#define P_8x8           5 
 
//B Mb mode 
#define B_Skip          6 
#define B_Direct_16x16  7 
#define B_Fwd_16x16     8 
#define B_Bck_16x16     9 
#define B_Sym_16x16     10 
#define B_Fwd_Fwd_16x8  11 
#define B_Fwd_Fwd_8x16  12 
#define B_Bck_Bck_16x8  13 
#define B_Bck_Bck_8x16  14 
#define B_Fwd_Bck_16x8  15 
#define B_Fwd_Bck_8x16  16 
#define B_Bck_Fwd_16x8  17 
#define B_Bck_Fwd_8x16  18 
#define B_Fwd_Sym_16x8  19 
#define B_Fwd_Sym_8x16  20 
#define B_Bck_Sym_16x8  21 
#define B_Bck_Sym_8x16  22 
#define B_Sym_Fwd_16x8  23 
#define B_Sym_Fwd_8x16  24 
#define B_Sym_Bck_16x8  25 
#define B_Sym_Bck_8x16  26 
#define B_Sym_Sym_16x8  27 
#define B_Sym_Sym_8x16  28 
#define B_8x8           29       
 
// B_8x8 Part Mode 
#define SB_Direct_8x8   30 
#define SB_Fwd_8x8      31 
#define SB_Bck_8x8      32 
#define SB_Sym_8x8      33 
 
//IntraLumaPredMode 
#define Intra_8x8_Vertical      0 
#define Intra_8x8_Horizontal    1 
#define Intra_8x8_DC            2 
#define Intra_8x8_Down_Left     3 
#define Intra_8x8_Down_Right    4 
 
//IntraChromaPredMode 
#define Intra_Chroma_DC         0 
#define Intra_Chroma_Horizontal 1 
#define Intra_Chroma_Vertical   2 
#define Intra_Chroma_Plane      3 
 
 
#define PREDDIRFWD              1 
#define PREDDIRBWD              0 
#define PREDDIRSYM              2 
// Vlc constant------------------------------------------------- 
#define CODE2D_ESCAPE_SYMBOL 59 
 
 
//type define--------------------------------------------------- 
typedef unsigned char         BYTE; 
typedef unsigned char         byte; 
typedef unsigned long         DWORD; 
 
typedef unsigned long         AVS_DWORD; 
typedef unsigned char         AVS_BYTE; 
typedef short                 AVS_SHORT; 
typedef long                  AVS_LONG; 
typedef unsigned int          AVS_UINT; 
typedef unsigned short        AVS_USHORT; 
 
typedef char                  AVS_I8; 
typedef unsigned char         AVS_U8; 
typedef short                 AVS_I16; 
typedef unsigned short        AVS_U16; 
typedef int                   AVS_I32; 
typedef unsigned int          AVS_U32; 
typedef __int64               AVS_I64; 
typedef unsigned __int64      AVS_U64; 
 
typedef boolean               AVS_BOOL; 
typedef int                   AVS_INT; 
typedef float                 AVS_FLOAT; 
typedef double                AVS_DOUBLE; 
 
typedef unsigned int          AVS_HRESULT; 
//enum ------------------------------------------------------- 
typedef enum { 
  SE_HEADER, 
  SE_PTYPE, 
  SE_MBTYPE, 
  SE_REFFRAME, 
  SE_INTRAPREDMODE, 
  SE_MVD, 
  SE_CBP_INTRA, 
  SE_LUM_DC_INTRA, 
  SE_CHR_DC_INTRA, 
  SE_LUM_AC_INTRA, 
  SE_CHR_AC_INTRA, 
  SE_CBP_INTER, 
  SE_LUM_DC_INTER, 
  SE_CHR_DC_INTER, 
  SE_LUM_AC_INTER, 
  SE_CHR_AC_INTER, 
  SE_DELTA_QUANT_INTER, 
  SE_DELTA_QUANT_INTRA, 
  SE_BFRAME, 
  SE_EOS, 
  SE_MAX_ELEMENTS  //!< number of maximum syntax elements 
} SE_type;         // substituting the definitions in elements.h 
//structures---------------------------------------------------- 
 
struct VIDEODATA 
{ 
  AVS_DWORD dwDistanceIndex; 
  AVS_BYTE* y; 
  AVS_BYTE* u; 
  AVS_BYTE* v; 
  AVS_BYTE* reserve; 
}; 
 
struct MOTIONVECTOR{ 
  AVS_INT x; 
  AVS_INT y; 
}; 
 
struct MBINFO { 
  AVS_DWORD dwMbType; 
  AVS_DWORD dwMvNum;  
  AVS_DWORD dwMbPartType[4];           //B_8x8 only 
  AVS_DWORD dwCBPCodeNum; 
  AVS_DWORD  bPredModeFlag[4];         //I_8x8 only 
  AVS_INT   iIntraLumaPredMode[4];     //I_8x8 only 
  AVS_INT   iIntraLumaPredModeNew[4]; 
  AVS_DWORD dwintraChromaPredMode; 
  AVS_DWORD dwintraChromaPredMode422;  //Chroma 4:2:2 only 
 
  AVS_DWORD dwMbReferenceIndex[4]; 
  AVS_DWORD dwMbReferenceIndexBw[4]; 
   
  AVS_INT   iMvDiffX[4]; 
  AVS_INT   iMvDiffY[4]; 
  AVS_DWORD dwWeightingPrediction; 
  AVS_DWORD  bHasCbp; 
  AVS_DWORD dwCbp; 
  AVS_DWORD dwCbp422; 
  AVS_INT   iMbQpDelta; 
  AVS_INT   predDir[4];    //fwd: 1, bwd: 0, sym: 2 
  AVS_INT   iBlockDistance[4]; 
  AVS_INT   iBlockDistanceBw[4]; 
  MOTIONVECTOR mv[4]; 
  MOTIONVECTOR mvBw[4]; 
 
  AVS_DWORD dwMbQp; 
}; 
 
struct SEQENCEINFO { 
  AVS_DWORD dwWidth; 
  AVS_DWORD dwHeight; 
  AVS_DWORD dwChromaFormat; 
  AVS_DWORD dwAspectRatio; 
  AVS_FLOAT fFrameRate; 
  AVS_DWORD dwMbWidth; 
  AVS_DWORD dwMbHeight; 
  AVS_BOOL  bProgressive; 
  AVS_DWORD dwProfile; 
  AVS_DWORD dwLevel; 
  AVS_BOOL  bLowDelay; 
}; 
 
struct IMAGEINFO { 
  AVS_DWORD dwImageType; 
  AVS_DWORD dwImageType1; 
  AVS_DWORD dwPictureDistance; 
  AVS_BOOL  bProgressiveFrame; 
  AVS_BOOL  bPictureStructure; 
  AVS_BOOL  bTopFieldFirst; 
  AVS_BOOL  bRepeatFirstField; 
  AVS_BOOL  bFixedPictureQp; 
  AVS_DWORD dwPictureQp; 
  AVS_BOOL  bSkipModeFlag; 
  AVS_BOOL  bLoopFilterDisable; 
  AVS_INT   iAlphaCOffset; 
  AVS_INT   iBetaOffset; 
  //pb frame 
  AVS_BOOL  bPictureReferenceFlag; 
}; 
 
struct SLICEINFO { 
  AVS_DWORD  bFixedSliceQp; 
  AVS_DWORD dwSliceQp; 
  AVS_DWORD LumaScale[4]; 
  AVS_DWORD LumaShift[4]; 
  AVS_DWORD ChromaScale[4]; 
  AVS_DWORD ChromaShift[4]; 
  AVS_DWORD  bMbWeightingFlag; 
}; 
 
struct STREAMINFO { 
  SEQENCEINFO SeqInfo; 
  IMAGEINFO ImgInfo; 
  SLICEINFO SlcInfo; 
}; 
 
struct BWREFINFO{ 
  AVS_DWORD    dwMbType; 
  MOTIONVECTOR mvRef[4]; 
  AVS_INT      iBlockDistanceRef[4]; 
  AVS_INT      iDistanceIndexRef[4]; 
  AVS_INT      PictureStructure; 
}; 
 
#define max(a, b) (((a) > (b)) ? (a) : (b)) 
#define min(a,b) (((a) < (b)) ? (a) : (b)) 
#define min1(a,b) (((a) < (b)) ? (a) : (b)) 
#define Clip(a) ( (a)<(0) ? (0) : ((a)>(255)?(255):(a)) )  
#define Median(a,b,c) (a + b + c - min(a, min(b, c)) - max(a, max(b, c))); 
#define sign1(x) (x < 0 ? -1 : 1) 
#define sign(x) (x < 0 ? -1 : 1) 
#define Clip3(min,max,val) (((val)<(min))?(min):(((val)>(max))?(max):(val))) 
 
#endif