Nikolay Sivov : mfplat: Use texture pointer for DXGI surface buffer.
Alexandre Julliard
julliard at winehq.org
Wed Mar 24 16:20:40 CDT 2021
Module: wine
Branch: master
Commit: cd397d1aa6140a21ab3dd1043238f815365b67fa
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cd397d1aa6140a21ab3dd1043238f815365b67fa
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed Mar 24 12:37:22 2021 +0300
mfplat: Use texture pointer for DXGI surface buffer.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mfplat/buffer.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c
index abfb3e738d7..cf9ead7d809 100644
--- a/dlls/mfplat/buffer.c
+++ b/dlls/mfplat/buffer.c
@@ -63,7 +63,7 @@ struct memory_buffer
} d3d9_surface;
struct
{
- IUnknown *surface;
+ ID3D11Texture2D *texture;
unsigned int subresource;
struct attributes attributes;
} dxgi_surface;
@@ -131,9 +131,9 @@ static ULONG WINAPI memory_buffer_Release(IMFMediaBuffer *iface)
{
if (buffer->d3d9_surface.surface)
IDirect3DSurface9_Release(buffer->d3d9_surface.surface);
- if (buffer->dxgi_surface.surface)
+ if (buffer->dxgi_surface.texture)
{
- IUnknown_Release(buffer->dxgi_surface.surface);
+ ID3D11Texture2D_Release(buffer->dxgi_surface.texture);
clear_attributes_object(&buffer->dxgi_surface.attributes);
}
DeleteCriticalSection(&buffer->cs);
@@ -913,7 +913,7 @@ static HRESULT WINAPI dxgi_buffer_GetResource(IMFDXGIBuffer *iface, REFIID riid,
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
- return IUnknown_QueryInterface(buffer->dxgi_surface.surface, riid, obj);
+ return ID3D11Texture2D_QueryInterface(buffer->dxgi_surface.texture, riid, obj);
}
static HRESULT WINAPI dxgi_buffer_GetSubresourceIndex(IMFDXGIBuffer *iface, UINT *index)
@@ -1170,32 +1170,44 @@ static HRESULT create_dxgi_surface_buffer(IUnknown *surface, UINT subresource, B
{
struct memory_buffer *object;
D3D11_TEXTURE2D_DESC desc;
+ ID3D11Texture2D *texture;
unsigned int stride;
D3DFORMAT format;
GUID subtype;
BOOL is_yuv;
HRESULT hr;
- ID3D11Texture2D_GetDesc((ID3D11Texture2D *)surface, &desc);
+ if (FAILED(hr = IUnknown_QueryInterface(surface, &IID_ID3D11Texture2D, (void **)&texture)))
+ {
+ WARN("Failed to get texture interface, hr %#x.\n", hr);
+ return hr;
+ }
+
+ ID3D11Texture2D_GetDesc(texture, &desc);
TRACE("format %#x, %u x %u.\n", desc.Format, desc.Width, desc.Height);
memcpy(&subtype, &MFVideoFormat_Base, sizeof(subtype));
subtype.Data1 = format = MFMapDXGIFormatToDX9Format(desc.Format);
if (!(stride = mf_format_get_stride(&subtype, desc.Width, &is_yuv)))
+ {
+ ID3D11Texture2D_Release(texture);
return MF_E_INVALIDMEDIATYPE;
+ }
object = heap_alloc_zero(sizeof(*object));
if (!object)
+ {
+ ID3D11Texture2D_Release(texture);
return E_OUTOFMEMORY;
+ }
object->IMFMediaBuffer_iface.lpVtbl = &dxgi_surface_1d_buffer_vtbl;
object->IMF2DBuffer2_iface.lpVtbl = &dxgi_surface_buffer_vtbl;
object->IMFDXGIBuffer_iface.lpVtbl = &dxgi_buffer_vtbl;
object->refcount = 1;
InitializeCriticalSection(&object->cs);
- object->dxgi_surface.surface = surface;
- IUnknown_AddRef(surface);
+ object->dxgi_surface.texture = texture;
object->dxgi_surface.subresource = subresource;
MFGetPlaneSize(format, desc.Width, desc.Height, &object->_2d.plane_size);
More information about the wine-cvs
mailing list