Пример #1
0
BaseDecoder *OGG_LoadDecoder()
{
	MediaDecoder *ifce;
	OGGWraper *wrap;
	SAFEALLOC(ifce, sizeof(MediaDecoder));
	SAFEALLOC(wrap, sizeof(OGGWraper));
	ifce->privateStack = wrap;
	ifce->CanHandleStream = OGG_CanHandleStream;
	M4_REG_PLUG(ifce, M4MEDIADECODERINTERFACE, "GPAC XIPH.org package", "gpac distribution", 0)

	/*other interfaces will be setup at run time*/
	return (BaseDecoder *)ifce;
}
Пример #2
0
M4PathIterator *m4_path_new_iterator(M4Path *_this)
{
	M4PathIterator *it;
	u32 i, j, nb;
	M4Point2D start, end;
	M4PATH();
	
	SAFEALLOC(it, sizeof(M4PathIterator));

	nb = 0;
	for (i=0; i<path->subpathlen; i++) {
		nb += path->subpath[i]->pointlen;
	}
	it->seg = malloc(sizeof(IterInfo) * nb);
	it->num_seg = 0;
	it->length = 0;
	for (i=0; i<path->subpathlen; i++) {
		if (!path->subpath[i]->pointlen) continue;
		start = path->subpath[i]->point[0];
		for (j=1; j<path->subpath[i]->pointlen; j++) {
			end = path->subpath[i]->point[j];

			it->seg[it->num_seg].start_x = start.x;
			it->seg[it->num_seg].start_y = start.y;
			it->seg[it->num_seg].dx = end.x - start.x;
			it->seg[it->num_seg].dy = end.y - start.y;
			it->seg[it->num_seg].len = (Float) sqrt(it->seg[it->num_seg].dx*it->seg[it->num_seg].dx + it->seg[it->num_seg].dy*it->seg[it->num_seg].dy);
			it->length += it->seg[it->num_seg].len;
			start = end;
			if (it->seg[it->num_seg].len) it->num_seg++;
		}
	}
	return it;
}
Пример #3
0
LPPROTO SG_NewProto(LPSCENEGRAPH inScene, u32 ProtoID, char *name, Bool unregistered)
{
	PrototypeNode *tmp;
	if (!inScene) return NULL;

	/*make sure we don't define a proto already defined in this scope*/
	if (!unregistered) {
		tmp = SG_FindProto(inScene, ProtoID, name);
		if (tmp) return NULL;
	}

	SAFEALLOC(tmp, sizeof(PrototypeNode));
	if (!tmp) return NULL;

	tmp->proto_fields = NewChain();
	tmp->node_code = NewChain();
	tmp->parent_graph = inScene;
	tmp->sub_graph = SG_NewSubScene(inScene);
	tmp->instances = NewChain();

	if (name) 
		tmp->Name = strdup(name);
	else
		tmp->Name = strdup("Unnamed Proto");
	tmp->ID = ProtoID;
	if (!unregistered) {
		ChainAddEntry(inScene->protos, tmp);
	} else {
		ChainAddEntry(inScene->unregistered_protos, tmp);
	}
	return tmp;
}
Пример #4
0
CommandFieldInfo *SG_NewFieldCommand(SGCommand *com)
{
	CommandFieldInfo *ptr;
	SAFEALLOC(ptr, sizeof(CommandFieldInfo));
	ChainAddEntry(com->command_fields, ptr);
	return ptr;
}
Пример #5
0
Atom *ftab_New()
{
	FontTableAtom *tmp;
	SAFEALLOC(tmp, sizeof(FontTableAtom));
	if (!tmp) return NULL;
	tmp->type = FontTableAtomType;
	return (Atom *) tmp;
}
Пример #6
0
Atom *tx3g_New()
{
	TextSampleEntryAtom *tmp;
	SAFEALLOC(tmp, sizeof(TextSampleEntryAtom));
	if (!tmp) return NULL;
	tmp->type = TextSampleEntryAtomType;
	return (Atom *) tmp;
}
Пример #7
0
M4Err ProtoInstance_SetISField(SFNode *protoinst, u32 protoFieldIndex, SFNode *node, u32 nodeFieldIndex)
{
	M4Err e;
	Route *r;
	FieldInfo field, nodeField;
	if (protoinst->sgprivate->tag != TAG_ProtoNode) return M4BadParam;
	
	e = Node_GetField(protoinst, protoFieldIndex, &field);
	if (e) return e;
	e = Node_GetField(node, nodeFieldIndex, &nodeField);
	if (e) return e;
	if (field.fieldType != nodeField.fieldType) {
		if ((VRML_GetSFType(field.fieldType)==FT_SFString) && (VRML_GetSFType(nodeField.fieldType) == FT_SFURL)) {
			e = M4OK;
		} else if ((VRML_GetSFType(field.fieldType)==FT_SFURL) && (VRML_GetSFType(nodeField.fieldType) == FT_SFString)) {
			e = M4OK;
		} else {
//			printf("error in IS - node field %s.%s - inType %s - outType %s\n", Node_GetName(node) , nodeField.name, VRML_GetFieldTypeName(field.fieldType), VRML_GetFieldTypeName(nodeField.fieldType));
			return M4InvalidProto;
		}
	}

	SAFEALLOC(r, sizeof(Route));
	if (!r) return M4OutOfMem;
	r->IS_route = 1;

	if (nodeField.eventType==ET_EventOut) {
		r->FromFieldIndex = nodeFieldIndex;
		r->FromNode = node;
		r->ToFieldIndex = protoFieldIndex;
		r->ToNode = protoinst;
		ChainAddEntry(node->sgprivate->outRoutes, r);
	} else {
		switch (field.eventType) {
		case ET_Field:
		case ET_ExposedField:
		case ET_EventIn:
			r->FromFieldIndex = protoFieldIndex;
			r->FromNode = protoinst;
			r->ToFieldIndex = nodeFieldIndex;
			r->ToNode = node;
			break;
		case ET_EventOut:
			r->FromFieldIndex = nodeFieldIndex;
			r->FromNode = node;
			r->ToFieldIndex = protoFieldIndex;
			r->ToNode = protoinst;
			ChainAddEntry(node->sgprivate->outRoutes, r);
			break;
		default:
			free(r);
			return M4BadParam;
		}
	}
	r->graph = node->sgprivate->scenegraph;
	ActivateRoute(r);
	return ChainAddEntry(r->graph->Routes, r);
}
Пример #8
0
SFNode *Proto_CreateNode(LPSCENEGRAPH scene, PrototypeNode *proto, ProtoInstance *from_inst)
{
	u32 i;
	ProtoField *inst, *from_field;
	ProtoFieldInterface *field;

	ProtoInstance *proto_node;
	SAFEALLOC(proto_node, sizeof(ProtoInstance));
	if (!proto_node) return NULL;

	Node_Setup((SFNode *)proto_node, TAG_ProtoNode);
	proto_node->node_code = NewChain();
	proto_node->fields = NewChain();
	proto_node->scripts_to_load = NewChain();

	proto_node->proto_interface = proto;
	ChainAddEntry(proto->instances, proto_node);

#ifdef NODE_USE_POINTERS
	proto_node->sgprivate->node_del = protoinst_del;
	proto_node->sgprivate->get_field = protoinst_get_field;
	proto_node->sgprivate->get_field_count = Proto_GetNumFields;
	proto_node->sgprivate->name = strdup(proto->Name);
#else
	proto_node->proto_name = strdup(proto->Name);
#endif


	/*create the namespace*/
	proto_node->sgprivate->scenegraph = SG_NewSubScene(scene);
	/*set this proto as owner of the new graph*/
	proto_node->sgprivate->scenegraph->pOwningProto = proto_node;

	/*instanciate fields*/
	for (i=0; i<ChainGetCount(proto->proto_fields); i++) {
		field = ChainGetEntry(proto->proto_fields, i);
		inst = malloc(sizeof(ProtoField));
		inst->EventType = field->EventType;
		inst->FieldType = field->FieldType;

		/*this is OK to call on SFNode (returns NULL) and MFNode (returns NewChain() )*/
		inst->field_pointer = VRML_NewFieldPointer(inst->FieldType);

		/*regular field, duplicate from default value or instanciated one if specified (since
		a proto may be partially instanciated when used in another proto)*/
		if (VRML_GetSFType(inst->FieldType) != FT_SFNode) {
			if (from_inst) {
				from_field = ChainGetEntry(from_inst->fields, i);
				VRML_FieldCopy(inst->field_pointer, from_field->field_pointer, inst->FieldType);
			} else {
				VRML_FieldCopy(inst->field_pointer, field->default_value, inst->FieldType);
			}
		}
		/*No default values for SFNodes as interfaces ...*/
		ChainAddEntry(proto_node->fields, inst);
	}
	return (SFNode *) proto_node;
}
Пример #9
0
void InitStringSensor(InlineScene *is, SFNode *node)
{
	StringSensorStack*st;
	SAFEALLOC(st, sizeof(StringSensorStack));
	st->term = is->root_od->term;
	Node_SetPrivate(node, st);
	Node_SetPreDestroyFunction(node, DestroyStringSensor);
	ChainAddEntry(is->root_od->term->x3d_sensors, node);
}
Пример #10
0
M4Path *m4_path_clone(M4Path *_this)
{	
	u32 i;
	M4Path *tmp;
	M4PATH();
	SAFEALLOC(tmp, sizeof(M4Path));
	if (!tmp) return tmp;

	memcpy(tmp, path, sizeof(M4Path));
	tmp->subpath = malloc(sizeof(M4SubPath*) * path->subpathmax);
	for (i=0; i<path->subpathlen; i++) {
		SAFEALLOC(tmp->subpath[i] , sizeof(M4SubPath));
		memcpy(tmp->subpath, path->subpath, sizeof(M4SubPath));
		tmp->subpath[i]->point = malloc(sizeof(M4Point2D) * tmp->subpath[i]->pointmax);
		memcpy(tmp->subpath[i]->point, path->subpath[i]->point, sizeof(M4Point2D) * tmp->subpath[i]->pointlen);
	}
	return tmp;
}
Пример #11
0
void R2D_InitPathLayout(Render2D *sr, SFNode *node)
{
	PathLayoutStack *stack;
	SAFEALLOC(stack, sizeof(PathLayoutStack));
	SetupGroupingNode2D((GroupingNode2D*)stack, sr, node);

	Node_SetPrivate(node, stack);
	Node_SetPreDestroyFunction(node, DestroyPathLayout);
	Node_SetRenderFunction(node, RenderPathLayout);
}
Пример #12
0
M4Path *m4_new_path()
{	
	M4Path *path;
	SAFEALLOC(path , sizeof(M4Path));
	if (path == NULL) return NULL;
	path->subpathmax = 8;
	SAFEALLOC(path->subpath , sizeof (M4SubPath*) * path->subpathmax);
	if (path->subpath == NULL) {
		free(path);
		return NULL;
	}
	path->min_x = FLT_MAX;
	path->min_y = FLT_MAX;
	path->max_x = -1 * FLT_MAX;
	path->max_y = -1 * FLT_MAX;
	path->fineness = 0.5;
	path->resolution = M4_DEFAULT_RESOLUTION;
	path->fill_mode = M4PathFillOddEven;
	return path;
}
Пример #13
0
SGCommand *SG_NewCommand(LPSCENEGRAPH graph, u32 tag)
{
	SGCommand *ptr;
	SAFEALLOC(ptr, sizeof(SGCommand));
	if (!ptr) return NULL;
	ptr->tag = tag;
	ptr->in_scene = graph;
	ptr->new_proto_list = NewChain();
	ptr->command_fields = NewChain();
	return ptr;
}
Пример #14
0
GF_FontReader *gdip_new_font_driver()
{
	GdiplusStartupInput startupInput;
	GF_FontReader *dr;
	FontPriv *ctx;

	SAFEALLOC(ctx, FontPriv);
	SAFEALLOC(dr, GF_FontReader);
	GdiplusStartup(&ctx->gdiToken, &startupInput, NULL);

	GF_REGISTER_MODULE_INTERFACE(dr, GF_FONT_READER_INTERFACE, "GDIplus Font Reader", "gpac distribution")
	dr->init_font_engine = gdip_init_font_engine;
	dr->shutdown_font_engine = gdip_shutdown_font_engine;
	dr->set_font = gdip_set_font;
	dr->get_font_info = gdip_get_font_info;
	dr->get_glyphs = gdip_get_glyphs;
	dr->load_glyph = gdip_load_glyph;

	dr->udta = ctx;
	return dr;
}
Пример #15
0
BaseDecoder *NewBIFSDec()
{
	BIFSPriv *priv;
	SceneDecoder *tmp;
	
	SAFEALLOC(tmp, sizeof(SceneDecoder));
	if (!tmp) return NULL;
	SAFEALLOC(priv, sizeof(BIFSPriv));
	priv->codec = NULL;
	tmp->privateStack = priv;
	tmp->AttachStream = BIFS_AttachStream;
	tmp->DetachStream = BIFS_DetachStream;
	tmp->GetCapabilities = BIFS_GetCapabilities;
	tmp->SetCapabilities = BIFS_SetCapabilities;
	tmp->ProcessData = BIFS_ProcessData;
	tmp->AttachScene = BIFS_AttachScene;
	tmp->CanHandleStream = BIFS_CanHandleStream;
	tmp->ReleaseScene = BIFS_ReleaseScene;
	M4_REG_PLUG(tmp, M4SCENEDECODERINTERFACE, "GPAC BIFS Decoder", "gpac distribution", 0)
	return (BaseDecoder *) tmp;
}
Пример #16
0
M4Err ftab_Read(Atom *s, BitStream *bs, u64 *read)
{
	u32 i;
	FontTableAtom *ptr = (FontTableAtom *)s;
	ptr->entry_count = BS_ReadInt(bs, 16);
	*read += 2;
	SAFEALLOC(ptr->fonts, sizeof(FontRecord)*ptr->entry_count);
	for (i=0; i<ptr->entry_count; i++) {
		u32 len;
		ptr->fonts[i].fontID = BS_ReadInt(bs, 16);
		len = BS_ReadInt(bs, 8);
		*read += 3;
		if (len) {
			SAFEALLOC(ptr->fonts[i].fontName, sizeof(char)*(len+1));
			BS_ReadData(bs, ptr->fonts[i].fontName, len);
			*read += len;
		}
	}
	if (*read != ptr->size) return M4ReadAtomFailed;
	return M4OK;
}
Пример #17
0
static void LASeR_InitGenericAnimate(Render2D *sr, SFNode *node, void (*UpdateTimeNode)(TimeNode *))
{
	LASeR_AnimateStack *animate_stack;
	SAFEALLOC(animate_stack, sizeof(LASeR_AnimateStack))
	animate_stack->time_handle.UpdateTimeNode = UpdateTimeNode;
	animate_stack->time_handle.obj = node;
	animate_stack->num_cycles = 0;
	animate_stack->compositor = sr->compositor;

	Node_SetPrivate(node, animate_stack);
	Node_SetPreDestroyFunction(node, LASeR_DestroyGenericAnimate);	
	SR_RegisterTimeNode(animate_stack->compositor, &animate_stack->time_handle);
}
Пример #18
0
GenericCodec *Codec_UseDecoder(GenericCodec *codec, ODManager *odm)
{
	GenericCodec *tmp;
	if (!codec->decio) return NULL;
	SAFEALLOC(tmp, sizeof(GenericCodec));
	tmp->type = codec->type;
	tmp->inChannels = NewChain();	
	tmp->Status = CODEC_STOP;
	tmp->odm = odm;
	tmp->flags = codec->flags | COD_IS_USE;
	tmp->decio = codec->decio;
	return tmp;
}
Пример #19
0
LPLASERDEC LASeR_NewDecoder(LPSCENEGRAPH scenegraph)
{
	LASeRDecoder * tmp;
	SAFEALLOC(tmp, sizeof(LASeRDecoder));

	tmp->scenegraph = scenegraph;
	if (!scenegraph) {
		tmp->dec_memory_mode = 1;
		tmp->conditionals = NewChain();
	}
	tmp->current_graph = NULL;
	tmp->mx = NewMutex();
	return tmp;
}
Пример #20
0
M4SubPath *new_subpath2D()
{
	M4SubPath *subpath;

	SAFEALLOC(subpath, sizeof (M4SubPath));
	if (subpath == NULL) return NULL;
	subpath->pointmax = 16;
	subpath->point = malloc(sizeof (M4Point2D) * subpath->pointmax);
	if (subpath->point == NULL) {
		free(subpath);
		return NULL;
	}
	return subpath;
}
Пример #21
0
Drawable *NewDrawableNode()
{
	Drawable *tmp;
	SAFEALLOC(tmp, sizeof(Drawable))
	tmp->on_surfaces = NewChain();
	tmp->path = m4_new_path();
	/*init with default*/
	tmp->Draw = drawable_draw;
	tmp->IsPointOver = drawable_point_over;
	tmp->strike_list = NewChain();

	/*alloc bounds storage*/
	check_bounds_size(tmp);	
	return tmp;
}
Пример #22
0
GF_Raster2D *gdip_LoadRenderer()
{
	GdiplusStartupInput startupInput;
	GF_Raster2D *driver;
	struct _gdip_context *ctx;
	SAFEALLOC(ctx, struct _gdip_context);
	SAFEALLOC(driver, GF_Raster2D);
	GdiplusStartup(&ctx->gdiToken, &startupInput, NULL);
	driver->internal = ctx;
	GF_REGISTER_MODULE_INTERFACE(driver, GF_RASTER_2D_INTERFACE, "GDIplus 2D Raster", "gpac distribution")
	gdip_init_driver_texture(driver);
	gdip_init_driver_surface(driver);
	gdip_init_driver_grad(driver);
	return driver;
}
Пример #23
0
BaseDecoder *NewDIVXDec()
{
	MediaDecoder *ifcd;
	DIVXDec *dec;
	
	SAFEALLOC(ifcd, sizeof(MediaDecoder));
	SAFEALLOC(dec, sizeof(DIVXDec));
	M4_REG_PLUG(ifcd, M4MEDIADECODERINTERFACE, "DIVX Decoder", "gpac distribution", 0)

	ifcd->privateStack = dec;

	/*get config*/
	dec->base_filters = 0;

	/*setup our own interface*/	
	ifcd->AttachStream = DIVX_AttachStream;
	ifcd->DetachStream = DIVX_DetachStream;
	ifcd->GetCapabilities = DIVX_GetCapabilities;
	ifcd->SetCapabilities = DIVX_SetCapabilities;
	ifcd->GetName = DIVX_GetCodecName;
	ifcd->CanHandleStream = DIVX_CanHandleStream;
	ifcd->ProcessData = DIVX_ProcessData;
	return (BaseDecoder *) ifcd;
}
Пример #24
0
M4Err avcc_Read(Atom *s, BitStream *bs, u64 *read)
{
	u32 size;
	char *data;
	u32 i, count;
	AVCConfigurationAtom *ptr = (AVCConfigurationAtom *)s;

	if (ptr->config) DeleteAVCConfig(ptr->config);
	SAFEALLOC(ptr->config, sizeof(AVCDecoderConfigurationRecord));
	ptr->config->configurationVersion = BS_ReadInt(bs, 8);
	ptr->config->AVCProfileIndication = BS_ReadInt(bs, 8);
	ptr->config->profile_compatibility = BS_ReadInt(bs, 8);
	ptr->config->AVCLevelIndication = BS_ReadInt(bs, 8);
	BS_ReadInt(bs, 6);
	ptr->config->nal_unit_size = 1 + BS_ReadInt(bs, 2);
	BS_ReadInt(bs, 3);
	count = ptr->config->numSequenceParameterSets = BS_ReadInt(bs, 5);
	*read += 6;

	ptr->config->sequenceParameterSets = malloc(sizeof(AVCConfigSlot)*count);
	for (i=0; i<count; i++) {
		size = BS_ReadInt(bs, 16);
		data = malloc(sizeof(char) * size);
		BS_ReadData(bs, data, size);
		ptr->config->sequenceParameterSets[i].size = size;
		ptr->config->sequenceParameterSets[i].data = data;
		*read += 2+size;
	}

	count = ptr->config->numPictureParameterSets = BS_ReadInt(bs, 8);
	*read += 1;
	ptr->config->pictureParameterSets = malloc(sizeof(AVCConfigSlot)*count);
	for (i=0; i<count; i++) {
		size = BS_ReadInt(bs, 16);
		data = malloc(sizeof(char) * size);
		BS_ReadData(bs, data, size);
		ptr->config->pictureParameterSets[i].size = size;
		ptr->config->pictureParameterSets[i].data = data;
		*read += 2+size;
	}
	/*"Readers should be prepared to ignore unrecognised data beyond the definition of the data they understand"*/
	if (*read < ptr->size) {
		BS_ReadInt(bs, (u32) (8*(ptr->size - *read)) );
		*read = ptr->size;
	}
	return (*read != ptr->size) ? M4ReadAtomFailed : M4OK;
}
Пример #25
0
LPPROTOFIELD Proto_NewField(LPPROTO proto, u32 fieldType, u32 eventType, char *fieldName)
{
	ProtoFieldInterface *tmp;

	if (fieldName) {
		tmp = Proto_FindFieldByName(proto, fieldName);
		if (tmp) return NULL;
	}
	SAFEALLOC(tmp, sizeof(ProtoFieldInterface));
	if (!tmp) return NULL;

	tmp->FieldType = fieldType;
	tmp->EventType = eventType;
	
	/*create container - can be NULL if SF node*/
	tmp->default_value = VRML_NewFieldPointer(fieldType);
	
	if (fieldName) tmp->FieldName = strdup(fieldName);
	
	tmp->ALL_index = ChainGetCount(proto->proto_fields);
	tmp->OUT_index = tmp->DEF_index = tmp->IN_index = -1;

	switch (eventType) {
	case ET_ExposedField:
		tmp->IN_index = proto->NumIn;
		proto->NumIn ++;
		tmp->OUT_index = proto->NumOut;
		proto->NumOut ++;
	case ET_Field:
		tmp->DEF_index = proto->NumDef;
		proto->NumDef ++;
		break;
	case ET_EventIn:
		tmp->IN_index = proto->NumIn;
		proto->NumIn ++;
		break;
	case ET_EventOut:
		tmp->OUT_index = proto->NumOut;
		proto->NumOut ++;
		break;
	}

	ChainAddEntry(proto->proto_fields, tmp);
	return tmp;
}