Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.9 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: VPMUtil.h
  3. *
  4. *
  5. *
  6. *
  7. * Created: Tue 05/05/2000
  8. * Author: GlenneE
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. \**************************************************************************/
  12. #ifndef __VPMUtil__h
  13. #define __VPMUtil__h
  14. struct VPWININFO;
  15. // global utility functions for the VPM
  16. struct tagVIDEOINFOHEADER2;
  17. typedef struct tagVIDEOINFOHEADER2 VIDEOINFOHEADER2;
  18. #include <dvp.h>
  19. namespace VPMUtil
  20. {
  21. int GetRegistryDword(HKEY hk, const TCHAR *pKey, int iDefault);
  22. int GetPropPagesRegistryDword( int iDefault );
  23. LONG SetRegistryDword( HKEY hk, const TCHAR *pKey, int iRet );
  24. BITMAPINFOHEADER* GetbmiHeader( CMediaType *pMediaType);
  25. const BITMAPINFOHEADER* GetbmiHeader(const CMediaType *pMediaType);
  26. HRESULT GetPictAspectRatio(const CMediaType& pMediaType, DWORD *pdwPictAspectRatioX, DWORD *pdwPictAspectRatioY);
  27. const DWORD* WINAPI GetBitMasks(const CMediaType *pMediaType);
  28. const BYTE* GetColorInfo(const CMediaType *pMediaType);
  29. HRESULT GetSrcRectFromMediaType(const CMediaType& pMediaType, RECT *pRect);
  30. HRESULT GetDestRectFromMediaType(const CMediaType& pMediaType, RECT *pRect);
  31. AM_MEDIA_TYPE* AllocVideoMediaType(const AM_MEDIA_TYPE * pmtSource, GUID formattype);
  32. AM_MEDIA_TYPE* ConvertSurfaceDescToMediaType(const LPDDSURFACEDESC pSurfaceDesc, BOOL bInvertSize, CMediaType cMediaType);
  33. HRESULT IsPalettised(const CMediaType& mediaType, BOOL *pPalettised);
  34. HRESULT GetInterlaceFlagsFromMediaType(const CMediaType& mediaType, DWORD *pdwInterlaceFlags);
  35. HRESULT CreateDIB(LONG lSize, BITMAPINFO *pBitMapInfo, DIBDATA *pDibData);
  36. HRESULT DeleteDIB(DIBDATA *pDibData);
  37. void FastDIBBlt(DIBDATA *pDibData, HDC hTargetDC, HDC hSourceDC, RECT *prcTarget, RECT *prcSource);
  38. void SlowDIBBlt(BYTE *pDibBits, BITMAPINFOHEADER *pHeader, HDC hTargetDC, RECT *prcTarget, RECT *prcSource);
  39. // decimation
  40. BOOL IsDecimationNeeded( DWORD ScaleFactor );
  41. DWORD GetCurrentScaleFactor( const VPWININFO& VPWinInfo,
  42. DWORD* lpxScaleFactor = NULL,
  43. DWORD* lpyScaleFactor = NULL);
  44. VIDEOINFOHEADER2* GetVideoInfoHeader2(CMediaType *pMediaType);
  45. const VIDEOINFOHEADER2* GetVideoInfoHeader2(const CMediaType *pMediaType);
  46. BOOL EqualPixelFormats( const DDPIXELFORMAT& lpFormat1, const DDPIXELFORMAT& lpFormat2);
  47. HRESULT FindVideoPortCaps( IDDVideoPortContainer* pVPContainer, LPDDVIDEOPORTCAPS pVPCaps, DWORD dwVideoPortId );
  48. HRESULT FindVideoPortCaps( LPDIRECTDRAW7 pDirectDraw, LPDDVIDEOPORTCAPS pVPCaps, DWORD dwVideoPortId );
  49. void FixupVideoInfoHeader2( VIDEOINFOHEADER2 *pVideoInfo, DWORD dwComppression, int nBitCount );
  50. void InitVideoInfoHeader2( VIDEOINFOHEADER2 *pVideoInfo );
  51. VIDEOINFOHEADER2* SetToVideoInfoHeader2( CMediaType* pmt, DWORD dwExtraBytes = 0);
  52. };
  53. template <typename T>
  54. __inline void ZeroStruct(T& t)
  55. {
  56. ZeroMemory(&t, sizeof(t));
  57. }
  58. template <typename T>
  59. __inline void ZeroArray(T* pArray, unsigned uCount)
  60. {
  61. ZeroMemory(pArray, sizeof(pArray[0])*uCount);
  62. }
  63. template <typename T>
  64. __inline void CopyArray(T* pDest, const T* pSrc, unsigned uCount)
  65. {
  66. memcpy( pDest, pSrc, sizeof(pDest[0])*uCount);
  67. }
  68. template <typename T>
  69. __inline void INITDDSTRUCT(T& dd)
  70. {
  71. ZeroStruct(dd);
  72. dd.dwSize = sizeof(dd);
  73. }
  74. template<typename T>
  75. __inline void RELEASE( T* &p )
  76. {
  77. if( p ) {
  78. p->Release();
  79. p = NULL;
  80. }
  81. }
  82. #ifndef CHECK_HR
  83. #define CHECK_HR(expr) do { if (FAILED(expr)) __leave; } while(0);
  84. #endif
  85. #endif //__VPMUtil__