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

📄 pocketmvp.cpp

📁 PocketMVP V0.8082503 source for Pocket 的程序源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
static int __inline Decode(unsigned char *stream, int length, unsigned char *bmp, int render_flag, int Extra, int refresh)
#else
static int __inline Decode(unsigned char *stream, int length, unsigned char *bmp, int render_flag, int Extra)
#endif
{
	AVPicture avpict;
	EnterCriticalSection(&cs);
#ifdef _USEVIDBUFF
	SetKMode(true);
#endif
	int d=DecodeFrame(stream,length,(unsigned char*) &avpict,render_flag);
	if (!d&&(render_flag))
	{
		nDrop++;
		render_flag=0;
	}

	if (render_flag) 
	{
/*		int FrameDiff;
		while((FrameDiff=nShouldbe-nCurrentFrame)<-1&&(nShouldbe>=0)&&(!bPaused)&&(!bEnd))
		{
			if (PlayerOptions.Audio&&(vidinfo->audio_bytes))
			{
				WaitForSingleObject(eventNextFrame,500);
				ResetEvent(eventNextFrame);
			}
			else
			{
				Sleep(0);
			}
		}
*/
#ifdef ARM
#ifndef IPAQ
			if (Extra==-1) Extra=0;
#endif
			convert_yuv(avpict.data[0], avpict.linesize[0],
				avpict.data[1], avpict.data[2], avpict.linesize[1],
				(unsigned char*) bmp, g_nWidth,g_nHeight,Extra,PlayerOptions.Clean*(twelve_bit+1),PlayerOptions.Brightness,avpict.last_picture[0],avpict.last_picture[1],avpict.last_picture[2],lastshow&&(!refresh)&&(avpict.last_picture[0]!=avpict.data[0]), g_bInvert);
#else

		convert_yuv(avpict.data[0], avpict.linesize[0],
			avpict.data[1], avpict.data[2], avpict.linesize[1],
			bmp, g_nWidth,g_nHeight,Extra,PlayerOptions.Clean);
#endif
	}


#ifdef ARM
	lastshow=render_flag;
#endif


#ifdef _USEVIDBUFF
	SetKMode(false);
#endif
	LeaveCriticalSection(&cs);
	return render_flag;
}
#endif

long decEnd()
{
	DecodeMessage((long) NULL, DEC_OPT_RELEASE, NULL, NULL);

	return 0;
}

static void DropFrames()
{	
	int size;
	int refresh;
	unsigned char* rb=GetNextBuffer(&refresh,&size,1);
	if (rb<=0)
	{
		if (!rb) nDrop++	;
		nCurrentFrame--;
		return;
	}
#ifdef ARM
	Decode(rb,size,0,0,0,1);
#else
	Decode(rb,size,0,0,0);
#endif
	nDrop++;
	if (DropTwo)
	{
		rb=GetNextBuffer(&refresh,&size,1);
		if (!rb) return;
#ifdef ARM
		Decode(rb,size,0,0,0,1);
#else
		Decode(rb,size,0,0,0);
#endif
		nDrop++;
	}
	else
	{
		nCurrentFrame--;
	}

}



/*****************************************************************************************/
//Screen Functions
/*****************************************************************************************/

void  RefreshDisplay(bool Full)
{
	RECT rc;
	if (Full)
	{
		GetClientRect(hWndMain,&rc);
		InvalidateRect(hWndMain,&rc,true);
		UpdateWindow(hWndMain);
	}
	else
		SendMessage(hWndMain,WM_PAINT,(WPARAM)NULL,(LPARAM)1);

}

void ShowControls(bool bShow)
{
	EnableWindow(hwndCB,bShow);
	if (bShow)
	{
		ShowWindow(hwndCB,SW_SHOWNORMAL);
		HWND hWndTB=FindWindow(TEXT("HHTaskbar"),NULL);
		ShowWindow(hWndTB,SW_SHOWNORMAL);
#if (_WIN32_WCE >= 300 && !defined(HPC))
		RECT rc;
		GetWindowRect(hWndMain,&rc);
		rc.top=26;
		rc.bottom=294;
		SHFullScreen(hWndMain,2);
		MoveWindow(hWndMain, 
		  rc.left, 
		  rc.top, 
		  rc.right, 
		  rc.bottom, 
		  false);
#endif
//#if (defined(MIPS)&&(defined(GAPI)))
//		if (1)
//#else
		if (NeedHide)
//#endif
			RefreshDisplay(true);
	}
	else
	{
		HWND hWndTB=FindWindow(TEXT("HHTaskbar"),NULL);
		ShowWindow(hWndTB,SW_HIDE);
#if (_WIN32_WCE >= 300 && !defined(HPC))
		RECT rc;
		GetWindowRect(hWndMain,&rc);
		rc.top=0;
		rc.bottom=320;
		SHFullScreen(hWndMain,1);
		MoveWindow(hWndMain,
		  rc.left, 
		  rc.top, 
		  rc.right, 
		  rc.bottom, 
		  false);
#else
#if (defined(MIPS)&&(defined(GAPI)))
		GXCloseDisplay();
		GXOpenDisplay(hWnd, GX_FULLSCREEN);
#endif
		RefreshDisplay(true);
#endif
		ShowWindow(hwndCB,SW_HIDE);

	}
}

#ifdef ATI

void SetupATIOverlay(int nWidth, int nHeight)
{
//	if (VH1) AtiCore_DestroySurface(VH1);
//	if (VH2) AtiCore_DestroySurface(VH2);
//	if (!PlayerOptions.Double)
//	{
		ATI_EXTENDEDOVERLAYPROP prop;
		OvlWinProp.SrcPitch =  nWidth<DisplayWidth?nWidth:DisplayWidth; 

		if (PlayerOptions.Rotate)
		{
		//	if (OvlWinProp.SrcPitch%16) OvlWinProp.SrcPitch+=16-(OvlWinProp.SrcPitch%16);
			if (OvlWinProp.SrcPitch%16) OvlWinProp.SrcPitch-=(OvlWinProp.SrcPitch%16);
			prop.x.ExtVideoProp.HInvert=1;
			prop.x.ExtVideoProp.VInvert=1;
			prop.HExpansion=1;
			prop.VExpansion=1;
			prop.RConversion=0;
			OvlWinProp.SrcHeight = 320;
		}
		else
		{
			if (OvlWinProp.SrcPitch%16) OvlWinProp.SrcPitch+=16-(OvlWinProp.SrcPitch%16);
			prop.x.ExtVideoProp.HInvert=0;
			prop.x.ExtVideoProp.VInvert=0;
			prop.HExpansion=1;
			prop.VExpansion=1;
			prop.RConversion=0;
			OvlWinProp.SrcHeight = nHeight;
		}
		OvlWinProp.XCoord = 0;
		OvlWinProp.YCoord = 0;

		OvlWinProp.lpOverlayKey = 0;
		OvlWinProp.OverlayFormat = OVLTYPE_YUV420;

		ForceFit=false;

		if (!PlayerOptions.Double)
		{
			int fitHeight=g_nHeight;
			int fitWidth=g_nWidth;
			if (PlayerOptions.Rotate)
			{
				fitHeight=g_nWidth;
				fitWidth=g_nHeight;
			}
			if (!PlayerOptions.FitToViewPort||(fitHeight<=PlayerSkin.ViewPort.height&&(fitWidth<=PlayerSkin.ViewPort.width)))
			{
				if (PlayerOptions.Rotate) OvlWinProp.OverlayWidth = OvlWinProp.SrcPitch; 
				else  OvlWinProp.OverlayWidth=nWidth<DisplayWidth?nWidth:DisplayWidth; 
			//	OvlWinProp.OverlayWidth = nWidth<DisplayWidth?nWidth:DisplayWidth; 
				OvlWinProp.OverlayHeight = nHeight;
				OvlWinProp.lpSrcBitmap = (U32*)VRAMoffset2;
			}
			else
			{
				U32 pitch;
				U32 offset;
				OvlWinProp.SrcPitch = PlayerSkin.ViewPort.width; 
				OvlWinProp.SrcHeight = PlayerSkin.ViewPort.height;
				if (OvlWinProp.SrcHeight%16) OvlWinProp.SrcHeight-=(OvlWinProp.SrcHeight%16);
				OvlWinProp.OverlayWidth = OvlWinProp.SrcPitch; 
				OvlWinProp.OverlayHeight = OvlWinProp.SrcHeight;
				OvlWinProp.lpSrcBitmap = (U32*)VRAMoffset2; //offset;
				ForceFit=true;
			}
		}
		else
		{
			int fitHeight=g_nHeight;
			int fitWidth=g_nWidth;
			if (PlayerOptions.Rotate)
			{
				fitHeight=g_nWidth;
				fitWidth=g_nHeight;
			}
			if (fitHeight>DisplayHeight||(fitWidth>DisplayWidth))
			{
				U32 pitch;
				U32 offset;
				OvlWinProp.SrcPitch = DisplayWidth; 
				OvlWinProp.SrcHeight = DisplayHeight;
				OvlWinProp.OverlayWidth = OvlWinProp.SrcPitch; 
				OvlWinProp.OverlayHeight = OvlWinProp.SrcHeight;
				OvlWinProp.lpSrcBitmap = (U32*)VRAMoffset2; //offset;
				ForceFit=true;
			}

			else
			{
				U32 pitch;
				U32 offset;
				OvlWinProp.SrcPitch = DisplayWidth; 
				OvlWinProp.SrcHeight =DisplayHeight;
				//if (OvlWinProp.SrcHeight%16) OvlWinProp.SrcHeight-=(OvlWinProp.SrcHeight%16);
				if (OvlWinProp.SrcHeight%16) OvlWinProp.SrcHeight+=16-(OvlWinProp.SrcHeight%16);
				OvlWinProp.OverlayWidth = OvlWinProp.SrcPitch; 
				OvlWinProp.OverlayHeight = OvlWinProp.SrcHeight;
				AtiCore_GetFrontBufferPitchOffset( &pitch, &offset );
				OvlWinProp.lpSrcBitmap = (U32*)offset;
			}
		}
		if ( AtiCore_SetupOverlay( OverlayHandle, &OvlWinProp ) != SUCCESS )
		{
			MessageBox(hWndMain,_T("Failed overlay"),_T(""),MB_OK);
		}
		AtiCore_SetupOverlayExtended(OverlayHandle,&prop);
		if (!PlayerOptions.Double)
		{
			if (!ForceFit)
				AtiCore_SetOverlayPos(OverlayHandle,sX,sY); 
			else
				AtiCore_SetOverlayPos(OverlayHandle,PlayerSkin.ViewPort.left+(PlayerSkin.ViewPort.width-OvlWinProp.SrcPitch)/2,PlayerSkin.ViewPort.top+26+(PlayerSkin.ViewPort.height-OvlWinProp.SrcHeight)/2); 
		}
		else
		{
			AtiCore_SetOverlayPos(OverlayHandle,0,0); 
		}

	//	int nWidth;
	//	int nHeight;
		stretchOptions.Count = 1;
		stretchOptions.BlendOn = PlayerOptions.Clean;
		if (ForceFit) stretchOptions.BlendOn=0;
		nWidth=PlayerOptions.Rotate?g_nHeight:g_nWidth;
		nHeight=PlayerOptions.Rotate?g_nWidth:g_nHeight;
		if (PlayerOptions.Rotate&&(nWidth%16)) nWidth-=nWidth%16;
		if (!ForceFit)
		{
			stretchOptions.ScaleXFactor = 16 * (nWidth<DisplayWidth?nWidth:DisplayWidth) / DisplayWidth;
			stretchOptions.ScaleYFactor = 16 * (nHeight<DisplayHeight?nHeight:DisplayHeight) / DisplayHeight;
		}
		else
		{
			stretchOptions.ScaleXFactor = 16 * (nWidth) / OvlWinProp.SrcPitch +1;
			stretchOptions.ScaleYFactor = 16 * (nHeight) / OvlWinProp.SrcHeight +1;
		}
		if (stretchOptions.ScaleXFactor==16) stretchOptions.ScaleXFactor = stretchOptions.ScaleYFactor;
		else if (stretchOptions.ScaleYFactor==16) stretchOptions.ScaleYFactor=stretchOptions.ScaleXFactor;
		if (stretchOptions.ScaleXFactor>31) 
			stretchOptions.ScaleXFactor=31;
		if (stretchOptions.ScaleYFactor>31)
			stretchOptions.ScaleYFactor=31;

		if ( stretchOptions.ScaleXFactor > stretchOptions.ScaleYFactor )
		{
			stretchOptions.ScaleYFactor = stretchOptions.ScaleXFactor;
		}
		else
		{
			stretchOptions.ScaleXFactor = stretchOptions.ScaleYFactor;
		}

	AtiCore_SetRopOperation( ROP3_SRCCOPY );
	AtiCore_SetDstType( DSTTYPE_8BPP );
	AtiCore_SetSrcType( SRCTYPE_EQU_DST );

}
/*

void SetupATIOverlay(int nWidth, int nHeight)
{
//	if (VH1) AtiCore_DestroySurface(VH1);
//	if (VH2) AtiCore_DestroySurface(VH2);
	if (!PlayerOptions.Double)
	{
		ATI_EXTENDEDOVERLAYPROP prop;
		OvlWinProp.SrcPitch =  nWidth<DisplayWidth?nWidth:DisplayWidth; 
		if (OvlWinProp.SrcPitch%16) OvlWinProp.SrcPitch+=16-(OvlWinProp.SrcPitch%16);

		if (PlayerOptions.Rotate)
		{
			prop.x.ExtVideoProp.HInvert=1;
			prop.x.ExtVideoProp.VInvert=1;
			prop.HExpansion=1;
			prop.VExpansion=1;
			prop.RConversion=0;
			OvlWinProp.SrcHeight = 320;
		}
		else
		{
			prop.x.ExtVideoProp.HInvert=0;
			prop.x.ExtVideoProp.VInvert=0;
			prop.HExpansion=1;
			prop.VExpansion=1;
			prop.RConversion=0;
			OvlWinProp.SrcHeight = nHeight;
		}
		OvlWinProp.XCoord = 0;
		OvlWinProp.YCoord = 0;

		OvlWinProp.lpOverlayKey = 0;
		OvlWinProp.OverlayFormat = OVLTYPE_YUV420;


		OvlWinProp.OverlayWidth = nWidth<DisplayWidth?nWidth:DisplayWidth; 
		OvlWinProp.OverlayHeight = nHeight;
		OvlWinProp.lpSrcBitmap = (U32*)VRAMoffset2;
		if ( AtiCore_SetupOverlay( OverlayHandle, &OvlWinProp ) != SUCCESS )
		{
			MessageBox(hWndMain,_T("Failed overlay"),_T(""),MB_OK);
		}
		AtiCore_SetupOverlayExtended(OverlayHandle,&prop);
		AtiCore_SetOverlayPos(OverlayHandle,sX,sY); 
	}
}
*/
#endif

void RecalculateDimensions(HWND hWnd)
{
#if (defined(MIPS)&&(defined(GAPI)))
		if (vidinfo)
		{
			if (vidinfo->video_frames)
			{
				GXCloseDisplay();
				GXOpenDisplay(hWnd, GX_FULLSCREEN);
			}
		}
#endif

	short nWidth=DrawWidth=g_nWidth;
	short nHeight=DrawHeight=g_nHeight;

	if (PlayerOptions.Rotate)
	{
		DrawWidth=nWidth=g_nHeight;
		DrawHeight=nHeight=g_nWidth;

	}
	bEnd=false;
	NeedHide=PlayerOptions.AlwaysHide;
	if (PlayerOptions.Double)
	{
		if ((nWidth<<1)>VisibleWidth) nWidth=VisibleWidth>>1;
		if ((nHeight<<1)>VisibleHeight) nHeight=VisibleHeight>>1;
		DrawWidth=nWidth<<1;
		DrawHeight=nHeight<<1;
	}
	else
	{

		if (nWidth>VisibleWidth) nWidth=VisibleWidth;
		if (nHeight>VisibleHeight) nHeight=VisibleHeight;		
		DrawWidth=nWidth;
		DrawHeight=nHeight;
	
	}
#ifdef IPAQ
	if (DrawWidth>PlayerSkin.ViewPort.height||((DrawHeight>PlayerSkin.ViewPort.width)&&(PlayerSkin.ViewPort.width<VisibleHeight)))
#else
	if (DrawHeight>PlayerSkin.ViewPort.height||((DrawWidth>PlayerSkin.ViewPort.width)&&(PlayerSkin.ViewPort.width<VisibleWidth)))
#endif
	{
#ifdef ATI
		if (!PlayerOptions.FitToViewPort||(PlayerOptions.Double))
		{
#endif
			sY=(VisibleHeight-DrawHeight)/2;
			sX=(VisibleWidth-DrawWidth)/2;
			if (DrawWidth>=VisibleWidth) sX=0;

⌨️ 快捷键说明

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