📄 global.h
字号:
/*
*****************************************************************************
* COPYRIGHT AND WARRANTY INFORMATION
*
* Copyright 2003, Advanced Audio Video Coding Standard, Part II
*
* DISCLAIMER OF WARRANTY
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations under
* the License.
*
* THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY.
* The AVS Working Group doesn't represent or warrant that the programs
* furnished here under are free of infringement of any third-party patents.
* Commercial implementations of AVS, including shareware, may be
* subject to royalty fees to patent holders. Information regarding
* the AVS patent policy for standardization procedure is available at
* AVS Web site http://www.avs.org.cn. Patent Licensing is outside
* of AVS Working Group.
*
* The Original Code is Reference Software for China National Standard
* GB/T 20090.2-2006 (short for AVS-P2 or AVS Video) at version RM52J.
*
* The Initial Developer of the Original Code is Video subgroup of AVS
* Workinggroup (Audio and Video coding Standard Working Group of China).
* Contributors: Guoping Li, Siwei Ma, Jian Lou, Qiang Wang ,
* Jianwen Chen,Haiwu Zhao, Xiaozhen Zheng, Junhao Zheng, Zhiming Wang
*
******************************************************************************
*/
/*
*************************************************************************************
* File name:
* Function:
*
*************************************************************************************
*/
#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#include <stdio.h>
#include "defines.h"
#ifndef WIN32
#include "minmax.h"
#else
#define snprintf _snprintf
#endif
#ifdef _TMS320C6X
#define EXTERN extern
#else
#define EXTERN
#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; //!< byte type definition
#define pel_t byte
#define MAX_V_SEARCH_RANGE 1024
#define MAX_V_SEARCH_RANGE_FIELD 512
#define MAX_H_SEARCH_RANGE 8192
EXTERN byte *pic_buf;
//! Boolean Type
typedef enum {
FALSE,
TRUE
} Boolean;
typedef enum {
FRAME_CODING,
FIELD_CODING,
PAFF_CODING
} CodingType;
//! definition of AVS syntax elements
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;
//Lou
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 {
FRAME,
TOP_FIELD,
BOTTOM_FIELD
} PictureType; //!< New enum for field processing
/*Lou 1016 Start*/
typedef enum{
NS_BLOCK,
VS_BLOCK
}SmbMode;
/*Lou 1016 End*/
//! Syntaxelement
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
int k; //!< CABAC context for coeff_count,uv
int golomb_grad; //needed if type is a golomb element (AVS)
int golomb_maxlevels; // if this is zero, do not use the golomb coding. (AVS)
//!< for mapping of syntaxElement to UVLC
void (*mapping)(int value1, int value2, int* len_ptr, int* info_ptr);
} SyntaxElement;
//! Macroblock
typedef struct macroblock
{
int currSEnr; //!< number of current syntax element
byte slice_nr;
byte delta_qp;
byte qp ;
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] \n
NULL pointer identifies neighboring MBs which are unavailable */
// some storage of macroblock syntax elements for global access
byte mb_type;
byte mb_type_2;/*lgp*/
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,scbp;/*lgp*/
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 c_ipred_mode; //!< chroma intra prediction mode
int IntraChromaPredModeFlag;
int mb_field;
int ****cofAC;/*lgp*dct*modify*/ //!< AC coefficients [8x8block][4x4block][level/run][scan_pos]
int ****chromacofAC;/*lgp*/
int c_ipred_mode_2; /*lgp*/ //!< chroma intra prediction mode
} Macroblock;
//! Bitstream
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
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
} Bitstream;
EXTERN Bitstream *currBitStream;
#define MAXSLICEPERPICTURE 100
typedef struct
{
int no_slices;
int bits_per_picture;
float distortion_y;
float distortion_u;
float distortion_v;
} Picture;
typedef struct{
int extension_id;
int copyright_flag;
int copyright_id;
int original_or_copy;
int reserved;
int copyright_number;
} CopyRight;
typedef struct{
int reserved;
int camera_id;
int height_of_image_device;
int focal_length;
int f_number;
int vertical_angle_of_view;
int camera_position_x;
int camera_position_y;
int camera_position_z;
int camera_direction_x;
int camera_direction_y;
int camera_direction_z;
int image_plane_vertical_x;
int image_plane_vertical_y;
int image_plane_vertical_z;
} CameraParamters;
extern CopyRight *cp;
extern CameraParamters *camera;
EXTERN Picture *frame_pic;
EXTERN byte *imgY_org_buffer; //!< Reference luma image
// global picture format dependend buffers, mem allocation in image.c
EXTERN byte **imgY_frm; //!< Encoded luma images
EXTERN byte ***imgUV_frm; //!< Encoded croma images
EXTERN byte **imgY_org_frm; //!< Reference luma image
EXTERN byte ***imgUV_org_frm; //!< Reference croma image
EXTERN int ***tmp_mv_frm; //!< motion vector buffer
EXTERN int **refFrArr_frm; //!< Array for reference frames of each block
EXTERN byte **imgY; //!< Encoded luma images
EXTERN byte ***imgUV; //!< Encoded croma images
EXTERN byte **imgY_org; //!< Reference luma image
EXTERN byte ***imgUV_org; //!< Reference croma image
EXTERN byte **imgY_pf; //!< Post filter luma image
EXTERN byte ***imgUV_pf; //!< Post filter croma image
EXTERN byte **mref[4]; //!< 1/4 pix luma
EXTERN byte **mcef[4][2]; //!< pix chroma
EXTERN int **img4Y_tmp; //!< for quarter pel interpolation
EXTERN int ***tmp_mv; //!< motion vector buffer
EXTERN int **refFrArr; //!< Array for reference frames of each block
// B pictures
// motion vector : forward, backward, direct
EXTERN int ***tmp_fwMV;
EXTERN int ***tmp_bwMV;
EXTERN int ***dfMV;
EXTERN int ***dbMV;
EXTERN int **fw_refFrArr;
EXTERN int **bw_refFrArr;
EXTERN byte **nextP_imgY;
EXTERN byte ***nextP_imgUV;
EXTERN pel_t *Refbuf11[4]; //!< 1/1th pel (full pel) reference frame buffer
// global picture format dependend buffers, mem allocation in image.c (field picture)
EXTERN byte **imgY_com; //!< Encoded luma images
EXTERN byte ***imgUV_com; //!< Encoded croma images
// global picture format dependend buffers, mem allocation in image.c (field picture)
EXTERN byte **mref_fld[4]; //!< 1/4 pix luma
EXTERN byte ***mref_mbfld; //!< For MB level field/frame coding tools
// global picture format dependend buffers, mem allocation in image.c (frame buffer)
EXTERN byte **mref_frm[2]; //!< 1/4 pix luma //[2:ref_index]
// B pictures
// motion vector : forward, backward, direct
EXTERN int **fwdir_refFrArr; //!< direct mode forward reference buffer
EXTERN int **bwdir_refFrArr; //!< direct mode backward reference buffer
// global picture format dependend buffers, mem allocation in image.c (frame buffer)
EXTERN byte **imgY_org_frm;
EXTERN byte ***imgUV_org_frm;
EXTERN byte **imgY_frm; //!< Encoded luma images
EXTERN byte ***imgUV_frm; //!< Encoded croma images
EXTERN byte (*tmpmpr)[16];
EXTERN int **refFrArr_frm; //!< Array for reference frames of each block
// B pictures
// motion vector : forward, backward, direct
EXTERN int **fw_refFrArr_frm;
EXTERN int **bw_refFrArr_frm;
EXTERN byte intras; //!< Counts the intra updates in each frame.
EXTERN byte Bframe_ctr, frame_no, nextP_tr_frm,nextP_tr;
EXTERN byte tmp_buf_cycle; // jlzheng 7.21
EXTERN short bot_field_mb_nr; // record the relative mb index in the top field, Xiaozhen Zheng HiSilicon, 20070327
#define ET_SIZE 300 //!< size of error text buffer
EXTERN char errortext[ET_SIZE]; //!< buffer for error message for exit with error()
//! SNRParameters
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;
//! all input parameters
typedef struct
{
byte no_frames; //!< number of frames to be encoded
int qp0; //!< QP of first frame
int qpN; //!< QP of remaining frames
byte jumpd; //!< number of frames to skip in input sequence (e.g 2 takes frame 0,3,6,9...)
byte 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 infile_header; //!< If input file has a header set this to the length of the header
char infile[100]; //!< YUV 4:2:0 input format
char outfile[100]; //!< AVS compressed output bitstream
char ReconFile[100]; //!< Reconstructed Pictures
int intra_period;
// B pictures
int successive_Bframe; //!< number of B frames that will be used
int qpB; //!< QP of B frames
int SequenceHeaderType;
int InterSearch16x16;
int InterSearch16x8;
int InterSearch8x16;
int InterSearch8x8;
char PictureTypeSequence[MAXPICTURETYPESEQUENCELEN];
int rdopt;
int InterlaceCodingOption;
//AVS
int aspect_ratio_information;
int frame_rate_code;//xfwang 2004.7.28
//int bit_rate;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -