global.h

来自「the newest JM software by h.264 JVT offi」· C头文件 代码 · 共 1,538 行 · 第 1/4 页

H
1,538
字号
  int long_term_reference_flag;

  DecRefPicMarking_t *dec_ref_pic_marking_buffer;

  int model_number;

  // rate control variables
  int NumberofCodedMacroBlocks;
  int BasicUnitQP;
  int NumberofMBTextureBits;
  int NumberofMBHeaderBits;
  unsigned int BasicUnit;
  byte write_macroblock;
  byte bot_MB;
  int write_mbaff_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 out_unit_size_on_disk;
  int bitdepth_luma;
  int bitdepth_chroma;
  int bitdepth_scale[2];
  int bitdepth_luma_qp_scale;
  int bitdepth_chroma_qp_scale;
  int bitdepth_lambda_scale;
  int max_bitCount;
  int max_qp_delta;
  int min_qp_delta;
  // Lagrangian Parameters
  LambdaParams **lambda;
  double  **lambda_md;     //!< Mode decision Lambda
  double ***lambda_me;     //!< Motion Estimation Lambda
  int    ***lambda_mf;     //!< Integer formatted Motion Estimation Lambda

  double **lambda_mf_factor; //!< Motion Estimation Lamda Scale Factor

  unsigned int dc_pred_value_comp[MAX_PLANE]; //!< component value for DC prediction (depends on component pel bit depth)
  unsigned int dc_pred_value;                 //!< DC prediction value for current component
  int max_imgpel_value_comp      [MAX_PLANE];       //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)
  int max_imgpel_value_comp_sq   [MAX_PLANE];       //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)
  int max_imgpel_value;              //!< max value that one picture element (pixel) can take (depends on pic_unit_bitdepth)

  int num_blk8x8_uv;
  int num_cdc_coeff;
  int yuv_format;
  int P444_joined;
  int lossless_qpprime_flag;
  int mb_cr_size_x;
  int mb_cr_size_y;
  int mb_size[MAX_PLANE][2];

  int chroma_qp_offset[2];      //!< offset for qp for chroma [0-Cb, 1-Cr]

  int auto_crop_right;
  int auto_crop_bottom;

  short checkref;
  int last_valid_reference;
  int bytes_in_picture;

  int AverageFrameQP;
  int SumFrameQP;
  int GopLevels;

  int ChromaArrayType;
  Macroblock    *mb_data_JV[MAX_PLANE];  //!< mb_data to be used during 4:4:4 independent mode encoding
  int colour_plane_id;    //!< colour_plane_id of the current coded slice (valid only when separate_colour_plane_flag is 1)

  int lastIDRnumber;
  int lastIntraNumber;
  int lastINTRA;
  int last_ref_idc;
  int idr_refresh;

  unsigned int primary_pic_type;

  int frameOffsetTotal[2][MAX_REFERENCE_PICTURES]; 
  int frameOffsetCount[2][MAX_REFERENCE_PICTURES]; 
  int frameOffset[2][MAX_REFERENCE_PICTURES];
  int frameOffsetAvail; 

} ImageParameters;


//! definition of pic motion parameters
typedef struct pic_motion_params2
{
  int64    ref_pic_id;    //!< reference picture identifier [list][subblock_y][subblock_x]
  int64    ref_id;        //!< reference picture identifier [list][subblock_y][subblock_x]
  short    mv[2];         //!< motion vector       [list][subblock_x][subblock_y][component]
  char     ref_idx;       //!< reference picture   [list][subblock_y][subblock_x]
  byte     mb_field;      //!< field macroblock indicator
  byte     field_frame;   //!< indicates if co_located is field or frame.
} PicMotionParams2;

// Motion Vector structure
typedef struct
{
  short mv_x;
  short mv_y;
} MotionVector;

//! For MB level field/frame coding tools
//! temporary structure to store MB data for field/frame coding
typedef struct
{
  double min_rdcost;
  double min_dcost;

  imgpel **rec_mbY;       // hold the Y component of reconstructed MB
  imgpel ***rec_mb_cr;       // hold the Y component of reconstructed MB
  int    ****cofAC;
  int    ***cofDC;
  int    *****cofAC_new;
  int    mb_type;  
  int    cbp;
  int    mode;
  int    i16offset;
  int    c_ipred_mode;
  int    luma_transform_size_8x8_flag;
  int    NoMbPartLessThan8x8Flag;

  int    qp;
  int    prev_qp;
  int    prev_dqp;
  int    prev_cbp;
  short  delta_qp;
  short  b8mode[4], b8pdir[4];  
  
  int64  cbp_blk;
  short  ******pred_mv;        //!< predicted motion vectors
  short  ******all_mv;         //!< all modes motion vectors

  char   intra_pred_modes[16];
  char   intra_pred_modes8x8[16];
  char   **ipredmode;
  char   ***refar;       //!< reference frame array [list][y][x]
} 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
{
  double smb_p8x8_rdcost[4]; 
  int mb_p8x8_cost;
  int smb_p8x8_cost[4];  
  int cbp8x8;
  int cbp_blk8x8;
  int cnt_nonz_8x8;
  short part8x8mode[4];
  short part8x8bipred[4];
  char  part8x8pdir[4];
  char  part8x8l0ref[4];
  char  part8x8l1ref[4];  
  int **lrec; // transform and quantized coefficients will be stored here for SP frames
  imgpel **mpr8x8;
  imgpel ***mpr8x8CbCr;
  imgpel **rec_mbY8x8;
  imgpel ***rec_mb8x8_cr;
} 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
  int    best_mcost[2];

  short  valid[MAXMODE];
  short  list_offset[2];
  short  curr_mb_field;
} 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

RD_DATA rddata_trellis_best, rddata_trellis_curr;
short *****tmp_mv8, *****tmp_pmv8;
int   ***motion_cost8;

extern InputParameters *params;
extern ImageParameters *img;

extern DistortionParams *dist;

// files
FILE *p_log;                     //!< SNR file
FILE *p_trace;                   //!< Trace file
int  p_dec;                      //!< decoded image file handle

int coeff_cost_cr[MAX_PLANE];
int cmp_cbp[3], i16x16mode, curr_cbp[2];
int64 cur_cbp_blk[MAX_PLANE];
int CbCr_predmode_8x8[4]; 

/***********************************************************************
 * P r o t o t y p e s   f o r    T M L
 ***********************************************************************
 */

void intrapred_4x4   (Macroblock *currMB, ColorPlane pl, int CurrPixX,int CurrPixY, int *left_available, int *up_available, int *all_available);
void intrapred_16x16 (Macroblock *currMB, ColorPlane pl);
// Transform function pointers
int (*pDCT_4x4)      (Macroblock *currMB, ColorPlane pl, int block_x, int block_y, int *coeff_cost, int intra, int is_cavlc);
int (*pDCT_16x16)    (Macroblock *currMB, ColorPlane pl, int, int is_cavlc);
int (*pDCT_8x8)      (Macroblock *currMB, ColorPlane pl, int b8, int *coeff_cost, int intra);
int  (*dct_cr_4x4[2])(Macroblock *currMB, int uv,int i11, int is_cavlc);

int  dct_8x8         (Macroblock *currMB, ColorPlane pl, int b8, int *coeff_cost, int intra);
int  dct_8x8_cavlc   (Macroblock *currMB, ColorPlane pl, int b8, int *coeff_cost, int intra);
int  dct_8x8_ls      (Macroblock *currMB, ColorPlane pl, int b8, int *coeff_cost, int intra);

void copyblock_sp    (Macroblock *currMB, ColorPlane pl, int pos_mb1,int pos_mb2);
int  dct_chroma_sp   (Macroblock *currMB, int uv,int i11, int is_cavlc);
int  dct_chroma_sp2  (Macroblock *currMB, int uv,int i11, int is_cavlc);


int  distortion4x4(int*);
int  distortion8x8(int*);

extern int*   refbits;
extern int**** motion_cost;
double *mb16x16_cost_frame;

void  FindSkipModeMotionVector  (Macroblock *currMB);
void  Get_Direct_Motion_Vectors (Macroblock *currMB);
void  PartitionMotionSearch     (Macroblock *currMB, int, int, int*);
int   BIDPartitionCost          (Macroblock *currMB, int, int, char[2], int);
int   BPredPartitionCost        (Macroblock *currMB, int, int, short, short, int, int);
int   GetDirectCostMB           (Macroblock *currMB, int bslice);
int   GetDirectCost8x8          (Macroblock *currMB, int, int*);


void poc_based_ref_management_frame_pic(int current_pic_num);
void poc_based_ref_management_field_pic(int current_pic_num);

int  picture_coding_decision (Picture *picture1, Picture *picture2, int qp);

unsigned CeilLog2( unsigned uiVal);


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

void free_img    (void);

int  get_mem_ACcoeff_new (int****** cofAC, int chroma);
int  get_mem_ACcoeff  (int*****);
int  get_mem_DCcoeff  (int****);
void free_mem_ACcoeff (int****);
void free_mem_ACcoeff_new (int***** cofAC);
void free_mem_DCcoeff (int***);

#if TRACE
void  trace2out(SyntaxElement *se);
void  trace2out_cabac(SyntaxElement *se);
#endif

void error(char *text, int code);

byte  field_flag_inference(Macroblock  *currMB);
void set_mbaff_parameters(Macroblock  *currMB);  // For MB AFF

//============= restriction of reference frames based on the latest intra-refreshes==========
void UpdatePixelMap(void);

int64 compute_SSE(imgpel **imgRef, imgpel **imgSrc, int xRef, int xSrc, int ySize, int xSize);

int CalculateFrameNumber(ImageParameters *img);

void encode_one_macroblock_low          (Slice *currSlice, Macroblock *currMB);
void encode_one_macroblock_high         (Slice *currSlice, Macroblock *currMB);
void encode_one_macroblock_highfast     (Slice *currSlice, Macroblock *currMB);
void encode_one_macroblock_highloss     (Slice *currSlice, Macroblock *currMB);
void (*encode_one_macroblock)           (Slice *currSlice, Macroblock *currMB);

int is_bipred_enabled(int mode); 

void update_qp    (ImageParameters *img, Macroblock *currMB);
void select_plane (ColorPlane color_plane);
void select_dct   (ImageParameters *img, Macroblock *currMB);

void store_coding_state_cs_cm(Slice *currSlice, Macroblock *currMB);
void reset_coding_state_cs_cm(Slice *currSlice, Macroblock *currMB);

void set_slice_type(ImageParameters *img, int slice_type);

void free_encoder_memory(ImageParameters *img);

int check_for_SI16(void);
int **lrec ;
int ***lrec_uv;
int si_frame_indicator;

int sp2_frame_indicator;
int number_sp2_frames;

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_x_m8;
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 residual DPCM
int ipmode_DPCM;
int lossless_res[4][4];

// For 4:4:4 independent mode
void change_plane_JV( int nplane );
void make_frame_picture_JV(void);

int Motion_Selected;
int Intra_Selected; 

#endif

⌨️ 快捷键说明

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