Commit 26876b4a authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

mfplat: Append MFVIDEOFORMAT user data after the structure padding.

Instead of using the last palette entry, which might be misaligned.
parent c11f9a8b
......@@ -3864,10 +3864,14 @@ HRESULT WINAPI MFInitMediaTypeFromMFVideoFormat(IMFMediaType *media_type, const
if (format->compressedInfo.MaxKeyFrameSpacing)
mediatype_set_uint32(media_type, &MF_MT_MAX_KEYFRAME_SPACING, format->compressedInfo.MaxKeyFrameSpacing, &hr);
if ((palette_size = format->surfaceInfo.PaletteEntries * sizeof(*format->surfaceInfo.Palette)))
if (!(palette_size = format->surfaceInfo.PaletteEntries * sizeof(*format->surfaceInfo.Palette)))
user_data = format + 1;
else
{
mediatype_set_blob(media_type, &MF_MT_PALETTE, (BYTE *)format->surfaceInfo.Palette, palette_size, &hr);
user_data = &format->surfaceInfo.Palette[format->surfaceInfo.PaletteEntries + 1];
}
user_data = &format->surfaceInfo.Palette[format->surfaceInfo.PaletteEntries + 1];
if ((user_data_size = (BYTE *)format + format->dwSize - (BYTE *)user_data))
mediatype_set_blob(media_type, &MF_MT_USER_DATA, user_data, user_data_size, &hr);
......
......@@ -8448,6 +8448,20 @@ static void test_MFInitMediaTypeFromMFVideoFormat(void)
ok(!memcmp(user_data, expect_user_data, value32), "Unexpected user data.\n");
IMFMediaType_DeleteAllItems(media_type);
/* check that user data follows MFVIDEOFORMAT struct, which is padded, when no palette is present */
format_buf->surfaceInfo.PaletteEntries = 0;
memmove(format_buf + 1, expect_user_data, sizeof(expect_user_data));
format_buf->dwSize = sizeof(*format_buf) + sizeof(expect_user_data);
hr = MFInitMediaTypeFromMFVideoFormat(media_type, format_buf, format_buf->dwSize);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
value32 = 0xdeadbeef;
memset(&user_data, 0xcd, sizeof(user_data));
hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, (BYTE *)user_data, sizeof(user_data), &value32);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(value32 == sizeof(expect_user_data), "got %u.\n", value32);
ok(!memcmp(user_data, expect_user_data, value32), "Unexpected user data.\n");
IMFMediaType_DeleteAllItems(media_type);
IMFMediaType_Release(media_type);
}
......
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