From 12ac428c2f5e004ac6fec9149f83feaf85a29e49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 25 Jul 2012 20:47:20 +0100 Subject: [PATCH] Support apps that use DXVA. --- dispatch/dxvaint.h | 154 +++++++++++++++++ specs/d3d9dxva2.py | 374 ++++++++++++++++++++++++++++++++++++++++ wrappers/CMakeLists.txt | 1 + wrappers/d3d9trace.py | 12 ++ 4 files changed, 541 insertions(+) create mode 100644 dispatch/dxvaint.h create mode 100644 specs/d3d9dxva2.py diff --git a/dispatch/dxvaint.h b/dispatch/dxvaint.h new file mode 100644 index 0000000..f275d55 --- /dev/null +++ b/dispatch/dxvaint.h @@ -0,0 +1,154 @@ +/************************************************************************** + * + * Copyright 2012 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ + + +#include + + +typedef struct _DXVA2_PVP_SETKEY DXVA2_PVP_SETKEY; /* XXX */ + +typedef struct _DXVA2_DECODEBUFFERDESC { + IDirect3DSurface9 *pRenderTarget; + DWORD CompressedBufferType; + DWORD BufferIndex; + DWORD DataOffset; + DWORD DataSize; + DWORD FirstMBaddress; + DWORD NumMBsInBuffer; + DWORD Width; + DWORD Height; + DWORD Stride; + DWORD ReservedBits; + PVOID pCipherCounter; +} DXVA2_DECODEBUFFERDESC; + +typedef struct _DXVA2_DECODEEXECUTE { + UINT NumCompBuffers; + DXVA2_DECODEBUFFERDESC *pCompressedBuffers; +} DXVA2_DECODEEXECUTE; + +typedef struct _DXVA2_VIDEOSAMPLE { + REFERENCE_TIME Start; + REFERENCE_TIME End; + DXVA2_ExtendedFormat SampleFormat; + DWORD SampleFlags; + IDirect3DSurface9* SrcSurface; + RECT SrcRect; + RECT DstRect; + DXVA2_AYUVSample8 Pal[16]; + DXVA2_Fixed32 PlanarAlpha; +} DXVA2_VIDEOSAMPLE; + +/** + * See also: + * - D3DDDIARG_VIDEOPROCESSBLT + * - DXVA2_VideoProcessBltParams + */ +typedef struct _DXVA2_VIDEOPROCESSBLT { + REFERENCE_TIME TargetFrame; + RECT TargetRect; + SIZE ConstrictionSize; + DWORD StreamingFlags; + DXVA2_AYUVSample16 BackgroundColor; + DXVA2_ExtendedFormat DestFormat; + DWORD DestFlags; + DXVA2_ProcAmpValues ProcAmpValues; + DXVA2_Fixed32 Alpha; + DXVA2_FilterValues NoiseFilterLuma; + DXVA2_FilterValues NoiseFilterChroma; + DXVA2_FilterValues DetailFilterLuma; + DXVA2_FilterValues DetailFilterChroma; + DXVA2_VIDEOSAMPLE *pSrcSurfaces; + UINT NumSrcSurfaces; +} DXVA2_VIDEOPROCESSBLT; + +typedef struct _DXVA2_DECODEBUFFERINFO DXVA2_DECODEBUFFERINFO; /* XXX */ + +typedef struct _DXVA2_EXTENSIONEXECUTE DXVA2_EXTENSIONEXECUTE; /* XXX */ + + +static const GUID IID_IDirect3DDecodeDevice9 = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; /* XXX */ +static const GUID IID_IDirect3DVideoProcessDevice9 = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} /* XXX */; +static const GUID IID_IDirect3DDXVAExtensionDevice9 = {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; /* XXX */ +static const GUID IID_IDirect3DDxva2Container9 = {0x126D0349,0x4787,0x4AA6,{0x8E,0x1B,0x40,0xC1,0x77,0xC6,0x0A,0x01}}; + + +class IDirect3DDecodeDevice9 : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE DecodeBeginFrame(DXVA2_PVP_SETKEY *pPVPSetKey) = 0; + virtual HRESULT STDMETHODCALLTYPE DecodeEndFrame(HANDLE *pHandleComplete) = 0; + virtual HRESULT STDMETHODCALLTYPE DecodeSetRenderTarget(IDirect3DSurface9 *pRenderTarget) = 0; + virtual HRESULT STDMETHODCALLTYPE DecodeExecute(DXVA2_DECODEEXECUTE /* const */ *pExecuteParams) = 0; +}; + + +class IDirect3DVideoProcessDevice9 : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE VideoProcessBeginFrame(void) = 0; + virtual HRESULT STDMETHODCALLTYPE VideoProcessEndFrame(HANDLE *pHandleComplete) = 0; + virtual HRESULT STDMETHODCALLTYPE VideoProcessSetRenderTarget(IDirect3DSurface9 *pRenderTarget) = 0; + virtual HRESULT STDMETHODCALLTYPE VideoProcessBlt(DXVA2_VIDEOPROCESSBLT /* const */ *pData) = 0; +}; + + +class IDirect3DDXVAExtensionDevice9 : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE ExtensionExecute(DXVA2_EXTENSIONEXECUTE *pData) = 0; +}; + + +class IDirect3DDxva2Container9 : public IUnknown +{ +public: + virtual HRESULT STDMETHODCALLTYPE CreateSurface(UINT Width, UINT Height, UINT BackBuffers, D3DFORMAT Format, D3DPOOL Pool, DWORD Usage, DWORD DxvaType, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle) = 0; + virtual HRESULT STDMETHODCALLTYPE VidToSysBlt(IDirect3DSurface9 *pSourceSurface, RECT *pSourceRect, IDirect3DSurface9 *pDestSurface, RECT *pDestRect) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeGuidCount(UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeGuids(UINT Count, GUID *pGuids) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeRenderTargetFormatCount(REFGUID Guid, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeRenderTargets(REFGUID Guid, UINT Count, D3DFORMAT *pFormats) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeCompressedBufferCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeCompressedBuffers(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT Count, DXVA2_DECODEBUFFERINFO *pBufferInfo) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeConfigurationCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDecodeConfigurations(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT Count, DXVA2_ConfigPictureDecode *pConfigs) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateDecodeDevice(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, DXVA2_ConfigPictureDecode const *pConfig, IDirect3DSurface9 * *ppDecoderRenderTargets, UINT NumSurfaces, IDirect3DDecodeDevice9 ** ppDecode) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorDeviceGuidCount(const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorDeviceGuids(const DXVA2_VideoDesc *pVideoDesc, UINT Count, GUID *pGuids) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorCaps(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, DXVA2_VideoProcessorCaps *pCaps) = 0; + virtual HRESULT STDMETHODCALLTYPE GetProcAmpRange(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT ProcAmpCap, DXVA2_ValueRange *pRange) = 0; + virtual HRESULT STDMETHODCALLTYPE GetFilterPropertyRange(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT FilterSetting, DXVA2_ValueRange *pRange) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorRenderTargetCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorRenderTargets(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, UINT Count, D3DFORMAT *pFormats) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorSubStreamFormatCount(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetVideoProcessorSubStreamFormats(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT Count, D3DFORMAT *pFormats) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateVideoProcessDevice(REFGUID Guid, const DXVA2_VideoDesc *pVideoDesc, D3DFORMAT Format, UINT, IDirect3DVideoProcessDevice9 * * ppVideoProcessDevice) = 0; + virtual HRESULT STDMETHODCALLTYPE GetExtensionGuidCount(DWORD Extension, UINT *pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE GetExtensionGuids(DWORD Extension, UINT Count, GUID *pGuids) = 0; + virtual HRESULT STDMETHODCALLTYPE GetExtensionCaps(REFGUID Guid, UINT, void *, UINT, void *, UINT) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateExtensionDevice(REFGUID Guid, void *, UINT, IDirect3DDXVAExtensionDevice9 ** ppExtension) = 0; +}; + diff --git a/specs/d3d9dxva2.py b/specs/d3d9dxva2.py new file mode 100644 index 0000000..bb9cf59 --- /dev/null +++ b/specs/d3d9dxva2.py @@ -0,0 +1,374 @@ +########################################################################## +# +# Copyright 2012 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +##########################################################################/ + + +from d3d9 import * + +REFERENCE_TIME = Alias("REFERENCE_TIME", LONGLONG) + +DXVA2_ProcAmp = Flags(UINT, [ + "DXVA2_ProcAmp_None", + "DXVA2_ProcAmp_Brightness", + "DXVA2_ProcAmp_Contrast", + "DXVA2_ProcAmp_Hue", + "DXVA2_ProcAmp_Saturation", +]) + +HRESULT = FakeEnum(HRESULT, [ + "DXVA2_E_NOT_INITIALIZED", + "DXVA2_E_NEW_VIDEO_DEVICE", + "DXVA2_E_VIDEO_DEVICE_LOCKED", + "DXVA2_E_NOT_AVAILABLE", +]) + +DXVA2_SampleFormat = Enum("DXVA2_SampleFormat", [ + "DXVA2_SampleFormatMask", + "DXVA2_SampleUnknown", + "DXVA2_SampleProgressiveFrame", + "DXVA2_SampleFieldInterleavedEvenFirst", + "DXVA2_SampleFieldInterleavedOddFirst", + "DXVA2_SampleFieldSingleEven", + "DXVA2_SampleFieldSingleOdd", + "DXVA2_SampleSubStream", +]) + +DXVA2_VideoChromaSubSampling = Enum("DXVA2_VideoChromaSubSampling", [ + "DXVA2_VideoChromaSubsamplingMask", + "DXVA2_VideoChromaSubsampling_Unknown", + "DXVA2_VideoChromaSubsampling_ProgressiveChroma", + "DXVA2_VideoChromaSubsampling_Horizontally_Cosited", + "DXVA2_VideoChromaSubsampling_Vertically_Cosited", + "DXVA2_VideoChromaSubsampling_Vertically_AlignedChromaPlanes", + "DXVA2_VideoChromaSubsampling_MPEG2", + "DXVA2_VideoChromaSubsampling_MPEG1", + "DXVA2_VideoChromaSubsampling_DV_PAL", + "DXVA2_VideoChromaSubsampling_Cosited", +]) + +DXVA2_NominalRange = Enum("DXVA2_NominalRange", [ + "DXVA2_NominalRangeMask", + "DXVA2_NominalRange_Unknown", + "DXVA2_NominalRange_Normal", + "DXVA2_NominalRange_Wide", + "DXVA2_NominalRange_0_255", + "DXVA2_NominalRange_16_235", + "DXVA2_NominalRange_48_208", +]) + +DXVA2_VideoLighting = Enum("DXVA2_VideoLighting", [ + "DXVA2_VideoLightingMask", + "DXVA2_VideoLighting_Unknown", + "DXVA2_VideoLighting_bright", + "DXVA2_VideoLighting_office", + "DXVA2_VideoLighting_dim", + "DXVA2_VideoLighting_dark", +]) + +DXVA2_VideoPrimaries = Enum("DXVA2_VideoPrimaries", [ + "DXVA2_VideoPrimariesMask", + "DXVA2_VideoPrimaries_Unknown", + "DXVA2_VideoPrimaries_reserved", + "DXVA2_VideoPrimaries_BT709", + "DXVA2_VideoPrimaries_BT470_2_SysM", + "DXVA2_VideoPrimaries_BT470_2_SysBG", + "DXVA2_VideoPrimaries_SMPTE170M", + "DXVA2_VideoPrimaries_SMPTE240M", + "DXVA2_VideoPrimaries_EBU3213", + "DXVA2_VideoPrimaries_SMPTE_C", +]) + +DXVA2_VideoTransferFunction = Enum("DXVA2_VideoTransferFunction", [ + "DXVA2_VideoTransFuncMask", + "DXVA2_VideoTransFunc_Unknown", + "DXVA2_VideoTransFunc_10", + "DXVA2_VideoTransFunc_18", + "DXVA2_VideoTransFunc_20", + "DXVA2_VideoTransFunc_22", + "DXVA2_VideoTransFunc_709", + "DXVA2_VideoTransFunc_240M", + "DXVA2_VideoTransFunc_sRGB", + "DXVA2_VideoTransFunc_28", +]) + +DXVA2_SurfaceType = FakeEnum(DWORD, [ + "DXVA2_SurfaceType_DecoderRenderTarget", + "DXVA2_SurfaceType_ProcessorRenderTarget", + "DXVA2_SurfaceType_D3DRenderTargetTexture", +]) + +DXVA2_VideoTransferMatrix = Enum("DXVA2_VideoTransferMatrix", [ + "DXVA2_VideoTransferMatrixMask", + "DXVA2_VideoTransferMatrix_Unknown", + "DXVA2_VideoTransferMatrix_BT709", + "DXVA2_VideoTransferMatrix_BT601", + "DXVA2_VideoTransferMatrix_SMPTE240M", +]) + +DXVA2_AYUVSample16 = Struct("DXVA2_AYUVSample16", [ + (USHORT, "Cr"), + (USHORT, "Cb"), + (USHORT, "Y"), + (USHORT, "Alpha"), +]) + +DXVA2_AYUVSample8 = Struct("DXVA2_AYUVSample8", [ + (UCHAR, "Cr"), + (UCHAR, "Cb"), + (UCHAR, "Y"), + (UCHAR, "Alpha"), +]) + +DXVA2_ConfigPictureDecode = Struct("DXVA2_ConfigPictureDecode", [ + (GUID, "guidConfigBitstreamEncryption"), + (GUID, "guidConfigMBcontrolEncryption"), + (GUID, "guidConfigResidDiffEncryption"), + (UINT, "ConfigBitstreamRaw"), + (UINT, "ConfigMBcontrolRasterOrder"), + (UINT, "ConfigResidDiffHost"), + (UINT, "ConfigSpatialResid8"), + (UINT, "ConfigResid8Subtraction"), + (UINT, "ConfigSpatialHost8or9Clipping"), + (UINT, "ConfigSpatialResidInterleaved"), + (UINT, "ConfigIntraResidUnsigned"), + (UINT, "ConfigResidDiffAccelerator"), + (UINT, "ConfigHostInverseScan"), + (UINT, "ConfigSpecificIDCT"), + (UINT, "Config4GroupedCoefs"), + (USHORT, "ConfigMinRenderTargetBuffCount"), + (USHORT, "ConfigDecoderSpecific"), +]) + +DXVA2_DecodeBufferDesc = Struct("DXVA2_DecodeBufferDesc", [ + (DWORD, "CompressedBufferType"), + (UINT, "BufferIndex"), + (UINT, "DataOffset"), + (UINT, "DataSize"), + (UINT, "FirstMBaddress"), + (UINT, "NumMBsInBuffer"), + (UINT, "Width"), + (UINT, "Height"), + (UINT, "Stride"), + (UINT, "ReservedBits"), + (PVOID, "pvPVPState"), +]) + +DXVA2_DecodeExtensionData = Struct("DXVA2_DecodeExtensionData", [ + (UINT, "Function"), + (PVOID, "pPrivateInputData"), + (UINT, "PrivateInputDataSize"), + (PVOID, "pPrivateOutputData"), + (UINT, "PrivateOutputDataSize"), +]) + +DXVA2_DecodeExecuteParams = Struct("DXVA2_DecodeExecuteParams", [ + (UINT, "NumCompBuffers"), + (Pointer(DXVA2_DecodeBufferDesc), "pCompressedBuffers"), + (Pointer(DXVA2_DecodeExtensionData), "pExtensionData"), +]) + +DXVA2_ExtendedFormat = Struct("DXVA2_ExtendedFormat", [ + (UINT, "value"), +]) + +DXVA2_Fixed32 = Struct("DXVA2_Fixed32", [ + (USHORT, "Fraction"), + (SHORT, "Value"), +]) + +DXVA2_FilterValues = Struct("DXVA2_FilterValues", [ + (DXVA2_Fixed32, "Level"), + (DXVA2_Fixed32, "Threshold"), + (DXVA2_Fixed32, "Radius"), +]) + +DXVA2_Frequency = Struct("DXVA2_Frequency", [ + (UINT, "Numerator"), + (UINT, "Denominator"), +]) + +DXVA2_ProcAmpValues = Struct("DXVA2_ProcAmpValues", [ + (DXVA2_Fixed32, "Brightness"), + (DXVA2_Fixed32, "Contrast"), + (DXVA2_Fixed32, "Hue"), + (DXVA2_Fixed32, "Saturation"), +]) + +DXVA2_ValueRange = Struct("DXVA2_ValueRange", [ + (DXVA2_Fixed32, "MinValue"), + (DXVA2_Fixed32, "MaxValue"), + (DXVA2_Fixed32, "DefaultValue"), + (DXVA2_Fixed32, "StepSize"), +]) + +DXVA2_VideoDesc = Struct("DXVA2_VideoDesc", [ + (UINT, "SampleWidth"), + (UINT, "SampleHeight"), + (DXVA2_ExtendedFormat, "SampleFormat"), + (D3DFORMAT, "Format"), + (DXVA2_Frequency, "InputSampleFreq"), + (DXVA2_Frequency, "OutputFrameFreq"), + (UINT, "UABProtectionLevel"), + (UINT, "Reserved"), +]) + +DXVA2_VideoProcessBltParams = Struct("DXVA2_VideoProcessBltParams", [ + (REFERENCE_TIME, "TargetFrame"), + (RECT, "TargetRect"), + (SIZE, "ConstrictionSize"), + (UINT, "StreamingFlags"), + (DXVA2_AYUVSample16, "BackgroundColor"), + (DXVA2_ExtendedFormat, "DestFormat"), + (DXVA2_ProcAmpValues, "ProcAmpValues"), + (DXVA2_Fixed32, "Alpha"), + (DXVA2_FilterValues, "NoiseFilterLuma"), + (DXVA2_FilterValues, "NoiseFilterChroma"), + (DXVA2_FilterValues, "DetailFilterLuma"), + (DXVA2_FilterValues, "DetailFilterChroma"), + (DWORD, "DestData"), +]) + +DXVA2_VideoProcessorCaps = Struct("DXVA2_VideoProcessorCaps", [ + (UINT, "DeviceCaps"), + (D3DPOOL, "InputPool"), + (UINT, "NumForwardRefSamples"), + (UINT, "NumBackwardRefSamples"), + (UINT, "Reserved"), + (UINT, "DeinterlaceTechnology"), + (UINT, "ProcAmpControlCaps"), + (UINT, "VideoProcessorOperations"), + (UINT, "NoiseFilterTechnology"), + (UINT, "DetailFilterTechnology"), +]) + + +DXVA2_PVP_SETKEY = Opaque('DXVA2_PVP_SETKEY') + +DXVA2_DECODEBUFFERDESC = Struct("DXVA2_DECODEBUFFERDESC", [ + (ObjPointer(IDirect3DSurface9), "pRenderTarget"), + (DWORD, "CompressedBufferType"), + (DWORD, "BufferIndex"), + (DWORD, "DataOffset"), + (DWORD, "DataSize"), + (DWORD, "FirstMBaddress"), + (DWORD, "NumMBsInBuffer"), + (DWORD, "Width"), + (DWORD, "Height"), + (DWORD, "Stride"), + (DWORD, "ReservedBits"), + (PVOID, "pCipherCounter"), +]) + +DXVA2_DECODEEXECUTE = Struct("DXVA2_DECODEEXECUTE", [ + (UINT, "NumCompBuffers"), + (Array(DXVA2_DECODEBUFFERDESC, "_NumCompBuffers"), "pCompressedBuffers"), +]) + +DXVA2_VIDEOSAMPLE = Struct("DXVA2_VIDEOSAMPLE", [ + (REFERENCE_TIME, "Start"), + (REFERENCE_TIME, "End"), + (DXVA2_ExtendedFormat, "SampleFormat"), + (DWORD, "SampleFlags"), + (ObjPointer(IDirect3DSurface9), "SrcSurface"), + (RECT, "SrcRect"), + (RECT, "DstRect"), + #(Array(DXVA2_AYUVSample8, 16), "Pal"), + (DXVA2_Fixed32, "PlanarAlpha"), +]) + +DXVA2_VIDEOPROCESSBLT = Struct("DXVA2_VIDEOPROCESSBLT", [ + (REFERENCE_TIME, "TargetFrame"), + (RECT, "TargetRect"), + (SIZE, "ConstrictionSize"), + (DWORD, "StreamingFlags"), + (DXVA2_AYUVSample16, "BackgroundColor"), + (DXVA2_ExtendedFormat, "DestFormat"), + (DWORD, "DestFlags"), + (DXVA2_ProcAmpValues, "ProcAmpValues"), + (DXVA2_Fixed32, "Alpha"), + (DXVA2_FilterValues, "NoiseFilterLuma"), + (DXVA2_FilterValues, "NoiseFilterChroma"), + (DXVA2_FilterValues, "DetailFilterLuma"), + (DXVA2_FilterValues, "DetailFilterChroma"), + (Array(DXVA2_VIDEOSAMPLE, "_NumSrcSurfaces"), "pSrcSurfaces"), + (UINT, "NumSrcSurfaces"), +]) + +DXVA2_EXTENSIONEXECUTE = Opaque('DXVA2_EXTENSIONEXECUTE') +DXVA2_DECODEBUFFERINFO = Opaque('DXVA2_DECODEBUFFERINFO') + + +IDirect3DDecodeDevice9 = Interface("IDirect3DDecodeDevice9", IUnknown) +IDirect3DDecodeDevice9.methods += [ + Method(HRESULT, "DecodeBeginFrame", [(OpaquePointer(DXVA2_PVP_SETKEY), "pPVPSetKey")]), + Method(HRESULT, "DecodeEndFrame", [(Pointer(HANDLE), "pHandleComplete")]), + Method(HRESULT, "DecodeSetRenderTarget", [(ObjPointer(IDirect3DSurface9), "pRenderTarget")]), + Method(HRESULT, "DecodeExecute", [(Pointer(DXVA2_DECODEEXECUTE), "pExecuteParams")]), +] + +IDirect3DVideoProcessDevice9 = Interface("IDirect3DVideoProcessDevice9", IUnknown) +IDirect3DVideoProcessDevice9.methods += [ + Method(HRESULT, "VideoProcessBeginFrame", []), + Method(HRESULT, "VideoProcessEndFrame", [(Pointer(HANDLE), "pHandleComplete")]), + Method(HRESULT, "VideoProcessSetRenderTarget", [(ObjPointer(IDirect3DSurface9), "pRenderTarget")]), + Method(HRESULT, "VideoProcessBlt", [(Pointer(DXVA2_VIDEOPROCESSBLT), "pData")]), +] + +IDirect3DDXVAExtensionDevice9 = Interface("IDirect3DDXVAExtensionDevice9", IUnknown) +IDirect3DDXVAExtensionDevice9.methods += [ + Method(HRESULT, "ExtensionExecute", [(OpaquePointer(DXVA2_EXTENSIONEXECUTE), "pData")]), +] + +IDirect3DDxva2Container9 = Interface("IDirect3DDxva2Container9", IUnknown) +IDirect3DDxva2Container9.methods += [ + Method(HRESULT, "CreateSurface", [(UINT, "Width"), (UINT, "Height"), (UINT, "BackBuffers"), (D3DFORMAT, "Format"), (D3DPOOL, "Pool"), (DWORD, "Usage"), (DXVA2_SurfaceType, "DxvaType"), Out(Array(ObjPointer(IDirect3DSurface9), "1 + BackBuffers"), "ppSurface"), (Pointer(HANDLE), "pSharedHandle")]), + Method(HRESULT, "VidToSysBlt", [(ObjPointer(IDirect3DSurface9), "pSourceSurface"), (Pointer(RECT), "pSourceRect"), (ObjPointer(IDirect3DSurface9), "pDestSurface"), (Pointer(RECT), "pDestRect")]), + Method(HRESULT, "GetDecodeGuidCount", [Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetDecodeGuids", [(UINT, "Count"), Out(Array(GUID, "Count"), "pGuids")], sideeffects=False), + Method(HRESULT, "GetDecodeRenderTargetFormatCount", [(REFGUID, "Guid"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetDecodeRenderTargets", [(REFGUID, "Guid"), (UINT, "Count"), Out(Array(D3DFORMAT, "Count"), "pFormats")], sideeffects=False), + Method(HRESULT, "GetDecodeCompressedBufferCount", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetDecodeCompressedBuffers", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (UINT, "Count"), Out(OpaquePointer(DXVA2_DECODEBUFFERINFO), "pBufferInfo")], sideeffects=False), + Method(HRESULT, "GetDecodeConfigurationCount", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetDecodeConfigurations", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (UINT, "Count"), Out(Array(DXVA2_ConfigPictureDecode, "Count"), "pConfigs")], sideeffects=False), + Method(HRESULT, "CreateDecodeDevice", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (Pointer(Const(DXVA2_ConfigPictureDecode)), "pConfig"), (Array(ObjPointer(IDirect3DSurface9), "NumSurfaces"), "ppDecoderRenderTargets"), (UINT, "NumSurfaces"), Out(Pointer(ObjPointer(IDirect3DDecodeDevice9)), "ppDecode")]), + Method(HRESULT, "GetVideoProcessorDeviceGuidCount", [(Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetVideoProcessorDeviceGuids", [(Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (UINT, "Count"), Out(Pointer(GUID), "pGuids")], sideeffects=False), + Method(HRESULT, "GetVideoProcessorCaps", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "Format"), Out(Pointer(DXVA2_VideoProcessorCaps), "pCaps")], sideeffects=False), + Method(HRESULT, "GetProcAmpRange", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "Format"), (UINT, "ProcAmpCap"), Out(Pointer(DXVA2_ValueRange), "pRange")]), + Method(HRESULT, "GetFilterPropertyRange", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "Format"), (UINT, "FilterSetting"), Out(Pointer(DXVA2_ValueRange), "pRange")], sideeffects=False), + Method(HRESULT, "GetVideoProcessorRenderTargetCount", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetVideoProcessorRenderTargets", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (UINT, "Count"), Out(Array(D3DFORMAT, "Count"), "pFormats")], sideeffects=False), + Method(HRESULT, "GetVideoProcessorSubStreamFormatCount", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "Format"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetVideoProcessorSubStreamFormats", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "Format"), (UINT, "Count"), Out(Array(D3DFORMAT, "Count"), "pFormats")], sideeffects=False), + Method(HRESULT, "CreateVideoProcessDevice", [(REFGUID, "Guid"), (Pointer(Const(DXVA2_VideoDesc)), "pVideoDesc"), (D3DFORMAT, "Format"), (UINT, "MaxSubStreams"), Out(Pointer(ObjPointer(IDirect3DVideoProcessDevice9)), "ppVideoProcessDevice")]), + Method(HRESULT, "GetExtensionGuidCount", [(DWORD, "Extension"), Out(Pointer(UINT), "pCount")], sideeffects=False), + Method(HRESULT, "GetExtensionGuids", [(DWORD, "Extension"), (UINT, "Count"), Out(Array(GUID, "Count"), "pGuids")], sideeffects=False), + Method(HRESULT, "GetExtensionCaps", [(REFGUID, "Guid"), (UINT, "arg2"), (OpaquePointer(Void), "arg3"), (UINT, "arg4"), (OpaquePointer(Void), "arg5"), (UINT, "arg6")], sideeffects=False), + Method(HRESULT, "CreateExtensionDevice", [(REFGUID, "Guid"), (OpaquePointer(Void), "arg2"), (UINT, "arg3"), Out(Pointer(ObjPointer(IDirect3DDXVAExtensionDevice9)), "ppExtension")]), +] + +d3d9.addInterfaces([ + IDirect3DDxva2Container9, +]) diff --git a/wrappers/CMakeLists.txt b/wrappers/CMakeLists.txt index 17aff4c..f65817d 100644 --- a/wrappers/CMakeLists.txt +++ b/wrappers/CMakeLists.txt @@ -101,6 +101,7 @@ if (WIN32) ${CMAKE_SOURCE_DIR}/specs/d3d9.py ${CMAKE_SOURCE_DIR}/specs/d3d9types.py ${CMAKE_SOURCE_DIR}/specs/d3d9caps.py + ${CMAKE_SOURCE_DIR}/specs/d3d9dxva2.py ${CMAKE_SOURCE_DIR}/specs/winapi.py ${CMAKE_SOURCE_DIR}/specs/stdapi.py ) diff --git a/wrappers/d3d9trace.py b/wrappers/d3d9trace.py index 6ee059f..17ebe19 100644 --- a/wrappers/d3d9trace.py +++ b/wrappers/d3d9trace.py @@ -27,6 +27,8 @@ from dlltrace import DllTracer from specs.d3d9 import d3d9, D3DSHADER9 +import specs.d3d9dxva2 + class D3D9Tracer(DllTracer): @@ -52,6 +54,12 @@ class D3D9Tracer(DllTracer): return variables def implementWrapperInterfaceMethodBody(self, interface, base, method): + if method.name == 'DecodeExecute': + print r' _NumCompBuffers = pExecuteParams->NumCompBuffers;' + + if method.name == 'VideoProcessBlt': + print r' _NumSrcSurfaces = pData->NumSrcSurfaces;' + if method.name in ('Unlock', 'UnlockRect', 'UnlockBox'): print ' if (_LockedSize && m_pbData) {' self.emit_memcpy('(LPBYTE)m_pbData', '(LPBYTE)m_pbData', '_LockedSize') @@ -78,6 +86,7 @@ if __name__ == '__main__': print '#include "d3d9imports.hpp"' print '#include "d3dsize.hpp"' print '#include "d3d9shader.hpp"' + print '#include "dxvaint.h"' print print ''' static inline size_t @@ -89,6 +98,9 @@ _declCount(const D3DVERTEXELEMENT9 *pVertexElements) { } return count; } + +static UINT _NumCompBuffers = 0; /* XXX */ +static UINT _NumSrcSurfaces = 0; /* XXX */ ''' tracer = D3D9Tracer('d3d9.dll') tracer.traceApi(d3d9) -- 2.43.0