device_directx9.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*********************************************************************************
  2. INTEL CORPORATION PROPRIETARY INFORMATION
  3. This software is supplied under the terms of a license agreement or nondisclosure
  4. agreement with Intel Corporation and may not be copied or disclosed except in
  5. accordance with the terms of that agreement
  6. Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved.
  7. **********************************************************************************/
  8. #pragma once
  9. #if defined( _WIN32 ) || defined ( _WIN64 )
  10. #include "common_utils.h"
  11. #pragma warning(disable : 4201)
  12. #include <initguid.h>
  13. #include <d3d9.h>
  14. #include <dxva2api.h>
  15. #include <dxva.h>
  16. #include <windows.h>
  17. #define VIDEO_MAIN_FORMAT D3DFMT_YUY2
  18. class IGFXS3DControl;
  19. /// Base class for hw device
  20. class CHWDevice
  21. {
  22. public:
  23. virtual ~CHWDevice(){}
  24. /** Initializes device for requested processing.
  25. @param[in] hWindow Window handle to bundle device to.
  26. @param[in] nViews Number of views to process.
  27. @param[in] nAdapterNum Number of adapter to use
  28. */
  29. virtual mfxStatus Init(
  30. mfxHDL hWindow,
  31. mfxU16 nViews,
  32. mfxU32 nAdapterNum) = 0;
  33. /// Reset device.
  34. virtual mfxStatus Reset() = 0;
  35. /// Get handle can be used for MFX session SetHandle calls
  36. virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl) = 0;
  37. /** Set handle.
  38. Particular device implementation may require other objects to operate.
  39. */
  40. virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) = 0;
  41. virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc) = 0;
  42. virtual void Close() = 0;
  43. };
  44. enum {
  45. MFX_HANDLE_GFXS3DCONTROL = 0x100, /* A handle to the IGFXS3DControl instance */
  46. MFX_HANDLE_DEVICEWINDOW = 0x101 /* A handle to the render window */
  47. }; //mfxHandleType
  48. /** Direct3D 9 device implementation.
  49. @note Can be initilized for only 1 or two 2 views. Handle to
  50. MFX_HANDLE_GFXS3DCONTROL must be set prior if initializing for 2 views.
  51. @note Device always set D3DPRESENT_PARAMETERS::Windowed to TRUE.
  52. */
  53. class CD3D9Device : public CHWDevice
  54. {
  55. public:
  56. CD3D9Device();
  57. virtual ~CD3D9Device();
  58. virtual mfxStatus Init(
  59. mfxHDL hWindow,
  60. mfxU16 nViews,
  61. mfxU32 nAdapterNum);
  62. virtual mfxStatus Reset();
  63. virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl);
  64. virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl);
  65. virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc);
  66. virtual void UpdateTitle(double /*fps*/) { }
  67. virtual void Close() ;
  68. void DefineFormat(bool isA2rgb10) { m_bIsA2rgb10 = (isA2rgb10) ? TRUE : FALSE; }
  69. protected:
  70. mfxStatus CreateVideoProcessors();
  71. bool CheckOverlaySupport();
  72. virtual mfxStatus FillD3DPP(mfxHDL hWindow, mfxU16 nViews, D3DPRESENT_PARAMETERS &D3DPP);
  73. private:
  74. IDirect3D9Ex* m_pD3D9;
  75. IDirect3DDevice9Ex* m_pD3DD9;
  76. IDirect3DDeviceManager9* m_pDeviceManager9;
  77. D3DPRESENT_PARAMETERS m_D3DPP;
  78. UINT m_resetToken;
  79. mfxU16 m_nViews;
  80. IGFXS3DControl* m_pS3DControl;
  81. D3DSURFACE_DESC m_backBufferDesc;
  82. // service required to create video processors
  83. IDirectXVideoProcessorService* m_pDXVAVPS;
  84. //left channel processor
  85. IDirectXVideoProcessor* m_pDXVAVP_Left;
  86. // right channel processor
  87. IDirectXVideoProcessor* m_pDXVAVP_Right;
  88. // target rectangle
  89. RECT m_targetRect;
  90. // various structures for DXVA2 calls
  91. DXVA2_VideoDesc m_VideoDesc;
  92. DXVA2_VideoProcessBltParams m_BltParams;
  93. DXVA2_VideoSample m_Sample;
  94. BOOL m_bIsA2rgb10;
  95. };
  96. #endif // #if defined( _WIN32 ) || defined ( _WIN64 )