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

📄 global.h

📁 h.264 影像壓縮 必須在 .net 的環境 下操作
💻 H
📖 第 1 页 / 共 4 页
字号:

  char                intra_pred_modes[MB_BLOCK_PARTITIONS];
  char                intra_pred_modes8x8[MB_BLOCK_PARTITIONS];           //!< four 8x8 blocks in a macroblock

  int64               cbp_blk ;    //!< 1 bit set for every 4x4 block with coefs (not implemented for INTRA)
  int64               cbp_bits[3];
  int64               cbp_bits_8x8[3];

  short               bi_pred_me;

  // rate control
  double              actj;               // macroblock activity measure for macroblock j
  int                 prev_qp;
  int                 prev_dqp;
  int                 prev_cbp;
  int                 predict_qp;
  int                 predict_error;

  struct macroblock   *mb_available_up;   //!< pointer to neighboring MB (CABAC)
  struct macroblock   *mb_available_left; //!< pointer to neighboring MB (CABAC)

} Macroblock;



//! Bitstream
typedef struct
{
  int             byte_pos;           //!< current position in bitstream;
  int             bits_to_go;         //!< current bitcounter
  
  int             stored_byte_pos;    //!< storage for position in bitstream;
  int             stored_bits_to_go;  //!< storage for bitcounter
  int             byte_pos_skip;      //!< storage for position in bitstream;
  int             bits_to_go_skip;    //!< storage for bitcounter
  int             write_flag;         //!< Bitstream contains data and needs to be written

  byte            byte_buf;           //!< current buffer for last written byte
  byte            stored_byte_buf;    //!< storage for buffer of last written byte
  byte            byte_buf_skip;      //!< current buffer for last written byte
  byte            *streamBuffer;      //!< actual buffer for written bytes

#if TRACE
  Boolean             trace_enabled;
#endif

} Bitstream;

//! DataPartition
typedef struct datapartition
{

  Bitstream           *bitstream;
  EncodingEnvironment ee_cabac;
  EncodingEnvironment ee_recode;
} DataPartition;

//! Slice
typedef struct
{
  int                 picture_id;
  int                 qp;
  int                 picture_type; //!< picture type
  int                 start_mb_nr;
  int                 max_part_nr;  //!< number of different partitions
  int                 num_mb;       //!< number of MBs in the slice

  int                 ref_pic_list_reordering_flag_l0;
  int                 *reordering_of_pic_nums_idc_l0;
  int                 *abs_diff_pic_num_minus1_l0;
  int                 *long_term_pic_idx_l0;
  int                 ref_pic_list_reordering_flag_l1;
  int                 *reordering_of_pic_nums_idc_l1;
  int                 *abs_diff_pic_num_minus1_l1;
  int                 *long_term_pic_idx_l1;
  int                 field_ctx[3][2]; //GB

  Boolean             (*slice_too_big)(int bits_slice); //!< for use of callback functions

  DataPartition       *partArr;     //!< array of partitions
  MotionInfoContexts  *mot_ctx;     //!< pointer to struct of context models for use in CABAC
  TextureInfoContexts *tex_ctx;     //!< pointer to struct of context models for use in CABAC

} Slice;



#define MAXSLICEPERPICTURE 100
typedef struct
{
  int   no_slices;
  int   idr_flag;
  int bits_per_picture;
  Slice *slices[MAXSLICEPERPICTURE];

  float distortion_y;
  float distortion_u;
  float distortion_v;
} Picture;

Picture *p_frame_pic;
Picture **frame_pic;
Picture **field_pic;
Picture *frame_pic_si;

#ifdef _LEAKYBUCKET_
long *Bit_Buffer;
#endif

// global picture format dependend buffers, mem allocation in image.c
imgpel **pImgOrg[MAX_PLANE];
imgpel **pCurImg;            //!< Reference image. Luma for other profiles, can be any component for 4:4:4
imgpel ***imgUV_org;         //!< Reference chroma image
int    **imgY_sub_tmp;       //!< Y picture temporary component (Quarter pel)

int **PicPos;
unsigned int log2_max_frame_num_minus4;
unsigned int log2_max_pic_order_cnt_lsb_minus4;
unsigned int max_frame_num;
unsigned int max_pic_order_cnt_lsb;


time_t  me_tot_time,me_time;
pic_parameter_set_rbsp_t *active_pps;
seq_parameter_set_rbsp_t *active_sps;


int dsr_new_search_range; //!<Dynamic Search Range.
//////////////////////////////////////////////////////////////////////////
// B pictures
// motion vector : forward, backward, direct
int  mb_adaptive;       //!< For MB level field/frame coding tools
int  MBPairIsField;     //!< For MB level field/frame coding tools


//Weighted prediction
int ***wp_weight;  // weight in [list][index][component] order
int ***wp_offset;  // offset in [list][index][component] order
int ****wbp_weight;  // weight in [list][fwd_index][bwd_idx][component] order
int luma_log_weight_denom;
int chroma_log_weight_denom;
int wp_luma_round;
int wp_chroma_round;

// global picture format dependend buffers, mem allocation in image.c (field picture)
imgpel   **imgY_org_top;
imgpel   **imgY_org_bot;

imgpel  ***imgUV_org_top;
imgpel  ***imgUV_org_bot;

imgpel   **imgY_org_frm;
imgpel  ***imgUV_org_frm;

imgpel   **imgY_com;               //!< Encoded luma images
imgpel   **imgY_org_frm_JV[MAX_PLANE];  //!< imgY_org_frm to be used during 4:4:4 independent mode encoding
imgpel  ***imgUV_com;              //!< Encoded croma images

char    ***direct_ref_idx;           //!< direct mode reference index buffer
char    **direct_pdir;              //!< direct mode reference index buffer

// Buffers for rd optimization with packet losses, Dim. Kontopodis
byte **pixel_map;   //!< Shows the latest reference frame that is reliable for each pixel
byte **refresh_map; //!< Stores the new values for pixel_map
int intras;         //!< Counts the intra updates in each frame.

int  frame_ctr[5];
int  frame_no, nextP_tr_fld, nextP_tr_frm;

time_t  tot_time;

#define ET_SIZE 300      //!< size of error text buffer
char errortext[ET_SIZE]; //!< buffer for error message for exit with error()

// Residue Color Transform
char b8_ipredmode8x8[4][4], b8_intra_pred_modes8x8[16];

//! Info for the "decoders-in-the-encoder" used for rdoptimization with packet losses
typedef struct
{
  int  **resY;               //!< Residue of Luminance
  imgpel ***decY;            //!< Decoded values at the simulated decoders
  imgpel ****decref;         //!< Reference frames of the simulated decoders
  imgpel ***decY_best;       //!< Decoded frames for the best mode for all decoders
  imgpel **RefBlock;
  byte **status_map;
  byte **dec_mb_mode;
} Decoders;
extern Decoders *decs;

//! SNRParameters
typedef struct
{
  float snr_y;               //!< current Y SNR
  float snr_u;               //!< current U SNR
  float snr_v;               //!< current V SNR
  float snr_y1;              //!< SNR Y(dB) first frame
  float snr_u1;              //!< SNR U(dB) first frame
  float snr_v1;              //!< SNR V(dB) first frame
  float snr_yt[5];           //!< SNR Y(dB) based on frame type
  float snr_ut[5];           //!< SNR U(dB) based on frame type
  float snr_vt[5];           //!< SNR V(dB) based on frame type
  float snr_ya;              //!< Average SNR Y(dB) remaining frames
  float snr_ua;              //!< Average SNR U(dB) remaining frames
  float snr_va;              //!< Average SNR V(dB) remaining frames
  float sse_y;               //!< SSE Y
  float sse_u;               //!< SSE U
  float sse_v;               //!< SSE V
  float msse_y;              //!< Average SSE Y
  float msse_u;              //!< Average SSE U
  float msse_v;              //!< Average SSE V
  int   frame_ctr;           //!< number of coded frames
} SNRParameters;

#define FILE_NAME_SIZE 200

// VUI Parameters
typedef struct
{
  int aspect_ratio_info_present_flag;
  int aspect_ratio_idc;
  int sar_width;
  int sar_height;
  int overscan_info_present_flag;
  int overscan_appropriate_flag;
  int video_signal_type_present_flag;
  int video_format;
  int video_full_range_flag;
  int colour_description_present_flag;
  int colour_primaries;
  int transfer_characteristics; 
  int matrix_coefficients;
  int chroma_location_info_present_flag;
  int chroma_sample_loc_type_top_field;
  int chroma_sample_loc_type_bottom_field;
  int timing_info_present_flag;
  int num_units_in_tick;
  int time_scale;
  int fixed_frame_rate_flag;
  int nal_hrd_parameters_present_flag;
  int nal_cpb_cnt_minus1;
  int nal_bit_rate_scale;
  int nal_cpb_size_scale;
  int nal_bit_rate_value_minus1;
  int nal_cpb_size_value_minus1;
  int nal_vbr_cbr_flag;
  int nal_initial_cpb_removal_delay_length_minus1;
  int nal_cpb_removal_delay_length_minus1;
  int nal_dpb_output_delay_length_minus1;
  int nal_time_offset_length;
  int vcl_hrd_parameters_present_flag;
  int vcl_cpb_cnt_minus1;
  int vcl_bit_rate_scale;
  int vcl_cpb_size_scale;
  int vcl_bit_rate_value_minus1;
  int vcl_cpb_size_value_minus1;
  int vcl_vbr_cbr_flag;
  int vcl_initial_cpb_removal_delay_length_minus1;
  int vcl_cpb_removal_delay_length_minus1;
  int vcl_dpb_output_delay_length_minus1;
  int vcl_time_offset_length;
  int low_delay_hrd_flag;
  int pic_struct_present_flag;
  int bitstream_restriction_flag;
  int motion_vectors_over_pic_boundaries_flag;
  int max_bytes_per_pic_denom;
  int max_bits_per_mb_denom;
  int log2_max_mv_length_vertical;
  int log2_max_mv_length_horizontal;
  int num_reorder_frames;
  int max_dec_frame_buffering;
} VUIParameters;

                             //! all input parameters
typedef struct
{
  int ProfileIDC;                    //!< value of syntax element profile_idc
  int LevelIDC;                      //!< value of syntax element level_idc
  int IntraProfile;                  //!< Enable Intra profiles

  int no_frames;                     //!< number of frames to be encoded
  int qp0;                           //!< QP of first frame
  int qpN;                           //!< QP of remaining frames
  int jumpd;                         //!< number of frames to skip in input sequence (e.g 2 takes frame 0,3,6,9...)
  int DisableSubpelME;               //!< Disable sub-pixel motion estimation
  int search_range;                  /*!< search range - integer pel search and 16x16 blocks.  The search window is
                                          generally around the predicted vector. Max vector is 2xmcrange.  For 8x8
                                          and 4x4 block sizes the search range is 1/2 of that for 16x16 blocks.       */
  int num_ref_frames;                //!< number of reference frames to be used
  int P_List0_refs;                  //!< number of reference picture in list 0 in P pictures
  int B_List0_refs;                  //!< number of reference picture in list 0 in B pictures
  int B_List1_refs;                  //!< number of reference picture in list 1 in B pictures
  int Log2MaxFNumMinus4;             //!< value of syntax element log2_max_frame_num
  int Log2MaxPOCLsbMinus4;           //!< value of syntax element log2_max_pic_order_cnt_lsb_minus4

  int img_width;                     //!< image width  (must be a multiple of 16 pels)
  int img_height;                    //!< image height (must be a multiple of 16 pels)
  int yuv_format;                    //!< YUV format (0=4:0:0, 1=4:2:0, 2=4:2:2, 3=4:4:4)
  int intra_upd;                     /*!< For error robustness. 0: no special action. 1: One GOB/frame is intra coded
                                          as regular 'update'. 2: One GOB every 2 frames is intra coded etc.
                                          In connection with this intra update, restrictions is put on motion vectors
                                          to prevent errors to propagate from the past                                */
  int blc_size[8][2];                //!< array for different block sizes
  int part_size[8][2];               //!< array for different partition sizes
  int blocktype_lut[4][4];           //!< array for different partition sizes
  int slice_mode;                    //!< Indicate what algorithm to use for setting slices
  int slice_argument;                //!< Argument to the specified slice algorithm
  int UseConstrainedIntraPred;       //!< 0: Inter MB pixels are allowed for intra prediction 1: Not allowed
  int  infile_header;                //!< If input file has a header set this to the length of the header
  char infile[FILE_NAME_SIZE];       //!< YUV 4:2:0 input format
  char outfile[FILE_NAME_SIZE];      //!< H.264 compressed output bitstream
  char ReconFile[FILE_NAME_SIZE];    //!< Reconstructed Pictures
  char TraceFile[FILE_NAME_SIZE];    //!< Trace Outputs
  char QmatrixFile[FILE_NAME_SIZE];  //!< Q matrix cfg file
  int  EnableOpenGOP;                 //!< support for open gops.
  int  EnableIDRGOP;                  //!< support for open gops.

  int idr_period;                    //!< IDR picture period
  int intra_period;                  //!< intra picture period
  int intra_delay;                   //!< IDR picture delay
  int adaptive_idr_period;
  int adaptive_intra_period;         //!< reinitialize start of intra period

  int start_frame;                   //!< Encode sequence starting from Frame start_frame

  int GenerateMultiplePPS;
  int GenerateSEIMessage;
  char SEIMessageText[500];

  int ResendSPS;
  int ResendPPS;

  // B pictures
  int successive_Bframe;             //!< number of B frames that will be used
  int PReplaceBSlice;
  int qpB;                           //!< QP for non-reference B slice coded pictures
  int qpBRSOffset;                   //!< QP for reference B slice coded pictures
  int direct_spatial_mv_pred_flag;   //!< Direct Mode type to be used (0: Temporal, 1: Spatial)
  int directInferenceFlag;           //!< Direct Mode Inference Flag

  int BiPredMotionEstimation;
  int BiPredMERefinements;
  int BiPredMESearchRange;
  int BiPredMESubPel;


  // SP Pictures
  int sp_periodicity;                //!< The periodicity of SP-pictures
  int qpsp;                          //!< SP Picture QP for prediction error
  int qpsp_pred;                     //!< SP Picture QP for predicted block

  int si_frame_indicator;            //!< Flag indicating whether SI frames should be encoded rather than SP frames (0: not used, 1: used)
  int sp2_frame_indicator;           //!< Flag indicating whether switching SP frames should be encoded rather than SP frames (0: not used, 1: used)
  int sp_output_indicator;           //!< Flag indicating whether coefficients are output to allow future encoding of switchin SP frames (0: not used, 1: used)
  char sp_output_filename[FILE_NAME_SIZE];    //!<Filename where SP coefficients are output
  char sp2_input_filename1[FILE_NAME_SIZE];   //!<Filename of coefficients of the first bitstream when encoding SP frames to switch bitstreams
  char sp2_input_filename2[FILE_NAME_SIZE];   //!<Filenames of coefficients of the second bitstream when encoding SP frames to switch bitstreams

  int WeightedPrediction;            //!< Weighted prediction for P frames (0: not used, 1: explicit)
  int WeightedBiprediction;          //!< Weighted prediction for B frames (0: not used, 1: explicit, 2: implicit)
  int UseWeightedReferenceME;        //!< Use Weighted Reference for ME.
  int RDPictureDecision;             //!< Perform RD optimal decision between various coded versions of same picture
  int RDPictureIntra;                //!< Enabled RD pic decision for intra as well.
  int RDPSliceWeightOnly;            //!< If enabled, does not check QP variations for P slices.
  int RDPSliceBTest;                 //!< Tests B slice replacement for P.
  int RDBSliceWeightOnly;            //!< If enabled, does not check QP variations for B slices.
  int SkipIntraInInterSlices;        //!< Skip intra type checking in inter slices if best_mode is skip/direct
  int BRefPictures;                  //!< B coded reference pictures replace P pictures (0: not used, 1: used)
  int HierarchicalCoding;
  int HierarchyLevelQPEnable;
  char ExplicitHierarchyFormat[1024];//!< Explicit GOP format (HierarchicalCoding==3).
  int ReferenceReorder;              //!< Reordering based on Poc distances
  int PocMemoryManagement;           //!< Memory management based on Poc distances for hierarchical coding

  int symbol_mode;                   //!< Specifies the mode the symbols are mapped on bits
  int of_mode;                       //!< Specifies the mode of the output file
  int partition_mode;                //!< Specifies the mode of data partitioning

  int InterSearch[2][8];

  int DisableIntraInInter;
  int IntraDisableInterOnly;
  int Intra4x4ParDisable;
  int Intra4x4DiagDisable;
  int Intra4x4DirDisable;
  int Intra16x16ParDisable;
  int Intra16x16PlaneDisable;
  int ChromaIntraDisable;

  int EnableIPCM;

  double FrameRate;

  int EPZSPattern;
  int EPZSDual;
  int EPZSFixed;
  int EPZSTemporal;
  int EPZSSpatialMem;
  int EPZSMinThresScale;
  int EPZSMaxThresScale;
  int EPZSMedThresScale;
  int EPZSSubPelGrid;
  int EPZSGrid;
  int EPZSSubPelME;
  int EPZSSubPelMEBiPred;

⌨️ 快捷键说明

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