Пример #1
0
TFB_VideoDecoder*
VideoDecoder_Load (uio_DirHandle *dir, const char *filename)
{
	const char* pext;
	TFB_RegVideoDecoder* info;
	TFB_VideoDecoder* decoder;
	

	if (!vd_inited)
		return NULL;

	pext = strrchr (filename, '.');
	if (!pext)
	{
		log_add (log_Warning, "VideoDecoder_Load: Unknown file type");
		return NULL;
	}
	++pext;

	for (info = vd_decoders; info->used &&
			(!info->ext || strcmp (info->ext, pext) != 0);
			++info)
		;
	if (!info->ext)
	{
		log_add (log_Warning, "VideoDecoder_Load: Unsupported file type");
		return NULL;
	}

	decoder = (TFB_VideoDecoder*) HCalloc (info->funcs->GetStructSize ());
	decoder->funcs = info->funcs;
	if (!decoder->funcs->Init (decoder, &vd_vidfmt))
	{
		log_add (log_Warning, "VideoDecoder_Load: "
				"Cannot init '%s' decoder, code %d",
				decoder->funcs->GetName (),
				decoder->funcs->GetError (decoder));
		HFree (decoder);
		return NULL;
	}

	decoder->dir = dir;
	decoder->filename = (char *) HMalloc (strlen (filename) + 1);
	strcpy (decoder->filename, filename);
	decoder->error = VIDEODECODER_OK;

	if (!decoder->funcs->Open (decoder, dir, filename))
	{
		log_add (log_Warning, "VideoDecoder_Load: "
				"'%s' decoder did not load %s, code %d",
				decoder->funcs->GetName (),	filename,
				decoder->funcs->GetError (decoder));
		
		VideoDecoder_Free (decoder);
		return NULL;
	}

	return decoder;
}
Пример #2
0
BOOLEAN
DestroyVideo (VIDEO_REF VideoRef)
{
	TFB_VideoClip* vid = (TFB_VideoClip*) VideoRef;

	if (!vid)
		return FALSE;

	VideoDecoder_Free (vid->decoder);
	DestroyMutex (vid->guard);
	HFree (vid);
	
	return TRUE;
}