From: Giovanni Mascellani gmascellani@codeweavers.com
--- dlls/mfplat/buffer.c | 23 +++++++++++++++++++++-- dlls/mfplat/tests/mfplat.c | 10 +++++----- 2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 63647c33ece..cb1b3176a08 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -601,9 +601,28 @@ static HRESULT WINAPI memory_2d_buffer_GetContiguousLength(IMF2DBuffer2 *iface,
static HRESULT WINAPI memory_2d_buffer_ContiguousCopyTo(IMF2DBuffer2 *iface, BYTE *dest_buffer, DWORD dest_length) { - FIXME("%p, %p, %lu.\n", iface, dest_buffer, dest_length); + struct buffer *buffer = impl_from_IMF2DBuffer2(iface); + BYTE *src_scanline0, *src_buffer_start; + DWORD src_length; + LONG src_pitch; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %p, %lu.\n", iface, dest_buffer, dest_length); + + if (dest_length < buffer->_2d.plane_size) + return E_INVALIDARG; + + hr = IMF2DBuffer2_Lock2DSize(iface, MF2DBuffer_LockFlags_Read, &src_scanline0, &src_pitch, &src_buffer_start, &src_length); + + if (SUCCEEDED(hr)) + { + copy_image(buffer, dest_buffer, buffer->_2d.width, src_scanline0, src_pitch, buffer->_2d.width, buffer->_2d.height); + + if (FAILED(IMF2DBuffer2_Unlock2D(iface))) + WARN("Couldn't unlock source buffer %p, hr %#lx.\n", iface, hr); + } + + return S_OK; }
static HRESULT WINAPI memory_2d_buffer_ContiguousCopyFrom(IMF2DBuffer2 *iface, const BYTE *src_buffer, DWORD src_length) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 6fc84f37e7d..c5026ce2cf1 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -6259,12 +6259,12 @@ static void test_MFCreate2DMediaBuffer(void) ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
hr = IMF2DBuffer2_ContiguousCopyTo(_2dbuffer2, data2, ptr->contiguous_length - 1); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
memset(data2, 0xff, ptr->contiguous_length + 16);
hr = IMF2DBuffer2_ContiguousCopyTo(_2dbuffer2, data2, ptr->contiguous_length + 16); - todo_wine ok(hr == S_OK, "Failed to copy to contiguous buffer, hr %#lx.\n", hr); + ok(hr == S_OK, "Failed to copy to contiguous buffer, hr %#lx.\n", hr);
for (j = 0; j < ptr->contiguous_length; j++) { @@ -6278,12 +6278,12 @@ static void test_MFCreate2DMediaBuffer(void) if (data2[j] != (j & 0x7f)) break; } - todo_wine ok(j == ptr->contiguous_length, "Unexpected byte %02x instead of %02x at position %u.\n", data2[j], j & 0x7f, j); + ok(j == ptr->contiguous_length, "Unexpected byte %02x instead of %02x at position %u.\n", data2[j], j & 0x7f, j);
memset(data2, 0xff, ptr->contiguous_length + 16);
hr = IMF2DBuffer2_ContiguousCopyTo(_2dbuffer2, data2, ptr->contiguous_length); - todo_wine ok(hr == S_OK, "Failed to copy to contiguous buffer, hr %#lx.\n", hr); + ok(hr == S_OK, "Failed to copy to contiguous buffer, hr %#lx.\n", hr);
for (j = 0; j < ptr->contiguous_length; j++) { @@ -6297,7 +6297,7 @@ static void test_MFCreate2DMediaBuffer(void) if (data2[j] != (j & 0x7f)) break; } - todo_wine ok(j == ptr->contiguous_length, "Unexpected byte %02x instead of %02x at position %u.\n", data2[j], j & 0x7f, j); + ok(j == ptr->contiguous_length, "Unexpected byte %02x instead of %02x at position %u.\n", data2[j], j & 0x7f, j);
free(data2);