///////////////////////////////////////////////////////////////////////////////
//
// DXVA-HD IDL
//
// Contains interface definitions for DirectX Video Acceleration for HD API.
//
// Copyright (C) Microsoft Corporation
//
///////////////////////////////////////////////////////////////////////////////

import "unknwn.idl";


//
// TEMPORARY DECLARATIONS FOR MIDL COMPILER
//

cpp_quote("#if 0")

typedef DWORD IDirect3DDevice9Ex;
typedef DWORD IDirect3DSurface9;
typedef DWORD D3DCOLOR;
typedef DWORD D3DFORMAT;
typedef DWORD D3DPOOL;

cpp_quote("#endif // 0")


//
// DXVA-HD COM INTERFACE ID
//

cpp_quote("#if defined(_WIN32) && !defined(_NO_COM)")

cpp_quote("

DEFINE_GUID(IID_IDXVAHD_Device,         0x95f12dfd,0xd77e,0x49be,0x81,0x5f,0x57,0xd5,0x79,0x63,0x4d,0x6d);
DEFINE_GUID(IID_IDXVAHD_VideoProcessor, 0x95f4edf4,0x6e03,0x4cd7,0xbe,0x1b,0x30,0x75,0xd6,0x65,0xaa,0x52);

") // cpp_quote

cpp_quote("#endif")


//
// FORWARD DECLARATIONS
//

interface IDXVAHD_Device;
interface IDXVAHD_VideoProcessor;


//
// DXVA-HD API ENUMERATIONS
//

typedef enum _DXVAHD_FRAME_FORMAT
{
    DXVAHD_FRAME_FORMAT_PROGRESSIVE                   = 0,
    DXVAHD_FRAME_FORMAT_INTERLACED_TOP_FIELD_FIRST    = 1,
    DXVAHD_FRAME_FORMAT_INTERLACED_BOTTOM_FIELD_FIRST = 2
} DXVAHD_FRAME_FORMAT;

typedef enum _DXVAHD_DEVICE_USAGE
{
    DXVAHD_DEVICE_USAGE_PLAYBACK_NORMAL = 0,
    DXVAHD_DEVICE_USAGE_OPTIMAL_SPEED   = 1,
    DXVAHD_DEVICE_USAGE_OPTIMAL_QUALITY = 2
} DXVAHD_DEVICE_USAGE;

typedef enum _DXVAHD_SURFACE_TYPE
{
    DXVAHD_SURFACE_TYPE_VIDEO_INPUT         = 0,
    DXVAHD_SURFACE_TYPE_VIDEO_INPUT_PRIVATE = 1,
    DXVAHD_SURFACE_TYPE_VIDEO_OUTPUT        = 2
} DXVAHD_SURFACE_TYPE;

typedef enum _DXVAHD_DEVICE_TYPE
{
    DXVAHD_DEVICE_TYPE_HARDWARE  = 0,
    DXVAHD_DEVICE_TYPE_SOFTWARE  = 1,
    DXVAHD_DEVICE_TYPE_REFERENCE = 2,
    DXVAHD_DEVICE_TYPE_OTHER     = 3
} DXVAHD_DEVICE_TYPE;

typedef enum _DXVAHD_DEVICE_CAPS
{
    DXVAHD_DEVICE_CAPS_LINEAR_SPACE            = 0x1,
    DXVAHD_DEVICE_CAPS_xvYCC                   = 0x2,
    DXVAHD_DEVICE_CAPS_RGB_RANGE_CONVERSION    = 0x4,
    DXVAHD_DEVICE_CAPS_YCbCr_MATRIX_CONVERSION = 0x8
} DXVAHD_DEVICE_CAPS;

typedef enum _DXVAHD_FEATURE_CAPS
{
    DXVAHD_FEATURE_CAPS_ALPHA_FILL    = 0x1,
    DXVAHD_FEATURE_CAPS_CONSTRICTION  = 0x2,
    DXVAHD_FEATURE_CAPS_LUMA_KEY      = 0x4,
    DXVAHD_FEATURE_CAPS_ALPHA_PALETTE = 0x8
} DXVAHD_FEATURE_CAPS;

typedef enum _DXVAHD_FILTER_CAPS
{
    DXVAHD_FILTER_CAPS_BRIGHTNESS         = 0x1,
    DXVAHD_FILTER_CAPS_CONTRAST           = 0x2,
    DXVAHD_FILTER_CAPS_HUE                = 0x4,
    DXVAHD_FILTER_CAPS_SATURATION         = 0x8,
    DXVAHD_FILTER_CAPS_NOISE_REDUCTION    = 0x10,
    DXVAHD_FILTER_CAPS_EDGE_ENHANCEMENT   = 0x20,
    DXVAHD_FILTER_CAPS_ANAMORPHIC_SCALING = 0x40
} DXVAHD_FILTER_CAPS;

typedef enum _DXVAHD_INPUT_FORMAT_CAPS
{
    DXVAHD_INPUT_FORMAT_CAPS_RGB_INTERLACED     = 0x1,
    DXVAHD_INPUT_FORMAT_CAPS_RGB_PROCAMP        = 0x2,
    DXVAHD_INPUT_FORMAT_CAPS_RGB_LUMA_KEY       = 0x4,
    DXVAHD_INPUT_FORMAT_CAPS_PALETTE_INTERLACED = 0x8
} DXVAHD_INPUT_FORMAT_CAPS;

typedef enum _DXVAHD_PROCESSOR_CAPS
{
    DXVAHD_PROCESSOR_CAPS_DEINTERLACE_BLEND               = 0x1,
    DXVAHD_PROCESSOR_CAPS_DEINTERLACE_BOB                 = 0x2,
    DXVAHD_PROCESSOR_CAPS_DEINTERLACE_ADAPTIVE            = 0x4,
    DXVAHD_PROCESSOR_CAPS_DEINTERLACE_MOTION_COMPENSATION = 0x8,
    DXVAHD_PROCESSOR_CAPS_INVERSE_TELECINE                = 0x10,
    DXVAHD_PROCESSOR_CAPS_FRAME_RATE_CONVERSION           = 0x20
} DXVAHD_PROCESSOR_CAPS;

typedef enum _DXVAHD_ITELECINE_CAPS
{
    DXVAHD_ITELECINE_CAPS_32           = 0x1,
    DXVAHD_ITELECINE_CAPS_22           = 0x2,
    DXVAHD_ITELECINE_CAPS_2224         = 0x4,
    DXVAHD_ITELECINE_CAPS_2332         = 0x8,
    DXVAHD_ITELECINE_CAPS_32322        = 0x10,
    DXVAHD_ITELECINE_CAPS_55           = 0x20,
    DXVAHD_ITELECINE_CAPS_64           = 0x40,
    DXVAHD_ITELECINE_CAPS_87           = 0x80,
    DXVAHD_ITELECINE_CAPS_222222222223 = 0x100,
    DXVAHD_ITELECINE_CAPS_OTHER        = 0x80000000
} DXVAHD_ITELECINE_CAPS;

typedef enum _DXVAHD_FILTER
{
    DXVAHD_FILTER_BRIGHTNESS         = 0,
    DXVAHD_FILTER_CONTRAST           = 1,
    DXVAHD_FILTER_HUE                = 2,
    DXVAHD_FILTER_SATURATION         = 3,
    DXVAHD_FILTER_NOISE_REDUCTION    = 4,
    DXVAHD_FILTER_EDGE_ENHANCEMENT   = 5,
    DXVAHD_FILTER_ANAMORPHIC_SCALING = 6
} DXVAHD_FILTER;

typedef enum _DXVAHD_BLT_STATE
{
    DXVAHD_BLT_STATE_TARGET_RECT        = 0,
    DXVAHD_BLT_STATE_BACKGROUND_COLOR   = 1,
    DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE = 2,
    DXVAHD_BLT_STATE_ALPHA_FILL         = 3,
    DXVAHD_BLT_STATE_CONSTRICTION       = 4,
    DXVAHD_BLT_STATE_PRIVATE            = 1000
} DXVAHD_BLT_STATE;

typedef enum _DXVAHD_ALPHA_FILL_MODE
{
    DXVAHD_ALPHA_FILL_MODE_OPAQUE        = 0,
    DXVAHD_ALPHA_FILL_MODE_BACKGROUND    = 1,
    DXVAHD_ALPHA_FILL_MODE_DESTINATION   = 2,
    DXVAHD_ALPHA_FILL_MODE_SOURCE_STREAM = 3
} DXVAHD_ALPHA_FILL_MODE;

typedef enum _DXVAHD_STREAM_STATE
{
    DXVAHD_STREAM_STATE_D3DFORMAT                 = 0,
    DXVAHD_STREAM_STATE_FRAME_FORMAT              = 1,
    DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE         = 2,
    DXVAHD_STREAM_STATE_OUTPUT_RATE               = 3,
    DXVAHD_STREAM_STATE_SOURCE_RECT               = 4,
    DXVAHD_STREAM_STATE_DESTINATION_RECT          = 5,
    DXVAHD_STREAM_STATE_ALPHA                     = 6,
    DXVAHD_STREAM_STATE_PALETTE                   = 7,
    DXVAHD_STREAM_STATE_LUMA_KEY                  = 8,
    DXVAHD_STREAM_STATE_ASPECT_RATIO              = 9,
    DXVAHD_STREAM_STATE_FILTER_BRIGHTNESS         = 100,
    DXVAHD_STREAM_STATE_FILTER_CONTRAST           = 101,
    DXVAHD_STREAM_STATE_FILTER_HUE                = 102,
    DXVAHD_STREAM_STATE_FILTER_SATURATION         = 103,
    DXVAHD_STREAM_STATE_FILTER_NOISE_REDUCTION    = 104,
    DXVAHD_STREAM_STATE_FILTER_EDGE_ENHANCEMENT   = 105,
    DXVAHD_STREAM_STATE_FILTER_ANAMORPHIC_SCALING = 106,
    DXVAHD_STREAM_STATE_PRIVATE                   = 1000
} DXVAHD_STREAM_STATE;

typedef enum _DXVAHD_OUTPUT_RATE
{
    DXVAHD_OUTPUT_RATE_NORMAL = 0,
    DXVAHD_OUTPUT_RATE_HALF   = 1,
    DXVAHD_OUTPUT_RATE_CUSTOM = 2
} DXVAHD_OUTPUT_RATE;


//
// DXVA-HD API STRUCTURES
//

typedef struct _DXVAHD_RATIONAL
{
    UINT Numerator;
    UINT Denominator;
} DXVAHD_RATIONAL;

typedef struct _DXVAHD_COLOR_RGBA
{
    FLOAT R;
    FLOAT G;
    FLOAT B;
    FLOAT A;
} DXVAHD_COLOR_RGBA;

typedef struct _DXVAHD_COLOR_YCbCrA
{
    FLOAT Y;
    FLOAT Cb;
    FLOAT Cr;
    FLOAT A;
} DXVAHD_COLOR_YCbCrA;

typedef union _DXVAHD_COLOR
{
    DXVAHD_COLOR_RGBA   RGB;
    DXVAHD_COLOR_YCbCrA YCbCr;
} DXVAHD_COLOR;

typedef struct _DXVAHD_CONTENT_DESC
{
    DXVAHD_FRAME_FORMAT InputFrameFormat;
    DXVAHD_RATIONAL     InputFrameRate;
    UINT                InputWidth;
    UINT                InputHeight;
    DXVAHD_RATIONAL     OutputFrameRate;
    UINT                OutputWidth;
    UINT                OutputHeight;
} DXVAHD_CONTENT_DESC;

typedef struct _DXVAHD_VPDEVCAPS
{
    DXVAHD_DEVICE_TYPE DeviceType;
    UINT               DeviceCaps;          // DXVAHD_DEVICE_CAPS
    UINT               FeatureCaps;         // DXVAHD_FEATURE_CAPS
    UINT               FilterCaps;          // DXVAHD_FILTER_CAPS
    UINT               InputFormatCaps;     // DXVAHD_INPUT_FORMAT_CAPS
    D3DPOOL            InputPool;
    UINT               OutputFormatCount;
    UINT               InputFormatCount;
    UINT               VideoProcessorCount;
    UINT               MaxInputStreams;
    UINT               MaxStreamStates;
} DXVAHD_VPDEVCAPS;

typedef struct _DXVAHD_VPCAPS
{
    GUID VPGuid;
    UINT PastFrames;
    UINT FutureFrames;
    UINT ProcessorCaps;   // DXVAHD_PROCESSOR_CAPS
    UINT ITelecineCaps;   // DXVAHD_ITELECINE_CAPS
    UINT CustomRateCount;
} DXVAHD_VPCAPS;

typedef struct _DXVAHD_CUSTOM_RATE_DATA
{
    DXVAHD_RATIONAL CustomRate;
    UINT            OutputFrames;
    BOOL            InputInterlaced;
    UINT            InputFramesOrFields;
} DXVAHD_CUSTOM_RATE_DATA;

typedef struct _DXVAHD_FILTER_RANGE_DATA
{
    INT   Minimum;
    INT   Maximum;
    INT   Default;
    FLOAT Multiplier;
} DXVAHD_FILTER_RANGE_DATA;

typedef struct _DXVAHD_BLT_STATE_TARGET_RECT_DATA
{
    BOOL Enable;
    RECT TargetRect;
} DXVAHD_BLT_STATE_TARGET_RECT_DATA;

typedef struct _DXVAHD_BLT_STATE_BACKGROUND_COLOR_DATA
{
    BOOL         YCbCr;
    DXVAHD_COLOR BackgroundColor;
} DXVAHD_BLT_STATE_BACKGROUND_COLOR_DATA;

typedef struct _DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA
{
    union
    {
        struct
        {
            UINT Usage        :  1; // 0:Playback,     1:Processing
            UINT RGB_Range    :  1; // 0:Full(0-255),  1:Limited(16-235)
            UINT YCbCr_Matrix :  1; // 0:BT.601(SDTV), 1:BT.709(HDTV)
            UINT YCbCr_xvYCC  :  1; // 0:Conventional, 1:Extended(xvYCC)
            UINT Reserved     : 28;
        };

        UINT Value;
    };
} DXVAHD_BLT_STATE_OUTPUT_COLOR_SPACE_DATA;

typedef struct _DXVAHD_BLT_STATE_ALPHA_FILL_DATA
{
    DXVAHD_ALPHA_FILL_MODE Mode;
    UINT                   StreamNumber;
} DXVAHD_BLT_STATE_ALPHA_FILL_DATA;

typedef struct _DXVAHD_BLT_STATE_CONSTRICTION_DATA
{
    BOOL Enable;
    SIZE Size;
} DXVAHD_BLT_STATE_CONSTRICTION_DATA;

typedef struct _DXVAHD_BLT_STATE_PRIVATE_DATA
{
    GUID  Guid;
    UINT  DataSize;
    void* pData;
} DXVAHD_BLT_STATE_PRIVATE_DATA;

typedef struct _DXVAHD_STREAM_STATE_D3DFORMAT_DATA
{
    D3DFORMAT Format;
} DXVAHD_STREAM_STATE_D3DFORMAT_DATA;

typedef struct _DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA
{
    DXVAHD_FRAME_FORMAT FrameFormat;
} DXVAHD_STREAM_STATE_FRAME_FORMAT_DATA;

typedef struct _DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA
{
    union
    {
        struct
        {
            UINT Type         :  1; // 0:Video,        1:Graphics
            UINT RGB_Range    :  1; // 0:Full(0-255),  1:Limited(16-235)
            UINT YCbCr_Matrix :  1; // 0:BT.601(SDTV), 1:BT.709(HDTV)
            UINT YCbCr_xvYCC  :  1; // 0:Conventional, 1:Extended(xvYCC)
            UINT Reserved     : 28;
        };

        UINT Value;
    };
} DXVAHD_STREAM_STATE_INPUT_COLOR_SPACE_DATA;

typedef struct _DXVAHD_STREAM_STATE_OUTPUT_RATE_DATA
{
    BOOL               RepeatFrame;
    DXVAHD_OUTPUT_RATE OutputRate;
    DXVAHD_RATIONAL    CustomRate;
} DXVAHD_STREAM_STATE_OUTPUT_RATE_DATA;

typedef struct _DXVAHD_STREAM_STATE_SOURCE_RECT_DATA
{
    BOOL Enable;
    RECT SourceRect;
} DXVAHD_STREAM_STATE_SOURCE_RECT_DATA;

typedef struct _DXVAHD_STREAM_STATE_DESTINATION_RECT_DATA
{
    BOOL Enable;
    RECT DestinationRect;
} DXVAHD_STREAM_STATE_DESTINATION_RECT_DATA;

typedef struct _DXVAHD_STREAM_STATE_ALPHA_DATA
{
    BOOL  Enable;
    FLOAT Alpha;
} DXVAHD_STREAM_STATE_ALPHA_DATA;

typedef struct _DXVAHD_STREAM_STATE_PALETTE_DATA
{
    UINT      Count;
    D3DCOLOR* pEntries;
} DXVAHD_STREAM_STATE_PALETTE_DATA;

typedef struct _DXVAHD_STREAM_STATE_LUMA_KEY_DATA
{
    BOOL  Enable;
    FLOAT Lower;
    FLOAT Upper;
} DXVAHD_STREAM_STATE_LUMA_KEY_DATA;

typedef struct _DXVAHD_STREAM_STATE_ASPECT_RATIO_DATA
{
    BOOL            Enable;
    DXVAHD_RATIONAL SourceAspectRatio;
    DXVAHD_RATIONAL DestinationAspectRatio;
} DXVAHD_STREAM_STATE_ASPECT_RATIO_DATA;

typedef struct _DXVAHD_STREAM_STATE_FILTER_DATA
{
    BOOL Enable;
    INT  Level;
} DXVAHD_STREAM_STATE_FILTER_DATA;

typedef struct _DXVAHD_STREAM_STATE_PRIVATE_DATA
{
    GUID  Guid;
    UINT  DataSize;
    void* pData;
} DXVAHD_STREAM_STATE_PRIVATE_DATA;

typedef struct _DXVAHD_STREAM_DATA
{
    BOOL                Enable;
    UINT                OutputIndex;
    UINT                InputFrameOrField;
    UINT                PastFrames;
    UINT                FutureFrames;
    IDirect3DSurface9** ppPastSurfaces;
    IDirect3DSurface9*  pInputSurface;
    IDirect3DSurface9** ppFutureSurfaces;
} DXVAHD_STREAM_DATA;


//
// PRIVATE STATES
//

cpp_quote("

DEFINE_GUID(DXVAHD_STREAM_STATE_PRIVATE_IVTC, 0x9c601e3c,0x0f33,0x414c,0xa7,0x39,0x99,0x54,0x0e,0xe4,0x2d,0xa5);

") // cpp_quote

typedef struct _DXVAHD_STREAM_STATE_PRIVATE_IVTC_DATA
{
    BOOL Enable;
    UINT ITelecineFlags; // DXVAHD_ITELECINE_CAPS
    UINT Frames;
    UINT InputField;
} DXVAHD_STREAM_STATE_PRIVATE_IVTC_DATA;


//
// IDXVAHD_Device INTERFACE
//

[
    object,
    uuid(95f12dfd-d77e-49be-815f-57d579634d6d),
    helpstring("DXVA-HD Device Interface"),
    local
]
interface IDXVAHD_Device : IUnknown
{
    HRESULT
    CreateVideoSurface(
        [in, annotation("__in")] UINT Width,
        [in, annotation("__in")] UINT Height,
        [in, annotation("__in")] D3DFORMAT Format,
        [in, annotation("__in")] D3DPOOL Pool,
        [in, annotation("__in")] DWORD Usage,
        [in, annotation("__in")] DXVAHD_SURFACE_TYPE Type,
        [in, annotation("__in")] UINT NumSurfaces,
        [out, size_is(NumSurfaces), annotation("__out_ecount(NumSurfaces)")] IDirect3DSurface9** ppSurfaces,
        [in, out, annotation("__inout_opt")] HANDLE* pSharedHandle
        );

    HRESULT
    GetVideoProcessorDeviceCaps(
        [out, annotation("__out")] DXVAHD_VPDEVCAPS* pCaps
        );

    HRESULT
    GetVideoProcessorOutputFormats(
        [in, annotation("__in")] UINT Count,
        [out, size_is(Count), annotation("__out_ecount(Count)")] D3DFORMAT* pFormats
        );

    HRESULT
    GetVideoProcessorInputFormats(
        [in, annotation("__in")] UINT Count,
        [out, size_is(Count), annotation("__out_ecount(Count)")] D3DFORMAT* pFormats
        );

    HRESULT
    GetVideoProcessorCaps(
        [in, annotation("__in")] UINT Count,
        [out, size_is(Count), annotation("__out_ecount(Count)")] DXVAHD_VPCAPS* pCaps
        );

    HRESULT
    GetVideoProcessorCustomRates(
        [in, annotation("__in")] const GUID* pVPGuid,
        [in, annotation("__in")] UINT Count,
        [out, size_is(Count), annotation("__out_ecount(Count)")] DXVAHD_CUSTOM_RATE_DATA* pRates
        );

    HRESULT
    GetVideoProcessorFilterRange(
        [in, annotation("__in")] DXVAHD_FILTER Filter,
        [out, annotation("__out")] DXVAHD_FILTER_RANGE_DATA* pRange
        );

    HRESULT
    CreateVideoProcessor(
        [in, annotation("__in")] const GUID* pVPGuid,
        [out, annotation("__deref_out")] IDXVAHD_VideoProcessor** ppVideoProcessor
        );
};


//
// IDXVAHD_VideoProcessor INTERFACE
//

[
    object,
    uuid(95f4edf4-6e03-4cd7-be1b-3075d665aa52),
    helpstring("DXVA-HD Video Processor Interface"),
    local
]
interface IDXVAHD_VideoProcessor : IUnknown
{
    HRESULT
    SetVideoProcessBltState(
        [in, annotation("__in")] DXVAHD_BLT_STATE State,
        [in, annotation("__in")] UINT DataSize,
        [in, annotation("__in_bcount(DataSize)")] const void* pData
        );

    HRESULT
    GetVideoProcessBltState(
        [in, annotation("__in")] DXVAHD_BLT_STATE State,
        [in, annotation("__in")] UINT DataSize,
        [out, annotation("__inout_bcount(DataSize)")] void* pData
        );

    HRESULT
    SetVideoProcessStreamState(
        [in, annotation("__in")] UINT StreamNumber,
        [in, annotation("__in")] DXVAHD_STREAM_STATE State,
        [in, annotation("__in")] UINT DataSize,
        [in, annotation("__in_bcount(DataSize)")] const void* pData
        );

    HRESULT
    GetVideoProcessStreamState(
        [in, annotation("__in")] UINT StreamNumber,
        [in, annotation("__in")] DXVAHD_STREAM_STATE State,
        [in, annotation("__in")] UINT DataSize,
        [out, annotation("__inout_bcount(DataSize)")] void* pData
        );

    HRESULT
    VideoProcessBltHD(
        [in, annotation("__in")] IDirect3DSurface9* pOutputSurface,
        [in, annotation("__in")] UINT OutputFrame,
        [in, annotation("__in")] UINT StreamCount,
        [in, size_is(StreamCount), annotation("__in_ecount(StreamCount)")] const DXVAHD_STREAM_DATA* pStreams
        );
};


//
// DXVA-HD SOFTWARE PLUGIN
//

cpp_quote("

typedef HRESULT (CALLBACK* PDXVAHDSW_CreateDevice)(
    __in IDirect3DDevice9Ex* pD3DDevice,
    __out HANDLE* phDevice
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_ProposeVideoPrivateFormat)(
    __in HANDLE hDevice,
    __inout D3DFORMAT* pFormat
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessorDeviceCaps)(
    __in HANDLE hDevice,
    __in const DXVAHD_CONTENT_DESC* pContentDesc,
    __in DXVAHD_DEVICE_USAGE Usage,
    __out DXVAHD_VPDEVCAPS* pCaps
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessorOutputFormats)(
    __in HANDLE hDevice,
    __in const DXVAHD_CONTENT_DESC* pContentDesc,
    __in DXVAHD_DEVICE_USAGE Usage,
    __in UINT Count,
    __out_ecount(Count) D3DFORMAT* pFormats
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessorInputFormats)(
    __in HANDLE hDevice,
    __in const DXVAHD_CONTENT_DESC* pContentDesc,
    __in DXVAHD_DEVICE_USAGE Usage,
    __in UINT Count,
    __out_ecount(Count) D3DFORMAT* pFormats
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessorCaps)(
    __in HANDLE hDevice,
    __in const DXVAHD_CONTENT_DESC* pContentDesc,
    __in DXVAHD_DEVICE_USAGE Usage,
    __in UINT Count,
    __out_ecount(Count) DXVAHD_VPCAPS* pCaps
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessorCustomRates)(
    __in HANDLE hDevice,
    __in const GUID* pVPGuid,
    __in UINT Count,
    __out_ecount(Count) DXVAHD_CUSTOM_RATE_DATA* pRates
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessorFilterRange)(
    __in HANDLE hDevice,
    __in DXVAHD_FILTER Filter,
    __out DXVAHD_FILTER_RANGE_DATA* pRange
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_DestroyDevice)(
    __in HANDLE hDevice
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_CreateVideoProcessor)(
    __in HANDLE hDevice,
    __in const GUID* pVPGuid,
    __out HANDLE* phVideoProcessor
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_SetVideoProcessBltState)(
    __in HANDLE hVideoProcessor,
    __in DXVAHD_BLT_STATE State,
    __in UINT DataSize,
    __in_bcount(DataSize) const void* pData
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessBltStatePrivate)(
    __in HANDLE hVideoProcessor,
    __inout DXVAHD_BLT_STATE_PRIVATE_DATA* pData
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_SetVideoProcessStreamState)(
    __in HANDLE hVideoProcessor,
    __in UINT StreamNumber,
    __in DXVAHD_STREAM_STATE State,
    __in UINT DataSize,
    __in_bcount(DataSize) const void* pData
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_GetVideoProcessStreamStatePrivate)(
    __in HANDLE hVideoProcessor,
    __in UINT StreamNumber,
    __inout DXVAHD_STREAM_STATE_PRIVATE_DATA* pData
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_VideoProcessBltHD)(
    __in HANDLE hVideoProcessor,
    __in IDirect3DSurface9* pOutputSurface,
    __in UINT OutputFrame,
    __in UINT StreamCount,
    __in_ecount(StreamCount) const DXVAHD_STREAM_DATA* pStreams
    );

typedef HRESULT (CALLBACK* PDXVAHDSW_DestroyVideoProcessor)(
    __in HANDLE hVideoProcessor
    );

typedef struct _DXVAHDSW_CALLBACKS
{
    PDXVAHDSW_CreateDevice                      CreateDevice;
    PDXVAHDSW_ProposeVideoPrivateFormat         ProposeVideoPrivateFormat;
    PDXVAHDSW_GetVideoProcessorDeviceCaps       GetVideoProcessorDeviceCaps;
    PDXVAHDSW_GetVideoProcessorOutputFormats    GetVideoProcessorOutputFormats;
    PDXVAHDSW_GetVideoProcessorInputFormats     GetVideoProcessorInputFormats;
    PDXVAHDSW_GetVideoProcessorCaps             GetVideoProcessorCaps;
    PDXVAHDSW_GetVideoProcessorCustomRates      GetVideoProcessorCustomRates;
    PDXVAHDSW_GetVideoProcessorFilterRange      GetVideoProcessorFilterRange;
    PDXVAHDSW_DestroyDevice                     DestroyDevice;
    PDXVAHDSW_CreateVideoProcessor              CreateVideoProcessor;
    PDXVAHDSW_SetVideoProcessBltState           SetVideoProcessBltState;
    PDXVAHDSW_GetVideoProcessBltStatePrivate    GetVideoProcessBltStatePrivate;
    PDXVAHDSW_SetVideoProcessStreamState        SetVideoProcessStreamState;
    PDXVAHDSW_GetVideoProcessStreamStatePrivate GetVideoProcessStreamStatePrivate;
    PDXVAHDSW_VideoProcessBltHD                 VideoProcessBltHD;
    PDXVAHDSW_DestroyVideoProcessor             DestroyVideoProcessor;
} DXVAHDSW_CALLBACKS;

typedef HRESULT (CALLBACK* PDXVAHDSW_Plugin)(
    __in UINT Size,
    __out_bcount(Size) void* pCallbacks
    );

") // cpp_quote


//
// DXVA-HD API ETW
//

cpp_quote("

DEFINE_GUID(DXVAHDControlGuid, 0xa0386e75,0xf70c,0x464c,0xa9,0xce,0x33,0xc4,0x4e,0x09,0x16,0x23); // DXVA2Trace_Control

DEFINE_GUID(DXVAHDETWGUID_CREATEVIDEOPROCESSOR,     0x681e3d1e,0x5674,0x4fb3,0xa5,0x03,0x2f,0x20,0x55,0xe9,0x1f,0x60);
DEFINE_GUID(DXVAHDETWGUID_VIDEOPROCESSBLTSTATE,     0x76c94b5a,0x193f,0x4692,0x94,0x84,0xa4,0xd9,0x99,0xda,0x81,0xa8);
DEFINE_GUID(DXVAHDETWGUID_VIDEOPROCESSSTREAMSTATE,  0x262c0b02,0x209d,0x47ed,0x94,0xd8,0x82,0xae,0x02,0xb8,0x4a,0xa7);
DEFINE_GUID(DXVAHDETWGUID_VIDEOPROCESSBLTHD,        0xbef3d435,0x78c7,0x4de3,0x97,0x07,0xcd,0x1b,0x08,0x3b,0x16,0x0a);
DEFINE_GUID(DXVAHDETWGUID_VIDEOPROCESSBLTHD_STREAM, 0x27ae473e,0xa5fc,0x4be5,0xb4,0xe3,0xf2,0x49,0x94,0xd3,0xc4,0x95);
DEFINE_GUID(DXVAHDETWGUID_DESTROYVIDEOPROCESSOR,    0xf943f0a0,0x3f16,0x43e0,0x80,0x93,0x10,0x5a,0x98,0x6a,0xa5,0xf1);

") // cpp_quote

typedef struct _DXVAHDETW_CREATEVIDEOPROCESSOR
{
    ULONGLONG pObject;
    ULONGLONG pD3D9Ex;
    GUID      VPGuid;
} DXVAHDETW_CREATEVIDEOPROCESSOR;

typedef struct _DXVAHDETW_VIDEOPROCESSBLTSTATE
{
    ULONGLONG        pObject;
    DXVAHD_BLT_STATE State;
    UINT             DataSize;
    BOOL             SetState;
} DXVAHDETW_VIDEOPROCESSBLTSTATE;

typedef struct _DXVAHDETW_VIDEOPROCESSSTREAMSTATE
{
    ULONGLONG           pObject;
    UINT                StreamNumber;
    DXVAHD_STREAM_STATE State;
    UINT                DataSize;
    BOOL                SetState;
} DXVAHDETW_VIDEOPROCESSSTREAMSTATE;

typedef struct _DXVAHDETW_VIDEOPROCESSBLTHD
{
    ULONGLONG pObject;
    ULONGLONG pOutputSurface;
    RECT      TargetRect;
    D3DFORMAT OutputFormat;
    UINT      ColorSpace;
    UINT      OutputFrame;
    UINT      StreamCount;
    BOOL      Enter;
} DXVAHDETW_VIDEOPROCESSBLTHD;

typedef struct _DXVAHDETW_VIDEOPROCESSBLTHD_STREAM
{
    ULONGLONG           pObject;
    ULONGLONG           pInputSurface;
    RECT                SourceRect;
    RECT                DestinationRect;
    D3DFORMAT           InputFormat;
    DXVAHD_FRAME_FORMAT FrameFormat;
    UINT                ColorSpace;
    UINT                StreamNumber;
    UINT                OutputIndex;
    UINT                InputFrameOrField;
    UINT                PastFrames;
    UINT                FutureFrames;
} DXVAHDETW_VIDEOPROCESSBLTHD_STREAM;

typedef struct _DXVAHDETW_DESTROYVIDEOPROCESSOR
{
    ULONGLONG pObject;
} DXVAHDETW_DESTROYVIDEOPROCESSOR;


//
// DXVA-HD API FUNCTIONS
//

cpp_quote("

HRESULT WINAPI
DXVAHD_CreateDevice(
    __in IDirect3DDevice9Ex* pD3DDevice,
    __in const DXVAHD_CONTENT_DESC* pContentDesc,
    __in DXVAHD_DEVICE_USAGE Usage,
    __in_opt PDXVAHDSW_Plugin pPlugin,
    __deref_out IDXVAHD_Device** ppDevice
    );

typedef HRESULT (WINAPI* PDXVAHD_CreateDevice)(
    __in IDirect3DDevice9Ex* pD3DDevice,
    __in const DXVAHD_CONTENT_DESC* pContentDesc,
    __in DXVAHD_DEVICE_USAGE Usage,
    __in_opt PDXVAHDSW_Plugin pPlugin,
    __deref_out IDXVAHD_Device** ppDevice
    );

") // cpp_quote


