📄 global.h
字号:
int lastIDRnumber;
int lastIntraNumber;
int lastINTRA;
int last_ref_idc;
int idr_refresh;
} ImageParameters;
#define NUM_PIC_TYPE 5
//!< statistics
typedef struct
{
int quant0; //!< quant for the first frame
int quant1; //!< average quant for the remaining frames
float bitr; //!< bit rate for current frame, used only for output til terminal
float bitrate; //!< average bit rate for the sequence except first frame
int64 bit_ctr; //!< counter for bit usage
int64 bit_ctr_n; //!< bit usage for the current frame
int bit_slice; //!< number of bits in current slice
int stored_bit_slice; //!< keep number of bits in current slice (to restore status in case of MB re-encoding)
int bit_ctr_emulationprevention; //!< stored bits needed to prevent start code emulation
int b8_mode_0_use[NUM_PIC_TYPE][2];
int mode_use_transform_8x8[NUM_PIC_TYPE][MAXMODE];
int mode_use_transform_4x4[NUM_PIC_TYPE][MAXMODE];
int intra_chroma_mode[4];
// B pictures
int successive_Bframe;
int *mode_use_Bframe;
int *bit_use_mode_Bframe;
int64 bit_ctr_I;
int64 bit_ctr_P;
int64 bit_ctr_B;
float bitrate_I;
float bitrate_P;
float bitrate_B;
int64 mode_use [NUM_PIC_TYPE][MAXMODE]; //!< Macroblock mode usage for Intra frames
int64 bit_use_mode [NUM_PIC_TYPE][MAXMODE]; //!< statistics of bit usage
int64 bit_use_stuffingBits[NUM_PIC_TYPE];
int64 bit_use_mb_type [NUM_PIC_TYPE];
int64 bit_use_header [NUM_PIC_TYPE];
int64 tmp_bit_use_cbp [NUM_PIC_TYPE];
int64 bit_use_coeffY [NUM_PIC_TYPE];
int64 bit_use_coeffC [NUM_PIC_TYPE];
int64 bit_use_delta_quant [NUM_PIC_TYPE];
int em_prev_bits_frm;
int em_prev_bits_fld;
int *em_prev_bits;
int bit_ctr_parametersets;
int bit_ctr_parametersets_n;
} StatParameters;
//! For MB level field/frame coding tools
//! temporary structure to store MB data for field/frame coding
typedef struct
{
double min_rdcost;
imgpel rec_mbY[16][16]; // hold the Y component of reconstructed MB
imgpel rec_mbU[16][16], rec_mbV[16][16];
int ****cofAC;
int ***cofDC;
int mb_type;
short bi_pred_me;
int b8mode[4], b8pdir[4];
char **ipredmode;
char intra_pred_modes[16];
char intra_pred_modes8x8[16];
int cbp;
int64 cbp_blk;
int mode;
short ******pred_mv; //!< predicted motion vectors
short ******all_mv; //!< all modes motion vectors
char refar[2][4][4]; //!< reference frame array [list][y][x]
int i16offset;
int c_ipred_mode;
int luma_transform_size_8x8_flag;
int NoMbPartLessThan8x8Flag;
int qp;
int prev_qp;
int prev_delta_qp;
int delta_qp;
int prev_cbp;
} RD_DATA;
//! Set Explicit GOP Parameters.
//! Currently only supports Enhancement GOP but could be easily extended
typedef struct
{
int slice_type; //! Slice type
int display_no; //! GOP Display order
int reference_idc; //! Is reference?
int slice_qp; //! Assigned QP
int hierarchy_layer; //! Hierarchy layer (used with GOP Hierarchy option 2)
int hierarchyPocDelta; //! Currently unused
} GOP_DATA;
typedef struct
{
int cost8x8;
short part8x8mode[4];
char part8x8pdir[4];
char part8x8l0ref[4];
char part8x8l1ref[4];
imgpel rec_mbY8x8[16][16];
imgpel mpr8x8[16][16];
int lrec[16][16]; // transform and quantized coefficients will be stored here for SP frames
} RD_8x8DATA;
typedef struct
{
double lambda_md; //!< Mode decision Lambda
double lambda_me[3]; //!< Motion Estimation Lambda
int lambda_mf[3]; //!< Integer formatted Motion Estimation Lambda
short valid[MAXMODE];
short list_offset[2];
short curr_mb_field;
short best_ref[2];
int best_mcost[2];
} RD_PARAMS;
GOP_DATA *gop_structure;
RD_DATA *rdopt;
RD_DATA rddata_top_frame_mb, rddata_bot_frame_mb; //!< For MB level field/frame coding tools
RD_DATA rddata_top_field_mb, rddata_bot_field_mb; //!< For MB level field/frame coding tools
extern InputParameters *input;
extern ImageParameters *img;
extern StatParameters *stats;
extern SNRParameters *snr;
// files
FILE *p_stat; //!< status file for the last encoding session
FILE *p_log; //!< SNR file
FILE *p_trace; //!< Trace file
int p_in; //!< original YUV file handle
int p_dec; //!< decoded image file handle
/***********************************************************************
* P r o t o t y p e s f o r T M L
***********************************************************************
*/
void intrapred_luma(int CurrPixX,int CurrPixY, int *left_available, int *up_available, int *all_available);
int dct_luma(int pos_mb1,int pos_mb2,int *cnt_nonz, int intra);
int dct_luma_sp(int pos_mb1,int pos_mb2,int *cnt_nonz);
void copyblock_sp(int pos_mb1,int pos_mb2);
int dct_chroma(int uv,int i11);
int dct_chroma_sp(int uv,int i11);
void intrapred_luma_16x16(void);
int dct_luma_16x16(int);
void init_poc(void);
void init_img(void);
void report(void);
int get_picture_type(void);
void DeblockFrame(ImageParameters *img, imgpel **, imgpel ***) ;
int distortion4x4(int*);
int distortion8x8(int*);
extern int* refbits;
extern int**** motion_cost;
double *mb16x16_cost_frame;
void Get_Direct_Motion_Vectors (void);
void PartitionMotionSearch (int, int, int*);
int BIDPartitionCost (int, int, short, short, int);
int writeAbpCoeffIndex (int, int, int, int);
void estimate_weighting_factor_B_slice(void);
void estimate_weighting_factor_P_slice(int offset);
int test_wp_P_slice(int offset);
int test_wp_B_slice(int method);
void poc_based_ref_management(int current_pic_num);
int picture_coding_decision (Picture *picture1, Picture *picture2, int qp);
unsigned CeilLog2( unsigned uiVal);
int GetDirectCost8x8 (int, int*);
int BPredPartitionCost (int, int, short, short, int, int);
int GetDirectCostMB (void);
int GetSkipCostMB (void);
void FindSkipModeMotionVector (void);
// dynamic mem allocation
int init_global_buffers(void);
void free_global_buffers(void);
void no_mem_exit (char *where);
int get_mem_mv (short*******);
void free_mem_mv (short******);
void free_img (void);
int get_mem_ACcoeff (int*****);
int get_mem_DCcoeff (int****);
void free_mem_ACcoeff (int****);
void free_mem_DCcoeff (int***);
int decide_fld_frame(float snr_frame_Y, float snr_field_Y, int bit_field, int bit_frame, double lambda_picture);
void combine_field(void);
Picture *malloc_picture(void);
void free_picture (Picture *pic);
int encode_one_slice(int SLiceGroupId, Picture *pic, int TotalCodedMBs); //! returns the number of MBs in the slice
void free_slice_list(Picture *currPic);
void report_stats_on_error(void);
#if TRACE
void trace2out(SyntaxElement *se);
void trace2out_cabac(SyntaxElement *se);
#endif
void error(char *text, int code);
int start_sequence(void);
int rewrite_paramsets(void);
int terminate_sequence(void);
int start_slice(void);
int terminate_slice(int);
int write_PPS(int, int);
// B pictures
int get_fwMV(int *min_fw_sad, int tot_intra_sad);
void get_bwMV(int *min_bw_sad);
void get_bid(int *bid_sad, int fw_predframe_no);
void get_dir(int *dir_sad);
void compare_sad(int tot_intra_sad, int fw_sad, int bw_sad, int bid_sad, int dir_sad, int);
int BlkSize2CodeNumber(int blc_size_h, int blc_size_v);
void InitMotionVectorSearchModule(void);
int field_flag_inference(void);
void set_mbaff_parameters(void); // For MB AFF
void writeVlcByteAlign(Bitstream* currStream);
int writeMB_bits_for_4x4_luma (int, int, int);
int writeMB_bits_for_16x16_luma (void);
int writeMB_bits_for_luma (int);
int writeMB_bits_for_DC_chroma (int);
int writeMB_bits_for_AC_chroma (int);
int writeMB_bits_for_CBP (void);
int SingleUnifiedMotionSearch (int, int, int**, int***, int*****, int, int*****, double);
//============= rate-distortion optimization ===================
void clear_rdopt (void);
void init_rdopt (void);
void RD_Mode_Decision (void);
//============= rate-distortion opt with packet losses ===========
void decode_one_macroblock(void);
void decode_one_mb (int, Macroblock*);
void decode_one_b8block (int, int, int, int, int);
void Get_Reference_Block(imgpel **imY, int block_y, int block_x, int mvhor, int mvver, imgpel **out);
byte Get_Reference_Pixel(imgpel **imY, int y, int x);
int Half_Upsample(imgpel **imY, int j, int i);
void DecOneForthPix(imgpel **dY, imgpel ***dref);
void compute_residue(int mode);
void compute_residue_b8block (int, int);
void compute_residue_mb (int);
void UpdateDecoders(void);
void Build_Status_Map(byte **s_map);
void Error_Concealment(imgpel **inY, byte **s_map, imgpel ***refY);
void Conceal_Error(imgpel **inY, int mb_y, int mb_x, imgpel ***refY, byte **s_map);
//============= restriction of reference frames based on the latest intra-refreshes==========
void UpdatePixelMap(void);
//============= fast full integer search =======================
void ClearFastFullIntegerSearch (void);
void ResetFastFullIntegerSearch (void);
void SetImgType(void);
// Tian Dong: for IGOPs
extern Boolean In2ndIGOP;
extern int start_frame_no_in_this_IGOP;
extern int start_tr_in_this_IGOP;
extern int FirstFrameIn2ndIGOP;
extern int FrameNumberInFile;
int CalculateFrameNumber(void);
#define IMG_NUMBER (img->number - start_frame_no_in_this_IGOP)
void AllocNalPayloadBuffer(void);
void FreeNalPayloadBuffer(void);
void SODBtoRBSP(Bitstream *currStream);
int RBSPtoEBSP(byte *streamBuffer, int begin_bytepos, int end_bytepos, int min_num_bytes);
int Bytes_After_Header;
// Fast ME enable
int BlockMotionSearch (short,int,int,int,int,int, int*);
void low_complexity_encode_md (void);
void encode_one_macroblock_low (void);
void encode_one_macroblock_high (void);
void encode_one_macroblock_highfast (void);
void encode_one_macroblock_highloss (void);
void (*encode_one_macroblock) (void);
void set_chroma_qp(Macroblock *currMB);
void store_coding_state_cs_cm(void);
void reset_coding_state_cs_cm(void);
int writeIPCMBytes(Bitstream *currStream);
int writePCMByteAlign(Bitstream *currStream);
int dct_luma_sp2(int pos_mb1,int pos_mb2,int *cnt_nonz);
int dct_chroma_sp2(int ,int);
int check_for_SI16(void);
int **lrec ;
int ***lrec_uv;
int si_frame_indicator;
int sp2_frame_indicator;
int number_sp2_frames;
//#define sp_output_indicator 0 //will be in the config file
//#define sp_output_filename "sp_stored.txt" // will be in the config file
void output_SP_coefficients(void);
void read_SP_coefficients(void);
int giRDOpt_B8OnlyFlag;
#ifdef BEST_NZ_COEFF
int gaaiMBAFF_NZCoeff[4][12];
#endif
// Redundant picture
imgpel **imgY_tmp;
imgpel **imgUV_tmp[2];
int frameNuminGOP;
int redundant_coding;
int key_frame;
int redundant_ref_idx;
void Init_redundant_frame(void);
void Set_redundant_frame(void);
void encode_one_redundant_frame(void);
int img_pad_size_uv_x;
int img_pad_size_uv_y;
unsigned char chroma_mask_mv_y;
unsigned char chroma_mask_mv_x;
int chroma_shift_y, chroma_shift_x;
int shift_cr_x, shift_cr_x2, shift_cr_y;
int img_padded_size_x;
int img_padded_size_x2;
int img_padded_size_x4;
int img_padded_size_x_m8;
int img_padded_size_x_m8x8;
int img_padded_size_x_m4x4;
int img_cr_padded_size_x;
int img_cr_padded_size_x2;
int img_cr_padded_size_x4;
// struct with pointers to the sub-images
typedef struct {
imgpel ****luma; // component 0 (usually Y, X, or R)
imgpel ****crcb[2]; // component 2 (usually U/V, Y/Z, or G/B)
} SubImageContainer;
int start_me_refinement_hp; // if set then recheck the center position when doing half-pel motion refinement
int start_me_refinement_qp; // if set then recheck the center position when doing quarter-pel motion refinement
// For 4:4:4 independent mode
void change_plane_JV( int nplane );
void make_frame_picture_JV();
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -