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

📄 odf_code.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
GF_Err gf_odf_del_pl_ext(GF_PLExt *pld){	if (!pld) return GF_BAD_PARAM;	free(pld);	return GF_OK;}GF_Err gf_odf_read_pl_ext(GF_BitStream *bs, GF_PLExt *pld, u32 DescSize){	u32 nbBytes = 0;	if (!pld) return GF_BAD_PARAM;	pld->profileLevelIndicationIndex = gf_bs_read_int(bs, 8);	pld->ODProfileLevelIndication = gf_bs_read_int(bs, 8);	pld->SceneProfileLevelIndication = gf_bs_read_int(bs, 8);	pld->AudioProfileLevelIndication = gf_bs_read_int(bs, 8);	pld->VisualProfileLevelIndication = gf_bs_read_int(bs, 8);	pld->GraphicsProfileLevelIndication = gf_bs_read_int(bs, 8);	pld->MPEGJProfileLevelIndication = gf_bs_read_int(bs, 8);	nbBytes += 7;	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_pl_ext(GF_PLExt *pld, u32 *outSize){	if (!pld) return GF_BAD_PARAM;	*outSize = 7;	return GF_OK;}GF_Err gf_odf_write_pl_ext(GF_BitStream *bs, GF_PLExt *pld){	GF_Err e;	u32 size;	if (!pld) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)pld, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, pld->tag, size);	if (e) return e;	gf_bs_write_int(bs, pld->profileLevelIndicationIndex, 8);	gf_bs_write_int(bs, pld->ODProfileLevelIndication, 8);	gf_bs_write_int(bs, pld->SceneProfileLevelIndication, 8);	gf_bs_write_int(bs, pld->AudioProfileLevelIndication, 8);	gf_bs_write_int(bs, pld->VisualProfileLevelIndication, 8);	gf_bs_write_int(bs, pld->GraphicsProfileLevelIndication, 8);	gf_bs_write_int(bs, pld->MPEGJProfileLevelIndication, 8);	return GF_OK;}GF_Descriptor *gf_odf_new_segment(){	GF_Segment *newDesc = (GF_Segment *) malloc(sizeof(GF_Segment));	if (!newDesc) return NULL;	memset(newDesc, 0, sizeof(GF_Segment));	newDesc->tag = GF_ODF_SEGMENT_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_segment(GF_Segment *sd){	if (!sd) return GF_BAD_PARAM;	if (sd->SegmentName) free(sd->SegmentName);	free(sd);	return GF_OK;}GF_Err gf_odf_read_segment(GF_BitStream *bs, GF_Segment *sd, u32 DescSize){	u32 size, nbBytes = 0;	if (!sd) return GF_BAD_PARAM;	sd->startTime = gf_bs_read_double(bs);	sd->Duration = gf_bs_read_double(bs);	nbBytes += 16;	size = gf_bs_read_int(bs, 8);	nbBytes += 1;	if (size) {		sd->SegmentName = (char*) malloc(sizeof(char)*(size+1));		if (!sd->SegmentName) return GF_OUT_OF_MEM;		gf_bs_read_data(bs, sd->SegmentName, size);		sd->SegmentName[size] = 0;		nbBytes += size;	}	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_segment(GF_Segment *sd, u32 *outSize){	if (!sd) return GF_BAD_PARAM;	*outSize = 17;	if (sd->SegmentName) *outSize += strlen(sd->SegmentName);	return GF_OK;}GF_Err gf_odf_write_segment(GF_BitStream *bs, GF_Segment *sd){	GF_Err e;	u32 size;	if (!sd) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)sd, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, sd->tag, size);	if (e) return e;	gf_bs_write_double(bs, sd->startTime);	gf_bs_write_double(bs, sd->Duration);	if (sd->SegmentName) {		gf_bs_write_int(bs, strlen(sd->SegmentName), 8);		gf_bs_write_data(bs, sd->SegmentName, strlen(sd->SegmentName));	} else {		gf_bs_write_int(bs, 0, 8);	}	return GF_OK;}GF_Descriptor *gf_odf_new_mediatime(){	GF_MediaTime *newDesc = (GF_MediaTime *) malloc(sizeof(GF_MediaTime));	if (!newDesc) return NULL;	memset(newDesc, 0, sizeof(GF_MediaTime));	newDesc->tag = GF_ODF_MEDIATIME_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_mediatime(GF_MediaTime *mt){	if (!mt) return GF_BAD_PARAM;	free(mt);	return GF_OK;}GF_Err gf_odf_read_mediatime(GF_BitStream *bs, GF_MediaTime *mt, u32 DescSize){	if (!mt) return GF_BAD_PARAM;	mt->mediaTimeStamp = gf_bs_read_double(bs);	return GF_OK;}GF_Err gf_odf_size_mediatime(GF_MediaTime *mt, u32 *outSize){	if (!mt) return GF_BAD_PARAM;	*outSize = 8;	return GF_OK;}GF_Err gf_odf_write_mediatime(GF_BitStream *bs, GF_MediaTime *mt){	GF_Err e;	u32 size;	if (!mt) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)mt, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, mt->tag, size);	if (e) return e;	gf_bs_write_double(bs, mt->mediaTimeStamp);	return GF_OK;}GF_Descriptor *gf_odf_new_ipi_ptr(){	GF_IPIPtr *newDesc = (GF_IPIPtr *) malloc(sizeof(GF_IPIPtr));	if (!newDesc) return NULL;	newDesc->IPI_ES_Id = 0;	newDesc->tag = GF_ODF_IPI_PTR_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_ipi_ptr(GF_IPIPtr *ipid){	if (!ipid) return GF_BAD_PARAM;	free(ipid);	return GF_OK;}GF_Err gf_odf_read_ipi_ptr(GF_BitStream *bs, GF_IPIPtr *ipid, u32 DescSize){	u32 nbBytes = 0;	if (! ipid) return GF_BAD_PARAM;	ipid->IPI_ES_Id = gf_bs_read_int(bs, 16);	nbBytes += 2;	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_ipi_ptr(GF_IPIPtr *ipid, u32 *outSize){	if (! ipid) return GF_BAD_PARAM;	*outSize = 2;	return GF_OK;}GF_Err gf_odf_write_ipi_ptr(GF_BitStream *bs, GF_IPIPtr *ipid){	GF_Err e;	u32 size;	if (! ipid) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)ipid, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, ipid->tag, size);	if (e) return e;	gf_bs_write_int(bs, ipid->IPI_ES_Id, 16);	return GF_OK;}GF_Descriptor *gf_odf_new_ipmp(){	GF_IPMP_Descriptor *newDesc;	GF_SAFEALLOC(newDesc, GF_IPMP_Descriptor);	if (!newDesc) return NULL;	newDesc->ipmpx_data = gf_list_new();	newDesc->tag = GF_ODF_IPMP_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_ipmp(GF_IPMP_Descriptor *ipmp){	if (!ipmp) return GF_BAD_PARAM;	if (ipmp->opaque_data) free(ipmp->opaque_data);	/*TODO DELETE IPMPX*/	while (gf_list_count(ipmp->ipmpx_data)) {		GF_IPMPX_Data *p = (GF_IPMPX_Data *)gf_list_get(ipmp->ipmpx_data, 0);		gf_list_rem(ipmp->ipmpx_data, 0);		gf_ipmpx_data_del(p);	}	gf_list_del(ipmp->ipmpx_data);	free(ipmp);	return GF_OK;}GF_Err gf_odf_read_ipmp(GF_BitStream *bs, GF_IPMP_Descriptor *ipmp, u32 DescSize){	u32 size, nbBytes = 0;	if (!ipmp) return GF_BAD_PARAM;	ipmp->IPMP_DescriptorID = gf_bs_read_int(bs, 8);	ipmp->IPMPS_Type = gf_bs_read_int(bs, 16);	nbBytes += 3;	size = DescSize - 3;	/*IPMPX escape*/	if ((ipmp->IPMP_DescriptorID==0xFF) && (ipmp->IPMPS_Type==0xFFFF)) {		ipmp->IPMP_DescriptorIDEx = gf_bs_read_int(bs, 16);		gf_bs_read_data(bs, (char*)ipmp->IPMP_ToolID, 16);		ipmp->control_point = gf_bs_read_int(bs, 8);		nbBytes += 19;		if (ipmp->control_point) {			ipmp->cp_sequence_code = gf_bs_read_int(bs, 8);			nbBytes += 1;		}		while (nbBytes<DescSize) {			u32 pos;			GF_Err e;			GF_IPMPX_Data *p;			pos = (u32) gf_bs_get_position(bs);			e = gf_ipmpx_data_parse(bs, &p);			if (e) return e;			gf_list_add(ipmp->ipmpx_data, p);			nbBytes += (u32) gf_bs_get_position(bs) - pos;		}	}	/*URL*/	else if (! ipmp->IPMPS_Type) {		ipmp->opaque_data = (char*)malloc(size + 1);		if (! ipmp->opaque_data) return GF_OUT_OF_MEM;		gf_bs_read_data(bs, ipmp->opaque_data, size);		nbBytes += size;		ipmp->opaque_data[size] = 0;		ipmp->opaque_data_size = size;			}	/*data*/	else {		ipmp->opaque_data_size = size;		ipmp->opaque_data = (char*)malloc(size);		if (! ipmp->opaque_data) return GF_OUT_OF_MEM;		gf_bs_read_data(bs, ipmp->opaque_data, size);		nbBytes += size;	}	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_ipmp(GF_IPMP_Descriptor *ipmp, u32 *outSize){	u32 i, s;	if (!ipmp) return GF_BAD_PARAM;	*outSize = 3;	/*IPMPX escape*/	if ((ipmp->IPMP_DescriptorID==0xFF) && (ipmp->IPMPS_Type==0xFFFF)) {		GF_IPMPX_Data *p;		*outSize += 19;		if (ipmp->control_point) *outSize += 1;		s = 0;		i=0;		while ((p = (GF_IPMPX_Data *)gf_list_enum(ipmp->ipmpx_data, &i))) {			s += gf_ipmpx_data_full_size(p);		}		(*outSize) += s;	}	else if (! ipmp->IPMPS_Type) {		if (!ipmp->opaque_data) return GF_ODF_INVALID_DESCRIPTOR;		*outSize += strlen(ipmp->opaque_data);	} else {		*outSize += ipmp->opaque_data_size;	}	return GF_OK;}GF_Err gf_odf_write_ipmp(GF_BitStream *bs, GF_IPMP_Descriptor *ipmp){	GF_Err e;	u32 size, i;	if (!ipmp) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)ipmp, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, ipmp->tag, size);	if (e) return e;	gf_bs_write_int(bs, ipmp->IPMP_DescriptorID, 8);	gf_bs_write_int(bs, ipmp->IPMPS_Type, 16);	if ((ipmp->IPMP_DescriptorID==0xFF) && (ipmp->IPMPS_Type==0xFFFF)) {		GF_IPMPX_Data *p;		gf_bs_write_int(bs, ipmp->IPMP_DescriptorIDEx, 16);		gf_bs_write_data(bs, (char*)ipmp->IPMP_ToolID, 16);		gf_bs_write_int(bs, ipmp->control_point, 8);		if (ipmp->control_point) gf_bs_write_int(bs, ipmp->cp_sequence_code, 8);		i=0;		while ((p = (GF_IPMPX_Data *) gf_list_enum(ipmp->ipmpx_data, &i))) {			gf_ipmpx_data_write(bs, p);		}	}	else if (!ipmp->IPMPS_Type) {		if (!ipmp->opaque_data) return GF_ODF_INVALID_DESCRIPTOR;		gf_bs_write_data(bs, ipmp->opaque_data, strlen(ipmp->opaque_data));	} else {		gf_bs_write_data(bs, ipmp->opaque_data, ipmp->opaque_data_size);	}	return GF_OK;}GF_Descriptor *gf_odf_new_ipmp_ptr(){	GF_IPMPPtr *newDesc;	GF_SAFEALLOC(newDesc, GF_IPMPPtr);	if (!newDesc) return NULL;	newDesc->tag = GF_ODF_IPMP_PTR_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_ipmp_ptr(GF_IPMPPtr *ipmpd){	if (!ipmpd) return GF_BAD_PARAM;	free(ipmpd);	return GF_OK;}GF_Err gf_odf_read_ipmp_ptr(GF_BitStream *bs, GF_IPMPPtr *ipmpd, u32 DescSize){	u32 nbBytes = 0;	if (! ipmpd) return GF_BAD_PARAM;	ipmpd->IPMP_DescriptorID = gf_bs_read_int(bs, 8);	nbBytes += 1;	if (ipmpd->IPMP_DescriptorID == 0xFF) {		ipmpd->IPMP_DescriptorIDEx = gf_bs_read_int(bs, 16);		ipmpd->IPMP_ES_ID = gf_bs_read_int(bs, 16);		nbBytes += 4;	}	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_ipmp_ptr(GF_IPMPPtr *ipmpd, u32 *outSize){	if (! ipmpd) return GF_BAD_PARAM;	*outSize = 1;	if (ipmpd->IPMP_DescriptorID == 0xFF) *outSize += 4;	return GF_OK;}GF_Err gf_odf_write_ipmp_ptr(GF_BitStream *bs, GF_IPMPPtr *ipmpd){	GF_Err e;	u32 size;	if (! ipmpd) return GF_BAD_PARAM;	e = gf_odf_size_descriptor((GF_Descriptor *)ipmpd, &size);	if (e) return e;	e = gf_odf_write_base_descriptor(bs, ipmpd->tag, size);	if (e) return e;	gf_bs_write_int(bs, ipmpd->IPMP_DescriptorID, 8);	if (ipmpd->IPMP_DescriptorID == 0xFF) {		gf_bs_write_int(bs, ipmpd->IPMP_DescriptorIDEx, 16);		gf_bs_write_int(bs, ipmpd->IPMP_ES_ID, 16);	}	return GF_OK;}GF_Descriptor *gf_odf_new_kw(){	GF_KeyWord *newDesc = (GF_KeyWord *) malloc(sizeof(GF_KeyWord));	if (!newDesc) return NULL;	newDesc->keyWordsList = gf_list_new();	if (! newDesc->keyWordsList) {		free(newDesc);		return NULL;	}	newDesc->isUTF8 = 0;	newDesc->languageCode = 0;	newDesc->tag = GF_ODF_KW_TAG;	return (GF_Descriptor *) newDesc;}GF_Err gf_odf_del_kw(GF_KeyWord *kwd){	if (!kwd) return GF_BAD_PARAM;	while (gf_list_count(kwd->keyWordsList)) {		GF_KeyWordItem *tmp = (GF_KeyWordItem*)gf_list_get(kwd->keyWordsList, 0);		if (tmp) {			if (tmp->keyWord) free(tmp->keyWord);			free(tmp);		}	}	gf_list_del(kwd->keyWordsList);	free(kwd);	return GF_OK;}GF_Err gf_odf_read_kw(GF_BitStream *bs, GF_KeyWord *kwd, u32 DescSize){	GF_Err e;	u32 nbBytes = 0, aligned, i, kwcount, len;	if (!kwd) return GF_BAD_PARAM;	kwd->languageCode = gf_bs_read_int(bs, 24);	kwd->isUTF8 = gf_bs_read_int(bs, 1);	aligned = gf_bs_read_int(bs, 7);	kwcount = gf_bs_read_int(bs, 8);	nbBytes += 5;	for (i = 0 ; i < kwcount; i++) {		GF_KeyWordItem *tmp = (GF_KeyWordItem*)malloc(sizeof(GF_KeyWordItem));		if (! tmp) return GF_OUT_OF_MEM;		e = OD_ReadUTF8String(bs, & tmp->keyWord, kwd->isUTF8, &len);		if (e) return e;		e = gf_list_add(kwd->keyWordsList, tmp);		if (e) return e;		nbBytes  += len;	}	if (nbBytes != DescSize) return GF_ODF_INVALID_DESCRIPTOR;	return GF_OK;}GF_Err gf_odf_size_kw(GF_KeyWord *kwd, u32 *outSize){	u32 i;	GF_KeyWordItem *tmp;	if (!kwd) return GF_BAD_PARAM;	*outSize = 5;	i=0;	while ((tmp = (GF_KeyWordItem *)gf_list_enum(kwd->keyWordsList, &i))) {		*outSize += OD_SizeUTF8String(tmp->keyWord, kwd->isUTF8);	}	return GF_OK

⌨️ 快捷键说明

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