コード例 #1
0
ファイル: overlay_hires.c プロジェクト: Erikhht/TCPMP
static bool_t ProcessRawInfo(video* Video,char* Bits,char* RawBits,int Width,int Height,int Pitch,int* Offset,bool_t MovedSIP)
{
	int Dir = GetOrientation();

	Video->Pitch = Pitch;

	if (Width > Height) // native landscape device
		Dir = CombineDir(Dir,DIR_SWAPXY|DIR_MIRRORUPDOWN,0);

	// trust GetBits() if it's inside the Raw buffer
	if (Bits >= RawBits && Bits < RawBits + Height*Pitch) 
		return 0; 	

	if (!MovedSIP && Dir==0) // assuming working GetBits() with RotM in native mode
		return 0; 

	if (Dir & DIR_SWAPXY)
		SwapInt(&Video->Width,&Video->Height);

	if (Width > Height) // native landscape device
	{
		if ((Dir & DIR_SWAPXY)==0 ? GetHandedness() : (Dir & DIR_MIRRORLEFTRIGHT)!=0)
			*Offset = (Width-Video->Width)*(Video->Pixel.BitCount >> 3);
	}
	else 
	{
		// native portrait device
		if ((Dir & DIR_SWAPXY) && MovedSIP) // don't adjust for RotM (SIP stays on native bottom)
コード例 #2
0
ファイル: idct.c プロジェクト: 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;
}
コード例 #3
0
ファイル: idct.c プロジェクト: 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;
}
コード例 #4
0
ファイル: ge2d.c プロジェクト: BigHNF/tcpmp-revive
static int Update(ge2d* p)
{
	blitfx OvlFX = p->p.FX;
	video Buffer;

	if (p->p.Overlay)
		PALMCALL0(API.GE2DHideOverlay);

	p->SoftFX = p->p.FX;
	p->SoftFX.ScaleX = SCALE_ONE; // scale handled by hardware
	p->SoftFX.ScaleY = SCALE_ONE;
	OvlFX.Direction = 0;

	//align to 100%
	if (OvlFX.ScaleX > SCALE_ONE-(SCALE_ONE/16) && OvlFX.ScaleX < SCALE_ONE+(SCALE_ONE/16) &&
		OvlFX.ScaleY > SCALE_ONE-(SCALE_ONE/16) && OvlFX.ScaleY < SCALE_ONE+(SCALE_ONE/16))
	{
		OvlFX.ScaleX = SCALE_ONE;
		OvlFX.ScaleY = SCALE_ONE;
	}

	if (p->SoftFX.Direction & DIR_SWAPXY)
		SwapInt(&OvlFX.ScaleX,&OvlFX.ScaleY);

	memset(&Buffer,0,sizeof(Buffer));
	Buffer.Pixel.Flags = PF_YUV420;
	Buffer.Width = p->p.Input.Format.Video.Width;
	Buffer.Height = p->p.Input.Format.Video.Height;
	Buffer.Direction = CombineDir(p->p.InputDirection,p->p.OrigFX.Direction,p->p.Output.Format.Video.Direction);
	if (Buffer.Direction & DIR_SWAPXY)
		SwapInt(&Buffer.Width,&Buffer.Height);
	Buffer.Pitch = Buffer.Width;

	for (;;)
	{
		VirtToPhy(&p->p.Viewport,&p->p.DstAlignedRect,&p->p.Output.Format.Video);
		VirtToPhy(NULL,&p->OverlayRect,&Buffer);

		AnyAlign(&p->p.DstAlignedRect, &p->OverlayRect, &OvlFX, 2, 1, SCALE_ONE/256, SCALE_ONE*256);

		if ((OvlFX.ScaleX != SCALE_ONE || OvlFX.ScaleY != SCALE_ONE) && 
			(p->p.DstAlignedRect.Width != p->OverlayRect.Width && p->p.DstAlignedRect.Height != p->OverlayRect.Height))
		{
			if (!AllocBuffer(&p->Scale,p->p.DstAlignedRect.Width,p->p.DstAlignedRect.Height,&p->ScaleSize))
			{
				// fallback to 100%
				OvlFX.ScaleX = SCALE_ONE;
				OvlFX.ScaleY = SCALE_ONE;
				continue;
			}
		}
		else
			FreeBuffer(&p->Scale,&p->ScaleSize);
		break;
	}

	VirtToPhy(NULL,&p->p.SrcAlignedRect,&p->p.Input.Format.Video);

	BlitRelease(p->p.Soft);
	p->p.Soft = BlitCreate(&Buffer,&p->p.Input.Format.Video,&p->SoftFX,&p->p.Caps);
	BlitAlign(p->p.Soft,&p->OverlayRect,&p->p.SrcAlignedRect);

	if (!AllocBuffer(&p->Buffer,p->OverlayRect.Width,p->OverlayRect.Height,&p->BufferSize))
		return ERR_OUT_OF_MEMORY;

	Buffer.Width = p->OverlayRect.Width;
	Buffer.Height = p->OverlayRect.Height;
	Buffer.Pitch = Buffer.Width;
	p->OverlayRect.x = 0;
	p->OverlayRect.y = 0;

	BlitRelease(p->p.Soft);
	p->p.Soft = BlitCreate(&Buffer,&p->p.Input.Format.Video,&p->SoftFX,&p->p.Caps);
	BlitAlign(p->p.Soft,&p->OverlayRect,&p->p.SrcAlignedRect);

	if (!p->Scale.format) // no scaling -> adjust dst rectangle with soft yuv blitting alignement
	{
		p->p.DstAlignedRect.x += (p->p.DstAlignedRect.Width - p->OverlayRect.Width) >> 1;
		p->p.DstAlignedRect.y += (p->p.DstAlignedRect.Height - p->OverlayRect.Height) >> 1;
		p->p.DstAlignedRect.Width = p->OverlayRect.Width;
		p->p.DstAlignedRect.Height = p->OverlayRect.Height;
	}