common_directx9.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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> class safe_array {
  23. public:
  24. safe_array(T *ptr = 0)
  25. : m_ptr(ptr){
  26. // construct from object pointer
  27. };
  28. ~safe_array() { reset(0); }
  29. T *get()
  30. { // return wrapped pointer
  31. return m_ptr;
  32. }
  33. T *release()
  34. { // return wrapped pointer and give up ownership
  35. T *ptr = m_ptr;
  36. m_ptr = 0;
  37. return ptr;
  38. }
  39. void reset(T *ptr)
  40. { // destroy designated object and store new pointer
  41. if (m_ptr) {
  42. delete[] m_ptr;
  43. }
  44. m_ptr = ptr;
  45. }
  46. protected:
  47. T *m_ptr; // the wrapped object pointer
  48. };
  49. mfxStatus dx9_simple_alloc(mfxHDL pthis, mfxFrameAllocRequest *request,
  50. mfxFrameAllocResponse *response);
  51. mfxStatus dx9_simple_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);
  52. mfxStatus dx9_simple_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);
  53. mfxStatus dx9_simple_gethdl(mfxHDL pthis, mfxMemId mid, mfxHDL *handle);
  54. mfxStatus dx9_simple_free(mfxHDL pthis, mfxFrameAllocResponse *response);
  55. mfxStatus DX9_CreateHWDevice(mfxSession session, mfxHDL *deviceHandle,
  56. HWND hWnd, bool bCreateSharedHandles);
  57. void DX9_CleanupHWDevice();