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

📄 global.h

📁 H.264编码解码器源码(c语言).zip
💻 H
📖 第 1 页 / 共 3 页
字号:
/*! ************************************************************************ *  \file *     global.h *  \brief *     global definitions for for H.26L encoder. *  \author *     Copyright (C) 1999  Telenor Satellite Services,Norway *                         Ericsson Radio Systems, Sweden * *     Inge Lille-Lang鴜               <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>#include "defines.h"#include "nalucommon.h"#include "parsetcommon.h"#ifndef WIN32  #include "minmax.h"#else  #define  snprintf _snprintf#endif/*********************************************************************** * T y p e    d e f i n i t i o n s    f o r    T M L *********************************************************************** */#define pel_t byte//! Data Partitioning Modestypedef enum{  PAR_DP_1,   //!< no data partitioning is supported  PAR_DP_3,   //!< data partitioning with 3 partitions} PAR_DP_TYPE;//! Output File Typestypedef enum{  PAR_OF_ANNEXB,    //!< Annex B bytestream format  PAR_OF_RTP,       //!< RTP packets in outfile//  PAR_OF_IFF        //!< Interim File Format} PAR_OF_TYPE;//! Boolean Type/*typedef enum {  FALSE,  TRUE} Boolean;*/typedef enum {  FRAME_CODING,  ADAPTIVE_CODING,  FIELD_CODING,  MB_CODING} CodingType;//! definition of H.26L syntax elementstypedef 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.htypedef enum {  INTER_MB,  INTRA_MB_4x4,  INTRA_MB_16x16} IntraInterDecision;typedef enum {  BITS_HEADER,  BITS_TOTAL_MB,  BITS_MB_MODE,  BITS_INTER_MB,  BITS_CBP_MB,  BITS_COEFF_Y_MB,  BITS_COEFF_UV_MB,  BITS_DELTA_QUANT_MB,  MAX_BITCOUNTER_MB} BitCountType;typedef enum {  NO_SLICES,  FIXED_MB,  FIXED_RATE,  CALLBACK,  FMO} SliceMode;typedef enum {  UVLC,  CABAC} SymbolMode;typedef enum {  FRAME,  TOP_FIELD,  BOTTOM_FIELD} PictureStructure;           //!< New enum for field processingtypedef 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 enginetypedef struct{  unsigned int  Elow, Erange;  unsigned int  Ebuffer;  unsigned int  Ebits_to_go;  unsigned int  Ebits_to_follow;  byte          *Ecodestrm;  int           *Ecodestrm_len;//  int           *Ecodestrm_laststartcode;  // storage in case of recode MB  unsigned int  ElowS, ErangeS;  unsigned int  EbufferS;  unsigned int  Ebits_to_goS;  unsigned int  Ebits_to_followS;  byte          *EcodestrmS;  int           *Ecodestrm_lenS;  int           C, CS;  int           E, ES;  int           B, BS;} EncodingEnvironment;typedef EncodingEnvironment *EncodingEnvironmentPtr;//! struct for context managementtypedef struct{  unsigned short state;         // index into state-table CP    unsigned char  MPS;           // Least Probable Symbol 0/1 CP  unsigned long  count;} 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 4typedef struct{  BiContextType mb_type_contexts [3][NUM_MB_TYPE_CTX];  BiContextType b8_type_contexts [2][NUM_B8_TYPE_CTX];  BiContextType mv_res_contexts  [2][NUM_MV_RES_CTX];  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];} 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    5typedef struct{  BiContextType  ipr_contexts [NUM_IPR_CTX];   BiContextType  cipr_contexts[NUM_CIPR_CTX];   BiContextType  cbp_contexts [3][NUM_CBP_CTX];  BiContextType  bcbp_contexts[NUM_BLOCK_TYPES][NUM_BCBP_CTX];  BiContextType  map_contexts [NUM_BLOCK_TYPES][NUM_MAP_CTX];  BiContextType  last_contexts[NUM_BLOCK_TYPES][NUM_LAST_CTX];  BiContextType  one_contexts [NUM_BLOCK_TYPES][NUM_ONE_CTX];  BiContextType  abs_contexts [NUM_BLOCK_TYPES][NUM_ABS_CTX];  BiContextType  fld_map_contexts [NUM_BLOCK_TYPES][NUM_MAP_CTX];  BiContextType  fld_last_contexts[NUM_BLOCK_TYPES][NUM_LAST_CTX];} TextureInfoContexts;//*********************** end of data type definition for CABAC *******************typedef struct pix_pos{  int available;  int mb_addr;  int x;  int y;  int pos_x;  int pos_y;} PixelPos;/*! Buffer structure for RMPNI commands */typedef struct RMPNIbuffer_s{  int RMPNI;  int Data;  struct RMPNIbuffer_s *Next;} RMPNIbuffer_t;/*! Buffer structure for decoded referenc picture marking commands */typedef struct DecRefPicMarking_s{  int memory_management_control_operation;  int difference_of_pic_nums_minus1;  int long_term_pic_num;  int long_term_frame_idx;  int max_long_term_frame_idx_plus1;  struct DecRefPicMarking_s *Next;} DecRefPicMarking_t;//! Syntaxelementtypedef struct syntaxelement{  int                 type;           //!< type of syntax element for data part.  int                 value1;         //!< numerical value of syntax element  int                 value2;         //!< for blocked symbols, e.g. run/level  int                 len;            //!< length of code  int                 inf;            //!< info part of UVLC code  unsigned int        bitpattern;     //!< UVLC bitpattern  int                 context;        //!< CABAC context  int                 k;              //!< CABAC context for coeff_count,uv#if TRACE  #define             TRACESTRING_SIZE 100            //!< size of trace string  char                tracestring[TRACESTRING_SIZE];  //!< trace string#endif  //!< for mapping of syntaxElement to UVLC  void    (*mapping)(int value1, int value2, int* len_ptr, int* info_ptr);  //!< used for CABAC: refers to actual coding method of each individual syntax element type  void    (*writing)(struct syntaxelement *, EncodingEnvironmentPtr);} SyntaxElement;//! Macroblocktypedef struct macroblock{  int                 currSEnr;                   //!< number of current syntax element  int                 slice_nr;  int                 delta_qp;  int                 qp ;  int                 bitcounter[MAX_BITCOUNTER_MB];  struct macroblock   *mb_available_up;   //!< pointer to neighboring MB (CABAC)  struct macroblock   *mb_available_left; //!< pointer to neighboring MB (CABAC)  int                 mb_type;  int                 mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2];          //!< indices correspond to [forw,backw][block_y][block_x][x,y]  int                 intra_pred_modes[BLOCK_MULTIPLE*BLOCK_MULTIPLE];  int                 cbp ;  int                 cbp_blk ;    //!< 1 bit set for every 4x4 block with coefs (not implemented for INTRA)  int                 b8mode[4];  int                 b8pdir[4];  unsigned long       cbp_bits;  int                 lf_disable;  int                 lf_alpha_c0_offset;  int                 lf_beta_offset;  int                 c_ipred_mode;      //!< chroma intra prediction mode  int                 IntraChromaPredModeFlag;    int                 mb_field;  int mbAddrA, mbAddrB, mbAddrC, mbAddrD;  int mbAvailA, mbAvailB, mbAvailC, mbAvailD;} Macroblock;//! Bitstreamtypedef struct{  int             byte_pos;           //!< current position in bitstream;  int             bits_to_go;         //!< current bitcounter  byte            byte_buf;           //!< current buffer for last written byte  int             stored_byte_pos;    //!< storage for position in bitstream;  int             stored_bits_to_go;  //!< storage for bitcounter  byte            stored_byte_buf;    //!< storage for buffer of last written byte  byte            byte_buf_skip;      //!< current buffer for last written byte  int             byte_pos_skip;      //!< storage for position in bitstream;  int             bits_to_go_skip;    //!< storage for bitcounter  byte            *streamBuffer;      //!< actual buffer for written bytes  int             write_flag;         //!< Bitstream contains data and needs to be written} Bitstream;//! DataPartitiontypedef struct datapartition{  Bitstream           *bitstream;  EncodingEnvironment ee_cabac;  int                 (*writeSyntaxElement)(SyntaxElement *, struct datapartition *);                      /*!< virtual function;                           actual method depends on chosen data partition and                           entropy coding method  */} DataPartition;//! Slicetypedef struct{  int                 picture_id;  int                 qp;  int                 picture_type; //!< picture type  int                 start_mb_nr;  int                 max_part_nr;  //!< number of different partitions  int                 num_mb;       //!< number of MBs in the slice  DataPartition       *partArr;     //!< array of partitions  MotionInfoContexts  *mot_ctx;     //!< pointer to struct of context models for use in CABAC  TextureInfoContexts *tex_ctx;     //!< pointer to struct of context models for use in CABAC  // !KS: RMPNI buffer should be retired. just do some sore simple stuff  RMPNIbuffer_t        *rmpni_buffer; //!< stores the slice temporary buffer remapping commands  int                 ref_pic_list_reordering_flag_l0;  int                 *remapping_of_pic_nums_idc_l0;  int                 *abs_diff_pic_num_minus1_l0;  int                 *long_term_pic_idx_l0;  int                 ref_pic_list_reordering_flag_l1;  int                 *remapping_of_pic_nums_idc_l1;  int                 *abs_diff_pic_num_minus1_l1;  int                 *long_term_pic_idx_l1;  Boolean             (*slice_too_big)(int bits_slice); //!< for use of callback functions  int                 field_ctx[3][2]; //GB} Slice;#define MAXSLICEPERPICTURE 100typedef struct {  int   no_slices;  int   idr_flag;  Slice *slices[MAXSLICEPERPICTURE];  int bits_per_picture;  float distortion_y;

⌨️ 快捷键说明

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