Esempio n. 1
0
File: idct.c Progetto: Jsoucek/q3ce
int IDCTBackup(idct* p,idctbackup* Backup)
{
	int No;
	planes Planes;
	video Format;

	memset(Backup,0,sizeof(idctbackup));

	if (p->Get(p,IDCT_FORMAT,&Backup->Format,sizeof(video))!=ERR_NONE || !Backup->Format.Pixel.Flags ||
		p->Get(p,IDCT_BUFFERWIDTH,&Backup->Width,sizeof(int))!=ERR_NONE ||
		p->Get(p,IDCT_BUFFERHEIGHT,&Backup->Height,sizeof(int))!=ERR_NONE ||
		p->Get(p,IDCT_BUFFERCOUNT,&Backup->Count,sizeof(int))!=ERR_NONE ||
		p->Get(p,IDCT_SHOW,&Backup->Show,sizeof(int))!=ERR_NONE)
		return ERR_INVALID_DATA;

	for (No=0;No<Backup->Count;++No)
	{
		idctbufferbackup* Buffer = Backup->Buffer+No;

		Buffer->FrameNo = -1;
		p->Get(p,IDCT_FRAMENO+No,&Buffer->FrameNo,sizeof(int));

		if (p->Lock(p,No,Planes,&Buffer->Brightness,&Format) == ERR_NONE)
		{
			Buffer->Format = Format;
			DefaultPitch(&Buffer->Format);
			if (SurfaceAlloc(Buffer->Buffer,&Buffer->Format) == ERR_NONE)
				SurfaceCopy(&Format,&Buffer->Format,Planes,Buffer->Buffer,NULL);
			p->Unlock(p,No);
		}
	}

	p->Set(p,IDCT_FORMAT,NULL,0);
	return ERR_NONE;
}
Esempio n. 2
0
static Err GE2DBlitBitmap(void *dstP, Coord left, Coord top,
		UInt16 dstWidth, UInt16 dstHeight, GE2DBitmapType* p)
{
	video Src;
	video Dst;
	planes SrcPlanes;
	planes DstPlanes;

	memset(&Src,0,sizeof(Src));
	Src.Pixel.Flags = PF_YUV420;
	Src.Width = p->width;
	Src.Height = p->height;
	Src.Pitch = p->pitch;
	SrcPlanes[0] = p->plane1P;
	SrcPlanes[1] = p->plane3P;
	SrcPlanes[2] = p->plane2P;

	memset(&Dst,0,sizeof(Dst));
	DefaultRGB(&Dst.Pixel,16,5,6,5,0,0,0);
	Dst.Width = p->width;
	Dst.Height = p->height;
	Dst.Pitch = dstWidth*2;
	DstPlanes[0] = (char*)dstP + top * Dst.Pitch + left * 2;

	SurfaceCopy(&Src,&Dst,SrcPlanes,DstPlanes,NULL);
	return 0;
}
Esempio n. 3
0
File: idct.c Progetto: Jsoucek/q3ce
int IDCTRestore(idct* p,idctbackup* Backup)
{
	int No;
	if (p && Backup->Format.Pixel.Flags)
	{
		int Brightness;
		planes Planes;
		video Format;
		blitfx FX;

		memset(&FX,0,sizeof(FX));
		FX.ScaleX = SCALE_ONE;
		FX.ScaleY = SCALE_ONE;

		p->Set(p,IDCT_BUFFERWIDTH,&Backup->Width,sizeof(int));
		p->Set(p,IDCT_BUFFERHEIGHT,&Backup->Height,sizeof(int));
		p->Set(p,IDCT_FORMAT,&Backup->Format,sizeof(video));
		p->Set(p,IDCT_BUFFERCOUNT,&Backup->Count,sizeof(int));

		for (No=0;No<Backup->Count;++No)
		{
			idctbufferbackup* Buffer = Backup->Buffer+No;

			p->Set(p,IDCT_FRAMENO+No,&Buffer->FrameNo,sizeof(int));

			if (Buffer->Buffer[0] && p->Lock(p,No,Planes,&Brightness,&Format) == ERR_NONE)
			{
				FX.Direction = CombineDir(Buffer->Format.Direction, 0, Format.Direction);
				FX.Brightness = Brightness - Buffer->Brightness;
					
				SurfaceCopy(&Buffer->Format,&Format,Buffer->Buffer,Planes,&FX);

				p->Unlock(p,No);
			}
		}

		p->Set(p,IDCT_SHOW,&Backup->Show,sizeof(int));
	}

	for (No=0;No<Backup->Count;++No)
		SurfaceFree(Backup->Buffer[No].Buffer);

	memset(Backup,0,sizeof(idctbackup));
	return ERR_NONE;
}
Esempio n. 4
0
File: idct.c Progetto: Jsoucek/q3ce
static int SetIDCT(codecidct* p, idct* Dst)
{
	int Count;
	blitfx FX;
	planes SrcPlanes,DstPlanes;
	int SrcBrightness,DstBrightness;
	int No;
	int Result;
	idct* Src = p->IDCT.Ptr;

	if (Src == Dst)
		return ERR_NONE;

	if (!Src)
	{
		p->IDCT.Ptr = Dst;
		Result= Prepair(p);
		if (Result != ERR_NONE)
			p->IDCT.Ptr = NULL;
		return Result;
	}

	if (Dst)
	{
		assert(NodeIsClass(Dst->Class,IDCT_CLASS));

		Result = Dst->Set(Dst,IDCT_BUFFERWIDTH,&p->IDCT.Width,sizeof(int));
		if (Result != ERR_NONE)	return Result;
		Result = Dst->Set(Dst,IDCT_BUFFERHEIGHT,&p->IDCT.Height,sizeof(int));
		if (Result != ERR_NONE)	return Result;
		Result = Dst->Set(Dst,IDCT_FORMAT,&p->IDCT.Format,sizeof(video));
		if (Result != ERR_NONE)	return Result;
		Result = Dst->Set(Dst,IDCT_BUFFERCOUNT,&p->MinCount,sizeof(int));
		if (Result != ERR_NONE)	return Result;

		if (Src->Get(Src,IDCT_BUFFERCOUNT,&Count,sizeof(Count))==ERR_NONE && Count>p->MinCount)
			Dst->Set(Dst,IDCT_BUFFERCOUNT,&Count,sizeof(Count)); // optional

		memset(&FX,0,sizeof(FX));
		FX.ScaleX = SCALE_ONE;
		FX.ScaleY = SCALE_ONE;

		for (No=0;No<Count;++No)
		{
			video SrcFormat,DstFormat;
			int FrameNo = -1;
			Src->Get(Src,IDCT_FRAMENO+No,&FrameNo,sizeof(FrameNo));
			Dst->Set(Dst,IDCT_FRAMENO+No,&FrameNo,sizeof(FrameNo));

			if (Src->Lock(Src,No,SrcPlanes,&SrcBrightness,&SrcFormat) == ERR_NONE)
			{
				if (Dst->Lock(Dst,No,DstPlanes,&DstBrightness,&DstFormat) == ERR_NONE)
				{
					FX.Direction = CombineDir(SrcFormat.Direction, 0, DstFormat.Direction);
					FX.Brightness = DstBrightness - SrcBrightness;
					
					SurfaceCopy(&SrcFormat,&DstFormat,SrcPlanes,DstPlanes,&FX);

					Dst->Unlock(Dst,No);
				}
				Src->Unlock(Src,No);
			}
		}

		if (Src->Get(Src,IDCT_SHOW,&No,sizeof(No))==ERR_NONE)
			Dst->Set(Dst,IDCT_SHOW,&No,sizeof(No));
	}

	Src->Set(Src,IDCT_FORMAT,NULL,0);
	p->IDCT.Ptr = Dst;
	UpdateCount(p); // can't and shouldn't fail here (src already cleared and dst pointer saved)
	return ERR_NONE;
}