Commit cd719c7c authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

mfplat/tests: Test IMF2DBuffer::ContiguousCopyFrom().

parent 73dbdf30
...@@ -6181,14 +6181,82 @@ static void test_MFCreate2DMediaBuffer(void) ...@@ -6181,14 +6181,82 @@ static void test_MFCreate2DMediaBuffer(void)
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&_2dbuffer); hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&_2dbuffer);
ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer2, (void **)&_2dbuffer2);
ok(hr == S_OK, "Failed to get interface, hr %#lx.\n", hr);
hr = IMF2DBuffer_GetContiguousLength(_2dbuffer, &length); hr = IMF2DBuffer_GetContiguousLength(_2dbuffer, &length);
ok(hr == S_OK, "Failed to get length, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to get length, hr %#lx.\n", hr);
ok(length == ptr->contiguous_length, "Unexpected contiguous length %lu.\n", length); ok(length == ptr->contiguous_length, "Unexpected contiguous length %lu.\n", length);
data2 = malloc(ptr->contiguous_length + 16);
ok(!!data2, "Failed to allocate buffer.\n");
for (j = 0; j < ptr->contiguous_length + 16; j++)
data2[j] = j & 0x7f;
hr = IMF2DBuffer2_ContiguousCopyFrom(_2dbuffer2, data2, ptr->contiguous_length - 1);
todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaBuffer_Lock(buffer, &data, &length2, NULL); hr = IMFMediaBuffer_Lock(buffer, &data, &length2, NULL);
ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr);
ok(length2 == ptr->contiguous_length, "Unexpected linear buffer length %lu.\n", length2); ok(length2 == ptr->contiguous_length, "Unexpected linear buffer length %lu.\n", length2);
memset(data, 0xff, length2);
hr = IMFMediaBuffer_Unlock(buffer);
ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
hr = IMF2DBuffer2_ContiguousCopyFrom(_2dbuffer2, data2, ptr->contiguous_length + 16);
todo_wine ok(hr == S_OK, "Failed to copy from contiguous buffer, hr %#lx.\n", hr);
hr = IMFMediaBuffer_Lock(buffer, &data, &length2, NULL);
ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr);
ok(length2 == ptr->contiguous_length, "%d: unexpected linear buffer length %lu for %u x %u, format %s.\n",
i, length2, ptr->width, ptr->height, wine_dbgstr_guid(ptr->subtype));
for (j = 0; j < ptr->contiguous_length; j++)
{
if (IsEqualGUID(ptr->subtype, &MFVideoFormat_IMC1) || IsEqualGUID(ptr->subtype, &MFVideoFormat_IMC3))
{
if (j < ptr->height * ptr->pitch && j % ptr->pitch >= ptr->width)
continue;
if (j >= ptr->height * ptr->pitch && j % ptr->pitch >= ptr->width / 2)
continue;
}
if (data[j] != (j & 0x7f))
break;
}
todo_wine ok(j == ptr->contiguous_length, "Unexpected byte %02x instead of %02x at position %u.\n", data[j], j & 0x7f, j);
memset(data, 0xff, length2);
hr = IMFMediaBuffer_Unlock(buffer);
ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
hr = IMF2DBuffer2_ContiguousCopyFrom(_2dbuffer2, data2, ptr->contiguous_length);
todo_wine ok(hr == S_OK, "Failed to copy from contiguous buffer, hr %#lx.\n", hr);
free(data2);
hr = IMFMediaBuffer_Lock(buffer, &data, &length2, NULL);
ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr);
ok(length2 == ptr->contiguous_length, "%d: unexpected linear buffer length %lu for %u x %u, format %s.\n",
i, length2, ptr->width, ptr->height, wine_dbgstr_guid(ptr->subtype));
for (j = 0; j < ptr->contiguous_length; j++)
{
if (IsEqualGUID(ptr->subtype, &MFVideoFormat_IMC1) || IsEqualGUID(ptr->subtype, &MFVideoFormat_IMC3))
{
if (j < ptr->height * ptr->pitch && j % ptr->pitch >= ptr->width)
continue;
if (j >= ptr->height * ptr->pitch && j % ptr->pitch >= ptr->width / 2)
continue;
}
if (data[j] != (j & 0x7f))
break;
}
todo_wine ok(j == ptr->contiguous_length, "Unexpected byte %02x instead of %02x at position %u.\n", data[j], j & 0x7f, j);
hr = pMFGetStrideForBitmapInfoHeader(ptr->subtype->Data1, ptr->width, &stride); hr = pMFGetStrideForBitmapInfoHeader(ptr->subtype->Data1, ptr->width, &stride);
ok(hr == S_OK, "Failed to get stride, hr %#lx.\n", hr); ok(hr == S_OK, "Failed to get stride, hr %#lx.\n", hr);
stride = abs(stride); stride = abs(stride);
...@@ -6304,6 +6372,7 @@ static void test_MFCreate2DMediaBuffer(void) ...@@ -6304,6 +6372,7 @@ static void test_MFCreate2DMediaBuffer(void)
ok(!ret, "%d: unexpected format flag %d.\n", i, ret); ok(!ret, "%d: unexpected format flag %d.\n", i, ret);
IMF2DBuffer_Release(_2dbuffer); IMF2DBuffer_Release(_2dbuffer);
IMF2DBuffer2_Release(_2dbuffer2);
IMFMediaBuffer_Release(buffer); IMFMediaBuffer_Release(buffer);
......
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