This is the first set of patches aimed at improving the functions to convert between media types and various representations. Not everything ended up being necessary for what I wanted to do (MFVIDEOFORMAT seems to be the only format able to carry aperture information after all) but the tests and implementation are now there and will still be useful to convert media types from/to AM_MEDIA_TYPE formats.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 200 ++++++++++++++++++++++++++++--------- 1 file changed, 154 insertions(+), 46 deletions(-)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 6897036e9dd..2c48852b4d4 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -9860,15 +9860,8 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void) todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
- vih.bmiHeader.biSize = sizeof(vih.bmiHeader); - vih.bmiHeader.biPlanes = 1; - vih.bmiHeader.biWidth = 16; - vih.bmiHeader.biHeight = 32; - vih.bmiHeader.biBitCount = 32; - hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected guid %s.\n", debugstr_guid(&guid)); @@ -9876,22 +9869,20 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&guid, &GUID_NULL), "Unexpected guid %s.\n", debugstr_guid(&guid)); hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value64 == ((UINT64)16 << 32 | 32), "Unexpected value %#I64x.\n", value64); - hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value64 == ((UINT64)1 << 32 | 1), "Unexpected value %#I64x.\n", value64); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value32 == MFVideoInterlace_Progressive, "Unexpected value %#x.\n", value32); - - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + + vih.bmiHeader.biWidth = 16; + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
vih.bmiHeader.biHeight = -32; @@ -9900,20 +9891,12 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void) hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value64 == ((UINT64)16 << 32 | 32), "Unexpected value %#I64x.\n", value64); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
vih.bmiHeader.biHeight = 32; - hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); - todo_wine - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (FAILED(hr)) goto failed; - - hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected guid %s.\n", debugstr_guid(&guid)); - hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine - ok(IsEqualGUID(&guid, &MFVideoFormat_RGB32), "Unexpected guid %s.\n", debugstr_guid(&guid)); hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value64 == ((UINT64)16 << 32 | 32), "Unexpected value %#I64x.\n", value64); @@ -9923,31 +9906,156 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void) hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(value32 == MFVideoInterlace_Progressive, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.bmiHeader.biSizeImage = 12345; + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value32 == 2048, "Unexpected value %u.\n", value32); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value32 == -64, "Unexpected value %d.\n", value32); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + todo_wine + ok(value32 == 12345, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.dwBitRate = 678910; + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!!value32, "Unexpected value %#x.\n", value32); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &value32); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(!!value32, "Unexpected value %#x.\n", value32); + todo_wine + ok(value32 == 678910, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
- /* Negative height. */ - vih.bmiHeader.biHeight = -32; - hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); + value32 = 0xdeadbeef; + vih.dwBitErrorRate = 11121314; + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &value32); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value32 == 64, "Unexpected value %d.\n", value32); - hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); + todo_wine + ok(value32 == 11121314, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value64 = 0xdeadbeef; + vih.AvgTimePerFrame = 1151617; + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - ok(value64 == ((UINT64)16 << 32 | 32), "Unexpected value %#I64x.\n", value64); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value64 == ((UINT64)10000000 << 32 | 1151617), "Unexpected value %#I64x.\n", value64); + + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &MFVideoFormat_NV12); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == 1, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == 1, "Unexpected value %#x.\n", value32); + + + /* biBitCount is used for implicit RGB format if GUID is NULL */ + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); + todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + for (vih.bmiHeader.biBitCount = 1; vih.bmiHeader.biBitCount <= 32; vih.bmiHeader.biBitCount++) + { + winetest_push_context("%u", vih.bmiHeader.biBitCount); + + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); + if (vih.bmiHeader.biBitCount != 1 && vih.bmiHeader.biBitCount != 4 && vih.bmiHeader.biBitCount != 8 + && vih.bmiHeader.biBitCount != 16 && vih.bmiHeader.biBitCount != 24 && vih.bmiHeader.biBitCount != 32) + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + else + { + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + memset(&guid, 0xcd, sizeof(guid)); + hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (vih.bmiHeader.biBitCount == 32) + todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB32), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 24) + todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB24), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 16) + todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB555), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 8) + todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB8), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 4) + todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB4), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 1) + todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB1), "Unexpected guid %s.\n", debugstr_guid(&guid)); + + value32 = 0xdeadbeef; + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (vih.bmiHeader.biBitCount > 1) + todo_wine + ok(value32 == 16 * vih.bmiHeader.biBitCount / 8, "Unexpected value %#x.\n", value32); + else + todo_wine ok(value32 == -4, "Unexpected value %#x.\n", value32); + + hr = IMFMediaType_GetItem(media_type, &MF_MT_PALETTE, NULL); + if (vih.bmiHeader.biBitCount > 1) + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + else + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == 1, "Unexpected value %#x.\n", value32); + value32 = 0xdeadbeef; + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == 1, "Unexpected value %#x.\n", value32); + + value32 = 0xdeadbeef; + vih.bmiHeader.biHeight = 32; + hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (vih.bmiHeader.biBitCount > 1) + todo_wine + ok(value32 == -16 * vih.bmiHeader.biBitCount / 8, "Unexpected value %#x.\n", value32); + else + todo_wine ok(value32 == -4, "Unexpected value %#x.\n", value32); + + vih.bmiHeader.biHeight = -32; + } + + winetest_pop_context(); + }
-failed: IMFMediaType_Release(media_type); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 37 +++++++++++++++++++++++++++++-------- dlls/mfplat/tests/mfplat.c | 28 +++++++--------------------- 2 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 66c0aaa2c62..afe611000a5 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -2697,13 +2697,14 @@ struct uncompressed_video_format
static int __cdecl uncompressed_video_format_compare(const void *a, const void *b) { - const GUID *guid = a; - const struct uncompressed_video_format *format = b; - return memcmp(guid, format->subtype, sizeof(*guid)); + const struct uncompressed_video_format *a_format = a, *b_format = b; + return memcmp(a_format->subtype, b_format->subtype, sizeof(GUID)); }
-static const struct uncompressed_video_format video_formats[] = +static struct uncompressed_video_format video_formats[] = { + { &MFVideoFormat_RGB1, 1, 0, 1, 0, BI_RGB }, + { &MFVideoFormat_RGB4, 4, 0, 1, 0, BI_RGB }, { &MFVideoFormat_RGB24, 24, 3, 1, 0, BI_RGB }, { &MFVideoFormat_ARGB32, 32, 3, 1, 0, BI_RGB }, { &MFVideoFormat_RGB32, 32, 3, 1, 0, BI_RGB }, @@ -2736,14 +2737,26 @@ static const struct uncompressed_video_format video_formats[] = { &MEDIASUBTYPE_RGB32, 32, 3, 1, 0, BI_RGB }, };
+static BOOL WINAPI mf_video_formats_init(INIT_ONCE *once, void *param, void **context) +{ + qsort(video_formats, ARRAY_SIZE(video_formats), sizeof(*video_formats), uncompressed_video_format_compare); + return TRUE; +} + static struct uncompressed_video_format *mf_get_video_format(const GUID *subtype) { - return bsearch(subtype, video_formats, ARRAY_SIZE(video_formats), sizeof(*video_formats), + static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; + struct uncompressed_video_format key = {.subtype = subtype}; + + InitOnceExecuteOnce(&init_once, mf_video_formats_init, NULL, NULL); + + return bsearch(&key, video_formats, ARRAY_SIZE(video_formats), sizeof(*video_formats), uncompressed_video_format_compare); }
static unsigned int mf_get_stride_for_format(const struct uncompressed_video_format *format, unsigned int width) { + if (format->bpp < 8) return (width * format->bpp) / 8; return (width * (format->bpp / 8) + format->alignment) & ~format->alignment; }
@@ -3743,14 +3756,22 @@ HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, cons DWORD height; LONG stride;
- FIXME("%p, %p, %u, %s.\n", media_type, vih, size, debugstr_guid(subtype)); + TRACE("%p, %p, %u, %s.\n", media_type, vih, size, debugstr_guid(subtype));
IMFMediaType_DeleteAllItems(media_type);
if (!subtype) { - FIXME("Implicit subtype is not supported.\n"); - return E_NOTIMPL; + switch (vih->bmiHeader.biBitCount) + { + case 1: subtype = &MFVideoFormat_RGB1; break; + case 4: subtype = &MFVideoFormat_RGB4; break; + case 8: subtype = &MFVideoFormat_RGB8; break; + case 16: subtype = &MFVideoFormat_RGB555; break; + case 24: subtype = &MFVideoFormat_RGB24; break; + case 32: subtype = &MFVideoFormat_RGB32; break; + default: return E_INVALIDARG; + } }
height = abs(vih->bmiHeader.biHeight); diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 2c48852b4d4..30f6d4b248e 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -9854,10 +9854,8 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void)
memset(&vih, 0, sizeof(vih)); hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, 0, NULL); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), &GUID_NULL); @@ -9974,7 +9972,6 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void)
/* biBitCount is used for implicit RGB format if GUID is NULL */ hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
for (vih.bmiHeader.biBitCount = 1; vih.bmiHeader.biBitCount <= 32; vih.bmiHeader.biBitCount++) @@ -9984,35 +9981,31 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void) hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); if (vih.bmiHeader.biBitCount != 1 && vih.bmiHeader.biBitCount != 4 && vih.bmiHeader.biBitCount != 8 && vih.bmiHeader.biBitCount != 16 && vih.bmiHeader.biBitCount != 24 && vih.bmiHeader.biBitCount != 32) - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); else { - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
memset(&guid, 0xcd, sizeof(guid)); hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); if (vih.bmiHeader.biBitCount == 32) - todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB32), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB32), "Unexpected guid %s.\n", debugstr_guid(&guid)); else if (vih.bmiHeader.biBitCount == 24) - todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB24), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB24), "Unexpected guid %s.\n", debugstr_guid(&guid)); else if (vih.bmiHeader.biBitCount == 16) - todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB555), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB555), "Unexpected guid %s.\n", debugstr_guid(&guid)); else if (vih.bmiHeader.biBitCount == 8) - todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB8), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB8), "Unexpected guid %s.\n", debugstr_guid(&guid)); else if (vih.bmiHeader.biBitCount == 4) - todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB4), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB4), "Unexpected guid %s.\n", debugstr_guid(&guid)); else if (vih.bmiHeader.biBitCount == 1) - todo_wine ok(IsEqualGUID(&guid, &MFVideoFormat_RGB1), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB1), "Unexpected guid %s.\n", debugstr_guid(&guid));
value32 = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); if (vih.bmiHeader.biBitCount > 1) - todo_wine ok(value32 == 16 * vih.bmiHeader.biBitCount / 8, "Unexpected value %#x.\n", value32); else todo_wine ok(value32 == -4, "Unexpected value %#x.\n", value32); @@ -10025,27 +10018,20 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void)
value32 = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(value32 == 1, "Unexpected value %#x.\n", value32); value32 = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(value32 == 1, "Unexpected value %#x.\n", value32);
value32 = 0xdeadbeef; vih.bmiHeader.biHeight = 32; hr = MFInitMediaTypeFromVideoInfoHeader(media_type, &vih, sizeof(vih), NULL); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); if (vih.bmiHeader.biBitCount > 1) - todo_wine ok(value32 == -16 * vih.bmiHeader.biBitCount / 8, "Unexpected value %#x.\n", value32); else todo_wine ok(value32 == -4, "Unexpected value %#x.\n", value32);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 25 +++++++++++++++++++++++-- dlls/mfplat/mfplat.spec | 2 +- include/mfapi.h | 3 +++ 3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index afe611000a5..10ec3d2acdb 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -3747,9 +3747,9 @@ HRESULT WINAPI MFCreateVideoMediaTypeFromVideoInfoHeader(const KS_VIDEOINFOHEADE }
/*********************************************************************** - * MFInitMediaTypeFromVideoInfoHeader (mfplat.@) + * MFInitMediaTypeFromVideoInfoHeader2 (mfplat.@) */ -HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, const VIDEOINFOHEADER *vih, UINT32 size, +HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader2(IMFMediaType *media_type, const VIDEOINFOHEADER2 *vih, UINT32 size, const GUID *subtype) { HRESULT hr = S_OK; @@ -3793,6 +3793,27 @@ HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, cons return hr; }
+/*********************************************************************** + * MFInitMediaTypeFromVideoInfoHeader (mfplat.@) + */ +HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, const VIDEOINFOHEADER *vih, UINT32 size, + const GUID *subtype) +{ + VIDEOINFOHEADER2 vih2 = + { + .rcSource = vih->rcSource, + .rcTarget = vih->rcTarget, + .dwBitRate = vih->dwBitRate, + .dwBitErrorRate = vih->dwBitErrorRate, + .AvgTimePerFrame = vih->AvgTimePerFrame, + .bmiHeader = vih->bmiHeader, + }; + + TRACE("%p, %p, %u, %s.\n", media_type, vih, size, debugstr_guid(subtype)); + + return MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih2, sizeof(vih2), subtype); +} + static HRESULT init_am_media_type_audio_format(AM_MEDIA_TYPE *am_type, UINT32 user_size, IMFMediaType *media_type) { UINT32 num_channels, value; diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index d7f75351960..44d1b89fff5 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -123,7 +123,7 @@ @ stub MFInitMediaTypeFromMFVideoFormat @ stub MFInitMediaTypeFromMPEG1VideoInfo @ stub MFInitMediaTypeFromMPEG2VideoInfo -@ stub MFInitMediaTypeFromVideoInfoHeader2 +@ stdcall MFInitMediaTypeFromVideoInfoHeader2(ptr ptr long ptr) @ stdcall MFInitMediaTypeFromVideoInfoHeader(ptr ptr long ptr) @ stdcall MFInitMediaTypeFromWaveFormatEx(ptr ptr long) @ stub MFInitVideoFormat diff --git a/include/mfapi.h b/include/mfapi.h index ef5bec16369..6ac5050e83f 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -23,6 +23,7 @@ #include <mmreg.h> #include <avrt.h> #include <dxgiformat.h> +#include <dvdmedia.h>
#if defined(__cplusplus) extern "C" { @@ -593,6 +594,8 @@ HRESULT WINAPI MFInitAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID f HRESULT WINAPI MFInitMediaTypeFromAMMediaType(IMFMediaType *mediatype, const AM_MEDIA_TYPE *am_type); HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, const VIDEOINFOHEADER *vih, UINT32 size, const GUID *subtype); +HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader2(IMFMediaType *media_type, const VIDEOINFOHEADER2 *vih, + UINT32 size, const GUID *subtype); HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WAVEFORMATEX *format, UINT32 size); HRESULT WINAPI MFInitVideoFormat_RGB(MFVIDEOFORMAT *format, DWORD width, DWORD height, DWORD d3dformat); HRESULT WINAPI MFInvokeCallback(IMFAsyncResult *result);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 259 +++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 30f6d4b248e..bd4ea469678 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -10045,6 +10045,264 @@ static void test_MFInitMediaTypeFromVideoInfoHeader(void) IMFMediaType_Release(media_type); }
+static void test_MFInitMediaTypeFromVideoInfoHeader2(void) +{ + IMFMediaType *media_type; + VIDEOINFOHEADER2 vih; + UINT32 value32; + UINT64 value64; + HRESULT hr; + GUID guid; + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + memset(&vih, 0, sizeof(vih)); + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, 0, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&guid, &MFMediaType_Video), "Unexpected guid %s.\n", debugstr_guid(&guid)); + hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&guid, &GUID_NULL), "Unexpected guid %s.\n", debugstr_guid(&guid)); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + vih.bmiHeader.biWidth = 16; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + vih.bmiHeader.biHeight = -32; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value64 == ((UINT64)16 << 32 | 32), "Unexpected value %#I64x.\n", value64); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + vih.bmiHeader.biHeight = 32; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &value64); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value64 == ((UINT64)16 << 32 | 32), "Unexpected value %#I64x.\n", value64); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == MFVideoInterlace_Progressive, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.bmiHeader.biSizeImage = 12345; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == 12345, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.dwBitRate = 678910; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == 678910, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.dwBitErrorRate = 11121314; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == 11121314, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value64 = 0xdeadbeef; + vih.AvgTimePerFrame = 1151617; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &value64); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value64 == ((UINT64)10000000 << 32 | 1151617), "Unexpected value %#I64x.\n", value64); + + value32 = 0xdeadbeef; + vih.dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == MFVideoInterlace_MixedInterlaceOrProgressive, "Unexpected value %#x.\n", value32); + + vih.dwPictAspectRatioX = 123; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64); + todo_wine + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value64 = 0xdeadbeef; + vih.dwPictAspectRatioY = 456; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(media_type, &MF_MT_PIXEL_ASPECT_RATIO, &value64); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value64 == ((UINT64)41 << 32 | 76), "Unexpected value %#I64x.\n", value64); + + vih.dwControlFlags = AMCONTROL_COLORINFO_PRESENT; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_YUV_MATRIX, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.dwControlFlags = AMCONTROL_COLORINFO_PRESENT | (MFVideoTransferMatrix_SMPTE240M << 15); + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_YUV_MATRIX, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == MFVideoTransferMatrix_SMPTE240M, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + vih.dwControlFlags = AMCONTROL_COLORINFO_PRESENT | (MFVideoTransferMatrix_SMPTE240M << 15) | (MFNominalRange_Wide << 12); + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &GUID_NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value32); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok(value32 == MFNominalRange_Wide, "Unexpected value %#x.\n", value32); + + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), &MFVideoFormat_NV12); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == 1, "Unexpected value %#x.\n", value32); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == 1, "Unexpected value %#x.\n", value32); + + + /* biBitCount is used for implicit RGB format if GUID is NULL */ + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + + for (vih.bmiHeader.biBitCount = 1; vih.bmiHeader.biBitCount <= 32; vih.bmiHeader.biBitCount++) + { + winetest_push_context("%u", vih.bmiHeader.biBitCount); + + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), NULL); + if (vih.bmiHeader.biBitCount != 1 && vih.bmiHeader.biBitCount != 4 && vih.bmiHeader.biBitCount != 8 + && vih.bmiHeader.biBitCount != 16 && vih.bmiHeader.biBitCount != 24 && vih.bmiHeader.biBitCount != 32) + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + else + { + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + memset(&guid, 0xcd, sizeof(guid)); + hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &guid); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (vih.bmiHeader.biBitCount == 32) + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB32), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 24) + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB24), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 16) + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB555), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 8) + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB8), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 4) + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB4), "Unexpected guid %s.\n", debugstr_guid(&guid)); + else if (vih.bmiHeader.biBitCount == 1) + ok(IsEqualGUID(&guid, &MFVideoFormat_RGB1), "Unexpected guid %s.\n", debugstr_guid(&guid)); + + value32 = 0xdeadbeef; + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (vih.bmiHeader.biBitCount > 1) + ok(value32 == 16 * vih.bmiHeader.biBitCount / 8, "Unexpected value %#x.\n", value32); + else + todo_wine ok(value32 == -4, "Unexpected value %#x.\n", value32); + + hr = IMFMediaType_GetItem(media_type, &MF_MT_PALETTE, NULL); + if (vih.bmiHeader.biBitCount > 1) + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + else + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + value32 = 0xdeadbeef; + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == 1, "Unexpected value %#x.\n", value32); + value32 = 0xdeadbeef; + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(value32 == 1, "Unexpected value %#x.\n", value32); + + value32 = 0xdeadbeef; + vih.bmiHeader.biHeight = 32; + hr = MFInitMediaTypeFromVideoInfoHeader2(media_type, &vih, sizeof(vih), NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, &value32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (vih.bmiHeader.biBitCount > 1) + ok(value32 == -16 * vih.bmiHeader.biBitCount / 8, "Unexpected value %#x.\n", value32); + else + todo_wine ok(value32 == -4, "Unexpected value %#x.\n", value32); + + vih.bmiHeader.biHeight = -32; + } + + winetest_pop_context(); + } + + IMFMediaType_Release(media_type); +} + static void test_MFInitMediaTypeFromAMMediaType(void) { IMFMediaType *media_type; @@ -10633,6 +10891,7 @@ START_TEST(mfplat) test_MFInitVideoFormat_RGB(); test_MFCreateVideoMediaTypeFromVideoInfoHeader(); test_MFInitMediaTypeFromVideoInfoHeader(); + test_MFInitMediaTypeFromVideoInfoHeader2(); test_MFInitMediaTypeFromAMMediaType(); test_MFCreatePathFromURL(); test_2dbuffer_copy();
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 106 +++++++++++++++++++++++-------------- dlls/mfplat/tests/mfplat.c | 8 +-- 2 files changed, 71 insertions(+), 43 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 10ec3d2acdb..52fcef25765 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -3902,11 +3902,51 @@ static HRESULT init_am_media_type_audio_format(AM_MEDIA_TYPE *am_type, UINT32 us return S_OK; }
-static HRESULT init_am_media_type_video_format(AM_MEDIA_TYPE *am_type, UINT32 user_size, IMFMediaType *media_type) +static void init_video_info_header2(VIDEOINFOHEADER2 *vih, const GUID *subtype, IMFMediaType *media_type) { + struct uncompressed_video_format *video_format = mf_get_video_format(subtype); UINT32 image_size, bitrate, sample_size; UINT64 frame_size, frame_rate; INT32 width, height; + + vih->bmiHeader.biSize = sizeof(vih->bmiHeader); + vih->bmiHeader.biPlanes = 1; + vih->bmiHeader.biBitCount = video_format ? video_format->bpp : 0; + + if (video_format && video_format->compression != -1) + vih->bmiHeader.biCompression = video_format->compression; + else + vih->bmiHeader.biCompression = subtype->Data1; + + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &bitrate))) + vih->dwBitRate = bitrate; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &bitrate))) + vih->dwBitErrorRate = bitrate; + if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &frame_rate)) && (frame_rate >> 32)) + vih->AvgTimePerFrame = round(10000000. * (UINT32)frame_rate / (frame_rate >> 32)); + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &sample_size))) + vih->bmiHeader.biSizeImage = sample_size; + + if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &frame_size))) + { + BOOL bottom_up = vih->bmiHeader.biCompression == BI_RGB || vih->bmiHeader.biCompression == BI_BITFIELDS; + + if (FAILED(IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, (UINT32 *)&width))) + width = (frame_size >> 32) * (bottom_up ? -1 : 1); + else if (video_format) + width /= video_format->bpp / 8; + height = (UINT32)frame_size; + + vih->bmiHeader.biWidth = abs(width); + vih->bmiHeader.biHeight = height * (bottom_up && width >= 0 ? -1 : 1); + + if (SUCCEEDED(MFCalculateImageSize(subtype, abs(width), height, &image_size))) + vih->bmiHeader.biSizeImage = image_size; + } +} + +static HRESULT init_am_media_type_video_format(AM_MEDIA_TYPE *am_type, UINT32 user_size, IMFMediaType *media_type) +{ HRESULT hr;
if (IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx)) @@ -3919,7 +3959,7 @@ static HRESULT init_am_media_type_video_format(AM_MEDIA_TYPE *am_type, UINT32 us if (IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo) || IsEqualGUID(&am_type->formattype, &GUID_NULL)) { - struct uncompressed_video_format *video_format = mf_get_video_format(&am_type->subtype); + VIDEOINFOHEADER2 vih = {{0}}; VIDEOINFOHEADER *format;
am_type->cbFormat = sizeof(*format) + user_size; @@ -3928,53 +3968,41 @@ static HRESULT init_am_media_type_video_format(AM_MEDIA_TYPE *am_type, UINT32 us format = (VIDEOINFOHEADER *)am_type->pbFormat; memset(format, 0, sizeof(*format));
- format->bmiHeader.biSize = sizeof(format->bmiHeader) + user_size; - format->bmiHeader.biPlanes = 1; - format->bmiHeader.biBitCount = video_format ? video_format->bpp : 0; - - if (video_format && video_format->compression != -1) - format->bmiHeader.biCompression = video_format->compression; - else - format->bmiHeader.biCompression = am_type->subtype.Data1; - - if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &bitrate))) - format->dwBitRate = bitrate; - if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &bitrate))) - format->dwBitErrorRate = bitrate; - if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &frame_rate)) && (frame_rate >> 32)) - format->AvgTimePerFrame = round(10000000. * (UINT32)frame_rate / (frame_rate >> 32)); - if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &sample_size))) - format->bmiHeader.biSizeImage = sample_size; - - if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &frame_size))) - { - BOOL bottom_up = format->bmiHeader.biCompression == BI_RGB || format->bmiHeader.biCompression == BI_BITFIELDS; - - if (FAILED(IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, (UINT32 *)&width))) - width = (frame_size >> 32) * (bottom_up ? -1 : 1); - else if (video_format) - width /= video_format->bpp / 8; - height = (UINT32)frame_size; - - format->bmiHeader.biWidth = abs(width); - format->bmiHeader.biHeight = height * (bottom_up && width >= 0 ? -1 : 1); - - if (SUCCEEDED(MFCalculateImageSize(&am_type->subtype, abs(width), height, &image_size))) - format->bmiHeader.biSizeImage = image_size; - } + init_video_info_header2(&vih, &am_type->subtype, media_type); + format->rcSource = vih.rcSource; + format->rcTarget = vih.rcTarget; + format->dwBitRate = vih.dwBitRate; + format->dwBitErrorRate = vih.dwBitErrorRate; + format->AvgTimePerFrame = vih.AvgTimePerFrame; + format->bmiHeader = vih.bmiHeader;
if (user_size && FAILED(hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, (BYTE *)(format + 1), user_size, NULL))) return hr; + format->bmiHeader.biSize += user_size;
am_type->formattype = FORMAT_VideoInfo; am_type->subtype = get_am_subtype_for_mf_subtype(am_type->subtype); } else if (IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo2)) { - FIXME("Not implemented!\n"); - am_type->formattype = GUID_NULL; - return E_NOTIMPL; + VIDEOINFOHEADER2 *format; + + am_type->cbFormat = sizeof(*format) + user_size; + if (!(am_type->pbFormat = CoTaskMemAlloc(am_type->cbFormat))) + return E_OUTOFMEMORY; + format = (VIDEOINFOHEADER2 *)am_type->pbFormat; + memset(format, 0, sizeof(*format)); + + init_video_info_header2(format, &am_type->subtype, media_type); + + if (user_size && FAILED(hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, + (BYTE *)(format + 1), user_size, NULL))) + return hr; + format->bmiHeader.biSize += user_size; + + am_type->formattype = FORMAT_VideoInfo2; + am_type->subtype = get_am_subtype_for_mf_subtype(am_type->subtype); } else { diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index bd4ea469678..634dd87ae09 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7213,11 +7213,11 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER), "got %lu\n", am_type.cbFormat); CoTaskMemFree(am_type.pbFormat); hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo2, &am_type); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type.majortype)); - todo_wine ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); - todo_wine ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo2), "got %s.\n", debugstr_guid(&am_type.formattype)); - todo_wine ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER2), "got %lu\n", am_type.cbFormat); + ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo2), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER2), "got %lu\n", am_type.cbFormat); CoTaskMemFree(am_type.pbFormat); hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_MFVideoFormat, &am_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=144022
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
mfplat: mfplat.c:10170: Test failed: Unexpected value 0x4.
=== w7u_el (32 bit report) ===
mfplat: mfplat.c:10170: Test failed: Unexpected value 0x4.
=== debian11b (64 bit WoW report) ===
d3dx10_34: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011B6160. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011C34C0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011C3580. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011D1820. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011C3750.
d3dx10_35: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011D1B30. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011D5530. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011D18E0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011D5530. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011BD790.
d3dx10_36: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011D1F10. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011958A0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011958A0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011D1D00. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011958A0.
d3dx10_37: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001239DE0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011A4A60. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011D5720. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011BB560. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011B6050.
d3dx10_38: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001182E90. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011BD560. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E36E0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011E36E0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011B5E80.
d3dx10_39: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001230C40. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 0000000001230C40. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 0000000001239E20. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 0000000001195B10. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 0000000001230C40.
d3dx10_40: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001195C70. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 0000000001195B70. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E3610. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011C3BF0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011D1F50.
d3dx10_41: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001239D50. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011D3E80. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E37E0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 0000000001239F20. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011D3E80.
d3dx10_42: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011A4690. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011A4860. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011D18E0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011D1AB0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011D55F0.
d3dx10_43: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011E3DE0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011C3690. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E3FB0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011E3DE0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011BBA70.
Nikolay Sivov (@nsivov) commented about include/mfapi.h:
#include <mmreg.h> #include <avrt.h> #include <dxgiformat.h> +#include <dvdmedia.h>
SDK does not do this. Instead they define just a structure pointer.