Skip to content

Commit

Permalink
mfplat/buffer: Do not flip in memory_2d_buffer_ContiguousCopy{From|To…
Browse files Browse the repository at this point in the history
…}().

CW-Bug-Id: #22084
  • Loading branch information
Paul Gofman authored and ivyl committed Sep 7, 2023
1 parent 6525ddf commit 2049fd4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 8 additions & 2 deletions dlls/mfplat/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,10 @@ static HRESULT WINAPI memory_2d_buffer_ContiguousCopyTo(IMF2DBuffer2 *iface, BYT

if (SUCCEEDED(hr))
{
copy_image(buffer, dest_buffer, buffer->_2d.width, src_scanline0, src_pitch, buffer->_2d.width, buffer->_2d.height);
if (src_pitch < 0)
src_pitch = -src_pitch;
copy_image(buffer, dest_buffer, buffer->_2d.width, src_buffer_start, 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);
Expand All @@ -652,7 +655,10 @@ static HRESULT WINAPI memory_2d_buffer_ContiguousCopyFrom(IMF2DBuffer2 *iface, c

if (SUCCEEDED(hr))
{
copy_image(buffer, dst_scanline0, dst_pitch, src_buffer, buffer->_2d.width, buffer->_2d.width, buffer->_2d.height);
if (dst_pitch < 0)
dst_pitch = -dst_pitch;
copy_image(buffer, dst_buffer_start, dst_pitch, src_buffer, buffer->_2d.width,
buffer->_2d.width, buffer->_2d.height);

if (FAILED(IMF2DBuffer2_Unlock2D(iface)))
WARN("Couldn't unlock destination buffer %p, hr %#lx.\n", iface, hr);
Expand Down
14 changes: 7 additions & 7 deletions dlls/mfplat/tests/mfplat.c
Original file line number Diff line number Diff line change
Expand Up @@ -8944,9 +8944,9 @@ static void test_MFInitMediaTypeFromAMMediaType(void)
IMFMediaType_Release(media_type);
}

#define check_reset_data(a, b, c, d, e, f) check_reset_data_(__LINE__, a, b, c, d, e, f)
#define check_reset_data(a, b, c, d, e) check_reset_data_(__LINE__, a, b, c, d, e)
static void check_reset_data_(unsigned int line, IMF2DBuffer2 *buffer2d, const BYTE *data, BOOL bottom_up,
DWORD width, DWORD height, BOOL todo)
DWORD width, DWORD height)
{
BYTE *scanline0, *buffer_start;
DWORD length, max_length;
Expand All @@ -8972,7 +8972,7 @@ static void check_reset_data_(unsigned int line, IMF2DBuffer2 *buffer2d, const B
ok(buffer_start == scanline0, "buffer start mismatch.\n");
}
for (i = 0; i < height; ++i)
todo_wine_if(bottom_up && todo) ok_(__FILE__,line)(!memcmp(buffer_start + abs(pitch) * i, data + width * i * 4, width * 4),
ok_(__FILE__,line)(!memcmp(buffer_start + abs(pitch) * i, data + width * i * 4, width * 4),
"2D Data mismatch, scaline %d.\n", i);
hr = IMF2DBuffer2_Unlock2D(buffer2d);
ok(hr == S_OK, "got hr %#lx.\n", hr);
Expand All @@ -8981,7 +8981,7 @@ static void check_reset_data_(unsigned int line, IMF2DBuffer2 *buffer2d, const B
ok(hr == S_OK, "got hr %#lx.\n", hr);
ok_(__FILE__,line)(max_length == width * height * 4, "got max_length %lu.\n", max_length);
ok_(__FILE__,line)(length == width * height * 4, "got length %lu.\n", length);
todo_wine_if(bottom_up && todo) ok_(__FILE__,line)(!memcmp(lock, data, length), "contiguous data mismatch.\n");
ok_(__FILE__,line)(!memcmp(lock, data, length), "contiguous data mismatch.\n");
memset(lock, 0xcc, length);
hr = IMFMediaBuffer_Unlock(buffer);
ok(hr == S_OK, "got hr %#lx.\n", hr);
Expand Down Expand Up @@ -9038,15 +9038,15 @@ static void test_2dbuffer_copy_(IMFMediaBuffer *buffer, BOOL bottom_up, DWORD wi

memset(data, 0xcc, sizeof(data));
data[0] = ((BYTE *)test_data)[0];
check_reset_data(buffer2d, data, bottom_up, width, height, FALSE);
check_reset_data(buffer2d, data, bottom_up, width, height);

hr = IMF2DBuffer2_ContiguousCopyFrom(buffer2d, (BYTE *)test_data, sizeof(test_data));
ok(hr == S_OK, "got hr %#lx.\n", hr);
hr = IMF2DBuffer2_ContiguousCopyTo(buffer2d, data, sizeof(data));
ok(hr == S_OK, "got hr %#lx.\n", hr);
ok(!memcmp(data, test_data, sizeof(data)), "data mismatch.\n");

check_reset_data(buffer2d, (const BYTE *)test_data, bottom_up, width, height, TRUE);
check_reset_data(buffer2d, (const BYTE *)test_data, bottom_up, width, height);

hr = IMFMediaBuffer_SetCurrentLength(src_buffer, sizeof(test_data) + 1);
ok(hr == S_OK, "got hr %#lx.\n", hr);
Expand All @@ -9058,7 +9058,7 @@ static void test_2dbuffer_copy_(IMFMediaBuffer *buffer, BOOL bottom_up, DWORD wi
hr = IMFSample_CopyToBuffer(sample, buffer);
ok(hr == S_OK, "got hr %#lx.\n", hr);

check_reset_data(buffer2d, (const BYTE *)test_data, bottom_up, width, height, FALSE);
check_reset_data(buffer2d, (const BYTE *)test_data, bottom_up, width, height);

IMF2DBuffer2_Release(buffer2d);
ref = IMFSample_Release(sample);
Expand Down

0 comments on commit 2049fd4

Please sign in to comment.