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

📄 descriptors.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 2 页
字号:
		if (hasSize) {			cfg->pixelWidth = gf_bs_read_int(bs, 16);			cfg->pixelHeight = gf_bs_read_int(bs, 16);		}		gf_bs_align(bs);		if (gf_bs_get_size(bs) != gf_bs_get_position(bs))  e = GF_ODF_INVALID_DESCRIPTOR;	}	gf_bs_del(bs);	return cfg;}/*special function for authoring - convert DSI to LASERConfig*/GF_EXPORTGF_Err gf_odf_get_laser_config(GF_DefaultDescriptor *dsi, GF_LASERConfig *cfg){	u32 to_skip;	GF_BitStream *bs;	if (!dsi || !dsi->data || !dsi->dataLength || !cfg) return GF_BAD_PARAM;	bs = gf_bs_new(dsi->data, dsi->dataLength, GF_BITSTREAM_READ);	memset(cfg, 0, sizeof(GF_LASERConfig));	cfg->tag = GF_ODF_LASER_CFG_TAG;	cfg->profile = gf_bs_read_int(bs, 8);	cfg->level = gf_bs_read_int(bs, 8);	/*cfg->reserved = */gf_bs_read_int(bs, 3);		cfg->pointsCodec = gf_bs_read_int(bs, 2);		cfg->pathComponents = gf_bs_read_int(bs, 4);		cfg->fullRequestHost = gf_bs_read_int(bs, 1);		if (gf_bs_read_int(bs, 1)) cfg->time_resolution = gf_bs_read_int(bs, 16);	else cfg->time_resolution = 1000;	cfg->colorComponentBits = 1 + gf_bs_read_int(bs, 4);	cfg->resolution = gf_bs_read_int(bs, 4);	if (cfg->resolution>7) cfg->resolution -= 16;	cfg->coord_bits = gf_bs_read_int(bs, 5);	cfg->scale_bits_minus_coord_bits = gf_bs_read_int(bs, 4);	cfg->newSceneIndicator = gf_bs_read_int(bs, 1);	/*reserved2*/ gf_bs_read_int(bs, 3);	cfg->extensionIDBits = gf_bs_read_int(bs, 4);	/*hasExtConfig - we just ignore it*/	if (gf_bs_read_int(bs, 1)) {		to_skip = gf_bs_read_vluimsbf5(bs);		while (to_skip) {			gf_bs_read_int(bs, 8);			to_skip--;		}	}	/*hasExtension - we just ignore it*/	if (gf_bs_read_int(bs, 1)) {		to_skip = gf_bs_read_vluimsbf5(bs);		while (to_skip) {			gf_bs_read_int(bs, 8);			to_skip--;		}	}	gf_bs_del(bs);	return GF_OK;}GF_EXPORTGF_Err gf_odf_get_ui_config(GF_DefaultDescriptor *dsi, GF_UIConfig *cfg){	u32 len, i;	GF_BitStream *bs;	if (!dsi || !dsi->data || !dsi->dataLength || !cfg) return GF_BAD_PARAM;	memset(cfg, 0, sizeof(GF_UIConfig));	cfg->tag = GF_ODF_UI_CFG_TAG;		bs = gf_bs_new(dsi->data, dsi->dataLength, GF_BITSTREAM_READ);	len = gf_bs_read_int(bs, 8);	cfg->deviceName = (char*)malloc(sizeof(char) * (len+1));	for (i=0; i<len; i++) cfg->deviceName[i] = gf_bs_read_int(bs, 8);	cfg->deviceName[i] = 0;	if (!stricmp(cfg->deviceName, "StringSensor") && gf_bs_available(bs)) {		cfg->termChar = gf_bs_read_int(bs, 8);		cfg->delChar = gf_bs_read_int(bs, 8);	}	gf_bs_del(bs);	return GF_OK;}GF_EXPORTGF_Err gf_odf_encode_ui_config(GF_UIConfig *cfg, GF_DefaultDescriptor **out_dsi){	u32 i, len;	GF_BitStream *bs;	GF_DefaultDescriptor *dsi;	if (!out_dsi || (cfg->tag != GF_ODF_UI_CFG_TAG)) return GF_BAD_PARAM;	*out_dsi = NULL;	if (!cfg->deviceName) return GF_OK;	bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);	len = strlen(cfg->deviceName);	gf_bs_write_int(bs, len, 8);	for (i=0; i<len; i++) gf_bs_write_int(bs, cfg->deviceName[i], 8);	if (!stricmp(cfg->deviceName, "StringSensor")) {		/*fixme - this should be UTF-8 chars*/		if (cfg->delChar || cfg->termChar) {			gf_bs_write_int(bs, cfg->termChar, 8);			gf_bs_write_int(bs, cfg->delChar, 8);		}	}	if (cfg->ui_data) gf_bs_write_data(bs, cfg->ui_data, cfg->ui_data_length);	dsi = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG);	gf_bs_get_content(bs, &dsi->data, &dsi->dataLength);	gf_bs_del(bs);	*out_dsi = dsi;	return GF_OK;}GF_EXPORTGF_AVCConfig *gf_odf_avc_cfg_new(){	GF_AVCConfig *cfg;	GF_SAFEALLOC(cfg, GF_AVCConfig);	if (!cfg) return NULL;	cfg->sequenceParameterSets = gf_list_new();	cfg->pictureParameterSets = gf_list_new();	return cfg;}GF_EXPORTvoid gf_odf_avc_cfg_del(GF_AVCConfig *cfg){	if (!cfg) return;	while (gf_list_count(cfg->sequenceParameterSets)) {		GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(cfg->sequenceParameterSets, 0);		gf_list_rem(cfg->sequenceParameterSets, 0);		if (sl->data) free(sl->data);		free(sl);	}	gf_list_del(cfg->sequenceParameterSets);	while (gf_list_count(cfg->pictureParameterSets)) {		GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(cfg->pictureParameterSets, 0);		gf_list_rem(cfg->pictureParameterSets, 0);		if (sl->data) free(sl->data);		free(sl);	}	gf_list_del(cfg->pictureParameterSets);	free(cfg);}GF_EXPORTGF_Err gf_odf_avc_cfg_write(GF_AVCConfig *cfg, char **outData, u32 *outSize){	u32 i, count;	GF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);	gf_bs_write_int(bs, cfg->configurationVersion, 8);	gf_bs_write_int(bs, cfg->AVCProfileIndication , 8);	gf_bs_write_int(bs, cfg->profile_compatibility, 8);	gf_bs_write_int(bs, cfg->AVCLevelIndication, 8);	gf_bs_write_int(bs, 0x3F, 6);	gf_bs_write_int(bs, cfg->nal_unit_size - 1, 2);	gf_bs_write_int(bs, 0x7, 3);	count = gf_list_count(cfg->sequenceParameterSets);	gf_bs_write_int(bs, count, 5);	for (i=0; i<count; i++) {		GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(cfg->sequenceParameterSets, i);		gf_bs_write_int(bs, sl->size, 16);		gf_bs_write_data(bs, sl->data, sl->size);	}	count = gf_list_count(cfg->pictureParameterSets);	gf_bs_write_int(bs, count, 8);	for (i=0; i<count; i++) {		GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)gf_list_get(cfg->pictureParameterSets, i);		gf_bs_write_int(bs, sl->size, 16);		gf_bs_write_data(bs, sl->data, sl->size);	}	*outSize = 0;	*outData = NULL;	gf_bs_get_content(bs, outData, outSize);	gf_bs_del(bs);	return GF_OK;}GF_EXPORTGF_AVCConfig *gf_odf_avc_cfg_read(char *dsi, u32 dsi_size){	u32 i, count;	GF_AVCConfig *avcc = gf_odf_avc_cfg_new();	GF_BitStream *bs = gf_bs_new(dsi, dsi_size, GF_BITSTREAM_READ);	avcc->configurationVersion = gf_bs_read_int(bs, 8);	avcc->AVCProfileIndication  = gf_bs_read_int(bs, 8);	avcc->profile_compatibility = gf_bs_read_int(bs, 8);	avcc->AVCLevelIndication  = gf_bs_read_int(bs, 8);	gf_bs_read_int(bs, 6);	avcc->nal_unit_size = 1 + gf_bs_read_int(bs, 2);	gf_bs_read_int(bs, 3);	count = gf_bs_read_int(bs, 5);	for (i=0; i<count; i++) {		GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)malloc(sizeof(GF_AVCConfigSlot));		sl->size = gf_bs_read_int(bs, 16);		sl->data = (char*)malloc(sizeof(char)*sl->size);		gf_bs_read_data(bs, sl->data, sl->size);		gf_list_add(avcc->sequenceParameterSets, sl);	}	count = gf_bs_read_int(bs, 8);	for (i=0; i<count; i++) {		GF_AVCConfigSlot *sl = (GF_AVCConfigSlot *)malloc(sizeof(GF_AVCConfigSlot));		sl->size = gf_bs_read_int(bs, 16);		sl->data = (char*)malloc(sizeof(char)*sl->size);		gf_bs_read_data(bs, sl->data, sl->size);		gf_list_add(avcc->pictureParameterSets, sl);	}	gf_bs_del(bs);	return avcc;}GF_Descriptor *gf_odf_new_tx3g(){	GF_TextSampleDescriptor *newDesc = (GF_TextSampleDescriptor*) malloc(sizeof(GF_TextSampleDescriptor));	if (!newDesc) return NULL;	memset(newDesc, 0, sizeof(GF_TextSampleDescriptor));	newDesc->tag = GF_ODF_TX3G_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_tx3g(GF_TextSampleDescriptor *sd){	u32 i;	for (i=0; i<sd->font_count; i++) 		if (sd->fonts[i].fontName) free(sd->fonts[i].fontName);	free(sd->fonts);	free(sd);	return GF_OK;}/*TextConfig*/GF_Descriptor *gf_odf_new_text_cfg(){	GF_TextConfig *newDesc = (GF_TextConfig*) malloc(sizeof(GF_TextConfig));	if (!newDesc) return NULL;	memset(newDesc, 0, sizeof(GF_TextConfig));	newDesc->tag = GF_ODF_TEXT_CFG_TAG;	newDesc->sample_descriptions = gf_list_new();	newDesc->Base3GPPFormat = 0x10;	newDesc->MPEGExtendedFormat = 0x10;	newDesc->profileLevel = 0x10;	newDesc->timescale = 1000;	return (GF_Descriptor *) newDesc;}void ResetTextConfig(GF_TextConfig *desc){	GF_List *bck;	while (gf_list_count(desc->sample_descriptions)) {		GF_TextSampleDescriptor *sd = (GF_TextSampleDescriptor *)gf_list_get(desc->sample_descriptions, 0);		gf_list_rem(desc->sample_descriptions, 0);		gf_odf_del_tx3g(sd);	}	bck = desc->sample_descriptions;	memset(desc, 0, sizeof(GF_TextConfig));	desc->tag = GF_ODF_TEXT_CFG_TAG;		desc->sample_descriptions = bck;}GF_Err gf_odf_del_text_cfg(GF_TextConfig *desc){	ResetTextConfig(desc);	gf_list_del(desc->sample_descriptions);	free(desc);	return GF_OK;}/*we need box parsing*/#include <gpac/internal/isomedia_dev.h>GF_EXPORTGF_Err gf_odf_get_text_config(GF_DefaultDescriptor *dsi, u8 oti, GF_TextConfig *cfg){	u32 i, j;	Bool has_alt_format, has_sd;	GF_Err e;	GF_BitStream *bs;	if (!dsi || !dsi->data || !dsi->dataLength || !cfg) return GF_BAD_PARAM;	if (oti != 0x08) return GF_NOT_SUPPORTED;	/*reset*/	ResetTextConfig(cfg);	bs = gf_bs_new(dsi->data, dsi->dataLength, GF_BITSTREAM_READ);	e = GF_OK;	cfg->Base3GPPFormat = gf_bs_read_int(bs, 8);	cfg->MPEGExtendedFormat = gf_bs_read_int(bs, 8);	cfg->profileLevel = gf_bs_read_int(bs, 8);	cfg->timescale = gf_bs_read_int(bs, 24);	has_alt_format = gf_bs_read_int(bs, 1);	cfg->sampleDescriptionFlags = gf_bs_read_int(bs, 2);	has_sd = gf_bs_read_int(bs, 1);	cfg->has_vid_info = gf_bs_read_int(bs, 1);	gf_bs_read_int(bs, 3);	cfg->layer = gf_bs_read_int(bs, 8);	cfg->text_width = gf_bs_read_int(bs, 16);	cfg->text_height = gf_bs_read_int(bs, 16);	if (has_alt_format) {		cfg->nb_compatible_formats = gf_bs_read_int(bs, 8);		for (i=0; i<cfg->nb_compatible_formats; i++) cfg->compatible_formats[i] = gf_bs_read_int(bs, 8);	}	if (has_sd) {		u8 sample_index;		GF_TextSampleDescriptor *txdesc;		GF_TextSampleEntryBox *a;		s32 avail;		u32 nb_desc = gf_bs_read_int(bs, 8);		/*parse TTU[5]s*/		avail = (s32) gf_bs_available(bs);		for (i=0; i<nb_desc; i++) {			sample_index = gf_bs_read_int(bs, 8);			avail -= 1;			e = gf_isom_parse_box((GF_Box **) &a, bs);			if (e) goto exit;			avail -= (s32) a->size;			if (avail<0) {				e = GF_NON_COMPLIANT_BITSTREAM;				goto exit;			}			txdesc = (GF_TextSampleDescriptor *)malloc(sizeof(GF_TextSampleDescriptor));			txdesc->sample_index = sample_index;			txdesc->displayFlags = a->displayFlags;			txdesc->back_color = a->back_color;			txdesc->default_pos = a->default_box;			txdesc->default_style = a->default_style;			txdesc->vert_justif = a->vertical_justification;			txdesc->horiz_justif = a->horizontal_justification;			txdesc->font_count = a->font_table ? a->font_table->entry_count : 0;			if (txdesc->font_count) {				txdesc->fonts = (GF_FontRecord*)malloc(sizeof(GF_FontRecord)*txdesc->font_count);				for (j=0; j<txdesc->font_count; j++) {					txdesc->fonts[j].fontID = a->font_table->fonts[j].fontID;					txdesc->fonts[j].fontName = a->font_table->fonts[j].fontName ? strdup(a->font_table->fonts[j].fontName) : NULL;				}			}			gf_list_add(cfg->sample_descriptions, txdesc);			gf_isom_box_del((GF_Box *)a);		}	}	if (cfg->has_vid_info) {		cfg->video_width = gf_bs_read_int(bs, 16);		cfg->video_height = gf_bs_read_int(bs, 16);		cfg->horiz_offset = gf_bs_read_int(bs, 16);		cfg->vert_offset = gf_bs_read_int(bs, 16);	}	exit:	gf_bs_del(bs);	if (e) ResetTextConfig(cfg);	return e;}

⌨️ 快捷键说明

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