⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.h

📁 JM 11.0 KTA 2.1 Source Code
💻 H
📖 第 1 页 / 共 5 页
字号:
  
  int MbaffFrameFlag;    //!< indicates frame with mb aff coding
  
  //the following should probably go in sequence parameters
  // unsigned int log2_max_frame_num_minus4;
  unsigned int pic_order_cnt_type;
  // for poc mode 0, POC200301
  // unsigned int log2_max_pic_order_cnt_lsb_minus4;  
  // for poc mode 1, POC200301
  unsigned int delta_pic_order_always_zero_flag;
  int offset_for_non_ref_pic;
  int offset_for_top_to_bottom_field;
  unsigned int num_ref_frames_in_pic_order_cnt_cycle;
  int offset_for_ref_frame[1];  // MAX_LENGTH_POC_CYCLE in decoder
  
  // POC200301
  //the following is for slice header syntax elements of poc
  // for poc mode 0.
  unsigned int pic_order_cnt_lsb;
  int delta_pic_order_cnt_bottom;
  // for poc mode 1.
  int delta_pic_order_cnt[2];
  
  
  // POC200301
  unsigned int field_picture;
  signed int toppoc;      //!< poc for this frame or field
  signed int bottompoc;   //!< for completeness - poc of bottom field of a frame (always = poc+1)
  signed int framepoc;    //!< min (toppoc, bottompoc)
  signed int ThisPOC;     //!< current picture POC
  unsigned int frame_num;   //!< frame_num for this frame
  
  unsigned int PicWidthInMbs;
  unsigned int PicHeightInMapUnits;
  unsigned int FrameHeightInMbs;
  unsigned int PicHeightInMbs;
  unsigned int PicSizeInMbs;
  unsigned int FrameSizeInMbs;
  
  //the following should probably go in picture parameters
  unsigned int pic_order_present_flag; // ????????
  
  //the following are sent in the slice header
  //  int delta_pic_order_cnt[2];
  int nal_reference_idc;
#ifdef  USE_HP_FILTER//BROUND
  int bipred_rounding_control;
#endif
  
  int adaptive_ref_pic_buffering_flag;
  int no_output_of_prior_pics_flag;
  int long_term_reference_flag;
  
  DecRefPicMarking_t *dec_ref_pic_marking_buffer;
  
  int model_number;

  /*rate control*/
  int NumberofHeaderBits; 
  int NumberofTextureBits;
  int NumberofBasicUnitHeaderBits;
  int NumberofBasicUnitTextureBits;
  double TotalMADBasicUnit;
  int NumberofMBTextureBits;
  int NumberofMBHeaderBits;
  int NumberofCodedBFrame; 
  int NumberofCodedPFrame;
  int NumberofGOP;
  int TotalQpforPPicture;
  int NumberofPPicture;
  double *MADofMB;
  int BasicUnitQP;
  int TopFieldFlag;
  int FieldControl;
  int FieldFrame;
  int Frame_Total_Number_MB;
  int IFLAG;
  int NumberofCodedMacroBlocks;
  int BasicUnit;
  int write_macroblock;
  int bot_MB;
  int write_macroblock_frame;
  
  int DeblockCall;
  
  int last_pic_bottom_field;
  int last_has_mmco_5;
  int pre_frame_num;
  
  int slice_group_change_cycle;
  
  int pic_unit_size_on_disk;
  int bitdepth_luma;
  int bitdepth_chroma;
  int bitdepth_luma_qp_scale;
  int bitdepth_chroma_qp_scale;
  int bitdepth_lambda_scale;
  // Lagrangian Parameters
  double **lambda_md;     //!< Mode decision Lambda
  double **lambda_me;     //!< Motion Estimation Lambda
  int    **lambda_mf;     //!< Integer formatted Motion Estimation Lambda
  
  unsigned int dc_pred_value_luma;   //!< luma value for DC prediction (depends on luma pel bit depth)
  unsigned int dc_pred_value_chroma; //!< chroma value for DC prediction (depends on chroma pel bit depth)
  int max_imgpel_value;              //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)
  int max_imgpel_value_uv;
  
  int num_blk8x8_uv;
  int num_cdc_coeff;
  int yuv_format;
  int lossless_qpprime_flag;
  int mb_cr_size_x;
  int mb_cr_size_y;
  
  int chroma_qp_offset[2];      //!< offset for qp for chroma [0-Cb, 1-Cr] 
  
  // Residue Color Transform
  int residue_transform_flag;
  
  int auto_crop_right;
  int auto_crop_bottom;
  
  short checkref;
  int last_valid_reference;
  
  
  int bytes_in_picture;
#ifdef RDO_Q
  int masterQP;
#endif

#ifdef ADAPTIVE_QUANTIZATION
  int mb_iaqms_idx;
  int slice_fractional_quant_flag;
  int slice_mqm_signaling_flag;
  int slice_modeling_qm_param0;
  int slice_modeling_qm_param1;
#endif
#ifdef ADAPTIVE_FILTER
  int AdaptiveFilterFlag;     // 0, if filter coeffitients still not found, 1 if ready for writing, -1 - no filter
#endif
#ifdef ADAPTIVE_FD_SD_CODING
  int    APEC_in_FD_and_SD;
  float  adjust_adaptive_f_spatial_domain_4x4;
  float  adjust_adaptive_f_spatial_domain_8x8;
#endif
#ifdef  INTERNAL_BIT_DEPTH_INCREASE
  int BitDepthIncrease;
  int BitDepthIncreaseChroma;
#endif
#ifdef USE_INTRA_MDDT
  long quant_stat[16];
  int  qp_shift[16];
  int  delta_shift;
  int  QPVal;
  long quant_stat8x8[64];
  int  qp_shift8x8[64];
  int  delta_shift8x8;
  int  QPVal8x8;
  long quant_stat16x16[256];
  int  qp_shift16x16[256];
  int  delta_shift16x16;
  int  QPVal16x16;
  
  byte scanOrder4x4[9][16][2];
  byte scanOrder8x8[9][64][2];
  int  scanStats4x4[9][16];
  int  scanStats8x8[9][64];
  int  update4x4[9];
  int  update8x8[9];
  int  update4x4Count[9];
  int  update8x8Count[9];
  int  update4x4Thres[9];
  int  update8x8Thres[9];
  
  byte scanOrder16x16[4][256][2];
  int  cofAC16[2][16*17];
#endif 
#ifdef USE_NEW_OFFSET
  int  frameOffsetTotal[2][MAX_REFERENCE_PICTURES]; 
  int  frameOffsetCount[2][MAX_REFERENCE_PICTURES]; 
  int  frameOffset[2][MAX_REFERENCE_PICTURES];
  int  frameOffsetAvail; 
#endif

#ifdef SWITCHED_FILTERS
  int filterFrame[16];                            // Filter selection computed on current frame
  int filterSequence[16];                         // Filter selection computed on sequence
  int subpelOffset_list0[16];                     // Sub-pel offsets for Frame0 in List0
  int subpelOffset_list1[16];                     // Sub-pel offsets for Frame0 in List1
  int imgOffset_list0[MAX_REFERENCE_PICTURES];    // Image offset for frames in List0
  int imgOffset_list1[MAX_REFERENCE_PICTURES];    // Image offset for frames List1
  int filterParam;
#endif  // SWITCHED_FILTERS
} ImageParameters;

#if defined(RDO_Q) || defined(ADAPTIVE_QUANTIZATION)
int Motion_Selected;
int Intra_Selected; 
int final_mb_encoding;
int saved_best_mode ;

#define IS_INTRA_MODE(mode)  ((mode==I4MB)||(mode==I8MB)||(mode==I16MB)||(mode==IPCM))
#endif

#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   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;
  
#ifdef MV_COMPETITION
  int64   predictor_for_skip_use    [NUM_PIC_TYPE][MAX_MV_PREDICTOR];
  int64   predictor_for_skip_trans  [NUM_PIC_TYPE];
  int64   bit_use_pred_for_skip     [NUM_PIC_TYPE];
  int64   bit_use_pred_for_mv_inter [NUM_PIC_TYPE];
#endif
  
} 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;
#ifdef ADAPTIVE_QUANTIZATION
  int    mb_iaqms_idx;
#endif
#ifdef ADAPTIVE_FD_SD_CODING
  int    best_SD_Coding_on_off;
  int    best_quantizer_indices  [16][16];
  int    best_SD_or_FD           [ 2][ 2];
  int    best_SD_or_FD_t8x8;
  //BUGFIX APEC
  short  ******bipred_mv1;
  short  ******bipred_mv2;
  //END BUGFIX APEC
  
  // <FTRD Compatibility with APEC
#ifdef MV_COMPETITION
  int *****send_index_mv_prediction_RDDATA;
  int *****predModeMV_RDDATA;
#endif
  // FTRD>
  
#endif
} 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;
  int rec_resG_8x8[16][16];
  int resTrans_R_8x8[16][16];
  int resTrans_B_8x8[16][16];
  int mprRGB_8x8[3][16][16];
  short part8x8mode[4];
  short part8x8pdir[4];
  char  part8x8fwref[4];
  char  part8x8bwref[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
  
#ifdef ADAPTIVE_FD_SD_CODING
  int    SD_Coding_on_off8x8;
  int    quantizer_indices8x8  [16][16];
  int    SD_or_FD8x8           [2][2];
  int    SD_or_FD_t8x88x8;
#endif
} RD_8x8DATA;

typedef struct
{  
  double lambda_md;     //!< Mode decision Lambda
  double lambda_me;     //!< Motion Estimation Lambda
  int    lambda_mf;     //!< 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
#ifdef ADAPTIVE_FD_SD_CODING

⌨️ 快捷键说明

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