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

📄 pocketmvp.cpp

📁 PocketMVP V0.8082503 source for Pocket 的程序源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 /***************************************************************************************
 *This program is free software; you can redistribute it and/or modify					*
 * it under the terms of the GNU General Public License as published by					*
 * the Free Software Foundation; either version 2 of the License, or					*
 * (at your option) any later version.													*
 *																						*
 * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html						*
 *																						*
 *																						*	
 ****************************************************************************************
 * Authors:																			  *
 *          Marc Dukette                                                              *
 **************************************************************************************/



#include "stdafx.h"
#include "pocketmvp.h"
#include <commctrl.h>
#include "decore.h"
#include "avidecaps.h"
#include "portab.h"
#include "yuv2rgb.h"
#include "skin.h"
#include "utilities.h"
#include "SipApi.h"
#include "imgdecmp.h"
#include "audiothread.h"

//ATI Specific
#ifdef ATI
extern "C"
{

#include <w100api.h>
U32 VRAMoffset,VRAMoffset2;
U16 VH1,VH2;
ATI_STRETCH stretchOptions;
bool Cleared=false;
ATI_OVERLAYPROP OvlWinProp;
U16 OverlayHandle = 0;
int xStart=0;
int yStart=0;
bool ForceFit=false;

}
#endif



/************************************************************************************************/
//Function prototypes
/************************************************************************************************/

#if (_WIN32_WCE >= 300 && !defined(HPC))
	
	typedef BOOL (CALLBACK* paygshell_SHFullScreen)( HWND hwnd, DWORD st );
	paygshell_SHFullScreen SHFullScreen;

	#define SHCMBM_GETMENU      (WM_USER + 402)
	#define SHGetMenu( hWndMB )  ( HMENU )SendMessage( ( hWndMB ), SHCMBM_GETMENU, ( WPARAM )0, ( LPARAM )0 )
	#define CommandBar_GetMenu( hWndMB, x )		( HMENU )SendMessage( ( hWndMB ), SHCMBM_GETMENU, ( WPARAM )0, ( LPARAM )0 )
#endif

void ResetDisplay(HWND hWnd);
#ifdef MIPS
int MyGetTickCount();
#else
#define MyGetTickCount() GetTickCount()
#endif
void SeekPos(int nPos,bool isChapter, int isFrame);
double GetPos();

#ifdef _USEVIDBUFF
extern "C" BOOL SetKMode (BOOL);
#endif


DWORD WINAPI PlayThread(LPVOID lpParameter);
extern int fnGetFileName(HWND Parent,LPTSTR Filter,LPTSTR initialDir,  LPTSTR OutFileName, int MaxFilName,LPTSTR* szMultiBuff,unsigned int vkctrl, int webview);

typedef void (CALLBACK* pInitializeReader)(reader* rd);
pInitializeReader READER_InitializeReader=InitializeReader;

HWND ExternalInit(HINSTANCE hDll, HINSTANCE hInstance, int nCmdShow,UserOptions* PlayerOptions, HWND* hwndcb,WNDPROC WndProc, LPTSTR* ToolTips);

void Configure(HINSTANCE hDll, HINSTANCE hInstance, HWND Parent,UserOptions* PlayerOptions);

int JumpTo(HWND Parent,int position);

void Equalizer(HINSTANCE hDll, HINSTANCE hInstance, HWND Parent,UserOptions* PlayerOptions);

void SaveOptions(UserOptions* PlayerOptions);
void LoadOptions(UserOptions* PlayerOptions);
void GetDisplayName();

//typedef BOOL (CALLBACK* VirtualCopy)(LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD fdwProtect );
typedef int (CALLBACK* pdecode_frame)(unsigned char *stream, int length, unsigned char *bmp,int flag);
typedef int (CALLBACK*  pdecode_msg)(
			unsigned long handle,
			unsigned long dec_opt,
			void *param1,
			void *param2);

pdecode_frame DecodeFrame=NULL; 
pdecode_msg DecodeMessage=NULL; 



ATOM				MyRegisterClass	(HINSTANCE, LPTSTR);
BOOL				InitInstance	(HINSTANCE, int);
LRESULT CALLBACK	WndProc			(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void PauseEvent();
void Pause();
void NextFile(int dir);

DWORD WINAPI AudioThread(LPVOID lpParameter);
pInit Init;
pExit Exit;
pSeekStart SeekStart;
pSeekEnd SeekEnd;
pDecompressAudio DecompressAudio;
pGetHeaderInfo GetHeaderInfo;

#ifdef ARM
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


/************************************************************************************************/
//Buffers
/************************************************************************************************/

char* toBuff;
unsigned char temp[VIDEO_BUFFER_SIZE];

char* outputBuffer =0;
TCHAR		FileName[200] = TEXT(".avi\0");
TCHAR		DisplayName[200];
unsigned char* vbuffStart=(unsigned char*)outputBuffer;
short *vbuff; 
TCHAR		szFile[MAX_PATH] = TEXT("");
videoinfo* vidinfo=NULL;
TCHAR PDLFile[200];


/************************************************************************************************/
//Global Flags
/************************************************************************************************/
int DropTwo=1;
int twelve_bit=0;
int e740=0;
int amigo=0;
int FadeMax;
extern int FirstChunk;

bool bPaused=false;
bool bEnd=false;
bool bStopRead=false;
bool NeedHide=false;
bool FastForward=false;
bool Closing=false;
bool bPlayNow=false;
bool EndReached=false;
bool NoIndex=false;
bool RawAudio=false;
bool NeedShuffle=false;
__int8 lastshow;
#ifdef ARM
	bool g_bInvert=false;
#endif

/************************************************************************************************/
//Global Data and Objects
/************************************************************************************************/

#ifdef GAPI
	#include "gx.h"
#endif

HANDLE ha;
HBITMAP  m_hBitmap=NULL;          // Handle to DIBSECTION
HBITMAP  m_hBitBack=NULL;          // Handle to DIBSECTION
HBITMAP  m_hBitButton=NULL;          // Handle to DIBSECTION
reader rd;
bool Chapters=false;
short sY=0;
short sX=0;
LPTSTR ToolTips[8]={_T(""),_T("Play"),_T("Stop"),_T("Fast Forward"),_T("Equalizer"),_T("Full Screen"),_T("PlayerOptions.Rotate"),_T("Next Item")};
int br;
int nDrop=0;
HINSTANCE			hInst;			// The current instance
HWND				hwndCB;			// The command bar handle
HDC compat=NULL;
HBITMAP hb=NULL;

DWORD ht=0;
DWORD hTimerSlider=0;
DWORD hTimerFade=0;
HANDLE hdivx=NULL;
int Display=2;
bool Stream=false;
bool bSkipChunk=false;
DWORD tid;
long oldproc,oldprocid3;
DWORD rtid=NULL;
DWORD ptid=NULL;
HANDLE hPlayThread=NULL;
HANDLE eventStopped;
HANDLE eventAudioStopped;
HANDLE eventAudio;
HANDLE eventNextFrame;
CRITICAL_SECTION cs;
HWND hWndMain=NULL;
UserOptions PlayerOptions;
Skin PlayerSkin;
HWAVEOUT m_hwo;
int totMsTime;
__int64 totAudio;
int nShouldbe;
int baseTick=0;
int tot=0;
int nCurrentFrame;
int DrawWidth;
int DrawHeight;
int g_nHeight;
int g_nWidth;
int nExtra;
int StartPos=0;
_Files* Files=0;
int Dir=1;
int MaxFile;
int CurrentFile;
int StartFile;
COLORREF backColor;
TCHAR lpTempSkin[255];

extern Written;

extern TCHAR ID3_Title[200];
extern TCHAR ID3_Artist[200];
extern TCHAR ID3_Album[200];

/*****************************************************************************************/
//Skin Functions
/*****************************************************************************************/
HWND hwndList,hwndID3;

void AddEntry(LPTSTR FileName, int pos)
{
	LVITEM lv;
	lv.mask=LVIF_TEXT;
	lv.pszText=_T("");
	lv.cchTextMax=1;
	lv.iSubItem=0;
	LPTSTR temp=FileName+wcslen(FileName);
	if (pos<0) lv.iItem=ListView_GetItemCount(hwndList);	
	else lv.iItem=pos;
	ListView_InsertItem(hwndList,&lv);
	while (temp[0]!='.')
	{
		temp--;
	}
	temp++;
	while (temp[0]!='\\'&&(temp[0]!='/'))
	{
		temp--;
	}
	temp++;
	ListView_SetItemText(hwndList,lv.iItem,0,temp);
}

void AddTextEntry(LPTSTR FileName, int pos)
{
	LVITEM lv;
	lv.mask=LVIF_TEXT;
	lv.pszText=_T("");
	lv.cchTextMax=1;
	lv.iSubItem=0;
	if (pos<0) lv.iItem=ListView_GetItemCount(hwndID3);	
	else lv.iItem=pos;
	ListView_InsertItem(hwndID3,&lv);
	ListView_SetItemText(hwndID3,lv.iItem,0,FileName);
}

void FadeIn()
{
	unsigned long pos;
	if (vidinfo->video_frames) return;
	waveOutGetVolume( 0, &pos);				
	int vol=(LOWORD(pos))*100/0xffff;
	if (vol>100) vol=100;
	if (vol<0) vol=0;
	FadeMax=vol;
	vol=0;
	if (!PlayerOptions.Mute)
	{
		waveOutSetVolume( 0, (unsigned long)(0xffff*vol)/100+(0xffff*vol)/100*0x10000  );				
		hTimerFade=SetTimer(hWndMain,444,50,NULL);
		if (!hTimerFade) waveOutSetVolume( 0, (unsigned long)(0xffff*FadeMax)/100+(0xffff*FadeMax)/100*0x10000  );				
	}
}
void LoadSkin(LPTSTR FileName,HWND hWnd)
{
	unsigned long nPos;
	LVCOLUMN lv;
	LoadSkinFile(FileName,hWnd);
	wcscpy(PlayerOptions.Skin,FileName);
	if (hTimerSlider) KillTimer(hWnd,hTimerSlider);
	if (PlayerSkin.SeekButton.width)
		hTimerSlider=SetTimer(hWnd,11,1000,NULL);
	else
		hTimerSlider=NULL;
	if (PlayerSkin.VolButton.width)
	{
		waveOutGetVolume(0,&nPos);
		nPos=(LOWORD(nPos))*100/0xffff;
		if (PlayerSkin.VolSlider.rotated)
			PlayerSkin.VolButton.top = PlayerSkin.VolSlider.top+((nPos*PlayerSkin.VolSlider.height*PlayerSkin.VolButton.step)/100); 
		else
			PlayerSkin.VolButton.left = PlayerSkin.VolSlider.left+((nPos*(PlayerSkin.VolSlider.width-PlayerSkin.VolButton.width)*PlayerSkin.VolButton.step)/100); 
	}
	if (hwndList) DestroyWindow(hwndList);
	if (hwndID3) DestroyWindow(hwndID3);
	hwndList=NULL;
	hwndList=CreateWindowEx(WS_EX_CLIENTEDGE,_T("SysListView32"), _T(""), WS_CHILD|WS_VSCROLL|LVS_SINGLESEL|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_NOCOLUMNHEADER,
		PlayerSkin.ViewPort.left , PlayerSkin.ViewPort.top, PlayerSkin.ViewPort.width, PlayerSkin.ViewPort.height, hWnd, NULL, hInst, NULL);

	LOGFONT lf;
	memset(&lf,0,sizeof(LOGFONT));

	lf.lfWeight=FW_NORMAL;
	HDC hdc=GetDC(hwndList);
	if (PlayerSkin.PlaylistView.point)
	{
		wcscpy(lf.lfFaceName,PlayerSkin.PlaylistView.font);
		__int64 t=(__int64)GetDeviceCaps(hdc, LOGPIXELSY)*(__int64)PlayerSkin.PlaylistView.point/(__int64)72;
		lf.lfHeight = (long)t;
	}
	else
	{
		wcscpy(lf.lfFaceName,_T("Tahoma"));
		__int64 t=(__int64)GetDeviceCaps(hdc, LOGPIXELSY)*(__int64)9/(__int64)72;
		lf.lfHeight = (long)t;
	}
	ReleaseDC(hwndList,hdc);
	HFONT hf=CreateFontIndirect(&lf);
	SendMessage(hwndList,WM_SETFONT,(WPARAM)hf,MAKELPARAM(TRUE,0));
	
	oldproc=SetWindowLong(hwndList,GWL_WNDPROC,(long)ListWndProc);
	if (PlayerSkin.PlaylistView.BackRed!=0||(PlayerSkin.PlaylistView.BackBlue!=0)||(PlayerSkin.PlaylistView.BackGreen!=0)) 
	{
		ListView_SetBkColor(hwndList,RGB(PlayerSkin.PlaylistView.BackRed,PlayerSkin.PlaylistView.BackGreen,PlayerSkin.PlaylistView.BackBlue));
		ListView_SetTextBkColor(hwndList,RGB(PlayerSkin.PlaylistView.BackRed,PlayerSkin.PlaylistView.BackGreen,PlayerSkin.PlaylistView.BackBlue));
	}
	if (PlayerSkin.PlaylistView.FontRed!=0||(PlayerSkin.PlaylistView.FontBlue!=0)||(PlayerSkin.PlaylistView.FontGreen!=0)) 
	{
		ListView_SetTextColor(hwndList,RGB(PlayerSkin.PlaylistView.FontRed,PlayerSkin.PlaylistView.FontGreen,PlayerSkin.PlaylistView.FontBlue));
	}
	ListView_SetExtendedListViewStyle(hwndList,LVS_EX_FULLROWSELECT);
	lv.mask=LVCF_TEXT | LVCF_WIDTH ;
	lv.fmt=LVCFMT_LEFT ;
	lv.cx=PlayerSkin.ViewPort.width-19;
	lv.pszText=_T("File");
	lv.cchTextMax=5;
	ListView_InsertColumn(hwndList,0,&lv);

	hwndID3=CreateWindowEx(WS_EX_CLIENTEDGE,_T("SysListView32"), _T(""), WS_CHILD|WS_VSCROLL|LVS_SINGLESEL|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_NOCOLUMNHEADER,
		PlayerSkin.ViewPort.left , PlayerSkin.ViewPort.top, PlayerSkin.ViewPort.width, PlayerSkin.ViewPort.height, hWnd, NULL, hInst, NULL);

	memset(&lf,0,sizeof(LOGFONT));

	lf.lfWeight=FW_NORMAL;
	hdc=GetDC(hwndID3);
	if (PlayerSkin.MediaView.point)
	{
		wcscpy(lf.lfFaceName,PlayerSkin.MediaView.font);
		__int64 t=(__int64)GetDeviceCaps(hdc, LOGPIXELSY)*(__int64)PlayerSkin.MediaView.point/(__int64)72;
		lf.lfHeight = (long)t;
	}
	else
	{
		wcscpy(lf.lfFaceName,_T("Tahoma"));
		__int64 t=(__int64)GetDeviceCaps(hdc, LOGPIXELSY)*(__int64)9/(__int64)72;
		lf.lfHeight = (long)t;
	}
	ReleaseDC(hwndID3,hdc);
	hf=CreateFontIndirect(&lf);
	SendMessage(hwndID3,WM_SETFONT,(WPARAM)hf,MAKELPARAM(TRUE,0));
	
	oldprocid3=SetWindowLong(hwndID3,GWL_WNDPROC,(long)ListWndProc);
	if (PlayerSkin.MediaView.BackRed!=0||(PlayerSkin.MediaView.BackBlue!=0)||(PlayerSkin.MediaView.BackGreen!=0)) 
	{
		ListView_SetBkColor(hwndID3,RGB(PlayerSkin.MediaView.BackRed,PlayerSkin.MediaView.BackGreen,PlayerSkin.MediaView.BackBlue));
		ListView_SetTextBkColor(hwndID3,RGB(PlayerSkin.MediaView.BackRed,PlayerSkin.MediaView.BackGreen,PlayerSkin.MediaView.BackBlue));
	}
	if (PlayerSkin.MediaView.FontRed!=0||(PlayerSkin.MediaView.FontBlue!=0)||(PlayerSkin.MediaView.FontGreen!=0)) 
	{
		ListView_SetTextColor(hwndID3,RGB(PlayerSkin.MediaView.FontRed,PlayerSkin.MediaView.FontGreen,PlayerSkin.MediaView.FontBlue));
	}
	ListView_SetExtendedListViewStyle(hwndID3,LVS_EX_FULLROWSELECT);
	lv.mask=LVCF_TEXT | LVCF_WIDTH ;
	lv.fmt=LVCFMT_LEFT ;
	lv.cx=PlayerSkin.ViewPort.width-19;
	lv.pszText=_T("File");
	lv.cchTextMax=5;
	ListView_InsertColumn(hwndID3,0,&lv);
	PostMessage(hWndMain,WM_USER+401,0,0);
	if (wcscmp(FileName,_T(""))) GetDisplayName();
}


void DrawButtonDown(SkinItem* location)
{
	if (!NeedHide||(bPaused))
	{
		HDC hdc=GetDC(hWndMain);
		HBITMAP old;
		old=(HBITMAP)SelectObject(compat,m_hBitButton);
		BitBlt(hdc,location->left,location->top,location->width,location->height,compat,location->pushedleft,location->pushedtop,SRCCOPY);
		SelectObject(compat,old);
		ReleaseDC(hWndMain,hdc);
	}
	location->status=1;

}


void DrawButtonUp(SkinItem* location)
{
	if (!NeedHide||(bPaused))
	{
		HDC hdc=GetDC(hWndMain);
		HBITMAP old;
		old=(HBITMAP)SelectObject(compat,m_hBitBack);
		BitBlt(hdc,location->left,location->top,location->width,location->height,compat,location->left,location->top-Y_ADJUST,SRCCOPY);
		SelectObject(compat,old);
		ReleaseDC(hWndMain,hdc);
	}
	location->status=0;

}

⌨️ 快捷键说明

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