cpp_quote("#if 0")

    import "unknwn.idl";

    typedef DWORD* LPDIRECTDRAW7;
    typedef DWORD* LPDIRECTDRAWSURFACE7;
    typedef DWORD* LPDDPIXELFORMAT;
    typedef DWORD* LPBITMAPINFOHEADER;
    typedef struct {DWORD dw1; DWORD dw2;} DDCOLORKEY;
    typedef DDCOLORKEY*    LPDDCOLORKEY;
cpp_quote ("#endif")

cpp_quote("#include <ddraw.h>")

cpp_quote("#define VMRBITMAP_DISABLE            0x00000001")
cpp_quote("#define VMRBITMAP_HDC                0x00000002")
cpp_quote("#define VMRBITMAP_ENTIREDDS          0x00000004")
cpp_quote("#define VMRBITMAP_SRCCOLORKEY        0x00000008")
cpp_quote("#define VMRBITMAP_SRCRECT            0x00000010")

interface IVMRSurface;
interface IVMRSurfaceAllocator;
interface IVMRSurfaceAllocatorNotify;
interface IVMRImagePresenter;
interface IVMRImagePresenterConfig;
interface IVMRWindowlessControl;
interface IVMRMixerControl;
interface IVMRMixerBitmap;
interface IVMRFilterConfig;
interface IVMRAspectRatioControl;
interface IVMRDeinterlaceControl;
interface IVMRMonitorConfig;
interface IVMRImageCompositor;
interface IVMRVideoStreamControl;

#define VMRDEVICENAMELEN 32
#define VMRDEVICEDESCRIPTIONLEN  256

typedef enum
{
    VMRSample_SyncPoint = 0x00000001,
    VMRSample_Preroll = 0x00000002,
    VMRSample_Discontinuity = 0x00000004,
    VMRSample_TimeValid = 0x00000008,
    VMRSample_SrcDstRectsValid= 0x00000010
} VMRPresentationFlags;

typedef enum
{
    AMAP_PIXELFORMAT_VALID = 0x01,
    AMAP_3D_TARGET = 0x02,
    AMAP_ALLOW_SYSMEM = 0x04,
    AMAP_FORCE_SYSMEM = 0x08,
    AMAP_DIRECTED_FLIP = 0x10,
    AMAP_DXVA_TARGET = 0x20
} VMRSurfaceAllocationFlags;

typedef enum
{
    VMR_ARMODE_NONE,
    VMR_ARMODE_LETTER_BOX
} VMR_ASPECT_RATIO_MODE;


typedef enum
{
    MixerPref_NoDecimation = 0x00000001,
    MixerPref_DecimateOutput = 0x00000002,
    MixerPref_ARAdjustXorY = 0x00000004,
    MixerPref_DecimationReserved = 0x00000008,
    MixerPref_DecimateMask = 0x0000000F,
    MixerPref_BiLinearFiltering = 0x00000010,
    MixerPref_PointFiltering = 0x00000020,
    MixerPref_FilteringMask = 0x000000F0,
    MixerPref_RenderTargetRGB = 0x00000100,
    MixerPref_RenderTargetYUV = 0x00001000,
    MixerPref_RenderTargetYUV420 = 0x00000200,
    MixerPref_RenderTargetYUV422 = 0x00000400,
    MixerPref_RenderTargetYUV444 = 0x00000800,
    MixerPref_RenderTargetReserved = 0x0000E000,
    MixerPref_RenderTargetMask = 0x0000FF00,
    MixerPref_DynamicSwitchToBOB = 0x00010000,
    MixerPref_DynamicDecimateBy2 = 0x00020000,
    MixerPref_DynamicReserved = 0x000C0000,
    MixerPref_DynamicMask = 0x000F0000
} VMRMixerPrefs;

typedef enum
{
    RenderPrefs_RestrictToInitialMonitor = 0x00000000,
    RenderPrefs_ForceOffscreen = 0x00000001,
    RenderPrefs_ForceOverlays = 0x00000002,
    RenderPrefs_AllowOverlays = 0x00000000,
    RenderPrefs_AllowOffscreen = 0x00000000,
    RenderPrefs_DoNotRenderColorKeyAndBorder = 0x00000008,
    RenderPrefs_Reserved = 0x00000010,
    RenderPrefs_PreferAGPMemWhenMixing = 0x00000020,

    RenderPrefs_Mask = 0x0000003f,
} VMRRenderPrefs;

typedef enum
{
    VMRMode_Windowed = 0x00000001,
    VMRMode_Windowless = 0x00000002,
    VMRMode_Renderless = 0x00000004,
    VMRMode_Mask = 0x00000007,
} VMRMode;

enum
{
    MAX_NUMBER_OF_STREAMS = 16
};

typedef enum
{
    DeinterlacePref_NextBest = 0x01,
    DeinterlacePref_BOB = 0x02,
    DeinterlacePref_Weave = 0x04,
    DeinterlacePref_Mask = 0x07
} VMRDeinterlacePrefs;

typedef enum
{
    DeinterlaceTech_Unknown = 0x0000,
    DeinterlaceTech_BOBLineReplicate = 0x0001,
    DeinterlaceTech_BOBVerticalStretch = 0x0002,
    DeinterlaceTech_MedianFiltering = 0x0004,
    DeinterlaceTech_EdgeFiltering = 0x0010,
    DeinterlaceTech_FieldAdaptive = 0x0020,
    DeinterlaceTech_PixelAdaptive = 0x0040,
    DeinterlaceTech_MotionVectorSteered = 0x0080
} VMRDeinterlaceTech;

typedef struct tagVMRPRESENTATIONINFO
{
    DWORD dwFlags;
    LPDIRECTDRAWSURFACE7 lpSurf;
    REFERENCE_TIME rtStart;
    REFERENCE_TIME rtEnd;
    SIZE szAspectRatio;
    RECT rcSrc;
    RECT rcDst;
    DWORD dwTypeSpecificFlags;
    DWORD dwInterlaceFlags;
} VMRPRESENTATIONINFO;

typedef struct tagVMRALLOCATIONINFO
{
    DWORD dwFlags;
    LPBITMAPINFOHEADER lpHdr;
    LPDDPIXELFORMAT lpPixFmt;
    SIZE szAspectRatio;
    DWORD dwMinBuffers;
    DWORD dwMaxBuffers;
    DWORD dwInterlaceFlags;
    SIZE szNativeSize;
} VMRALLOCATIONINFO;

typedef struct _NORMALIZEDRECT
{
    float left;
    float top;
    float right;
    float bottom;
} NORMALIZEDRECT, *PNORMALIZEDRECT;

typedef struct tagVMRGUID
{
    struct _GUID *pGUID, GUID;
} VMRGUID;

typedef struct tagVMRMONITORINFO
{
    VMRGUID guid;
    RECT rcMonitor;
    HMONITOR hMon;
    DWORD dwFlags;
    wchar_t szDevice[VMRDEVICENAMELEN];
    wchar_t szDescription[VMRDEVICEDESCRIPTIONLEN];
    LARGE_INTEGER liDriverVersion;
    DWORD dwVendorId;
    DWORD dwDeviceId;
    DWORD dwSubSysId;
    DWORD dwRevision;
} VMRMONITORINFO;

typedef struct _VMRFrequency
{
    DWORD dwNumerator;
    DWORD dwDenominator;
} VMRFrequency;

typedef struct _VMRVideoDesc
{
    DWORD dwSize;
    DWORD dwSampleWidth;
    DWORD dwSampleHeight;
    BOOL SingleFieldPerSample;
    DWORD dwFourCC;
    VMRFrequency InputSampleFreq;
    VMRFrequency OutputFrameFreq;
} VMRVideoDesc;

typedef struct _VMRDeinterlaceCaps
{
    DWORD dwSize;
    DWORD dwNumPreviousOutputFrames;
    DWORD dwNumForwardRefSamples;
    DWORD dwNumBackwardRefSamples;
    VMRDeinterlaceTech  DeinterlaceTechnology;
} VMRDeinterlaceCaps;

typedef struct _VMRALPHABITMAP
{
    DWORD dwFlags;
    HDC hdc;
    LPDIRECTDRAWSURFACE7 pDDS;
    RECT rSrc;
    NORMALIZEDRECT rDest;
    FLOAT fAlpha;
    COLORREF clrSrcKey;
} VMRALPHABITMAP, *PVMRALPHABITMAP;

typedef struct _VMRVIDEOSTREAMINFO
{
    LPDIRECTDRAWSURFACE7 pddsVideoSurface;
    DWORD dwWidth;
    DWORD dwHeight;
    FLOAT dwStrmID;
    FLOAT fAlpha;
    DDCOLORKEY ddClrKey;
    NORMALIZEDRECT rNormal;
} VMRVIDEOSTREAMINFO;



[
    local,
    object,
    uuid(CE704FE7-E71E-41fb-BAA2-C4403E1182F5),
    pointer_default(unique)
]
interface IVMRImagePresenter : IUnknown
{
    HRESULT StartPresenting([in] DWORD_PTR dwUserID);
    HRESULT StopPresenting([in] DWORD_PTR dwUserID);
    HRESULT PresentImage([in] DWORD_PTR dwUserID, [in] VMRPRESENTATIONINFO* lpPresInfo);
};

[
    local,
    object,
    uuid(31ce832e-4484-458b-8cca-f4d7e3db0b52),
    pointer_default(unique)
]
interface IVMRSurfaceAllocator : IUnknown
{
    HRESULT AllocateSurface([in] DWORD_PTR dwUserID, [in] VMRALLOCATIONINFO* lpAllocInfo, [in] [out] DWORD* lpdwActualBuffers, [out] LPDIRECTDRAWSURFACE7 *lplpSurface);
    HRESULT FreeSurface([in] DWORD_PTR dwID);
    HRESULT PrepareSurface([in] DWORD_PTR dwUserID, [in] LPDIRECTDRAWSURFACE7 lpSurface, [in] DWORD dwSurfaceFlags);
    HRESULT AdviseNotify([in] IVMRSurfaceAllocatorNotify* lpIVMRSurfAllocNotify);
};

[
    local,
    object,
    uuid(aada05a8-5a4e-4729-af0b-cea27aed51e2),
    pointer_default(unique)
]
interface IVMRSurfaceAllocatorNotify : IUnknown
{
    HRESULT AdviseSurfaceAllocator([in] DWORD_PTR dwUserID, [in] IVMRSurfaceAllocator* lpIVRMSurfaceAllocator);
    HRESULT SetDDrawDevice([in] LPDIRECTDRAW7 lpDDrawDevice, [in] HMONITOR hMonitor);
    HRESULT ChangeDDrawDevice([in] LPDIRECTDRAW7 lpDDrawDevice, [in] HMONITOR hMonitor);
    HRESULT RestoreDDrawSurfaces();
    HRESULT NotifyEvent([in] LONG EventCode, [in] LONG_PTR Param1, [in] LONG_PTR Param2);
    HRESULT SetBorderColor([in] COLORREF clrBorder);
};

[
    local,
    object,
    uuid(0eb1088c-4dcd-46f0-878f-39dae86a51b7),
    pointer_default(unique)
]
interface IVMRWindowlessControl : IUnknown
{
    HRESULT GetNativeVideoSize([out] LONG* lpWidth, [out] LONG* lpHeight, [out] LONG* lpARWidth, [out] LONG* lpARHeight);
    HRESULT GetMinIdealVideoSize([out] LONG* lpWidth, [out] LONG* lpHeight);
    HRESULT GetMaxIdealVideoSize([out] LONG* lpWidth, [out] LONG* lpHeight);
    HRESULT SetVideoPosition([in] const LPRECT lpSRCRect, [in] const LPRECT lpDSTRect);
    HRESULT GetVideoPosition([out] LPRECT lpSRCRect, [out] LPRECT lpDSTRect);
    HRESULT GetAspectRatioMode([out] DWORD* lpAspectRatioMode);
    HRESULT SetAspectRatioMode([in] DWORD AspectRatioMode);
    HRESULT SetVideoClippingWindow([in] HWND hwnd);
    HRESULT RepaintVideo([in] HWND hwnd, [in] HDC hdc);
    HRESULT DisplayModeChanged();
    HRESULT GetCurrentImage([out] BYTE** lpDib);
    HRESULT SetBorderColor([in] COLORREF Clr);
    HRESULT GetBorderColor([out] COLORREF* lpClr);
    HRESULT SetColorKey([in] COLORREF Clr);
    HRESULT GetColorKey([out] COLORREF* lpClr);
};

[
    local,
    object,
    uuid(1c1a17b0-bed0-415d-974b-dc6696131599),
    pointer_default(unique)
]
interface IVMRMixerControl : IUnknown
{
    HRESULT SetAlpha([in] DWORD dwStreamID, [in] float Alpha);
    HRESULT GetAlpha([in] DWORD dwStreamID, [out] float* pAlpha);
    HRESULT SetZOrder([in] DWORD dwStreamID, [in] DWORD dwZ);
    HRESULT GetZOrder([in] DWORD dwStreamID, [out] DWORD* pZ);
    HRESULT SetOutputRect([in] DWORD dwStreamID, [in] const NORMALIZEDRECT *pRect);
    HRESULT GetOutputRect([in] DWORD dwStreamID, [out] NORMALIZEDRECT *pRect);
    HRESULT SetBackgroundClr([in] COLORREF ClrBkg);
    HRESULT GetBackgroundClr([in] COLORREF* lpClrBkg);
    HRESULT SetMixingPrefs([in] DWORD dwMixerPrefs);
    HRESULT GetMixingPrefs([out] DWORD* pdwMixerPrefs);
};

[
    object,
    local,
    uuid(9cf0b1b6-fbaa-4b7f-88cf-cf1f130a0dce),
    pointer_default(unique)
]
interface IVMRMonitorConfig : IUnknown
{
    HRESULT SetMonitor([in] const VMRGUID *pGUID);
    HRESULT GetMonitor([out] VMRGUID *pGUID);
    HRESULT SetDefaultMonitor([in] const VMRGUID *pGUID);
    HRESULT GetDefaultMonitor([out] VMRGUID *pGUID);
    HRESULT GetAvailableMonitors([out, size_is(dwMaxInfoArraySize)] VMRMONITORINFO* pInfo, [in] DWORD dwMaxInfoArraySize, [out] DWORD* pdwNumDevices);
};


[
    object,
    local,
    uuid(9e5530c5-7034-48b4-bb46-0b8a6efc8e36),
    pointer_default(unique)
]
interface IVMRFilterConfig : IUnknown
{
    HRESULT SetImageCompositor([in] IVMRImageCompositor* lpVMRImgCompositor);
    HRESULT SetNumberOfStreams([in] DWORD dwMaxStreams);
    HRESULT GetNumberOfStreams([out] DWORD* pdwMaxStreams);
    HRESULT SetRenderingPrefs([in] DWORD dwRenderFlags);
    HRESULT GetRenderingPrefs([out] DWORD* pdwRenderFlags);
    HRESULT SetRenderingMode([in] DWORD Mode);
    HRESULT GetRenderingMode([out] DWORD* pMode);
}


[
    object,
    local,
    uuid(ede80b5c-bad6-4623-b537-65586c9f8dfd),
    pointer_default(unique)
]
interface IVMRAspectRatioControl : IUnknown
{
    HRESULT GetAspectRatioMode([out] LPDWORD lpdwARMode);
    HRESULT SetAspectRatioMode([in] DWORD dwARMode);
}

[
    object,
    local,
    uuid(bb057577-0db8-4e6a-87a7-1a8c9a505a0f),
    pointer_default(unique)
]
interface IVMRDeinterlaceControl : IUnknown
{

    HRESULT GetNumberOfDeinterlaceModes([in] VMRVideoDesc* lpVideoDescription, [in] [out] LPDWORD lpdwNumDeinterlaceModes, [out] LPGUID lpDeinterlaceModes);
    HRESULT GetDeinterlaceModeCaps([in] LPGUID lpDeinterlaceMode, [in] VMRVideoDesc* lpVideoDescription, [in] [out] VMRDeinterlaceCaps* lpDeinterlaceCaps);
    HRESULT GetDeinterlaceMode([in] DWORD dwStreamID, [out] LPGUID lpDeinterlaceMode );
    HRESULT SetDeinterlaceMode([in] DWORD dwStreamID, [in] LPGUID lpDeinterlaceMode);
    HRESULT GetDeinterlacePrefs([out] LPDWORD lpdwDeinterlacePrefs);
    HRESULT SetDeinterlacePrefs([in] DWORD dwDeinterlacePrefs);
    HRESULT GetActualDeinterlaceMode([in] DWORD dwStreamID, [out] LPGUID lpDeinterlaceMode);
}

[
    object,
    local,
    uuid(1E673275-0257-40aa-AF20-7C608D4A0428),
    pointer_default(unique)
]
interface IVMRMixerBitmap : IUnknown
{
    HRESULT SetAlphaBitmap([in] const VMRALPHABITMAP *pBmpParms);
    HRESULT UpdateAlphaBitmapParameters([in] PVMRALPHABITMAP pBmpParms);
    HRESULT GetAlphaBitmapParameters([out] PVMRALPHABITMAP pBmpParms);
};

[
    local,
    object,
    uuid(7a4fb5af-479f-4074-bb40-ce6722e43c82),
    pointer_default(unique)
]
interface IVMRImageCompositor : IUnknown
{
    HRESULT InitCompositionTarget([in] IUnknown* pD3DDevice, [in] LPDIRECTDRAWSURFACE7 pddsRenderTarget);
    HRESULT TermCompositionTarget([in] IUnknown* pD3DDevice, [in] LPDIRECTDRAWSURFACE7 pddsRenderTarget);
    HRESULT SetStreamMediaType([in] DWORD dwStrmID, [in] AM_MEDIA_TYPE* pmt, [in] BOOL fTexture);
    HRESULT CompositeImage([in] IUnknown* pD3DDevice, [in] LPDIRECTDRAWSURFACE7 pddsRenderTarget, [in] AM_MEDIA_TYPE* pmtRenderTarget, [in] REFERENCE_TIME rtStart, [in] REFERENCE_TIME rtEnd, [in] DWORD dwClrBkGnd, [in] VMRVIDEOSTREAMINFO* pVideoStreamInfo, [in] UINT cStreams);
};

[
    object,
    local,
    uuid(058d1f11-2a54-4bef-bd54-df706626b727),
    pointer_default(unique)
]
interface IVMRVideoStreamControl: IUnknown
{
    HRESULT SetColorKey([in] LPDDCOLORKEY lpClrKey);
    HRESULT GetColorKey([out] LPDDCOLORKEY lpClrKey);
    HRESULT SetStreamActiveState([in] BOOL fActive);
    HRESULT GetStreamActiveState([out] BOOL* lpfActive);
};

[
    local,
    object,
    uuid(a9849bbe-9ec8-4263-b764-62730f0d15d0),
    pointer_default(unique)
]
interface IVMRSurface : IUnknown
{
    HRESULT IsSurfaceLocked();
    HRESULT LockSurface([out] BYTE** lpSurface);
    HRESULT UnlockSurface();
    HRESULT GetSurface([out] LPDIRECTDRAWSURFACE7 *lplpSurface);
};

[
    local,
    object,
    uuid(9f3a1c85-8555-49ba-935f-be5b5b29d178),
    pointer_default(unique)
]

interface IVMRImagePresenterConfig : IUnknown
{
    HRESULT SetRenderingPrefs([in] DWORD dwRenderFlags);
    HRESULT GetRenderingPrefs([out] DWORD* dwRenderFlags);
}

[
    local,
    object,
    uuid(e6f7ce40-4673-44f1-8f77-5499d68cb4ea),
    pointer_default(unique)
]

interface IVMRImagePresenterExclModeConfig : IVMRImagePresenterConfig
{
    HRESULT SetXlcModeDDObjAndPrimarySurface([in] LPDIRECTDRAW7 lpDDObj, [in] LPDIRECTDRAWSURFACE7 lpPrimarySurf);
    HRESULT GetXlcModeDDObjAndPrimarySurface([out] LPDIRECTDRAW7* lpDDObj, [out] LPDIRECTDRAWSURFACE7* lpPrimarySurf);
}

[
    local,
    object,
    uuid(aac18c18-e186-46d2-825d-a1f8dc8e395a),
    pointer_default(unique)
]
interface IVPManager : IUnknown
{
    HRESULT SetVideoPortIndex([in] DWORD dwVideoPortIndex);
    HRESULT GetVideoPortIndex([out] DWORD* pdwVideoPortIndex);
};