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

📄 odf_parse.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 2 页
字号:
		else if (!stricmp(fieldName, "OCRResolution")) ret += sscanf(val, "%d", &slc->OCRResolution);		else if (!stricmp(fieldName, "timeStampLength")) GET_U8(slc->timestampLength)		else if (!stricmp(fieldName, "OCRLength")) GET_U8(slc->OCRLength)		else if (!stricmp(fieldName, "AU_Length")) GET_U8(slc->AULength)		else if (!stricmp(fieldName, "instantBitrateLength")) GET_U8(slc->instantBitrateLength)		else if (!stricmp(fieldName, "degradationPriorityLength")) GET_U8(slc->degradationPriorityLength)		else if (!stricmp(fieldName, "AU_seqNumLength")) GET_U8(slc->AUSeqNumLength)		else if (!stricmp(fieldName, "packetSeqNumLength")) GET_U8(slc->packetSeqNumLength)		else if (!stricmp(fieldName, "timeScale")) ret += sscanf(val, "%d", &slc->timeScale);		else if (!stricmp(fieldName, "accessUnitDuration")) ret += sscanf(val, "%hd", &slc->AUDuration);		else if (!stricmp(fieldName, "compositionUnitDuration")) ret += sscanf(val, "%hd", &slc->CUDuration);		else if (!stricmp(fieldName, "startDecodingTimeStamp")) {			ret += sscanf(val, "%d", &ts);			slc->startDTS = ts;		}		else if (!stricmp(fieldName, "startCompositionTimeStamp")) {			ret += sscanf(val, "%d", &ts);			slc->startCTS = ts;		}		else if (!stricmp(fieldName, "durationFlag")) ret = 1;	}			break;	case GF_ODF_ELEM_MASK_TAG:	{		GF_ElementaryMask* em = (GF_ElementaryMask*)desc;		if (!stricmp(fieldName, "atNode")) {			GET_U32(em->node_id);			if (!ret || !em->node_id) em->node_name = strdup(val);			ret = 1;		}		else if (!stricmp(fieldName, "numDynFields")) ret = 1;	}		break;	case GF_ODF_BIFS_CFG_TAG:	{		s32 notused;		GF_BIFSConfig *bcd = (GF_BIFSConfig*)desc;		if (!stricmp(val, "auto")) return GF_OK;		if (!stricmp(fieldName, "nodeIDbits")) ret += sscanf(val, "%hd", &bcd->nodeIDbits);		else if (!stricmp(fieldName, "nodeIDbits")) ret += sscanf(val, "%hd", &bcd->nodeIDbits);		else if (!stricmp(fieldName, "routeIDbits")) ret += sscanf(val, "%hd", &bcd->routeIDbits);		else if (!stricmp(fieldName, "protoIDbits")) ret += sscanf(val, "%hd", &bcd->protoIDbits);		else if (!stricmp(fieldName, "isCommandStream")) { /*GET_BOOL(bcd->isCommandStream)*/ ret = 1; }		else if (!stricmp(fieldName, "pixelMetric") || !stricmp(fieldName, "pixelMetrics")) GET_BOOL(bcd->pixelMetrics)		else if (!stricmp(fieldName, "pixelWidth")) ret += sscanf(val, "%hd", &bcd->pixelWidth);		else if (!stricmp(fieldName, "pixelHeight")) ret += sscanf(val, "%hd", &bcd->pixelHeight);		else if (!stricmp(fieldName, "use3DMeshCoding")) GET_BOOL(notused)		else if (!stricmp(fieldName, "usePredictiveMFField")) GET_BOOL(notused)		else if (!stricmp(fieldName, "randomAccess")) GET_BOOL(bcd->randomAccess);	}		break;	case GF_ODF_MUXINFO_TAG:	{		GF_MuxInfo *mi = (GF_MuxInfo *)desc;		if (!stricmp(fieldName, "fileName") || !stricmp(fieldName, "url")) GET_STRING(mi->file_name)		else if (!stricmp(fieldName, "streamFormat")) GET_STRING(mi->streamFormat)		else if (!stricmp(fieldName, "GroupID")) ret += sscanf(val, "%d", &mi->GroupID);		else if (!stricmp(fieldName, "startTime")) ret += sscanf(val, "%d", &mi->startTime);		else if (!stricmp(fieldName, "duration")) ret += sscanf(val, "%d", &mi->duration);		else if (!stricmp(fieldName, "compactSize"))		{ ret = 1; if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_USE_COMPACT_SIZE; }		else if (!stricmp(fieldName, "useDataReference"))		{ ret = 1; if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_USE_DATAREF; }		else if (!stricmp(fieldName, "noFrameDrop"))		{ ret = 1; if (!stricmp(val, "true") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_NO_FRAME_DROP; }		else if (!stricmp(fieldName, "SBR_Type")) { 			ret = 1; 			if (!stricmp(val, "implicit") || !stricmp(val, "1")) mi->import_flags |= GF_IMPORT_SBR_IMPLICIT;			else if (!stricmp(val, "explicit") || !stricmp(val, "2")) mi->import_flags |= GF_IMPORT_SBR_EXPLICIT;		}		else if (!stricmp(fieldName, "textNode")) GET_STRING(mi->textNode)		else if (!stricmp(fieldName, "fontNode")) GET_STRING(mi->fontNode)		else if (!stricmp(fieldName, "frameRate")) { ret = 1; mi->frame_rate = atof(val); }	}		break;	case GF_ODF_DSI_TAG:	{		GF_DefaultDescriptor *dsi = (GF_DefaultDescriptor*)desc;		if (!stricmp(fieldName, "info")) {			/*only parse true hexa strings*/			if (val[0] == '%') {				OD_ParseBinData(val, &dsi->data, &dsi->dataLength);				ret = 1;			} else if (!strnicmp(val, "file:", 5)) {				OD_ParseFileData(val+5, &dsi->data, &dsi->dataLength);				ret = 1;			} else if (!strlen(val)) ret = 1;		}		if (!stricmp(fieldName, "src")) {			u32 len = strlen("data:application/octet-string,");			if (strnicmp(val, "data:application/octet-string,", len)) break;			val += len;			/*only parse true hexa strings*/			if (val[0] == '%') {				OD_ParseBinData(val, &dsi->data, &dsi->dataLength);				ret = 1;			} else if (!strnicmp(val, "file:", 5)) {				OD_ParseFileData(val+5, &dsi->data, &dsi->dataLength);				ret = 1;			}		}	}		break;	case GF_ODF_SEGMENT_TAG:	{		GF_Segment *sd = (GF_Segment*)desc;		if (!stricmp(fieldName, "start") || !stricmp(fieldName, "startTime")) GET_DOUBLE(sd->startTime)		else if (!stricmp(fieldName, "duration")) GET_DOUBLE(sd->Duration)		else if (!stricmp(fieldName, "name") || !stricmp(fieldName, "segmentName")) GET_STRING(sd->SegmentName)	}		break;	case GF_ODF_UI_CFG_TAG:	{		GF_UIConfig *uic = (GF_UIConfig*)desc;		if (!stricmp(fieldName, "deviceName")) GET_STRING(uic->deviceName)		else if (!stricmp(fieldName, "termChar")) GET_U8(uic->termChar)		else if (!stricmp(fieldName, "delChar")) GET_U8(uic->delChar)		else if (!stricmp(fieldName, "uiData")) {			/*only parse true hexa strings*/			if (val[0] == '%') {				OD_ParseBinData(val, &uic->ui_data, &uic->ui_data_length);				ret = 1;			} else if (!strnicmp(val, "file:", 5)) {				OD_ParseFileData(val+5, &uic->ui_data, &uic->ui_data_length);				ret = 1;			} else {				ret = OD_ParseUIConfig(val, &uic->ui_data, &uic->ui_data_length);			}		}	}		break;	case GF_ODF_ESD_INC_TAG:	{		GF_ES_ID_Inc *inc = (GF_ES_ID_Inc *)desc;		if (!stricmp(fieldName, "trackID")) ret += sscanf(val, "%d", &inc->trackID);	}		break;	case GF_ODF_ESD_REF_TAG:	{		GF_ES_ID_Ref *inc = (GF_ES_ID_Ref *)desc;		if (!stricmp(fieldName, "trackID")) ret += sscanf(val, "%hd", &inc->trackRef);	}		break;	case GF_ODF_TEXT_CFG_TAG:	{		GF_TextConfig *txt = (GF_TextConfig*)desc;		if (!stricmp(fieldName, "3GPPBaseFormat")) GET_U8(txt->Base3GPPFormat)		else if (!stricmp(fieldName, "MPEGExtendedFormat")) GET_U8(txt->MPEGExtendedFormat)		else if (!stricmp(fieldName, "profileLevel")) GET_U8(txt->profileLevel)		else if (!stricmp(fieldName, "durationClock") || !stricmp(fieldName, "timescale") ) GET_U32(txt->timescale)		else if (!stricmp(fieldName, "layer")) GET_U32(txt->layer)		else if (!stricmp(fieldName, "text_width")) GET_U32(txt->text_width)		else if (!stricmp(fieldName, "text_height")) GET_U32(txt->text_height)		else if (!stricmp(fieldName, "video_width")) {			GET_U32(txt->video_width)			txt->has_vid_info = 1;		}		else if (!stricmp(fieldName, "video_height")) {			GET_U32(txt->video_height)			txt->has_vid_info = 1;		}		else if (!stricmp(fieldName, "horizontal_offset")) {			GET_S32(txt->horiz_offset)			txt->has_vid_info = 1;		}		else if (!stricmp(fieldName, "vertical_offset")) {			GET_S32(txt->vert_offset)			txt->has_vid_info = 1;		}	}		break;	case GF_ODF_TX3G_TAG:	{		GF_TextSampleDescriptor *sd = (GF_TextSampleDescriptor*)desc;		if (!stricmp(fieldName, "displayFlags")) GET_U32(sd->displayFlags)		else if (!stricmp(fieldName, "horiz_justif")) GET_S32(sd->horiz_justif)		else if (!stricmp(fieldName, "vert_justif")) GET_S32(sd->vert_justif)		else if (!stricmp(fieldName, "back_color")) GET_S32(sd->back_color)		else if (!stricmp(fieldName, "top")) GET_S32(sd->default_pos.top)		else if (!stricmp(fieldName, "bottom")) GET_S32(sd->default_pos.bottom)		else if (!stricmp(fieldName, "left")) GET_S32(sd->default_pos.left)		else if (!stricmp(fieldName, "right")) GET_S32(sd->default_pos.right)		else if (!stricmp(fieldName, "style_font_ID")) GET_S32(sd->default_style.fontID)		else if (!stricmp(fieldName, "style_font_size")) GET_S32(sd->default_style.font_size)		else if (!stricmp(fieldName, "style_text_color")) GET_U32(sd->default_style.text_color)		else if (!stricmp(fieldName, "style_flags")) {			char szStyles[1024];			strcpy(szStyles, val);			strlwr(szStyles);			if (strstr(szStyles, "bold")) sd->default_style.style_flags |= GF_TXT_STYLE_BOLD;			if (strstr(szStyles, "italic")) sd->default_style.style_flags |= GF_TXT_STYLE_ITALIC;			if (strstr(szStyles, "underlined")) sd->default_style.style_flags |= GF_TXT_STYLE_UNDERLINED;			ret = 1;		}		else if (!stricmp(fieldName, "fontID") || !stricmp(fieldName, "fontName")) {			/*check if we need a new entry*/			if (!sd->font_count) {				sd->fonts = (GF_FontRecord*)malloc(sizeof(GF_FontRecord));				sd->font_count = 1;				sd->fonts[0].fontID = 0;				sd->fonts[0].fontName = NULL;			} else {				Bool realloc_fonts = 0;				if (!stricmp(fieldName, "fontID") && sd->fonts[sd->font_count-1].fontID) realloc_fonts = 1;				else if (!stricmp(fieldName, "fontName") && sd->fonts[sd->font_count-1].fontName) realloc_fonts = 1;				if (realloc_fonts) {					sd->font_count += 1;					sd->fonts = (GF_FontRecord*)realloc(sd->fonts, sizeof(GF_FontRecord)*sd->font_count);					sd->fonts[sd->font_count-1].fontID = 0;					sd->fonts[sd->font_count-1].fontName = NULL;				}			}			if (!stricmp(fieldName, "fontID")) GET_U32(sd->fonts[sd->font_count-1].fontID)			if (!stricmp(fieldName, "fontName")) GET_STRING(sd->fonts[sd->font_count-1].fontName)			ret = 1;		}	}		break;	case GF_ODF_IPMP_TAG:	{		GF_IPMP_Descriptor *ipmp = (GF_IPMP_Descriptor*)desc;		if (!stricmp(fieldName, "IPMP_DescriptorID")) GET_U8(ipmp->IPMP_DescriptorID)		else if (!stricmp(fieldName, "IPMPS_Type")) GET_U16(ipmp->IPMPS_Type)		else if (!stricmp(fieldName, "IPMP_DescriptorIDEx")) GET_U16(ipmp->IPMP_DescriptorIDEx)		else if (!stricmp(fieldName, "IPMP_ToolID")) { ret = 1; OD_ParseBin128(val, &ipmp->IPMP_ToolID); }		else if (!stricmp(fieldName, "controlPointCode")) GET_U8(ipmp->control_point)		else if (!stricmp(fieldName, "sequenceCode")) GET_U8(ipmp->cp_sequence_code)	}		break;	case GF_ODF_IPMP_PTR_TAG:	{		GF_IPMPPtr *ipmpd = (GF_IPMPPtr*)desc;		if (!stricmp(fieldName, "IPMP_DescriptorID")) GET_U8(ipmpd->IPMP_DescriptorID)		else if (!stricmp(fieldName, "IPMP_DescriptorIDEx"))  ret += sscanf(val, "%hd", &ipmpd->IPMP_DescriptorIDEx);		else if (!stricmp(fieldName, "IPMP_ES_ID"))  ret += sscanf(val, "%hd", &ipmpd->IPMP_ES_ID);	}		break;	case GF_ODF_LANG_TAG:		{			GF_Language *ld = (GF_Language *)desc;			if (!stricmp(fieldName, "languageCode")) {				u32 li, l = strlen(val);				ld->langCode = 0;				for (li = 0; li < l; li++) {					/* Warning: sensitive to big endian, little endian */					ld->langCode |= (val[li] << (l-li-1)*8);				}				ret++;			}		}		break;	case GF_ODF_IPMP_TOOL_TAG:	{		GF_IPMP_Tool *it = (GF_IPMP_Tool*)desc;		if (!stricmp(fieldName, "IPMP_ToolID")) { ret = 1; OD_ParseBin128(val, &it->IPMP_ToolID); }		else if (!stricmp(fieldName, "ToolURL"))  GET_STRING(it->tool_url)	}		break;	}	return ret ? GF_OK : GF_BAD_PARAM;}Bool OD_ParseUIConfig(char *val, char **out_data, u32 *out_data_size){	GF_BitStream *bs;	if (!strnicmp(val, "HTK:", 4)) {		char szItem[100];		s32 pos, bs_start, bs_cur;		Bool has_word;		u32 nb_phonems, nbWords = 0;		bs_start = 0;		nb_phonems = 0;		bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);		/*we'll write the nb of words later on*/		gf_bs_write_int(bs, 0, 8);		has_word = 0;		/*parse all words*/		val += 4;		while (1) {			pos = gf_token_get(val, 0, " ;", szItem, 100);			if (pos>0) val += pos;			if (!has_word) {				has_word = 1;				nbWords++;				nb_phonems = 0;				bs_start = (u32) gf_bs_get_position(bs);				/*nb phonems*/				gf_bs_write_int(bs, 0, 8);				gf_bs_write_data(bs, szItem, strlen(szItem));				gf_bs_write_int(bs, 0, 8);				continue;			}			if (pos>0) {						nb_phonems ++;				/*would be nicer with a phone book & use indexes*/				if (!stricmp(szItem, "vcl")) {					gf_bs_write_data(bs, "vc", 2);				} else {					gf_bs_write_data(bs, szItem, 2);				}				while (val[0] && (val[0]==' ')) val += 1;			}			if ((pos<0) || !val[0] || val[0]==';') {				if (has_word) {					has_word = 0;					bs_cur = (u32) gf_bs_get_position(bs);					gf_bs_seek(bs, bs_start);					gf_bs_write_int(bs, nb_phonems, 8);					gf_bs_seek(bs, bs_cur);				}				if ((pos<0) || !val[0]) break;				val += 1;				while (val[0] && (val[0]==' ')) val += 1;			}		}		if (nbWords) {			bs_cur = (u32) gf_bs_get_position(bs);			gf_bs_seek(bs, 0);			gf_bs_write_int(bs, nbWords, 8);			gf_bs_seek(bs, bs_cur);			gf_bs_get_content(bs, out_data, out_data_size);		}		gf_bs_del(bs);		return 1;	}	return 0;}

⌨️ 快捷键说明

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