www.pudn.com > DirectDraw.rar > DirectDisplay.h, change:2007-09-20,size:5830b


// DirectDisplay.h: interface for the CDirectDisplay class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_DIRECTDISPLAY_H__BD674397_68F7_40DD_A59C_7E77C24C27D1__INCLUDED_) 
#define AFX_DIRECTDISPLAY_H__BD674397_68F7_40DD_A59C_7E77C24C27D1__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
#include <ddraw.h> 
#include "DVSPlayerSDK.h" 
 
#define SAFE_DELETE(p)  { if(p) { delete (p);     (p)=NULL; } } 
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } 
 
typedef signed char			int8_t; 
typedef unsigned char		uint8_t; 
typedef short				int16_t; 
typedef unsigned short		uint16_t;  
typedef int					int32_t; 
typedef unsigned int		uint32_t;   
typedef __int64				int64_t; 
typedef unsigned __int64	uint64_t;  
 
typedef enum 
{ 
	VOUT_MODE_NONE, 
	VOUT_MODE_RGB555, 
	VOUT_MODE_RGB565, 
	VOUT_MODE_RGB24, 
	VOUT_MODE_RGB32, 
	VOUT_MODE_YUY2, 
}VOUT_MODE; 
 
// 颜色空间转换矩阵变量  
static uint64_t mmw_mult_Y    = 0x2568256825682568; 
static uint64_t mmw_mult_U_G  = 0xf36ef36ef36ef36e; 
static uint64_t mmw_mult_U_B  = 0x40cf40cf40cf40cf; 
static uint64_t mmw_mult_V_R  = 0x3343334333433343; 
static uint64_t mmw_mult_V_G  = 0xe5e2e5e2e5e2e5e2; 
 
 
// 其他掩码和其它常量  
static uint64_t mmb_0x10      = 0x1010101010101010; 
static uint64_t mmw_0x0080    = 0x0080008000800080; 
static uint64_t mmw_0x00ff    = 0x00ff00ff00ff00ff; 
 
static uint64_t mask_0xf8	  = 0xf8f8f8f8f8f8f8f8; 
static uint64_t mask_0xfc	  = 0xfcfcfcfcfcfcfcfc; 
static uint64_t mask_0x1f	  = 0x1f1f1f1f1f1f1f1f; 
 
typedef void (*CSPTransFuncPtr)(PBYTE in_Y,PBYTE in_U,PBYTE in_V,DWORD dwWidth,DWORD dwHeight,int nSrcPitch,PBYTE pOut,int nDstPitch,BOOL bFlip); 
 
class CDirectDisplay   
{ 
public: 
	CDirectDisplay(); 
	virtual ~CDirectDisplay(); 
public: 
	BOOL CreateDDraw(HWND hWnd); 
	BOOL InitDDraw(DWORD dwWidth,DWORD dwHeight); 
	BOOL DrawImageFromYUV(PBYTE in_Y,PBYTE in_U,PBYTE in_V,int nPitch,RECT *destRec  = NULL); 
	BOOL CaptureImage(int nImageType,int nQuality,unsigned char *pImageBuf, unsigned long *pnImageSize); 
	void SetDrawcallback(DrawCallback pDrawcallback,LPVOID pDrawcontext); 
	void UpdateImage(RECT *pRect); 
 
	BOOL SetClipperWnd(HWND hWnd); 
 
	void SetDisplayRect(BOOL bDispRect,RECT *pRect); 
public: 
	static void SetFuncPointer(); 
	static CSPTransFuncPtr yv12to_rgb555 ,yv12to_rgb565,yv12to_rgb24bit,yv12to_rgb32bit,yv12to_yuv422; 
	LPDIRECTDRAWSURFACE7	m_pDDSBack; 
private: 
	static void colorspace_init(void); 
 
	static uint32_t RGB_Y_tab[256]; 
	static uint32_t B_U_tab[256]; 
	static uint32_t G_U_tab[256]; 
	static uint32_t G_V_tab[256]; 
	static uint32_t R_V_tab[256]; 
 
/*	static void yv12to_rgb555_c(PBYTE in_Y,PBYTE in_U,PBYTE in_V,DWORD dwWidth,DWORD dwHeight,int nSrcPitch,PBYTE pOut,int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb565_c(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb24bit_c(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb32bit_c(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_yuv422_c(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip);*/ 
 
	static void yv12to_rgb555_mmx(PBYTE in_Y,PBYTE in_U,PBYTE in_V,DWORD dwWidth,DWORD dwHeight,int nSrcPitch,PBYTE pOut,int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb565_mmx(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb24bit_mmx(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb32bit_mmx(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_yuv422_mmx(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
/*	static void yv12to_rgb555_sse2(PBYTE in_Y,PBYTE in_U,PBYTE in_V,DWORD dwWidth,DWORD dwHeight,int nSrcPitch,PBYTE pOut,int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb565_sse2(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb24bit_sse2(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_rgb32bit_sse2(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip); 
 
	static void yv12to_yuv422_sse2(PBYTE in_Y, PBYTE in_U, PBYTE in_V, DWORD dwWidth, DWORD dwHeight, int nSrcPitch, PBYTE pOut, int nDstPitch,BOOL bFlip);*/ 
 
 
	void ReleaseObjs(); 
	BOOL CreateOSDSurface(DWORD dwWidth,DWORD dwHeight); 
	BOOL CreateYUVSurface(DWORD dwWidth,DWORD dwHeight); 
	BOOL CreateRGBSurface(DWORD dwWidth,DWORD dwHeight); 
	 
	void DrawImageFromBack(RECT *destRec); 
 
	void Create_BmpHeader(PBYTE pBuf); 
 
	LPDIRECTDRAW7			m_pDD; 
	LPDIRECTDRAWSURFACE7	m_pDDSFront; 
	LPDIRECTDRAWSURFACE7	m_pDDSOSD; //当使用YUV加速且注册了OSD自画回调时才有效 
 
	DrawCallback			m_pDrawCallback; 
	LPVOID					m_pDrawcontext; 
 
	HWND					m_hWnd; 
	DWORD					m_dwWidth; 
	DWORD					m_dwHeight; 
	PBYTE					m_pY,m_pU,m_pV; 
	DWORD					m_nSrcPitch; 
 
	DWORD					m_dwDDMemtype; 
 
	HANDLE					m_hCapMutex; 
	VOUT_MODE				m_vout_mode; 
 
	BOOL					m_bDispRect; 
	RECT					m_DispRect; 
}; 
 
#endif // !defined(AFX_DIRECTDISPLAY_H__BD674397_68F7_40DD_A59C_7E77C24C27D1__INCLUDED_)