📄 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
/***********************************************************************
* 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
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)
#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);
} SyntaxElement;
//! Macroblock
typedef 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[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
int mb_type;
int 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 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 ****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
//rate control
int prev_cbp;
int prev_qp;
int predict_qp;
int predict_error;
} 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;
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;
Picture *frame_pic;
Picture *top_pic;
Picture *bot_pic;
byte *imgY_org_buffer; //!< Reference luma image
// global picture format dependend buffers, mem allocation in image.c
byte **imgY_frm; //!< Encoded luma images
byte ***imgUV_frm; //!< Encoded croma images
byte **imgY_org_frm; //!< Reference luma image
byte ***imgUV_org_frm; //!< Reference croma image
int ***tmp_mv_frm; //!< motion vector buffer
int **refFrArr_frm; //!< Array for reference frames of each block
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 **mref[4]; //!< 1/4 pix luma
byte **mcef[4][2]; //!< pix chroma
int **img4Y_tmp; //!< for quarter pel interpolation
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 ***tmp_fwMV_top; //!< For MB level field/frame coding tools
int ***tmp_fwMV_bot; //!< For MB level field/frame coding tools
int ***tmp_bwMV_top; //!< For MB level field/frame coding tools
int ***tmp_bwMV_bot; //!< For MB level field/frame coding tools
int **field_mb; //!< For MB level field/frame coding tools
int WriteFrameFieldMBInHeader; //! For MB level field/frame coding tools
int ***tmp_fwMV_fld;/*lgp*/ //!< For MB level field/frame coding tools
int ***tmp_bwMV_fld;/*lgp*/ //!< For MB level field/frame coding tools
int ***dfMV;
int ***dbMV;
int **fw_refFrArr;
int **bw_refFrArr;
byte **nextP_imgY;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -