global.h

来自「ccs环境下实现图像的平移 用的是DM642」· C头文件 代码 · 共 784 行 · 第 1/2 页

H
784
字号
	int bit_rate_lower;
	int bit_rate_upper;
	int slice_weighting_flag;
	int mb_weighting_flag;

    int vec_period;
	int seqheader_period;	// Random Access period though sequence header

	int bbv_buffer_size;
	int video_format;
	int color_description;
	int color_primaries;
	int transfer_characteristics;
	int matrix_coefficients;
	int hour;
	int minute;
	int second;
	int frame_offset;
	int profile_id;
	int level_id;
	int progressive_sequence;
	int repeat_first_field;
	int top_field_first;
	int low_delay;
	int chroma_format;
	int sample_precision;
	int video_range;
	int stream_length_flag;
	int picture_decoder_order_flag;
	int frame_pred_frame_dct;
	int progressive_frame;
	int fixed_picture_qp;
	int time_code_flag;
	int display_horizontal_size;
	int display_vertical_size;
	int dct_adaptive_flag;
//  int slice_enable;
  int slice_parameter;
  int slice_row_nr;
	int skip_mode_flag;
	int loop_filter_disable;
	int loop_filter_parameter_flag;
	int alpha_c_offset;
	int beta_offset;
  	//! Rate Control on AVS standard 
	int RCEnable;    
	int bit_rate;
	int SeinitialQP;
	int basicunit;
	int channel_type;
	int frame_rate;
    int stuff_height;
} InputParameters;

//! ImageParameters
typedef struct
{
  int number;                  //!< current image number to be encoded
  int pn;                      //!< picture number
 
  byte nb_references;
  short current_mb_nr;
  int total_number_mb;
  byte current_slice_nr;
  int type;
	int ptype;/*lgp*/
  int types;                   /*!< This is for SP-Pictures, since all the syntax elements for SP-Pictures
                                    are the same as P-pictures, we keep the img->type as P_IMG but indicate
                                    SP-Pictures by img->types */
  int no_multpred;             /*!< 1: prediction from the last frame only.
                                    2: prediction from the last or second last frame etc. */
  byte qp;                      //!< quant for the current frame
  int framerate;
   
  int width;                   //!< Number of pels
  int width_cr;                //!< Number of pels chroma
  int height;                  //!< Number of lines
  int height_cr;               //!< Number of lines  chroma
  int mb_y;                    //!< current MB vertical
  int mb_x;                    //!< current MB horizontal
  int block_y;                 //!< current block vertical
  int block_x;                 //!< current block horizontal
  int pix_y;                   //!< current pixel vertical
  int pix_x;                   //!< current pixel horizontal
  int pix_c_y;                 //!< current pixel chroma vertical
  int block_c_x;               //!< current block chroma vertical
  int pix_c_x;                 //!< current pixel chroma horizontal
  int **ipredmode;             //!< GH ipredmode[90][74];prediction mode for inter frames */ /* fix from ver 4.1
  int cod_counter;             //!< Current count of number of skipped macroblocks in a row

  // some temporal buffers
  int mprr[9][16][16];         //!< all 9 prediction modes? // enlarged from 4 to 16 for ABT (is that neccessary?)

  int mprr_2[5][16][16];       //!< all 4 new intra prediction modes
  int mprr_c[2][4][8][8];      //!< new chroma 8x8 intra prediction modes
  int***** mv;                 //!< motion vectors for all block types and all reference frames
  byte mpr[16][16];             //!< current best prediction mode
  int  m7[16][16];              //!< the diff pixel values between orginal image and prediction

  int ****chromacofAC; /*lgp*/        //!< AC coefficients [uv][4x4block][level/run][scan_pos]
  int ****cofAC;               //!< AC coefficients [8x8block][4x4block][level/run][scan_pos]
  int ***cofDC;                //!< DC coefficients [yuv][level/run][scan_pos]

  Macroblock    *mb_data;                                   //!< array containing all MBs of a whole frame
 // SyntaxElement   MB_SyntaxElements[MAX_SYMBOLS_PER_MB];    //!< temporal storage for all chosen syntax elements of one MB
  SyntaxElement   *MB_SyntaxElements; //!< by oliver 0612
  int *quad;               //!< Array containing square values,used for snr computation  */                                         /* Values are limited to 5000 for pixel differences over 70 (sqr(5000)).
  int **intra_block;

  int tr;
  int fld_type;                        //!< top or bottom field
  unsigned int fld_flag;                                
  int direct_intraP_ref[4][4];
  int imgtr_next_P_frm;
  int imgtr_last_P_frm;
 
  // B pictures
  int b_interval;
  int p_interval;
  int b_frame_to_code;
  int fw_mb_mode;
  int bw_mb_mode;
  int***** p_fwMV;       //!< for MVDFW
  int***** p_bwMV;       //!< for MVDBW

  int***** all_mv;       //!< replaces local all_mv
  int***** all_bmv;      //!< replaces local all_mv

  int num_ref_pic_active_fwd_minus1;
  int num_ref_pic_active_bwd_minus1;

  int auto_crop_right;
  int auto_crop_bottom;
  int buf_cycle;

  unsigned int frame_num;   //frame_num for this frame
  
  //the following are sent in the slice header
	int NoResidueDirect;

  int coding_stage;/*lgp*/
  int block8_x;/*lgp*/
  int block8_y;/*lgp*/  
  int coded_mb_nr;

  int***** omv;
  int***** all_omv;       //!< replaces local all_mv
  int***** omv_fld;
  int***** all_omv_fld;       //!< replaces local all_mv

  int current_slice_start_mb;
  int current_slice_qp;
	int progressive_frame;
	int picture_structure;
	int dropflag;
	int advanced_pred_mode_disable;
	int old_type;
	int current_mb_nr_fld;

	int top_bot;           // -1: frame / 0: top field / 1: bottom field / Yulj 2004.07.14
	int mb_no_currSliceLastMB; // the last MB no in current slice.      Yulj 2004.07.15

	int Seqheader_flag;			// Added by cjw, 20070327	
	int curr_picture_distance;	// Added by Xiaozhen Zheng, 20070405
	int last_picture_distance;	// Added by Xiaozhen Zheng, 20070405
	int count;
	int count_PAFF;
} ImageParameters;

                                //!< 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 bitr0;                  //!< stored bit rate for the first frame
  float bitrate;                //!< average bit rate for the sequence except first frame
  int   bit_ctr;                //!< counter for bit usage
  int   bit_ctr_0;              //!< stored bit use for the first frame
  int   bit_ctr_n;              //!< bit usage for the current frame
  int   bit_slice;              //!< number of bits in current slice
  int   bit_use_mode_inter[2][MAXMODE]; //!< statistics of bit usage
  int   bit_ctr_emulationprevention; //!< stored bits needed to prevent start code emulation
  int   mode_use_intra[25];     //!< Macroblock mode usage for Intra frames
  int   mode_use_inter[2][MAXMODE];
  
  int   mb_use_mode[2];/*lgp*/

  // B pictures
  int   *mode_use_Bframe;
  int   *bit_use_mode_Bframe;
  int   bit_ctr_P;
  int   bit_ctr_B;
  float bitrate_P;
  float bitrate_B;
  
#define NUM_PIC_TYPE 5
  int   bit_use_stuffingBits[NUM_PIC_TYPE];
  int   bit_use_mb_type[NUM_PIC_TYPE];
  int   bit_use_header[NUM_PIC_TYPE];
  int   tmp_bit_use_cbp[NUM_PIC_TYPE];
  int   bit_use_coeffY[NUM_PIC_TYPE];
  int   bit_use_coeffC[NUM_PIC_TYPE];
  int   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;
} StatParameters;

//!< For MB level field/frame coding tools
//!< temporary structure to store MB data for field/frame coding
typedef struct
{
  double min_rdcost;
  int tmp_mv[2][2][2];        // to hold the motion vectors for each block
  int tmp_fwMV[2][2][2];      // to hold forward motion vectors for B MB's
  int tmp_bwMV[2][2][2];      // to hold backward motion vectors for B MBs
  int dfMV[2][2][2], dbMV[2][2][2]; // to hold direct motion vectors for B MB's
  int    rec_mbY[16][16];       // hold the Y component of reconstructed MB
  int    rec_mbU[8][8], rec_mbV[8][8]; 
  int    ****cofAC;
	int    ****chromacofAC;/*lgp*/
  int    ***cofDC;
	int    mvd[2][BLOCK_MULTIPLE][BLOCK_MULTIPLE][2];/*lgp*/
  int    mb_type;
  int    b8mode[4], b8pdir[4];
  int    frefar[2][2], brefar[2][2];
  int    **ipredmode;
  int    intra_pred_modes[4];
  int    cbp, cbp_blk;
  int    mode;
  int    *****mv, *****p_fwMV, *****p_bwMV ;
  int    *****all_mv;
  int    *****all_bmv;
  int    c_ipred_mode;
} RD_DATA;

EXTERN RD_DATA *rdopt; 

EXTERN float singlefactor;
/*
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
*/
/*lgp*/
extern InputParameters *input;
extern ImageParameters *img;
extern StatParameters *stat;
extern SNRParameters *snr;

// cjw for WP prediction
EXTERN int *allalpha_lum, *allbelta_lum;

// cjw for mv limit
EXTERN byte mv_out_of_range;

// Tsinghua for picture_distance  200701
EXTERN byte picture_distance;		

// files
EXTERN FILE *p_dec,*p_dec_u,*p_dec_v;   //!< internal decoded image for debugging
EXTERN FILE *p_stat;                    //!< status file for the last encoding session
EXTERN FILE *p_log;                     //!< SNR file
EXTERN FILE *p_in;                      //!< YUV
EXTERN FILE *p_datpart;                 //!< file to write bitlength and id of all partitions

int  sign(int a,int b);
void init_img();

void  LumaPrediction4x4 (int, int, int, int, int, int);
int   SATD (int*, int);

pel_t* FastLineX (int, pel_t*, int, int);
pel_t* UMVLineX  (int, pel_t*, int, int);

void LumaResidualCoding ();
void ChromaResidualCoding (int*);
void IntraChromaPrediction8x8 (int*, int*, int*);
int  writeMBHeader   (int rdopt); 

extern int*   refbits;
extern int*** motion_cost;
/*Lou 1016 Start*/
//int calculate_distance(int blkref, int smbtype, int coding_stage, int ref);
int scale_motion_vector(int motion_vector, int currblkref, int neighbourblkref, int currsmbtype, int neighboursmbtype, int block_y_pos, int curr_block_y, int ref, int direct_mv);
/*Lou 1016 End*/
int calculate_distance(int blkref, int fw_bw ); // Yulj 2004.07.14
void  PartitionMotionSearch     (int, int, double);
void  PartitionMotionSearch_bid (int, int, double);
int   BIDPartitionCost          (int, int, int, int,int);
int   LumaResidualCoding8x8     (int*, int*, int, int, int, int, int);
int   writeLumaCoeff8x8         (int, int);
int   writeMotionVector8x8      (int, int, int, int, int, int, int, int);
int   writeIntra4x4Modes        (int);
int   writeChromaIntraPredMode  ();
int		Get_Direct_Cost8x8 (int, double);
int		Get_Direct_CostMB  (double);
int		B8Mode2Value (int b8mode, int b8pdir);
int		GetSkipCostMB (double lambda);
void	FindSkipModeMotionVector ();

// dynamic mem allocation
int  init_global_buffers();
void free_global_buffers();
void no_mem_exit  (char *where);

int  get_mem_mv  (int******);
void free_mem_mv (int*****);
void free_img    ();

int  get_mem_ACcoeff  (int*****);
int  get_mem_DCcoeff  (int****);
void free_mem_ACcoeff (int****);
void free_mem_DCcoeff (int***);

void split_field_top();
void split_field_bot();

int  writeBlockCoeff (int block8x8);
int  storeMotionInfo (int pos);

void intrapred_luma_AVS(int img_x,int img_y);

// Added for (re-) structuring the TML soft
Picture *malloc_picture();
void		free_picture (Picture *pic);
int			encode_one_slice(Picture *pic);   //! returns the number of MBs in the slice

void  encode_one_macroblock();
void  start_macroblock();
void  set_MB_parameters (short mb);           //! sets up img-> according to input-> and currSlice->

void  terminate_macroblock(Boolean *end_of_picture);
void  write_one_macroblock(int eos_bit);
void  proceed2nextMacroblock();

void  CheckAvailabilityOfNeighbors();

void free_slice_list(Picture *currPic);

void error(char *text, int code);
int  start_sequence();
int  terminate_sequence();
int  start_slice();

void stuffing_byte(int n);

int   writeCBPandLumaCoeff  ();
int   writeChromaCoeff      ();

//============= rate-distortion optimization ===================
void  clear_rdopt      ();
void  init_rdopt       ();

void SetImgType();

#define IMG_NUMBER (img->number)

extern int*** motion_cost_bid;

void  Get_IP_direct();
void FreeBitstream();
void AllocateBitstream();

// reference frame buffer
EXTERN unsigned char **reference_frame[3][3];  //[refnum][yuv][height][width]

EXTERN unsigned char ***ref[4];  //[refnum(4 for filed)][yuv][height(height/2)][width]
EXTERN unsigned char ***ref_frm[2];  //[refnum(4 for filed)][yuv][height(height/2)][width]
EXTERN unsigned char ***ref_fld[6];  //[refnum(4 for filed)][yuv][height(height/2)][width]
EXTERN unsigned char ***b_ref[2],***f_ref[2];
EXTERN unsigned char ***b_ref_frm[2],***f_ref_frm[2];
EXTERN unsigned char ***b_ref_fld[2],***f_ref_fld[2];
EXTERN unsigned char ***current_frame;//[yuv][height][width]

//qhg for demulation 
EXTERN Bitstream *tmpStream;  
EXTERN short current_slice_bytepos;
//qhg 20060327 for de-emulation
void AllocatetmpBitstream();
void FreetmpBitstream();
void Demulate(Bitstream *currStream, short current_slice_bytepos);

void SetModesAndRefframeForBlocks (byte mode);

void SetModesAndRefframe (int b8, int* fw_mode, int* bw_mode, int* fw_ref, int* bw_ref);
//Rate control
EXTERN byte   QP;
#endif

⌨️ 快捷键说明

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