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

📄 bitstream.c

📁 基于Linux的ffmepg decoder
💻 C
📖 第 1 页 / 共 2 页
字号:
			READ_MARKER();			if (BitstreamGetBit(bs))	/* fixed_vop_rate */			{				BitstreamSkip(bs, dec->time_inc_bits);	/* fixed_vop_time_increment */			}			if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) {				if (dec->shape == VIDOBJLAY_SHAPE_RECTANGULAR) {					uint32_t width, height;					READ_MARKER();					width = BitstreamGetBits(bs, 13);	/* video_object_layer_width */					READ_MARKER();					height = BitstreamGetBits(bs, 13);	/* video_object_layer_height */					READ_MARKER();#if 0				//ben modify					dec->width = width;					dec->height = height;#else					/* for auto set width & height */					if (dec->width == 0)							dec->width = width;					if (dec->height == 0)						dec->height = height;					if (width != dec->width || height != dec->height)						return -1;#endif				}				dec->interlacing = BitstreamGetBit(bs);				if (dec->interlacing != 0)					return -1; 		// not support interlacing now				if (!BitstreamGetBit(bs))	/* obmc_disable */				{					/* TODO */					/* fucking divx4.02 has this enabled */				}				if (BitstreamGetBits(bs, (vol_ver_id == 1 ? 1 : 2)))	/* sprite_enable */				{					return -1;				}				if (vol_ver_id != 1 &&					dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {					BitstreamSkip(bs, 1);	/* sadct_disable */				}				if (BitstreamGetBit(bs))	/* not_8_bit */				{					dec->quant_bits = BitstreamGetBits(bs, 4);	/* quant_precision */					BitstreamSkip(bs, 4);	/* bits_per_pixel */				} else {					dec->quant_bits = 5;				}				if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {					BitstreamSkip(bs, 1);	/* no_gray_quant_update */					BitstreamSkip(bs, 1);	/* composition_method */					BitstreamSkip(bs, 1);	/* linear_composition */				}				dec->quant_type = BitstreamGetBit(bs);	/* quant_type */				if (dec->quant_type) {					if (BitstreamGetBit(bs))	/* load_intra_quant_mat */					{						uint8_t matrix[64];						bs_get_matrix(bs, matrix);						set_intra_matrix_dec((uint32_t *)((uint32_t)dec->pu32BaseAddr + CUSTOM_INTRA_MATRIX_OFF), matrix);					} else {						set_intra_matrix_dec((uint32_t *)((uint32_t)dec->pu32BaseAddr + CUSTOM_INTRA_MATRIX_OFF),											get_default_intra_matrix_dec());					}					if (BitstreamGetBit(bs))	/* load_inter_quant_mat */					{						uint8_t matrix[64];												bs_get_matrix(bs, matrix);						set_inter_matrix_dec((uint32_t *)((uint32_t)dec->pu32BaseAddr + CUSTOM_INTER_MATRIX_OFF), matrix);					} else						set_inter_matrix_dec((uint32_t *)((uint32_t)dec->pu32BaseAddr + CUSTOM_INTER_MATRIX_OFF),											get_default_inter_matrix_dec());					if (dec->shape == VIDOBJLAY_SHAPE_GRAYSCALE) {						return -1;					}				}				if (vol_ver_id != 1) {					dec->quarterpel = BitstreamGetBit(bs);	/* quarter_sample */				}				else {					dec->quarterpel = 0;				}				if (!BitstreamGetBit(bs))	/* complexity_estimation_disable */				{					return -1;				}				dec->resync_marker_disable = BitstreamGetBits(bs,1);				/* resync_marker_disable */				dec->data_partitioned = BitstreamGetBits(bs,1);				if (dec->data_partitioned)	/* data_partitioned */				{					dec->reversible_vlc = BitstreamGetBits(bs,1);				}				if (vol_ver_id != 1) {					if (BitstreamGetBit(bs))	/* newpred_enable */					{						BitstreamSkip(bs, 2);	/* requested_upstream_message_type */						BitstreamSkip(bs, 1);	/* newpred_segment_type */					}					if (BitstreamGetBit(bs))	/* reduced_resolution_vop_enable */					{						return -1;					}				}				if ((dec->scalability = (int8_t)BitstreamGetBit(bs)) != 0)	/* scalability */				{					return -1;				}			} else				/* dec->shape == BINARY_ONLY */			{				if (vol_ver_id != 1) {					if (BitstreamGetBit(bs))	/* scalability */					{						return -1;					}				}				BitstreamSkip(bs, 1);	/* resync_marker_disable */			}		}		else if (start_code == GRPOFVOP_START_CODE) {			BitstreamSkip(bs, 32);			{				int hours, minutes, seconds;				hours = BitstreamGetBits(bs, 5);				minutes = BitstreamGetBits(bs, 6);				READ_MARKER();				seconds = BitstreamGetBits(bs, 6);							}			BitstreamSkip(bs, 1);	/* closed_gov */			BitstreamSkip(bs, 1);	/* broken_link */		} else if (start_code == VOP_START_CODE) {			BitstreamSkip(bs, 32);	/* vop_start_code */			coding_type = BitstreamGetBits(bs, 2);	/* vop_coding_type */			dec->picture_coding_type = coding_type;//**********************NOTE*****************************************			coding_type = coding_type & 0x1;/* *************************** for decode B-frame time *********************** */			while (BitstreamGetBit(bs) != 0)	/* time_base */				time_incr++;			READ_MARKER();			if (dec->time_inc_bits) {				time_increment = (BitstreamGetBits(bs, dec->time_inc_bits));	/* vop_time_increment */			} 			if (coding_type != B_VOP) {				dec->last_time_base = dec->time_base;				dec->time_base += time_incr;				dec->time = time_increment;/*					dec->time_base * time_increment_resolution +					time_increment;*/				if (time_increment_resolution!= 0)					dec->time_pp = (uint32_t) 						(time_increment_resolution + dec->time - dec->last_non_b_time)%time_increment_resolution;				dec->last_non_b_time = dec->time;			} else {				dec->time = time_increment; /*					(dec->last_time_base +					 time_incr) * time_increment_resolution + time_increment; */				dec->time_bp = (uint32_t) 					(time_increment_resolution + dec->last_non_b_time - dec->time)%time_increment_resolution;			}			READ_MARKER();			if (!BitstreamGetBit(bs))	/* vop_coded */			{				return N_VOP;			}			/* fix a little bug by MinChen <chenm002@163.com> */			if ((dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&				(coding_type == P_VOP)) {				*rounding = BitstreamGetBit(bs);	/* rounding_type */			}			if (dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) {				uint32_t width, height;				uint32_t horiz_mc_ref, vert_mc_ref;				width = BitstreamGetBits(bs, 13);				READ_MARKER();				height = BitstreamGetBits(bs, 13);				READ_MARKER();				horiz_mc_ref = BitstreamGetBits(bs, 13);				READ_MARKER();				vert_mc_ref = BitstreamGetBits(bs, 13);				READ_MARKER();				BitstreamSkip(bs, 1);	/* change_conv_ratio_disable */				if (BitstreamGetBit(bs))	/* vop_constant_alpha */				{					BitstreamSkip(bs, 8);	/* vop_constant_alpha_value */				}			}			if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) {				/* intra_dc_vlc_threshold */				* intra_dc_threshold_bit= BitstreamGetBits(bs, 3);//				* intra_dc_threshold_bit= BitstreamShowBits(bs, 3);//				*intra_dc_threshold = intra_dc_threshold_table[BitstreamGetBits(bs, 3)];				if (dec->interlacing) {					dec->top_field_first = BitstreamGetBit(bs);					dec->alternate_vertical_scan = BitstreamGetBit(bs);				}			}			if ((*quant = BitstreamGetBits(bs, dec->quant_bits)) < 1)	/* vop_quant */				*quant = 1;			if (coding_type != I_VOP) {				*fcode_forward = BitstreamGetBits(bs, 3);	/* fcode_forward *///**********************NOTE*****************************************				if (*fcode_forward < 1) *fcode_forward = 1;			}			if (coding_type == B_VOP) {				*fcode_backward = BitstreamGetBits(bs, 3);	/* fcode_backward */			}			if (!dec->scalability) {				if ((dec->shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&					(coding_type != I_VOP)) {					BitstreamSkip(bs, 1);	/* vop_shape_coding_type */				}			}			return coding_type;		} else if (start_code == USERDATA_START_CODE) {			BitstreamSkip(bs, 32);	/* user_data_start_code */		} else					/* start_code == ? */		{			if (BitstreamShowBits(bs, 24) == 0x000001) {			}			BitstreamSkip(bs, 8);		}	}	while ((BitstreamPos(bs) >> 3) < bs->length);	return -1;					/* ignore it */}

⌨️ 快捷键说明

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