winapi_ui_automation/um/
dxva2api.rs

1// Licensed under the Apache License, Version 2.0
2// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4// All files in the project carrying such notice may not be copied, modified, or distributed
5// except according to those terms.
6use ctypes::{c_float, c_void};
7use shared::basetsd::UINT64;
8use shared::d3d9::{IDirect3DDevice9, IDirect3DSurface9};
9use shared::d3d9types::{D3DFORMAT, D3DPOOL};
10use shared::guiddef::{GUID, REFGUID, REFIID};
11use shared::minwindef::{BOOL, DWORD, FLOAT, HIWORD, LOWORD, UCHAR, UINT, USHORT};
12use shared::windef::{RECT, SIZE};
13use um::unknwnbase::{IUnknown, IUnknownVtbl};
14use um::winnt::{HANDLE, HRESULT, LONG, LONGLONG, PVOID, SHORT};
15DEFINE_GUID!{DXVA2_ModeMPEG2_MoComp,
16    0xe6a9f44b, 0x61b0, 0x4563, 0x9e, 0xa4, 0x63, 0xd2, 0xa3, 0xc6, 0xfe, 0x66}
17DEFINE_GUID!{DXVA2_ModeMPEG2_IDCT,
18    0xbf22ad00, 0x03ea, 0x4690, 0x80, 0x77, 0x47, 0x33, 0x46, 0x20, 0x9b, 0x7e}
19DEFINE_GUID!{DXVA2_ModeMPEG2_VLD,
20    0xee27417f, 0x5e28, 0x4e65, 0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9}
21DEFINE_GUID!{DXVA2_ModeMPEG1_VLD,
22    0x6f3ec719, 0x3735, 0x42cc, 0x80, 0x63, 0x65, 0xcc, 0x3c, 0xb3, 0x66, 0x16}
23DEFINE_GUID!{DXVA2_ModeMPEG2and1_VLD,
24    0x86695f12, 0x340e, 0x4f04, 0x9f, 0xd3, 0x92, 0x53, 0xdd, 0x32, 0x74, 0x60}
25DEFINE_GUID!{DXVA2_ModeH264_A,
26    0x1b81be64, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
27DEFINE_GUID!{DXVA2_ModeH264_B,
28    0x1b81be65, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
29DEFINE_GUID!{DXVA2_ModeH264_C,
30    0x1b81be66, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
31DEFINE_GUID!{DXVA2_ModeH264_D,
32    0x1b81be67, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
33DEFINE_GUID!{DXVA2_ModeH264_E,
34    0x1b81be68, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
35DEFINE_GUID!{DXVA2_ModeH264_F,
36    0x1b81be69, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
37DEFINE_GUID!{DXVA2_ModeH264_VLD_WithFMOASO_NoFGT,
38    0xd5f04ff9, 0x3418, 0x45d8, 0x95, 0x61, 0x32, 0xa7, 0x6a, 0xae, 0x2d, 0xdd}
39DEFINE_GUID!{DXVA2_ModeH264_VLD_Stereo_Progressive_NoFGT,
40    0xd79be8da, 0x0cf1, 0x4c81, 0xb8, 0x2a, 0x69, 0xa4, 0xe2, 0x36, 0xf4, 0x3d}
41DEFINE_GUID!{DXVA2_ModeH264_VLD_Stereo_NoFGT,
42    0xf9aaccbb, 0xc2b6, 0x4cfc, 0x87, 0x79, 0x57, 0x07, 0xb1, 0x76, 0x05, 0x52}
43DEFINE_GUID!{DXVA2_ModeH264_VLD_Multiview_NoFGT,
44    0x705b9d82, 0x76cf, 0x49d6, 0xb7, 0xe6, 0xac, 0x88, 0x72, 0xdb, 0x01, 0x3c}
45DEFINE_GUID!{DXVA2_ModeWMV8_A,
46    0x1b81be80, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
47DEFINE_GUID!{DXVA2_ModeWMV8_B,
48    0x1b81be81, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
49DEFINE_GUID!{DXVA2_ModeWMV9_A,
50    0x1b81be90, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
51DEFINE_GUID!{DXVA2_ModeWMV9_B,
52    0x1b81be91, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
53DEFINE_GUID!{DXVA2_ModeWMV9_C,
54    0x1b81be94, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
55DEFINE_GUID!{DXVA2_ModeVC1_A,
56    0x1b81bea0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
57DEFINE_GUID!{DXVA2_ModeVC1_B,
58    0x1b81bea1, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
59DEFINE_GUID!{DXVA2_ModeVC1_C,
60    0x1b81bea2, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
61DEFINE_GUID!{DXVA2_ModeVC1_D,
62    0x1b81bea3, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
63DEFINE_GUID!{DXVA2_ModeVC1_D2010,
64    0x1b81bea4, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
65DEFINE_GUID!{DXVA2_NoEncrypt,
66    0x1b81bed0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5}
67DEFINE_GUID!{DXVA2_VideoProcProgressiveDevice,
68    0x5a54a0c9, 0xc7ec, 0x4bd9, 0x8e, 0xde, 0xf3, 0xc7, 0x5d, 0xc4, 0x39, 0x3b}
69DEFINE_GUID!{DXVA2_VideoProcBobDevice,
70    0x335aa36e, 0x7884, 0x43a4, 0x9c, 0x91, 0x7f, 0x87, 0xfa, 0xf3, 0xe3, 0x7e}
71DEFINE_GUID!{DXVA2_VideoProcSoftwareDevice,
72    0x4553d47f, 0xee7e, 0x4e3f, 0x94, 0x75, 0xdb, 0xf1, 0x37, 0x6c, 0x48, 0x10}
73DEFINE_GUID!{DXVA2_ModeMPEG4pt2_VLD_Simple,
74    0xefd64d74, 0xc9e8, 0x41d7, 0xa5, 0xe9, 0xe9, 0xb0, 0xe3, 0x9f, 0xa3, 0x19}
75DEFINE_GUID!{DXVA2_ModeMPEG4pt2_VLD_AdvSimple_NoGMC,
76    0xed418a9f, 0x010d, 0x4eda, 0x9a, 0xe3, 0x9a, 0x65, 0x35, 0x8d, 0x8d, 0x2e}
77DEFINE_GUID!{DXVA2_ModeMPEG4pt2_VLD_AdvSimple_GMC,
78    0xab998b5b, 0x4258, 0x44a9, 0x9f, 0xeb, 0x94, 0xe5, 0x97, 0xa6, 0xba, 0xae}
79DEFINE_GUID!{DXVA2_ModeHEVC_VLD_Main,
80    0x5b11d51b, 0x2f4c, 0x4452, 0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0}
81DEFINE_GUID!{DXVA2_ModeHEVC_VLD_Main10,
82    0x107af0e0, 0xef1a, 0x4d19, 0xab, 0xa8, 0x67, 0xa1, 0x63, 0x07, 0x3d, 0x13}
83DEFINE_GUID!{DXVA2_ModeVP9_VLD_Profile0,
84    0x463707f8, 0xa1d0, 0x4585, 0x87, 0x6d, 0x83, 0xaa, 0x6d, 0x60, 0xb8, 0x9e}
85DEFINE_GUID!{DXVA2_ModeVP9_VLD_10bit_Profile2,
86    0xa4c749ef, 0x6ecf, 0x48aa, 0x84, 0x48, 0x50, 0xa7, 0xa1, 0x16, 0x5f, 0xf7}
87DEFINE_GUID!{DXVA2_ModeVP8_VLD,
88    0x90b899ea, 0x3a62, 0x4705, 0x88, 0xb3, 0x8d, 0xf0, 0x4b, 0x27, 0x44, 0xe7}
89pub const DXVA2_ModeMPEG2_MOCOMP: GUID = DXVA2_ModeMPEG2_MoComp;
90pub const DXVA2_ModeWMV8_PostProc: GUID = DXVA2_ModeWMV8_A;
91pub const DXVA2_ModeWMV8_MoComp: GUID = DXVA2_ModeWMV8_B;
92pub const DXVA2_ModeWMV9_PostProc: GUID = DXVA2_ModeWMV9_A;
93pub const DXVA2_ModeWMV9_MoComp: GUID = DXVA2_ModeWMV9_B;
94pub const DXVA2_ModeWMV9_IDCT: GUID = DXVA2_ModeWMV9_C;
95pub const DXVA2_ModeVC1_PostProc: GUID = DXVA2_ModeVC1_A;
96pub const DXVA2_ModeVC1_MoComp: GUID = DXVA2_ModeVC1_B;
97pub const DXVA2_ModeVC1_IDCT: GUID = DXVA2_ModeVC1_C;
98pub const DXVA2_ModeVC1_VLD: GUID = DXVA2_ModeVC1_D;
99pub const DXVA2_ModeH264_MoComp_NoFGT: GUID = DXVA2_ModeH264_A;
100pub const DXVA2_ModeH264_MoComp_FGT: GUID = DXVA2_ModeH264_B;
101pub const DXVA2_ModeH264_IDCT_NoFGT: GUID = DXVA2_ModeH264_C;
102pub const DXVA2_ModeH264_IDCT_FGT: GUID = DXVA2_ModeH264_D;
103pub const DXVA2_ModeH264_VLD_NoFGT: GUID = DXVA2_ModeH264_E;
104pub const DXVA2_ModeH264_VLD_FGT: GUID = DXVA2_ModeH264_F;
105pub const DXVA2_E_NOT_INITIALIZED: HRESULT = 0x80041000;
106pub const DXVA2_E_NEW_VIDEO_DEVICE: HRESULT = 0x80041001;
107pub const DXVA2_E_VIDEO_DEVICE_LOCKED: HRESULT = 0x80041002;
108pub const DXVA2_E_NOT_AVAILABLE: HRESULT = 0x80041003;
109DEFINE_GUID!{IID_IDirect3DDeviceManager9,
110    0xa0cade0f, 0x06d5, 0x4cf4, 0xa1, 0xc7, 0xf3, 0xcd, 0xd7, 0x25, 0xaa, 0x75}
111DEFINE_GUID!{IID_IDirectXVideoAccelerationService,
112    0xfc51a550, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02}
113DEFINE_GUID!{IID_IDirectXVideoDecoderService,
114    0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02}
115DEFINE_GUID!{IID_IDirectXVideoProcessorService,
116    0xfc51a552, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02}
117DEFINE_GUID!{IID_IDirectXVideoDecoder,
118    0xf2b0810a, 0xfd00, 0x43c9, 0x91, 0x8c, 0xdf, 0x94, 0xe2, 0xd8, 0xef, 0x7d}
119DEFINE_GUID!{IID_IDirectXVideoProcessor,
120    0x8c3a39f0, 0x916e, 0x4690, 0x80, 0x4f, 0x4c, 0x80, 0x01, 0x35, 0x5d, 0x25}
121DEFINE_GUID!{IID_IDirectXVideoMemoryConfiguration,
122    0xb7f916dd, 0xdb3b, 0x49c1, 0x84, 0xd7, 0xe4, 0x5e, 0xf9, 0x9e, 0xc7, 0x26}
123pub const MAX_DEINTERLACE_SURFACES: usize = 32;
124pub const MAX_SUBSTREAMS: usize = 15;
125STRUCT!{struct DXVA2_ExtendedFormat {
126    value: UINT,
127}}
128BITFIELD!{DXVA2_ExtendedFormat value: UINT [
129    SampleFormat set_SampleFormat[0..8],
130    VideoChromaSubsampling set_VideoChromaSubsampling[8..12],
131    NominalRange set_NominalRange[12..15],
132    VideoTransferMatrix set_VideoTransferMatrix[15..18],
133    VideoLighting set_VideoLighting[18..22],
134    VideoPrimaries set_VideoPrimaries[22..27],
135    VideoTransferFunction set_VideoTransferFunction[27..32],
136]}
137ENUM!{enum DXVA2_SampleFormat {
138    DXVA2_SampleFormatMask = 0xff,
139    DXVA2_SampleUnknown = 0,
140    DXVA2_SampleProgressiveFrame = 2,
141    DXVA2_SampleFieldInterleavedEvenFirst = 3,
142    DXVA2_SampleFieldInterleavedOddFirst = 4,
143    DXVA2_SampleFieldSingleEven = 5,
144    DXVA2_SampleFieldSingleOdd = 6,
145    DXVA2_SampleSubStream = 7,
146}}
147ENUM!{enum DXVA2_VideoChromaSubSampling {
148    DXVA2_VideoChromaSubsamplingMask = 0xf,
149    DXVA2_VideoChromaSubsampling_Unknown = 0,
150    DXVA2_VideoChromaSubsampling_ProgressiveChroma = 0x8,
151    DXVA2_VideoChromaSubsampling_Horizontally_Cosited = 0x4,
152    DXVA2_VideoChromaSubsampling_Vertically_Cosited = 0x2,
153    DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes = 0x1,
154    DXVA2_VideoChromaSubsampling_MPEG2 = DXVA2_VideoChromaSubsampling_Horizontally_Cosited |
155        DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes,
156    DXVA2_VideoChromaSubsampling_MPEG1 =
157        DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes,
158    DXVA2_VideoChromaSubsampling_DV_PAL = DXVA2_VideoChromaSubsampling_Horizontally_Cosited |
159        DXVA2_VideoChromaSubsampling_Vertically_Cosited,
160    DXVA2_VideoChromaSubsampling_Cosited = DXVA2_VideoChromaSubsampling_Horizontally_Cosited |
161        DXVA2_VideoChromaSubsampling_Vertically_Cosited |
162        DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes,
163}}
164ENUM!{enum DXVA2_NominalRange {
165    DXVA2_NominalRangeMask = 0x7,
166    DXVA2_NominalRange_Unknown = 0,
167    DXVA2_NominalRange_Normal = 1,
168    DXVA2_NominalRange_Wide = 2,
169    DXVA2_NominalRange_0_255 = 1,
170    DXVA2_NominalRange_16_235 = 2,
171    DXVA2_NominalRange_48_208 = 3,
172}}
173ENUM!{enum DXVA2_VideoTransferMatrix {
174    DXVA2_VideoTransferMatrixMask = 0x7,
175    DXVA2_VideoTransferMatrix_Unknown = 0,
176    DXVA2_VideoTransferMatrix_BT709 = 1,
177    DXVA2_VideoTransferMatrix_BT601 = 2,
178    DXVA2_VideoTransferMatrix_SMPTE240M = 3,
179}}
180ENUM!{enum DXVA2_VideoLighting {
181    DXVA2_VideoLightingMask = 0xf,
182    DXVA2_VideoLighting_Unknown = 0,
183    DXVA2_VideoLighting_bright = 1,
184    DXVA2_VideoLighting_office = 2,
185    DXVA2_VideoLighting_dim = 3,
186    DXVA2_VideoLighting_dark = 4,
187}}
188ENUM!{enum DXVA2_VideoPrimaries {
189    DXVA2_VideoPrimariesMask = 0x1f,
190    DXVA2_VideoPrimaries_Unknown = 0,
191    DXVA2_VideoPrimaries_reserved = 1,
192    DXVA2_VideoPrimaries_BT709 = 2,
193    DXVA2_VideoPrimaries_BT470_2_SysM = 3,
194    DXVA2_VideoPrimaries_BT470_2_SysBG = 4,
195    DXVA2_VideoPrimaries_SMPTE170M = 5,
196    DXVA2_VideoPrimaries_SMPTE240M = 6,
197    DXVA2_VideoPrimaries_EBU3213 = 7,
198    DXVA2_VideoPrimaries_SMPTE_C = 8,
199}}
200ENUM!{enum DXVA2_VideoTransferFunction {
201    DXVA2_VideoTransFuncMask = 0x1f,
202    DXVA2_VideoTransFunc_Unknown = 0,
203    DXVA2_VideoTransFunc_10 = 1,
204    DXVA2_VideoTransFunc_18 = 2,
205    DXVA2_VideoTransFunc_20 = 3,
206    DXVA2_VideoTransFunc_22 = 4,
207    DXVA2_VideoTransFunc_709 = 5,
208    DXVA2_VideoTransFunc_240M = 6,
209    DXVA2_VideoTransFunc_sRGB = 7,
210    DXVA2_VideoTransFunc_28 = 8,
211}}
212pub const DXVA2_VideoTransFunc_22_709: DWORD = DXVA2_VideoTransFunc_709;
213pub const DXVA2_VideoTransFunc_22_240M: DWORD = DXVA2_VideoTransFunc_240M;
214pub const DXVA2_VideoTransFunc_22_8bit_sRGB: DWORD = DXVA2_VideoTransFunc_sRGB;
215STRUCT!{struct DXVA2_Frequency {
216    Numerator: UINT,
217    Denominator: UINT,
218}}
219STRUCT!{struct DXVA2_VideoDesc {
220    SampleWidth: UINT,
221    SampleHeight: UINT,
222    SampleFormat: DXVA2_ExtendedFormat,
223    Format: D3DFORMAT,
224    InputSampleFreq: DXVA2_Frequency,
225    OutputFrameFreq: DXVA2_Frequency,
226    UABProtectionLevel: UINT,
227    Reserved: UINT,
228}}
229ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0003 {
230    DXVA2_DeinterlaceTech_Unknown = 0,
231    DXVA2_DeinterlaceTech_BOBLineReplicate = 0x1,
232    DXVA2_DeinterlaceTech_BOBVerticalStretch = 0x2,
233    DXVA2_DeinterlaceTech_BOBVerticalStretch4Tap = 0x4,
234    DXVA2_DeinterlaceTech_MedianFiltering = 0x8,
235    DXVA2_DeinterlaceTech_EdgeFiltering = 0x10,
236    DXVA2_DeinterlaceTech_FieldAdaptive = 0x20,
237    DXVA2_DeinterlaceTech_PixelAdaptive = 0x40,
238    DXVA2_DeinterlaceTech_MotionVectorSteered = 0x80,
239    DXVA2_DeinterlaceTech_InverseTelecine = 0x100,
240    DXVA2_DeinterlaceTech_Mask = 0x1ff,
241}}
242ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0004 {
243    DXVA2_NoiseFilterLumaLevel = 1,
244    DXVA2_NoiseFilterLumaThreshold = 2,
245    DXVA2_NoiseFilterLumaRadius = 3,
246    DXVA2_NoiseFilterChromaLevel = 4,
247    DXVA2_NoiseFilterChromaThreshold = 5,
248    DXVA2_NoiseFilterChromaRadius = 6,
249    DXVA2_DetailFilterLumaLevel = 7,
250    DXVA2_DetailFilterLumaThreshold = 8,
251    DXVA2_DetailFilterLumaRadius = 9,
252    DXVA2_DetailFilterChromaLevel = 10,
253    DXVA2_DetailFilterChromaThreshold = 11,
254    DXVA2_DetailFilterChromaRadius = 12,
255}}
256ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0005 {
257    DXVA2_NoiseFilterTech_Unsupported = 0,
258    DXVA2_NoiseFilterTech_Unknown = 0x1,
259    DXVA2_NoiseFilterTech_Median = 0x2,
260    DXVA2_NoiseFilterTech_Temporal = 0x4,
261    DXVA2_NoiseFilterTech_BlockNoise = 0x8,
262    DXVA2_NoiseFilterTech_MosquitoNoise = 0x10,
263    DXVA2_NoiseFilterTech_Mask = 0x1f,
264}}
265ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0006 {
266    DXVA2_DetailFilterTech_Unsupported = 0,
267    DXVA2_DetailFilterTech_Unknown = 0x1,
268    DXVA2_DetailFilterTech_Edge = 0x2,
269    DXVA2_DetailFilterTech_Sharpening = 0x4,
270    DXVA2_DetailFilterTech_Mask = 0x7,
271}}
272ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0007 {
273    DXVA2_ProcAmp_None = 0,
274    DXVA2_ProcAmp_Brightness = 0x1,
275    DXVA2_ProcAmp_Contrast = 0x2,
276    DXVA2_ProcAmp_Hue = 0x4,
277    DXVA2_ProcAmp_Saturation = 0x8,
278    DXVA2_ProcAmp_Mask = 0xf,
279}}
280ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0008 {
281    DXVA2_VideoProcess_None = 0,
282    DXVA2_VideoProcess_YUV2RGB = 0x1,
283    DXVA2_VideoProcess_StretchX = 0x2,
284    DXVA2_VideoProcess_StretchY = 0x4,
285    DXVA2_VideoProcess_AlphaBlend = 0x8,
286    DXVA2_VideoProcess_SubRects = 0x10,
287    DXVA2_VideoProcess_SubStreams = 0x20,
288    DXVA2_VideoProcess_SubStreamsExtended = 0x40,
289    DXVA2_VideoProcess_YUV2RGBExtended = 0x80,
290    DXVA2_VideoProcess_AlphaBlendExtended = 0x100,
291    DXVA2_VideoProcess_Constriction = 0x200,
292    DXVA2_VideoProcess_NoiseFilter = 0x400,
293    DXVA2_VideoProcess_DetailFilter = 0x800,
294    DXVA2_VideoProcess_PlanarAlpha = 0x1000,
295    DXVA2_VideoProcess_LinearScaling = 0x2000,
296    DXVA2_VideoProcess_GammaCompensated = 0x4000,
297    DXVA2_VideoProcess_MaintainsOriginalFieldData = 0x8000,
298    DXVA2_VideoProcess_Mask = 0xffff,
299}}
300ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0009 {
301    DXVA2_VPDev_HardwareDevice = 0x1,
302    DXVA2_VPDev_EmulatedDXVA1 = 0x2,
303    DXVA2_VPDev_SoftwareDevice = 0x4,
304    DXVA2_VPDev_Mask = 0x7,
305}}
306ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0010 {
307    DXVA2_SampleData_RFF = 0x1,
308    DXVA2_SampleData_TFF = 0x2,
309    DXVA2_SampleData_RFF_TFF_Present = 0x4,
310    DXVA2_SampleData_Mask = 0xffff,
311}}
312ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0011 {
313    DXVA2_DestData_RFF = 0x1,
314    DXVA2_DestData_TFF = 0x2,
315    DXVA2_DestData_RFF_TFF_Present = 0x4,
316    DXVA2_DestData_Mask = 0xffff,
317}}
318STRUCT!{struct DXVA2_VideoProcessorCaps {
319    DeviceCaps: UINT,
320    InputPool: D3DPOOL,
321    NumForwardRefSamples: UINT,
322    NumBackwardRefSamples: UINT,
323    Reserved: UINT,
324    DeinterlaceTechnology: UINT,
325    ProcAmpControlCaps: UINT,
326    VideoProcessorOperations: UINT,
327    NoiseFilterTechnology: UINT,
328    DetailFilterTechnology: UINT,
329}}
330STRUCT!{struct DXVA2_Fixed32_s {
331    Fraction: USHORT,
332    Value: SHORT,
333}}
334UNION!{union DXVA2_Fixed32 {
335    [u32; 1],
336    s s_mut: DXVA2_Fixed32_s,
337    ll s_ll: LONG,
338}}
339STRUCT!{struct DXVA2_AYUVSample8 {
340    Cr: UCHAR,
341    Cb: UCHAR,
342    Y: UCHAR,
343    Alpha: UCHAR,
344}}
345STRUCT!{struct DXVA2_AYUVSample16 {
346    Cr: USHORT,
347    Cb: USHORT,
348    Y: USHORT,
349    Alpha: USHORT,
350}}
351pub type REFERENCE_TIME = LONGLONG;
352STRUCT!{struct DXVA2_VideoSample {
353    Start: REFERENCE_TIME,
354    End: REFERENCE_TIME,
355    SampleFormat: DXVA2_ExtendedFormat,
356    SrcSurface: *mut IDirect3DSurface9,
357    SrcRect: RECT,
358    DstRect: RECT,
359    Pal: [DXVA2_AYUVSample8; 16],
360    PlanarAlpha: DXVA2_Fixed32,
361    SampleData: DWORD,
362}}
363STRUCT!{struct DXVA2_ValueRange {
364    MinValue: DXVA2_Fixed32,
365    MaxValue: DXVA2_Fixed32,
366    DefaultValue: DXVA2_Fixed32,
367    StepSize: DXVA2_Fixed32,
368}}
369STRUCT!{struct DXVA2_ProcAmpValues {
370    Brightness: DXVA2_Fixed32,
371    Contrast: DXVA2_Fixed32,
372    Hue: DXVA2_Fixed32,
373    Saturation: DXVA2_Fixed32,
374}}
375STRUCT!{struct DXVA2_FilterValues {
376    Level: DXVA2_Fixed32,
377    Threshold: DXVA2_Fixed32,
378    Radius: DXVA2_Fixed32,
379}}
380STRUCT!{struct DXVA2_VideoProcessBltParams {
381    TargetFrame: REFERENCE_TIME,
382    TargetRect: RECT,
383    ConstrictionSize: SIZE,
384    StreamingFlags: UINT,
385    BackgroundColor: DXVA2_AYUVSample16,
386    DestFormat: DXVA2_ExtendedFormat,
387    ProcAmpValues: DXVA2_ProcAmpValues,
388    Alpha: DXVA2_Fixed32,
389    NoiseFilterLuma: DXVA2_FilterValues,
390    NoiseFilterChroma: DXVA2_FilterValues,
391    DetailFilterLuma: DXVA2_FilterValues,
392    DetailFilterChroma: DXVA2_FilterValues,
393    DestData: DWORD,
394}}
395ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0012 {
396    DXVA2_PictureParametersBufferType = 0,
397    DXVA2_MacroBlockControlBufferType = 1,
398    DXVA2_ResidualDifferenceBufferType = 2,
399    DXVA2_DeblockingControlBufferType = 3,
400    DXVA2_InverseQuantizationMatrixBufferType = 4,
401    DXVA2_SliceControlBufferType = 5,
402    DXVA2_BitStreamDateBufferType = 6,
403    DXVA2_MotionVectorBuffer = 7,
404    DXVA2_FilmGrainBuffer = 8,
405}}
406ENUM!{enum __MIDL___MIDL_itf_dxva2api_0000_0000_0013 {
407    DXVA2_VideoDecoderRenderTarget = 0,
408    DXVA2_VideoProcessorRenderTarget = 1,
409    DXVA2_VideoSoftwareRenderTarget = 2,
410}}
411STRUCT!{struct DXVA2_ConfigPictureDecode {
412    guidConfigBitstreamEncryption: GUID,
413    guidConfigMBcontrolEncryption: GUID,
414    guidConfigResidDiffEncryption: GUID,
415    ConfigBitstreamRaw: UINT,
416    ConfigMBcontrolRasterOrder: UINT,
417    ConfigResidDiffHost: UINT,
418    ConfigSpatialResid8: UINT,
419    ConfigResid8Subtraction: UINT,
420    ConfigSpatialHost8or9Clipping: UINT,
421    ConfigSpatialResidInterleaved: UINT,
422    ConfigIntraResidUnsigned: UINT,
423    ConfigResidDiffAccelerator: UINT,
424    ConfigHostInverseScan: UINT,
425    ConfigSpecificIDCT: UINT,
426    Config4GroupedCoefs: UINT,
427    ConfigMinRenderTargetBuffCount: USHORT,
428    ConfigDecoderSpecific: USHORT,
429}}
430STRUCT!{struct DXVA2_DecodeBufferDesc {
431    CompressedBufferType: DWORD,
432    BufferIndex: UINT,
433    DataOffset: UINT,
434    DataSize: UINT,
435    FirstMBaddress: UINT,
436    NumMBsInBuffer: UINT,
437    Width: UINT,
438    Height: UINT,
439    Stride: UINT,
440    ReservedBits: UINT,
441    pvPVPState: PVOID,
442}}
443STRUCT!{struct DXVA2_AES_CTR_IV {
444    IV: UINT64,
445    Count: UINT64,
446}}
447STRUCT!{struct DXVA2_DecodeExtensionData {
448    Function: UINT,
449    pPrivateInputData: PVOID,
450    PrivateInputDataSize: UINT,
451    pPrivateOutputData: PVOID,
452    PrivateOutputDataSize: UINT,
453}}
454pub const DXVA2_DECODE_GET_DRIVER_HANDLE: UINT = 0x725;
455pub const DXVA2_DECODE_SPECIFY_ENCRYPTED_BLOCKS: UINT = 0x724;
456STRUCT!{struct DXVA2_DecodeExecuteParams {
457    NumCompBuffers: UINT,
458    pCompressedBuffers: *mut DXVA2_DecodeBufferDesc,
459    pExtensionData: *mut DXVA2_DecodeExtensionData,
460}}
461RIDL!{#[uuid(0xa0cade0f, 0x06d5, 0x4cf4, 0xa1, 0xc7, 0xf3, 0xcd, 0xd7, 0x25, 0xaa, 0x75)]
462interface IDirect3DDeviceManager9(IDirect3DDeviceManager9Vtbl): IUnknown(IUnknownVtbl) {
463    fn ResetDevice(
464        pDevice: *mut IDirect3DDevice9,
465        resetToken: UINT,
466    ) -> HRESULT,
467    fn OpenDeviceHandle(
468        phDevice: *mut HANDLE,
469    ) -> HRESULT,
470    fn CloseDeviceHandle(
471        hDevice: HANDLE,
472    ) -> HRESULT,
473    fn TestDevice(
474        hDevice: HANDLE,
475    ) -> HRESULT,
476    fn LockDevice(
477        hDevice: HANDLE,
478        ppDevice: *mut *mut IDirect3DDevice9,
479        fBloc: BOOL,
480    ) -> HRESULT,
481    fn UnlockDevice(
482        hDevice: HANDLE,
483        fSaveState: BOOL,
484    ) -> HRESULT,
485    fn GetVideoService(
486        hDevice: HANDLE,
487        riid: REFIID,
488        ppService: *mut *mut c_void,
489    ) -> HRESULT,
490}}
491RIDL!{#[uuid(0xfc51a550, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)]
492interface IDirectXVideoAccelerationService(IDirectXVideoAccelerationServiceVtbl):
493    IUnknown(IUnknownVtbl) {
494    fn CreateSurface(
495        Width: UINT,
496        Height: UINT,
497        BackBuffers: UINT,
498        Format: D3DFORMAT,
499        Pool: D3DPOOL,
500        Usage: DWORD,
501        DxvaType: DWORD,
502        ppSurface: *mut *mut IDirect3DSurface9,
503        pSharedHandle: *mut HANDLE,
504    ) -> HRESULT,
505}}
506RIDL!{#[uuid(0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)]
507interface IDirectXVideoDecoderService(IDirectXVideoDecoderServiceVtbl):
508    IDirectXVideoAccelerationService(IDirectXVideoAccelerationServiceVtbl) {
509    fn GetDecoderDeviceGuids(
510        pCount: *mut UINT,
511        pGuids: *mut *mut GUID,
512    ) -> HRESULT,
513    fn GetDecoderRenderTargets(
514        Guid: REFGUID,
515        pCount: *mut UINT,
516        pFormats: *mut *mut D3DFORMAT,
517    ) -> HRESULT,
518    fn GetDecoderConfigurations(
519        Guid: REFGUID,
520        pVideoDesc: *const DXVA2_VideoDesc,
521        pReserved: *mut c_void,
522        pCount: *mut UINT,
523        ppConfigs: *mut *mut DXVA2_ConfigPictureDecode,
524    ) -> HRESULT,
525    fn CreateVideoDecoder(
526        Guid: REFGUID,
527        pVideoDesc: *const DXVA2_VideoDesc,
528        pConfig: *const DXVA2_ConfigPictureDecode,
529        ppDecoderRenderTargets: *mut *mut IDirect3DSurface9,
530        NumRenderTargets: UINT,
531        ppDecode: *mut *mut IDirectXVideoDecoder,
532    ) -> HRESULT,
533}}
534RIDL!{#[uuid(0xfc51a552, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)]
535interface IDirectXVideoProcessorService(IDirectXVideoProcessorServiceVtbl):
536    IDirectXVideoAccelerationService(IDirectXVideoAccelerationServiceVtbl) {
537    fn RegisterVideoProcessorSoftwareDevice(
538        pCallbacks: *mut c_void,
539    ) -> HRESULT,
540    fn GetVideoProcessorDeviceGuids(
541        pVideoDesc: *mut DXVA2_VideoDesc,
542        pCount: *mut UINT,
543        pGuids: *mut *mut GUID,
544    ) -> HRESULT,
545    fn GetVideoProcessorRenderTargets(
546        VideoProcDeviceGuid: REFGUID,
547        pVideoDesc: *const DXVA2_VideoDesc,
548        pCount: *mut UINT,
549        pFormats: *mut *mut D3DFORMAT,
550    ) -> HRESULT,
551    fn GetVideoProcessorSubStreamFormats(
552        VideoProcDeviceGuid: REFGUID,
553        pVideoDesc: *const DXVA2_VideoDesc,
554        RenderTargetFormat: D3DFORMAT,
555        pCount: *mut UINT,
556        pFormats: *mut *mut D3DFORMAT,
557    ) -> HRESULT,
558    fn GetVideoProcessorCaps(
559        VideoProcDeviceGuid: REFGUID,
560        pVideoDesc: *const DXVA2_VideoDesc,
561        RenderTargetFormat: D3DFORMAT,
562        pCaps: *mut DXVA2_VideoProcessorCaps,
563    ) -> HRESULT,
564    fn GetProcAmpRange(
565        VideoProcDeviceGuid: REFGUID,
566        pVideoDesc: *const DXVA2_VideoDesc,
567        RenderTargetFormat: D3DFORMAT,
568        ProcAmpCap: UINT,
569        pRange: *mut DXVA2_ValueRange,
570    ) -> HRESULT,
571    fn GetFilterPropertyRange(
572        VideoProcDeviceGuid: REFGUID,
573        pVideoDesc: *const DXVA2_VideoDesc,
574        RenderTargetFormat: D3DFORMAT,
575        FilterSetting: UINT,
576        pRange: *mut DXVA2_ValueRange,
577    ) -> HRESULT,
578    fn CreateVideoProcessor(
579        VideoProcDeviceGuid: REFGUID,
580        pVideoDesc: *const DXVA2_VideoDesc,
581        RenderTargetFormat: D3DFORMAT,
582        MaxNumSubStreams: UINT,
583        ppVidProcess: *mut *mut IDirectXVideoProcessor,
584    ) -> HRESULT,
585}}
586RIDL!{#[uuid(0xf2b0810a, 0xfd00, 0x43c9, 0x91, 0x8c, 0xdf, 0x94, 0xe2, 0xd8, 0xef, 0x7d)]
587interface IDirectXVideoDecoder(IDirectXVideoDecoderVtbl): IUnknown(IUnknownVtbl) {
588    fn GetVideoDecoderService(
589        ppService: *mut *mut IDirectXVideoDecoderService,
590    ) -> HRESULT,
591    fn GetCreationParameters(
592        pDeviceGuid: *mut GUID,
593        pVideoDesc: *mut DXVA2_VideoDesc,
594        pConfig: *mut DXVA2_ConfigPictureDecode,
595        pDecoderRenderTargets: *mut *mut *mut IDirect3DSurface9,
596        pNumSurfaces: *mut UINT,
597    ) -> HRESULT,
598    fn GetBuffer(
599        BufferType: UINT,
600        ppBuffer: *mut *mut c_void,
601        pBufferSize: *mut UINT,
602    ) -> HRESULT,
603    fn ReleaseBuffer(
604        BufferType: UINT,
605    ) -> HRESULT,
606    fn BeginFrame(
607        pRenderTarget: *mut IDirect3DSurface9,
608        pvPVPData: *mut c_void,
609    ) -> HRESULT,
610    fn EndFrame(
611        pHandleComplete: *mut HANDLE,
612    ) -> HRESULT,
613    fn Execute(
614        pExecuteParams: *const DXVA2_DecodeExecuteParams,
615    ) -> HRESULT,
616}}
617RIDL!{#[uuid(0x8c3a39f0, 0x916e, 0x4690, 0x80, 0x4f, 0x4c, 0x80, 0x01, 0x35, 0x5d, 0x25)]
618interface IDirectXVideoProcessor(IDirectXVideoProcessorVtbl): IUnknown(IUnknownVtbl) {
619    fn GetVideoProcessorService(
620        ppService: *mut *mut IDirectXVideoProcessorService,
621    ) -> HRESULT,
622    fn GetCreationParameters(
623        pDeviceGuid: *mut GUID,
624        pVideoDesc: *mut DXVA2_VideoDesc,
625        pRenderTargetFormat: *mut D3DFORMAT,
626        pMaxNumSubStreams: *mut UINT,
627    ) -> HRESULT,
628    fn GetVideoProcessorCaps(
629        pCaps: *mut DXVA2_VideoProcessorCaps,
630    ) -> HRESULT,
631    fn GetProcAmpRange(
632        ProcAmpCap: UINT,
633        pRange: *mut DXVA2_ValueRange,
634    ) -> HRESULT,
635    fn GetFilterPropertyRange(
636        FilterSetting: UINT,
637        pRange: *mut DXVA2_ValueRange,
638    ) -> HRESULT,
639    fn VideoProcessBlt(
640        pRenderTarget: *mut IDirect3DSurface9,
641        pBltParams: *const DXVA2_VideoProcessBltParams,
642        pSamples: *const DXVA2_VideoSample,
643        NumSamples: UINT,
644        pHandleComplete: *mut HANDLE,
645    ) -> HRESULT,
646}}
647ENUM!{enum DXVA2_SurfaceType {
648    DXVA2_SurfaceType_DecoderRenderTarget = 0,
649    DXVA2_SurfaceType_ProcessorRenderTarget = 1,
650    DXVA2_SurfaceType_D3DRenderTargetTexture = 2,
651}}
652RIDL!{#[uuid(0xb7f916dd, 0xdb3b, 0x49c1, 0x84, 0xd7, 0xe4, 0x5e, 0xf9, 0x9e, 0xc7, 0x26)]
653interface IDirectXVideoMemoryConfiguration(IDirectXVideoMemoryConfigurationVtbl):
654    IUnknown(IUnknownVtbl) {
655    fn GetAvailableSurfaceTypeByIndex(
656        dwTypeIndex: DWORD,
657        pdwType: *mut DXVA2_SurfaceType,
658    ) -> HRESULT,
659    fn SetSurfaceType(
660        dwType: DXVA2_SurfaceType,
661    ) -> HRESULT,
662}}
663extern "system" {
664    pub fn DXVA2CreateDirect3DDeviceManager9(
665        pResetToken: *mut UINT,
666        ppDeviceManager: *mut *mut IDirect3DDeviceManager9,
667    ) -> HRESULT;
668    pub fn DXVA2CreateVideoService(
669        pDD: *mut IDirect3DDevice9,
670        riid: REFIID,
671        ppService: *mut *mut c_void,
672    ) -> HRESULT;
673}
674#[inline]
675pub fn DXVA2FloatToFixed(_float_: c_float) -> DXVA2_Fixed32 {
676    unsafe {
677        let mut _fixed_: DXVA2_Fixed32 = ::core::mem::uninitialized();
678        _fixed_.s_mut().Fraction = LOWORD((_float_ * 0x10000 as c_float) as DWORD);
679        _fixed_.s_mut().Value = HIWORD((_float_ * 0x10000 as c_float) as DWORD) as SHORT;
680        _fixed_
681    }
682}
683#[inline]
684pub fn DXVA2FixedToFloat(_fixed_: DXVA2_Fixed32) -> c_float {
685    unsafe {
686        _fixed_.s().Value as FLOAT + _fixed_.s().Fraction as FLOAT / 0x10000 as FLOAT
687    }
688}
689#[inline]
690pub fn DXVA2_Fixed32TransparentAlpha() -> DXVA2_Fixed32 {
691    unsafe {
692        let mut _fixed_: DXVA2_Fixed32 = ::core::mem::uninitialized();
693        _fixed_.s_mut().Fraction = 0;
694        _fixed_.s_mut().Value = 0;
695        _fixed_
696    }
697}
698#[inline]
699pub fn DXVA2_Fixed32OpaqueAlpha() -> DXVA2_Fixed32 {
700    unsafe {
701        let mut _fixed_: DXVA2_Fixed32 = ::core::mem::uninitialized();
702        _fixed_.s_mut().Fraction = 0;
703        _fixed_.s_mut().Value = 1;
704        _fixed_
705    }
706}