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

📄 h264_define.h

📁 自己在wince的环境下做的一移动数字电视驱动
💻 H
📖 第 1 页 / 共 4 页
字号:
														// 6 : not used (T-DMB ?)
														// 7 : Sequence parameter set
														// 8 : Picture parameter set  
  uint8_t			nal_ref_idc;						//u(2) // NALU_PRIORITY_xxxx
														// 0 : slice of a non-reference picture
														//     or
														//	   having nal_unit_type =  6, 9, 10, 11, or 12
														// otherwise : nal_unit_type = 5, 7, or 8  
} NALU_t;
#endif 

typedef  struct // ( 36 bytes) // ( 28 ) bytes  (pointer : [1024])
{
  uint8_t		num_ref_frames;							// ue(v)			: 0 ~ 3 (T-DMB), non-constraint(DVB-H)
														//					  specifies the maximum number of short-term and long-term reference franes
														//					  the value shall be in the range of 0 ~ to MaxDpbSize(445.5kbytes in T-DMB)
  //uint8_t 	profile_idc;							// u(8)				: 66(0x42) (baseline profile)
  uint8_t		constrained_set012_reserved;			// u(8)	    : if the value=1, the bitstream obeys all constraints for each profiles
    //Boolean			constrained_set0_flag;			// u(1)		0 or 1	: for baseline profile
    //Boolean			constrained_set1_flag;			// u(1)		0 or 1	: for main profile
    //Boolean			constrained_set2_flag;			// u(1)		0 or 1	: for extened profile
    //uint8_t		reserved_zero_5bits;				// u(5)		0
  uint8_t		level_idc;								// u(8)		10 ~ 51	: 1 ~ 13 (T-DMB) -  1 ~ 1.3(max.) level
  uint8_t		seq_parameter_set_id;					// ue(v)	0 ~ 31	: identifies the sequance paramter set
														//					  is referred to by the picture parameter set
  uint8_t		log2_max_frame_num_minus4;				// ue(v)	0 ~ 12	: MaxPicOrderCntLsb = 2^(log2_log2_max_frame_num_minus4+4)
														//					  used in decoding process for picture order count
  uint8_t		pic_order_cnt_type;						// ue(v)	0 ~ 2	: 2 (T-DMB)
														//					  specifies the method to decode picture order count
  uint8_t		delta_pic_order_always_zero_flag;		// u(1)		0 or 1
  uint8_t		num_ref_frames_in_pic_order_cnt_cycle;	// ue(v)	0 ~ 255
  int			offset_for_non_ref_pic;					// se(v)	-2^(31) ~ 2^(31)-1
  int			offset_for_top_to_bottom_field;			// se(v)	-2^(31) ~ 2^(31)-1
  int			*ptr_offset_for_ref_frame;				// se(v)	-2^(31) ~ 2^(31)-1, [num_ref_frames_in_pic_order_cnt_cycle:256]

  uint8_t		log2_max_pic_order_cnt_lsb_minus4;		//ue(v) 0 ~ 12 : specifies the value of the variable MaxPicOrderCntLsb

  uint8_t		gaps_in_frame_num_value_allowed_flag;	// u(1)			: allowed values of frame_num as specified in 7.4.3

  uint8_t		pic_width_in_mbs_minus1;				// ue(v)	0 ~ 256	: ~max.23 (T-DMB)
														//					   PicWidthInMbs = pic_width_in_mbs_minus1+1
														//					   PicWidthInSamplesL = PicWidthInMbs*16
														//					   PicWidthInSamplesC = PicWidthInMbs*8
  uint8_t		pic_height_in_map_units_minus1;			// ue(v)	0 ~ 144	: ~max.17 (T-DMB): not allowed ASO and decoding order.
														// specifies the height in slice group map unit
														// PicHeightInMapUnits = pic_height_in_map_units_minus1+1;
														// PicSizeInMapUnits = PicWidthInMbs * PicHeightInMapUnits;

  uint8_t		frame_mbs_only_flag;					// u(1)				: 1 (baseline profile) - only frame(not used field...)

  //Boolean			direct_8x8_inference_flag;			// u(1)				: not used (baseline profile) - for B-slice
  uint8_t		frame_cropping_flag;					// u(1)				: if the value is 0, frame cropping offset parameters are not present
  
  uint8_t		vui_parameters_present_flag;		// u(1)				; vui_parameters() syntax structure is (not) present next in the bitstream
														//					  not support to vui_parameters() syntax in reference code.
  uint8_t		Valid;									// indicates the parameter set is valid

  unsigned short	frame_cropping_rect_left_offset;	// ue(v)
  unsigned short	frame_cropping_rect_right_offset;	// ue(v)
  unsigned short	frame_cropping_rect_top_offset;		// ue(v)
  unsigned short	frame_cropping_rect_bottom_offset;	// ue(v)


} seq_parameter_set_rbsp_t;

typedef struct // 12 bytes
{
  uint8_t		pic_parameter_set_id;					// ue(v)	0 ~ 255
  uint8_t		seq_parameter_set_id;					// ue(v)	0 ~ 31
  //uint8_t		num_slice_groups_minus1;				// ue(v)	0 ~ 7	: 0 (T-DMB) - not allowed FMO
  uint8_t		num_ref_idx_l0_active_minus1;			// ue(v)	0 ~ 31	: specifies the maximum reference index for reference picture list 0.
															//					  shall be used to decode each slice of the picture in which
															//						list 0 is used when num_ref_idx_active_overricde_flag is equal to 0 for the slice.
//  uint8_t		num_ref_idx_l1_active_minus1;			// ue(v)	0 ~ 31	: not used(baseline profile) - for B-slice 
  int8_t		pic_init_qp_minus26;					// se(v)	-26~+25 : specifies the initial value minus 26 of SliceQPY for each slice.
															//					  the value is modified at the slice layer when a non-zero value of slice-qp_delta is decoded,
															//					   and is modified further when a non-zero value of mb_qp_delta is decoded at the macroblock layer.
//  int8_t				pic_init_qs_minus26;					// se(v)	-26~+25	: not used(baseline profile) - for SP or SI
  int8_t		chroma_qp_index_offset;					// se(v)	-12~+12 :  specifies the offset that shall be added to QP_Y for addressing the table of QP_C values.
  uint8_t		deblocking_filter_control_present_flag; // u(1)				:1 - a set of syntax elements controlling the characteristics of the deblocking filter is present in the slice header.
															//					 0 - the set of syntax elements controlling the characteristics of the deblocking filter is not present int the slice header and their inferred values are in effect.
  uint8_t		constrained_intra_pred_flag;			// u(1)				:0 - intra prediction allows usage of residual data and decoded  samples of neighbouring macroblocks coded using Inter macroblock prediction modes for the prediction of macroblocks coded using Intra macroblock prediction modes
															//					 1 - constrained intra prediction, in which case prediction of macroblocks coded using Intra macroblock prediction modes only uses residual data and decoded samples from I macroblock type.
															//                   角力 I-slice牢 版快 葛滴 intra prediction捞骨肺 阂鞘夸 窍唱.
															//					 P-slice牢 版快 inter/intra 炼钦捞 啊瓷窍哥 捞 版快狼 intra俊辑 林困狼 inter MB甫 曼炼且锭俊父 林狼秦 林搁 凳.
//  Boolean			redundant_pic_cnt_present_flag;			// u(1)				: 0(T-DMB) specifies that the redundant_pic_cnt syntax element is not present in slice header.
  uint8_t		Valid;									// indicates the parameter set is valid
//  Boolean			entropy_coding_mode_flag;				// u(1)		0 or 1	: 0 (baseline profile) - only CAVLC

  int			pic_order_present_flag;					// u(1)		0 or 1	: 0 (T-DMB) - not allowed ASO //added by soo 20060121

//  Boolean			weighted_pred_flag;						// u(1)				: 0 (baseline profile)
//  Boolean			weighted_bipred_idc;					// u(2)				: 0 (baseline profile) for B-slice
} pic_parameter_set_rbsp_t;

//
// 96 bytes
//
typedef struct {

	int			mb_type;
	int			mb_type2;
	
	// reference of neigbour... : 12 bytes
	//int		intra_inter_flag; 			// 0: intra prediction, 
											// 1: inter prediction, 
											// 2: IPCM

	//
	// intra : 24 bytes
	
	uint8_t		*ptrNegibourhood4x4new;		// neighbourhood block data [6][17] -> [17] value : (MSB)YYXXDCBA(LSB)
											//   +---+---+---+  (x)..
											//   | D | B | C |  up-left  : D
											//   +---+---+---+  up       : B
											//   | A | x |   |  up-right : C
											//   +---+---+---+  left     : A

	int8_t		rem_intra4x4_pred_mode[16];				//u(3)											
	int			chroma_pred_mode;		//ue(v) 0 ~ 3  //c_ipred_mode in ref. code

	//
	// inter : 64 bytes	
	
	uint8_t		sub_mb_type[4];			//ue(v) 0 ~ 12	
	int32_t		LFEnFlag;
	int8_t		BS[2][4][4];

	int32_t		QPy_ave[3];
	int32_t		QPc_ave[3];	
	
}MacroBlock_t;


typedef struct	{

	
	//uint32_t	chroma_qp_index_offset12;		//12+pps->chroma_qp_index_offset(-12~12) //added by soo 20050916

	int32_t		itempBuffer[32];		// 128 bytes : temp. buffer for level(idx 0) and run(idx 16) in CAVLC, 捞甫 stack 肚绰 S-RAM栏肺 函版 抗沥.

	uint16_t			constrained_intra_pred_flag;
	int8_t			slice_alpha_c0_offset_div2;
  	int8_t			slice_beta_offset_div2;		// FrameStart interface - end

	uint8_t			slice_type;
	uint8_t			num_ref_idx_l0_active_minus1;
	int8_t			slice_qp_delta;
	int8_t			qp;
	
	uint32_t		frame_num;
	int32_t			first_mb_in_slice;
	
	uint8_t			disable_deblocking_filter_idc;
	uint8_t			pic_parameter_set_id;
	uint8_t			idr_pic_id;
	uint8_t			nal_reference_idc;
	
	int32_t			idr_flag;
	int32_t			Valid;

} Slice_data_t;


//added by soo 20070207 the RW region of list control and MMCO part on SDRAM
typedef struct {
	// for list control and MMCO
	// 1240 bytes =  {(4*8)+(2*1)+(1*4)}*H264_REF_FRAME_NUM_MAX(32)  +  24 //added by soo 20070403 reorder_long_term_pic_num
	//  980 bytes =  {(4*6)+(2*1)+(1*4)}*H264_REF_FRAME_NUM_MAX(32)  +  20
	uint32_t	listOrderCnt;
	uint32_t	listOrder[H264_REF_FRAME_NUM_MAX]; //

	int32_t		reorder_abs_diff_pic_num_minus1[H264_REF_FRAME_NUM_MAX];
	int32_t		reorder_long_term_pic_num[H264_REF_FRAME_NUM_MAX];				
	int			long_term_pic_num[H264_REF_FRAME_NUM_MAX];		
	int			difference_of_pic_nums_minus1[H264_REF_FRAME_NUM_MAX];			
	int			long_term_frame_idx[H264_REF_FRAME_NUM_MAX];					
	int			max_long_term_frame_idx_plus1[H264_REF_FRAME_NUM_MAX];

	uint8_t		*listXaddr[H264_REF_FRAME_NUM_MAX];			

	uint16_t	RefPicList[H264_REF_FRAME_NUM_MAX];			//reference picture list (frame num : PicNum or LongTermPicNum) added by soo 20050531

	int8_t		reordering_of_pic_nums_idc[H264_REF_FRAME_NUM_MAX];		
	uint8_t		mmco[H264_REF_FRAME_NUM_MAX];	

	int8_t		listX[H264_REF_FRAME_NUM_MAX];				//reference picture list in dec. mem. with current_img_idx modified by soo 20050531 from [6]
	int8_t		used_for_reference[H264_REF_FRAME_NUM_MAX];	//the number of short or long -term reference frames or non-existing	added by soo 20050531
															// 0: non-existing, 1: used for reference, 2: long-term, 3: short-term	
	int16_t		poc[H264_REF_FRAME_NUM_MAX];
	int8_t		no_output_of_prior_pics_flag;
	int8_t		long_term_reference_flag;
	int8_t		adaptive_ref_pic_marking_mode_flag;
	int8_t		DummyByte;

	// for Picture Order Count type 0 or 1
	int			pic_order_cnt_lsb;			//0~2^16
	int			delta_pic_order_cnt_bottom; //-2^31 ~ 2^31-1
	int			delta_pic_order_cnt[2];		//-2^31 ~ 2^31-1

	int32_t		PrevPicOrderCntMsb; //POC
	int32_t		PrevPicOrderCntLsb; //POC

} list_MMCO_t;


typedef struct	{
	uint8_t	y[MAXPICPICELHEIGHT][MAXPICPICELWIDTH];
	uint8_t	uv[2][MAXPICPICELHEIGHT/2][MAXPICPICELWIDTH/2];
}	image_t;


typedef struct	{
	uint32_t		intra_inter_flag	: 1;
	int32_t			qp				: 7;
	uint32_t		nBlk4x4_zeroflags	: 24;
}	prm_t;


typedef	struct	{
	int16_t		x;
	int16_t		y;
}	mv_t;


typedef struct	{
	prm_t	prm;						// 1 word
	int8_t	refIdx[2][2];				// 1 words
	mv_t	mv[4][4];					// 16 words
}	mb_lbuf_t;


#define	NEIGH_A	0
#define	NEIGH_B	1
#define	NEIGH_C	2
#define	NEIGH_D	3


#ifndef __arm
	/*
	#include <time.h>
	#include <sys/timeb.h>
	*/
#endif

typedef struct {

	//for reference frame reordering or list control
	//
	unsigned int				frame_num;									//frame_num for this frame  		
	unsigned int				FrameNumOffset;	
	int							MaxFrameNum;
	unsigned int				pre_frame_num;								//store the frame_num in the last decoded slice. For detecting gap in frame_num.
	unsigned int				PrevFrameNum;
	int							PrevFrameNumOffset;  
	int							PicNum;										//for short-term reference picture //added by soo 20050425
	int							LongTermPicNum;								//for  long-term reference frame //added by soo 20050425
	int							RefFrameNumMax;								//the max number of reference frames. added by soo 20050607
	int							PicNumCnt;									//the number of short-term reference frames //added by soo 20050607
	int							LongTermPicNumCnt;							//the number of long-term reference frames	//added by soo 20050607
	short						MaxLongTermRefFrameCnt;
	short						listX_Size;									//the total number of reference frames as short-term or long-term	
	int							framepoc;									//poc of this frame // POC200301 adaptive_memory_management()俊辑 last_has_mmco_5 != 0 锭 '0'	
	short						ref_pic_list_reordering_flag_l0;
	short						last_has_mmco_5;							//in init_dpb() and adaptive_memory_management() and store_picture_in_dpb() =0
																		// in adaptive_memory_management()狼 memory_management_control_operation==5牢 版快父 =1
	// for slice header parsing
	//
	OldSliceParams_t			old_slice;
	uint8_t						nal_reference_idc;				//NALU_TYPE_xxxx
	uint8_t						nal_unit_type;					//nal_reference_idc from NAL unit
	short						dummyS;
	unsigned long				frame_num_cnt;

	pic_parameter_set_rbsp_t	pps_tmp;			//12 bytes
	seq_parameter_set_rbsp_t	sps_tmp;			//28 bytes

	int							PicWidthInMbs;
	int							FrameSizeInMbs;		//total # of MBs
	int							FrameHeightInMbs;

	// image data
	// 136 bytes when H264_REF_FRAME_NUM_MAX is 32
	//  72 bytes when H264_REF_FRAME_NUM_MAX is 16
	//  56 bytes when H264_REF_FRAME_NUM_MAX is 12
	//
	image_t						*CurFrame;
	image_t						*PrevFrame; 
	image_t						*RefFrame[H264_REF_FRAME_NUM_MAX/*3*/];

#ifdef TEST_REC_LF
	image_t	*					testFrame;
#endif


} H264mem_t;

//////////////////////////////////////////////////////////////
// VUI

#define VUI_PRESFLAG_BITPOS_ASPECT_RATIO_IP_FLAG		 0	//[0]	aspect_ratio_info_present_flag				
#define VUI_PRESFLAG_BITPOS_OVERSCAN_IP_FLAG			 1	//[1]	overscan_info_present_flag
#define VUI_PRESFLAG_BITPOS_VIDEO_SIGNAL_TYPE_P_FLAG	 2	//[2]	video_signal_type_present_flag
#define VUI_PRESFLAG_BITPOS_CHROMA_LOC_IP_FLAG			 3	//[3]	chroma_loc_info_present_flag
#define VUI_PRESFLAG_BITPOS_TIMING_IP_FLAG				 4	//[4]	timing_info_present_flag
#define VUI_PRESFLAG_BITPOS_NAL_HRD_PARAM_P_FLAG		 5	//[5]	nal_hrd_parameters_present_flag
#define VUI_PRESFLAG_BITPOS_VCL_HRD_PARAM_P_FLAG		 6	//[6]	vcl_hrd_parameters_present_flag
#define VUI_PRESFLAG_BITPOS_PIC_STRUCT_P_FLAG			 7	//[7]	pic_struct_presnet_flag
#define VUI_PRESFLAG_BITPOS_BITSTREAM_RESTRICTION_FLAG	 8	//[8]	bitstrream_restriction_flag
#define VUI_PRESFLAG_BITPOS_FIXED_FRAME_RATE_FLAG		 9	//[9]	fixed_frame_rate_flag
#define VUI_PRESFLAG_BITPOS_LOW_DELAY_HRD_FLAG			10	//[10]	low_delay_hrd_flag
#define VUI_PRESFLAG_BITPOS_MV_OVER_PIC_BOUND_FLAG		11	//[11]	motion_vectiors_over_pic_boundaries_flag
#define VUI_PRESFLAG_BITPOS_VIDEO_FULL_RANGE_FLAG		12	//[12]  video_full_ragne_flag
#define VUI_PRESFLAG_BITPOS_COLOR_DES_P_FLAG			13	//[13]  colour_description_present_flag
#define VUI_PRESFLAG_BITPOS_VALID						14	//[14]  Valid

typedef struct tag_h264_hrdParam {		//2 bytes
	unsigned int hrd_parameter_present_flag		: 1;
	unsigned int cpb_removal_delay_length_minus1: 5;
	unsigned int dpb_output_delay_length_minus1	: 5;
	unsigned int time_offset_length				: 5;
} h264_hrdParam_t;

typedef struct tag_VuiInfo { //28 bytes (24 bytes when without VUI_PARAMETER_COLOR_CHROMA
	unsigned short vui_aspect_ratio_idc; //default 0
			// aspect_ratio_idc		Sample aspect ratio
			//		0				 Unspecified
			//		1				 1:1("square")
			//		2				 12:11
			//		3				 10:11
			//		4				 16:11

⌨️ 快捷键说明

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