common_directx9.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include "common_utils.h"
  10. #include <initguid.h>
  11. #include <d3d9.h>
  12. #include <dxva2api.h>
  13. #include <dxva.h>
  14. #include <windows.h>
  15. #define VIDEO_MAIN_FORMAT D3DFMT_YUY2
  16. class IGFXS3DControl;
  17. /** Direct3D 9 device implementation.
  18. @note Can be initialized for only 1 or two 2 views. Handle to
  19. MFX_HANDLE_GFXS3DCONTROL must be set prior if initializing for 2 views.
  20. @note Device always set D3DPRESENT_PARAMETERS::Windowed to TRUE.
  21. */
  22. template <class T>
  23. class safe_array
  24. {
  25. public:
  26. safe_array(T *ptr = 0):m_ptr(ptr)
  27. { // construct from object pointer
  28. };
  29. ~safe_array()
  30. {
  31. reset(0);
  32. }
  33. T* get()
  34. { // return wrapped pointer
  35. return m_ptr;
  36. }
  37. T* release()
  38. { // return wrapped pointer and give up ownership
  39. T* ptr = m_ptr;
  40. m_ptr = 0;
  41. return ptr;
  42. }
  43. void reset(T* ptr)
  44. { // destroy designated object and store new pointer
  45. if (m_ptr)
  46. {
  47. delete[] m_ptr;
  48. }
  49. m_ptr = ptr;
  50. }
  51. protected:
  52. T* m_ptr; // the wrapped object pointer
  53. };
  54. mfxStatus dx9_simple_alloc(mfxHDL pthis, mfxFrameAllocRequest* request, mfxFrameAllocResponse* response);
  55. mfxStatus dx9_simple_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData* ptr);
  56. mfxStatus dx9_simple_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData* ptr);
  57. mfxStatus dx9_simple_gethdl(mfxHDL pthis, mfxMemId mid, mfxHDL* handle);
  58. mfxStatus dx9_simple_free(mfxHDL pthis, mfxFrameAllocResponse* response);
  59. mfxStatus DX9_CreateHWDevice(mfxSession session, mfxHDL* deviceHandle, HWND hWnd, bool bCreateSharedHandles);
  60. void DX9_CleanupHWDevice();