?? global.h
字號:
/************************************************************************
*
* global.h for H.26L encoder.
* Copyright (C) 1999 Telenor Satellite Services,Norway
* Ericsson Radio Systems, Sweden
*
* Contacts:
* 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"
#ifndef WIN32
#include "minmax.h"
#endif
/***********************************************************************
* T y p e d e f i n i t i o n s f o r T M L
***********************************************************************
*/
typedef unsigned char byte;
#define pel_t byte
/* Introduced by TOM */
/* Data Partitioning Modes */
typedef enum
{
PAR_DP_1, /* no data partitioning is supported */
PAR_DP_CABAC /*data partitioning for CABAC, extra partition for UVLC-Header*/
} PAR_DP_TYPE;
/* Output File Types */
typedef enum
{
PAR_OF_26L /* Current TML description */
} PAR_OF_TYPE;
/* End Introduced by TOM */
typedef enum {
FALSE,
TRUE
} Boolean;
typedef enum {
SE_HEADER,
SE_PTYPE,
SE_MBTYPE,
SE_REFFRAME,
#ifdef DQUANT
SE_DELTA_QUANT,
#endif
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_BFRAME,
SE_EOS,
SE_MAX_ELEMENTS /* number of maximum syntax elements */
} 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,
#ifdef DQUANT
BITS_DELTA_QUANT_MB,
#endif
BITS_CBP_MB,
BITS_COEFF_Y_MB,
BITS_COEFF_UV_MB,
MAX_BITCOUNTER_MB
} BitCountType;
typedef enum {
SINGLE_SCAN,
DOUBLE_SCAN
} ScanMode;
typedef enum {
NO_SLICES,
FIXED_MB,
FIXED_RATE,
CALLBACK
} SliceMode;
typedef enum {
UVLC,
CABAC
} SymbolMode;
/***********************************************************************
* D a t a t y p e s f o r C A B A C
***********************************************************************
*/
typedef struct
{
unsigned int Elow, Ehigh;
unsigned int Ebuffer;
unsigned int Ebits_to_go;
unsigned int Ebits_to_follow;
byte *Ecodestrm;
int *Ecodestrm_len;
} EncodingEnvironment; /* struct to characterize the state of the arithmetic coding engine */
typedef EncodingEnvironment *EncodingEnvironmentPtr;
typedef struct
{
unsigned int cum_freq[2]; /* cumulated frequency counts */
Boolean in_use; /* flag for context in use */
unsigned int max_cum_freq; /* maximum frequency count */
} BiContextType; /* struct for context management*/
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 10
#define NUM_MV_RES_CTX 10
#define NUM_REF_NO_CTX 6
typedef struct
{
BiContextTypePtr mb_type_contexts[2];
BiContextTypePtr mv_res_contexts[2];
BiContextTypePtr ref_no_contexts;
} MotionInfoContexts;
#define NUM_IPR_CTX 2
#define NUM_CBP_CTX 4
#define NUM_TRANS_TYPE 9
#define NUM_LEVEL_CTX 4
#define NUM_RUN_CTX 2
typedef struct
{
BiContextTypePtr ipr_contexts[6];
BiContextTypePtr cbp_contexts[2][3];
BiContextTypePtr level_context[NUM_TRANS_TYPE];
BiContextTypePtr run_context[NUM_TRANS_TYPE];
} TextureInfoContexts;
/************************ end of data type definition for CABAC ********************/
/***********************************************************************
* N e w D a t a t y p e s f o r T M L
***********************************************************************
*/
typedef 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 */
#if TRACE
char tracestring[100]; /* trace string */
#endif
void (*mapping)(int value1, int value2, int* len_ptr, int* info_ptr); // for mapping of syntaxElement to UVLC
void (*writing)(struct syntaxelement *, EncodingEnvironmentPtr);
/* used for CABAC: refers to actual coding method of each individual syntax element type */
} SyntaxElement;
typedef struct macroblock
{
int currSEnr; /* number of current syntax element */
int slice_nr; /* slice number to which the MB belongs */
#ifndef DQUANT
int qp; /* for future use */
#endif
#ifdef DQANT
int delte_qp;
#endif
int intraOrInter;
int bitcounter[MAX_BITCOUNTER_MB];
struct macroblock *mb_available[3][3]; /* pointer to neighboring MBs in a 3x3 window of current MB, which is located at [1][1] */
/* NULL pointer identifies neighboring MBs which are unavailable */
/* some storage of macroblock syntax elements for global access */
int mb_type;
int mb_imode;
int ref_frame;
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;
} Macroblock;
typedef 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
int header_len;
byte header_byte_buffer;
byte stored_byte_buf; // storage for buffer of last written byte
byte *streamBuffer; // actual buffer for written bytes
} Bitstream;
typedef 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;
typedef struct {
int picture_id;
int slice_nr; // not necessary but o.k.
int qp;
int picture_type; // picture type
int start_mb_nr;
int dp_mode; // data partioning mode
int max_part_nr; // number of different partitions
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
Boolean (*slice_too_big)(int bits_slice); // for use of callback functions
} Slice;
/******************************* ~DM ************************************/
/* GH: global picture format dependend buffers, mem allocation in image.c*/
byte **imgY; /* Encoded luma images */
byte ***imgUV; /* Encoded croma images */
byte **imgY_org; /* Reference luma image */
byte ***imgUV_org; /* Reference croma image */
byte **imgY_pf; /* Post filter luma image */
byte ***imgUV_pf; /* Post filter croma image */
byte **loopb; /* array containing filter strenght for 4x4 luma block */
byte **loopc; /* array containing filter strenght for 4x4 chroma block */
byte ***mref; /* 1/4 pix luma */
byte ****mcef; /* pix chroma */
int **img4Y_tmp; /* for quarter pel interpolation */
byte **img8Y_tmp; /* for 1/8 pel interpolation */
byte **imgY_tmp; /* for loop filter */
byte ***imgUV_tmp;
int ***tmp_mv; /* motion vector buffer */
int **refFrArr; /* Array for reference frames of each block */
/* B pictures */
// motion vector : forward, backward, direct
int ***tmp_fwMV;
int ***tmp_bwMV;
int ***dfMV;
int ***dbMV;
int **fw_refFrArr;
int **bw_refFrArr;
byte **mref_P; //for B-frames: 1/4 pix luma for next P picture
byte ***mcef_P; //for B-frames: pix chroma for next P picture
byte **nextP_imgY;
byte ***nextP_imgUV;
pel_t **Refbuf11; // 1/1th pel (full pel) reference frame buffer
pel_t *Refbuf11_P; // 1/1th pel P picture buffer
int Bframe_ctr, frame_no, nextP_tr;
int tot_time;
char errortext[300];
typedef struct
{
float snr_y; /* current Y SNR */
float snr_u; /* current U SNR */
float snr_v; /* current V SNR */
float snr_y1; /* SNR Y(dB) first frame */
float snr_u1; /* SNR U(dB) first frame */
float snr_v1; /* SNR V(dB) first frame */
float snr_ya; /* Average SNR Y(dB) remaining frames */
float snr_ua; /* Average SNR U(dB) remaining frames */
float snr_va; /* Average SNR V(dB) remaining frames */
} SNRParameters;
typedef struct /* all input parameters */
{
int no_frames; /* number of frames to be encoded */
int qp0; /* QP of first frame */
int qpN; /* QP of remaining frames */
int jumpd; /* number of frames to skip in input sequence (e.g 2 takes frame 0,3,6,9...) */
int mv_res; /* motion vector resolution: 0: 1/4-pel, 1: 1/8-pel */
int hadamard; /* 0: 'normal' SAD in 1/3 pixel search. 1: use 4x4 Haphazard transform and ' */
/* Sum of absolute transform difference' in 1/3 pixel search */
int search_range; /* search range - integer pel search and 16x16 blocks. The search window is */
/* generally around the predicted vector. Max vector is 2xmcrange. For 8x8 */
/* and 4x4 block sizes the search range is 1/2 of that for 16x16 blocks. */
int no_multpred; /* 1: prediction from the last frame only. 2: prediction from the last or */
/* second last frame etc. Maximum 5 frames */
int img_width; /* GH: if CUSTOM image format is chosen, use this size */
int img_height; /* GH: width and height must be a multiple of 16 pels */
int yuv_format; /* GH: YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4,currently only 4:2:0 is supported)*/
int color_depth; /* GH: YUV color depth per component in bit/pel (currently only 8 bit/pel is supported) */
int intra_upd; /* For error robustness. 0: no special action. 1: One GOB/frame is intra coded */
/* as regular 'update'. 2: One GOB every 2 frames is intra coded etc. */
/* In connection with this intra update, restrictions is put on motion vectors */
/* to prevent errors to propagate from the past*/
int blc_size[8][2]; /* array for different block sizes */
int slice_mode; /* Indicate what algorithm to use for setting slices */
int slice_argument; /* Argument to the specified slice algorithm */
char infile[100]; /* YUV 4:2:0 input format*/
char outfile[100]; /* H.26L compressed output bitstream*/
char ReconFile[100]; // Reconstructed Pictures
char TraceFile[100]; // Trace Outputs
/* B pictures */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -