Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mfplat/buffer.c | 114 +++++++------------------------------------ 1 file changed, 18 insertions(+), 96 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index a7ba306223d..2bf06469576 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -485,44 +485,14 @@ static ULONG WINAPI memory_2d_buffer_Release(IMF2DBuffer2 *iface) return IMFMediaBuffer_Release(&buffer->IMFMediaBuffer_iface); }
-static HRESULT memory_2d_buffer_lock(struct buffer *buffer, BYTE **scanline0, LONG *pitch, - BYTE **buffer_start, DWORD *buffer_length) -{ - HRESULT hr = S_OK; - - if (buffer->_2d.linear_buffer) - hr = MF_E_UNEXPECTED; - else - { - ++buffer->_2d.locks; - *scanline0 = buffer->_2d.scanline0; - *pitch = buffer->_2d.pitch; - if (buffer_start) - *buffer_start = buffer->data; - if (buffer_length) - *buffer_length = buffer->max_length; - } - - return hr; -} - static HRESULT WINAPI memory_2d_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch) { - struct buffer *buffer = impl_from_IMF2DBuffer2(iface); - HRESULT hr; + DWORD buffer_length; + BYTE *buffer_start;
TRACE("%p, %p, %p.\n", iface, scanline0, pitch);
- if (!scanline0 || !pitch) - return E_POINTER; - - EnterCriticalSection(&buffer->cs); - - hr = memory_2d_buffer_lock(buffer, scanline0, pitch, NULL, NULL); - - LeaveCriticalSection(&buffer->cs); - - return hr; + return IMF2DBuffer2_Lock2DSize(iface, MF2DBuffer_LockFlags_ReadWrite, scanline0, pitch, &buffer_start, &buffer_length); }
static HRESULT WINAPI memory_2d_buffer_Unlock2D(IMF2DBuffer2 *iface) @@ -616,7 +586,7 @@ static HRESULT WINAPI memory_2d_buffer_Lock2DSize(IMF2DBuffer2 *iface, MF2DBuffe LONG *pitch, BYTE **buffer_start, DWORD *buffer_length) { struct buffer *buffer = impl_from_IMF2DBuffer2(iface); - HRESULT hr; + HRESULT hr = S_OK;
TRACE("%p, %#x, %p, %p, %p, %p.\n", iface, flags, scanline0, pitch, buffer_start, buffer_length);
@@ -625,7 +595,18 @@ static HRESULT WINAPI memory_2d_buffer_Lock2DSize(IMF2DBuffer2 *iface, MF2DBuffe
EnterCriticalSection(&buffer->cs);
- hr = memory_2d_buffer_lock(buffer, scanline0, pitch, buffer_start, buffer_length); + if (buffer->_2d.linear_buffer) + hr = MF_E_UNEXPECTED; + else + { + ++buffer->_2d.locks; + *scanline0 = buffer->_2d.scanline0; + *pitch = buffer->_2d.pitch; + if (buffer_start) + *buffer_start = buffer->data; + if (buffer_length) + *buffer_length = buffer->max_length; + }
LeaveCriticalSection(&buffer->cs);
@@ -655,37 +636,6 @@ static const IMF2DBuffer2Vtbl memory_2d_buffer_vtbl = memory_2d_buffer_Copy2DTo, };
-static HRESULT WINAPI d3d9_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch) -{ - struct buffer *buffer = impl_from_IMF2DBuffer2(iface); - HRESULT hr = S_OK; - - TRACE("%p, %p, %p.\n", iface, scanline0, pitch); - - if (!scanline0 || !pitch) - return E_POINTER; - - EnterCriticalSection(&buffer->cs); - - if (buffer->_2d.linear_buffer) - hr = MF_E_UNEXPECTED; - else if (!buffer->_2d.locks) - { - hr = IDirect3DSurface9_LockRect(buffer->d3d9_surface.surface, &buffer->d3d9_surface.rect, NULL, 0); - } - - if (SUCCEEDED(hr)) - { - buffer->_2d.locks++; - *scanline0 = buffer->d3d9_surface.rect.pBits; - *pitch = buffer->d3d9_surface.rect.Pitch; - } - - LeaveCriticalSection(&buffer->cs); - - return hr; -} - static HRESULT WINAPI d3d9_surface_buffer_Unlock2D(IMF2DBuffer2 *iface) { struct buffer *buffer = impl_from_IMF2DBuffer2(iface); @@ -781,7 +731,7 @@ static const IMF2DBuffer2Vtbl d3d9_surface_buffer_vtbl = memory_2d_buffer_QueryInterface, memory_2d_buffer_AddRef, memory_2d_buffer_Release, - d3d9_surface_buffer_Lock2D, + memory_2d_buffer_Lock2D, d3d9_surface_buffer_Unlock2D, d3d9_surface_buffer_GetScanline0AndPitch, memory_2d_buffer_IsContiguousFormat, @@ -1030,34 +980,6 @@ static HRESULT WINAPI dxgi_surface_buffer_SetCurrentLength(IMFMediaBuffer *iface return S_OK; }
-static HRESULT WINAPI dxgi_surface_buffer_Lock2D(IMF2DBuffer2 *iface, BYTE **scanline0, LONG *pitch) -{ - struct buffer *buffer = impl_from_IMF2DBuffer2(iface); - HRESULT hr = S_OK; - - TRACE("%p, %p, %p.\n", iface, scanline0, pitch); - - if (!scanline0 || !pitch) - return E_POINTER; - - EnterCriticalSection(&buffer->cs); - - if (buffer->_2d.linear_buffer) - hr = MF_E_UNEXPECTED; - else if (!buffer->_2d.locks++) - hr = dxgi_surface_buffer_map(buffer); - - if (SUCCEEDED(hr)) - { - *scanline0 = buffer->dxgi_surface.map_desc.pData; - *pitch = buffer->dxgi_surface.map_desc.RowPitch; - } - - LeaveCriticalSection(&buffer->cs); - - return hr; -} - static HRESULT WINAPI dxgi_surface_buffer_Unlock2D(IMF2DBuffer2 *iface) { struct buffer *buffer = impl_from_IMF2DBuffer2(iface); @@ -1236,7 +1158,7 @@ static const IMF2DBuffer2Vtbl dxgi_surface_buffer_vtbl = memory_2d_buffer_QueryInterface, memory_2d_buffer_AddRef, memory_2d_buffer_Release, - dxgi_surface_buffer_Lock2D, + memory_2d_buffer_Lock2D, dxgi_surface_buffer_Unlock2D, dxgi_surface_buffer_GetScanline0AndPitch, memory_2d_buffer_IsContiguousFormat,