⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.h

📁 JM 11.0 KTA 2.1 Source Code
💻 H
📖 第 1 页 / 共 3 页
字号:

/*!
************************************************************************
*  \file
*     global.h
*  \brief
*     global definitions for for H.264 decoder.
*  \author
*     Copyright (C) 1999  Telenor Satellite Services,Norway
*                         Ericsson Radio Systems, Sweden
*
*     Inge Lille-Langoy               <inge.lille-langoy@telenor.com>
*
*     Telenor Satellite Services
*     Keysers gt.13                       tel.:   +47 23 13 86 98
*     N-0130 Oslo,Norway                  fax.:   +47 22 77 79 80
*
*     Rickard Sjoberg                 <rickard.sjoberg@era.ericsson.se>
*
*     Ericsson Radio Systems
*     KI/ERA/T/VV
*     164 80 Stockholm, Sweden
*
************************************************************************
*/
#ifndef _GLOBAL_H_
#define _GLOBAL_H_

#include <stdio.h>                              //!< for FILE
#include <time.h>
#include <sys/timeb.h>
#include "defines.h"
#include "parsetcommon.h"

// Tool defines (AIF, 1/8pel, MVC) is moved to define.h by AT 2006/11/01

#ifdef MV_COMPETITION
#define MAX_MV_PREDICTOR  8
#endif

#ifdef WIN32
#define  snprintf _snprintf
#define  open     _open
#define  close    _close
#define  read     _read
#define  write    _write
#define  lseek    _lseeki64
#define  fsync    _commit
#define  OPENFLAGS_WRITE _O_WRONLY|_O_CREAT|_O_BINARY|_O_TRUNC
#define  OPEN_PERMISSIONS _S_IREAD | _S_IWRITE
#define  OPENFLAGS_READ  _O_RDONLY|_O_BINARY
#else
#define  OPENFLAGS_WRITE O_WRONLY|O_CREAT|O_TRUNC
#define  OPENFLAGS_READ  O_RDONLY
#define  OPEN_PERMISSIONS S_IRUSR | S_IWUSR
#endif


typedef unsigned char   byte;                   //!<  8 bit unsigned
typedef int             int32;
typedef unsigned int    u_int32;

#define imgpel unsigned short

#if defined(WIN32) && !defined(__GNUC__)
typedef __int64   int64;
# define FORMAT_OFF_T "I64d"
#ifndef INT64_MIN
# define INT64_MIN        (-9223372036854775807i64 - 1i64)
#endif
#else
typedef long long int64;
# define FORMAT_OFF_T "lld"
#ifndef INT64_MIN
# define INT64_MIN        (-9223372036854775807LL - 1LL)
#endif
#endif





pic_parameter_set_rbsp_t *active_pps;
seq_parameter_set_rbsp_t *active_sps;

// global picture format dependend buffers, mem allocation in decod.c ******************
int  **refFrArr;                                //!< Array for reference frames of each block

imgpel **imgY_ref;                                //!< reference frame find snr
imgpel ***imgUV_ref;

int  ReMapRef[20];
// B pictures
int  Bframe_ctr;
int  frame_no;

int  g_nFrame;

// For MB level frame/field coding
int  TopFieldForSkip_Y[16][16];
int  TopFieldForSkip_UV[2][16][16];

int  InvLevelScale4x4Luma_Intra[6][4][4];
int  InvLevelScale4x4Chroma_Intra[2][6][4][4];

int  InvLevelScale4x4Luma_Inter[6][4][4];
int  InvLevelScale4x4Chroma_Inter[2][6][4][4];

int  InvLevelScale8x8Luma_Intra[6][8][8];

int  InvLevelScale8x8Luma_Inter[6][8][8];

int  *qmatrix[8];

#ifdef ADAPTIVE_QUANTIZATION
int  *ScalingList4x4[6], *ScalingList8x8[2];
int  *ScalingList4x4_IAQMS[NUM_OF_IAQMS_MAT][6], *ScalingList8x8_IAQMS[NUM_OF_IAQMS_MAT][6];
int  InvLevelScale4x4Luma_Intra_IAQMS[NUM_OF_IAQMS_MAT][6][4][4];
int  InvLevelScale4x4Chroma_Intra_IAQMS[NUM_OF_IAQMS_MAT][2][6][4][4];
int  InvLevelScale4x4Luma_Inter_IAQMS[NUM_OF_IAQMS_MAT][6][4][4];
int  InvLevelScale4x4Chroma_Inter_IAQMS[NUM_OF_IAQMS_MAT][2][6][4][4];
int  InvLevelScale8x8Luma_Intra_IAQMS[NUM_OF_IAQMS_MAT][6][8][8];
int  InvLevelScale8x8Luma_Inter_IAQMS[NUM_OF_IAQMS_MAT][6][8][8];
int  *qmatrixIAQMS[NUM_OF_IAQMS_MAT][12];
#endif

#ifdef ADAPTIVE_FILTER
double **tmp_coef; 
#endif

#define ET_SIZE 300      //!< size of error text buffer
char errortext[ET_SIZE]; //!< buffer for error message for exit with error()

                         /***********************************************************************
                         * T y p e    d e f i n i t i o n s    f o r    T M L
                         ***********************************************************************
*/

//! Data Partitioning Modes
typedef enum
{
  PAR_DP_1,    //!< no data partitioning is supported
    PAR_DP_3,    //!< data partitioning with 3 partitions
} PAR_DP_TYPE;


//! Output File Types
typedef enum
{
  PAR_OF_ANNEXB,   //!< Current TML description
    PAR_OF_RTP,   //!< RTP Packet Output format
    //  PAR_OF_IFF    //!< Interim File Format
} PAR_OF_TYPE;

//! Boolean Type
/*typedef enum {
FALSE,
TRUE
} Boolean;
*/
//! definition of H.264 syntax elements
typedef enum {
  SE_HEADER,
    SE_PTYPE,
    SE_MBTYPE,
    SE_REFFRAME,
    SE_INTRAPREDMODE,
    SE_MVD,
#ifdef MV_COMPETITION
    SE_MV_PREDICTOR,
#endif
    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, this MUST be the last one!
} SE_type;        // substituting the definitions in element.h


typedef enum {
  INTER_MB,
    INTRA_MB_4x4,
    INTRA_MB_16x16
} IntraInterDecision;

typedef enum {
  BITS_TOTAL_MB,
    BITS_HEADER_MB,
    BITS_INTER_MB,
    BITS_CBP_MB,
    BITS_COEFF_Y_MB,
    BITS_COEFF_UV_MB,
    MAX_BITCOUNTER_MB
} BitCountType;

typedef enum {
  NO_SLICES,
    FIXED_MB,
    FIXED_RATE,
    CALLBACK,
    FMO
} SliceMode;


typedef enum {
  UVLC,
    CABAC
} SymbolMode;

typedef enum {
  LIST_0=0,
    LIST_1=1
} Lists;


typedef enum {
  FRAME,
    TOP_FIELD,
    BOTTOM_FIELD
} PictureStructure;           //!< New enum for field processing


typedef enum {
  P_SLICE = 0,
    B_SLICE,
    I_SLICE,
    SP_SLICE,
    SI_SLICE
} SliceType;

/***********************************************************************
* D a t a    t y p e s   f o r  C A B A C
***********************************************************************
*/

//! struct to characterize the state of the arithmetic coding engine
typedef struct
{
  unsigned int    Dlow, Drange;
  unsigned int    Dvalue;
  unsigned int    Dbuffer;
  int             Dbits_to_go;
  byte            *Dcodestrm;
  int             *Dcodestrm_len;
} DecodingEnvironment;

typedef DecodingEnvironment *DecodingEnvironmentPtr;

//! struct for context management
typedef struct
{
  unsigned short state;         // index into state-table CP  
  unsigned char  MPS;           // Least Probable Symbol 0/1 CP
} BiContextType;

typedef BiContextType *BiContextTypePtr;


/**********************************************************************
* C O N T E X T S   F O R   T M L   S Y N T A X   E L E M E N T S
**********************************************************************
*/

#define NUM_MB_TYPE_CTX  11
#define NUM_B8_TYPE_CTX  9
#define NUM_MV_RES_CTX   10
#define NUM_REF_NO_CTX   6
#define NUM_DELTA_QP_CTX 4
#define NUM_MB_AFF_CTX 4
#define NUM_TRANSFORM_SIZE_CTX 3
#ifdef ADAPTIVE_QUANTIZATION
#define NUM_MODULATED_QUANTIZATION_CTX 2
#endif

typedef struct
{
  BiContextType mb_type_contexts [4][NUM_MB_TYPE_CTX];
  BiContextType b8_type_contexts [2][NUM_B8_TYPE_CTX];
  BiContextType mv_res_contexts  [2][NUM_MV_RES_CTX];
#ifdef MV_COMPETITION
  BiContextType mv_predictor_skip_contexts  [MAX_MV_PREDICTOR];
  BiContextType mv_predictor_mvp_contexts   [MAX_MV_PREDICTOR];
  BiContextType mv_predictor_mvb_contexts   [MAX_MV_PREDICTOR];
#endif
  BiContextType ref_no_contexts  [2][NUM_REF_NO_CTX];
  BiContextType delta_qp_contexts[NUM_DELTA_QP_CTX];
  BiContextType mb_aff_contexts  [NUM_MB_AFF_CTX];
  BiContextType transform_size_contexts [NUM_TRANSFORM_SIZE_CTX];
#ifdef ADAPTIVE_QUANTIZATION
  BiContextType modulated_quantization_contexts [NUM_MODULATED_QUANTIZATION_CTX];
#endif
} MotionInfoContexts;

#define NUM_IPR_CTX    2
#define NUM_CIPR_CTX   4
#define NUM_CBP_CTX    4
#define NUM_BCBP_CTX   4
#define NUM_MAP_CTX   15
#define NUM_LAST_CTX  15
#define NUM_ONE_CTX    5
#define NUM_ABS_CTX    5

#ifdef ADAPTIVE_FD_SD_CODING
#define NUM_SCAN_CTX        4
#define NUM_MB_adap_CTX     4
#define NUM_BCBP_FD_SD_CTX  4
#define NUM_MAP8_CTX       63
#define NUM_LAST8_CTX      63
#endif

typedef struct
{
#ifdef ADAPTIVE_FD_SD_CODING
  BiContextType  MB_adaptive_SD_context[NUM_MB_adap_CTX];
  BiContextType  bcbp_contexts_FD_SD   [NUM_BCBP_FD_SD_CTX];
  BiContextType  bcbp8_contexts_FD_SD  [NUM_BCBP_FD_SD_CTX];
  BiContextType  one_contexts_SD       [NUM_ONE_CTX];
  BiContextType  one8_contexts_SD      [NUM_ONE_CTX];
  BiContextType  abs_contexts_SD       [NUM_ABS_CTX];
  BiContextType  abs8_contexts_SD      [NUM_ABS_CTX];
  BiContextType  map_contexts_SD       [NUM_MAP_CTX];
  BiContextType  map8_contexts_SD      [NUM_MAP8_CTX];
  BiContextType  last_contexts_SD      [NUM_LAST_CTX];
  BiContextType  last8_contexts_SD     [NUM_LAST8_CTX];
#endif
  BiContextType  ipr_contexts [NUM_IPR_CTX];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -