Commit cd397d1a authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Use texture pointer for DXGI surface buffer.

parent 31b88c38
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment