[PATCH 0/1] MR10682: mfplat/tests: Test MFInitAMMediaTypeFromMFMediaType GUID conversions.
Proves that it doesn't convert GUIDs when using FORMAT_MFVideoFormat. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10682
From: Rémi Bernon <rbernon@codeweavers.com> Proves that it doesn't convert GUIDs when using FORMAT_MFVideoFormat. --- dlls/mfplat/tests/mfplat.c | 138 +++++++++++++++++++++++++------------ 1 file changed, 95 insertions(+), 43 deletions(-) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 03b89993f6f..e28fece1418 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -631,6 +631,10 @@ static WCHAR *load_resource(const WCHAR *name) static BOOL is_MEDIASUBTYPE_RGB(const GUID *subtype) { return IsEqualGUID(subtype, &MEDIASUBTYPE_RGB8) + || IsEqualGUID(subtype, &MEDIASUBTYPE_RGB1) + || IsEqualGUID(subtype, &MEDIASUBTYPE_RGB4) + || IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB1555) + || IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB32) || IsEqualGUID(subtype, &MEDIASUBTYPE_RGB555) || IsEqualGUID(subtype, &MEDIASUBTYPE_RGB565) || IsEqualGUID(subtype, &MEDIASUBTYPE_RGB24) @@ -8678,6 +8682,46 @@ static void test_MFCreateMFVideoFormatFromMFMediaType(void) IMFMediaType_Release(media_type); } +static const struct guid_type_pair +{ + const GUID *am_type; + const GUID *mf_type; +} am_mf_guid_tests[] = +{ + /* these RGB formats are converted, MEDIASUBTYPE variant isn't + * defined using DEFINE_MEDIATYPE_GUID */ + { &MEDIASUBTYPE_RGB1, &MFVideoFormat_RGB1 }, + { &MEDIASUBTYPE_RGB4, &MFVideoFormat_RGB4 }, + { &MEDIASUBTYPE_RGB8, &MFVideoFormat_RGB8 }, + { &MEDIASUBTYPE_RGB555, &MFVideoFormat_RGB555 }, + { &MEDIASUBTYPE_RGB565, &MFVideoFormat_RGB565 }, + { &MEDIASUBTYPE_RGB24, &MFVideoFormat_RGB24 }, + { &MEDIASUBTYPE_RGB32, &MFVideoFormat_RGB32 }, + { &MEDIASUBTYPE_ARGB1555, &MFVideoFormat_ARGB1555 }, + { &MEDIASUBTYPE_ARGB4444, &MFVideoFormat_ARGB4444 }, + { &MEDIASUBTYPE_ARGB32, &MFVideoFormat_ARGB32 }, + { &MEDIASUBTYPE_A2R10G10B10, &MFVideoFormat_A2B10G10R10 }, + { &MEDIASUBTYPE_A2B10G10R10, &MFVideoFormat_A2R10G10B10 }, + + /* any other GUID is passed through */ + { &MEDIASUBTYPE_I420, &MFVideoFormat_I420 }, + { &MEDIASUBTYPE_AYUV, &MFVideoFormat_AYUV }, + { &MEDIASUBTYPE_YV12, &MFVideoFormat_YV12 }, + { &MEDIASUBTYPE_YUY2, &MFVideoFormat_YUY2 }, + { &MEDIASUBTYPE_UYVY, &MFVideoFormat_UYVY }, + { &MEDIASUBTYPE_YVYU, &MFVideoFormat_YVYU }, + { &MEDIASUBTYPE_NV12, &MFVideoFormat_NV12 }, + + /* even formats that don't exist in MF */ + { &DUMMY_GUID3, &DUMMY_GUID3 }, + { &MEDIASUBTYPE_NV24, &MEDIASUBTYPE_NV24 }, + { &MEDIASUBTYPE_P208, &MEDIASUBTYPE_P208 }, + + /* if the mapping is ambiguous, it is not corrected */ + { &MEDIASUBTYPE_h264, &MEDIASUBTYPE_h264 }, + { &MEDIASUBTYPE_H264, &MFVideoFormat_H264 }, +}; + static void test_MFInitAMMediaTypeFromMFMediaType(void) { static const MFVideoArea aperture = {.OffsetX = {.fract = 1, .value = 2}, .OffsetY = {.fract = 3, .value = 4}, .Area={56,78}}; @@ -8690,6 +8734,7 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) MPEG1VIDEOINFO *mpeg1_info; MPEG2VIDEOINFO *mpeg2_info; IMFMediaType *media_type, *other_type; + MFVIDEOFORMAT *video_format; AM_MEDIA_TYPE am_type; MFVideoArea *area; UINT32 value32; @@ -9530,6 +9575,52 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) IMFMediaType_DeleteAllItems(media_type); + for (UINT i = 0; i < ARRAY_SIZE(am_mf_guid_tests); ++i) + { + winetest_push_context("%s", debugstr_guid(am_mf_guid_tests[i].am_type)); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, am_mf_guid_tests[i].mf_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)1920 << 32 | 1088); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "Unexpected guid %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, am_mf_guid_tests[i].am_type), "Unexpected guid %s.\n", debugstr_guid(&am_type.subtype)); + if (IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB565)) + todo_wine ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER) + 3 * sizeof(DWORD), "got %lu\n", am_type.cbFormat); + else + ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER), "got %lu\n", am_type.cbFormat); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + if (!is_MEDIASUBTYPE_RGB(&am_type.subtype) && !IsEqualGUID(&am_type.subtype, &DUMMY_GUID3)) + ok(video_info->bmiHeader.biCompression == am_mf_guid_tests[i].mf_type->Data1, + "got compression %s\n", debugstr_fourcc(video_info->bmiHeader.biCompression)); + else if (IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB565)) + ok(video_info->bmiHeader.biCompression == BI_BITFIELDS, + "got compression %s\n", debugstr_fourcc(video_info->bmiHeader.biCompression)); + else + todo_wine_if(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_ARGB1555) || IsEqualGUID(&am_type.subtype, &DUMMY_GUID3)) + ok(video_info->bmiHeader.biCompression == BI_RGB, + "got compression %s\n", debugstr_fourcc(video_info->bmiHeader.biCompression)); + CoTaskMemFree(am_type.pbFormat); + + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_MFVideoFormat, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "Unexpected guid %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, am_mf_guid_tests[i].mf_type), "Unexpected guid %s.\n", debugstr_guid(&am_type.subtype)); + ok(am_type.cbFormat == sizeof(MFVIDEOFORMAT), "got %lu\n", am_type.cbFormat); + video_format = (MFVIDEOFORMAT *)am_type.pbFormat; + ok(IsEqualGUID(&video_format->guidFormat, am_mf_guid_tests[i].mf_type), "Unexpected guid %s.\n", debugstr_guid(&video_format->guidFormat)); + CoTaskMemFree(am_type.pbFormat); + + IMFMediaType_DeleteAllItems(media_type); + winetest_pop_context(); + } + + IMFMediaType_Release(media_type); } @@ -13284,45 +13375,6 @@ static void test_MFInitMediaTypeFromAMMediaType(void) {0}, {0}, 0, 0, 0, {sizeof(BITMAPINFOHEADER), 32, 24, 1, 0, 0xdeadbeef} }; - static const struct guid_type_pair - { - const GUID *am_type; - const GUID *mf_type; - } guid_types[] = - { - /* these RGB formats are converted, MEDIASUBTYPE variant isn't - * defined using DEFINE_MEDIATYPE_GUID */ - { &MEDIASUBTYPE_RGB1, &MFVideoFormat_RGB1 }, - { &MEDIASUBTYPE_RGB4, &MFVideoFormat_RGB4 }, - { &MEDIASUBTYPE_RGB8, &MFVideoFormat_RGB8 }, - { &MEDIASUBTYPE_RGB555, &MFVideoFormat_RGB555 }, - { &MEDIASUBTYPE_RGB565, &MFVideoFormat_RGB565 }, - { &MEDIASUBTYPE_RGB24, &MFVideoFormat_RGB24 }, - { &MEDIASUBTYPE_RGB32, &MFVideoFormat_RGB32 }, - { &MEDIASUBTYPE_ARGB1555, &MFVideoFormat_ARGB1555 }, - { &MEDIASUBTYPE_ARGB4444, &MFVideoFormat_ARGB4444 }, - { &MEDIASUBTYPE_ARGB32, &MFVideoFormat_ARGB32 }, - { &MEDIASUBTYPE_A2R10G10B10, &MFVideoFormat_A2B10G10R10 }, - { &MEDIASUBTYPE_A2B10G10R10, &MFVideoFormat_A2R10G10B10 }, - - /* any other GUID is passed through */ - { &MEDIASUBTYPE_I420, &MFVideoFormat_I420 }, - { &MEDIASUBTYPE_AYUV, &MFVideoFormat_AYUV }, - { &MEDIASUBTYPE_YV12, &MFVideoFormat_YV12 }, - { &MEDIASUBTYPE_YUY2, &MFVideoFormat_YUY2 }, - { &MEDIASUBTYPE_UYVY, &MFVideoFormat_UYVY }, - { &MEDIASUBTYPE_YVYU, &MFVideoFormat_YVYU }, - { &MEDIASUBTYPE_NV12, &MFVideoFormat_NV12 }, - - /* even formats that don't exist in MF */ - { &DUMMY_GUID3, &DUMMY_GUID3 }, - { &MEDIASUBTYPE_NV24, &MEDIASUBTYPE_NV24 }, - { &MEDIASUBTYPE_P208, &MEDIASUBTYPE_P208 }, - - /* if the mapping is ambiguous, it is not corrected */ - { &MEDIASUBTYPE_h264, &MEDIASUBTYPE_h264 }, - { &MEDIASUBTYPE_H264, &MFVideoFormat_H264 }, - }; static const GUID *audio_types[] = { &MEDIASUBTYPE_MP3, @@ -13509,10 +13561,10 @@ static void test_MFInitMediaTypeFromAMMediaType(void) ok(!memcmp(&aperture, &expect_aperture, sizeof(aperture)), "unexpected aperture\n"); vih.bmiHeader.biHeight = 24; - for (i = 0; i < ARRAY_SIZE(guid_types); ++i) + for (i = 0; i < ARRAY_SIZE(am_mf_guid_tests); ++i) { - winetest_push_context("%s", debugstr_guid(guid_types[i].am_type)); - memcpy(&mt.subtype, guid_types[i].am_type, sizeof(GUID)); + winetest_push_context("%s", debugstr_guid(am_mf_guid_tests[i].am_type)); + memcpy(&mt.subtype, am_mf_guid_tests[i].am_type, sizeof(GUID)); hr = MFInitMediaTypeFromAMMediaType(media_type, &mt); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -13522,7 +13574,7 @@ static void test_MFInitMediaTypeFromAMMediaType(void) 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_types[i].mf_type), "Unexpected guid %s.\n", debugstr_guid(&guid)); + ok(IsEqualGUID(&guid, am_mf_guid_tests[i].mf_type), "Unexpected guid %s.\n", debugstr_guid(&guid)); winetest_pop_context(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10682
Nikolay Sivov (@nsivov) commented about dlls/mfplat/tests/mfplat.c:
+ else if (IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB565)) + ok(video_info->bmiHeader.biCompression == BI_BITFIELDS, + "got compression %s\n", debugstr_fourcc(video_info->bmiHeader.biCompression)); + else + todo_wine_if(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_ARGB1555) || IsEqualGUID(&am_type.subtype, &DUMMY_GUID3)) + ok(video_info->bmiHeader.biCompression == BI_RGB, + "got compression %s\n", debugstr_fourcc(video_info->bmiHeader.biCompression)); + CoTaskMemFree(am_type.pbFormat); + + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_MFVideoFormat, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "Unexpected guid %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, am_mf_guid_tests[i].mf_type), "Unexpected guid %s.\n", debugstr_guid(&am_type.subtype)); + ok(am_type.cbFormat == sizeof(MFVIDEOFORMAT), "got %lu\n", am_type.cbFormat); + video_format = (MFVIDEOFORMAT *)am_type.pbFormat; + ok(IsEqualGUID(&video_format->guidFormat, am_mf_guid_tests[i].mf_type), "Unexpected guid %s.\n", debugstr_guid(&video_format->guidFormat)); Is it the guidFormat that it doesn't convert?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10682#note_136664
On Fri Apr 17 07:44:48 2026 +0000, Nikolay Sivov wrote:
Is it the guidFormat that it doesn't convert? I wanted to check that neither `am_type.subtype` nor `video_format->guidFormat` are converted to DMO subtypes when using FORMAT_MFVideoFormat, to the contrary to the case just above when using FORMAT_VideoInfo where `am_type.subtype` is converted.
This matters for how the color converter should implement its DMO/MFT conversions: it returns AM_MEDIA_TYPE with MFVIDEOFORMAT from its DMO interface when types have been set using the MFT iface, but with the DMO subtypes (and with MF subtypes of course when current type is checked through the MFT iface). As `MFInitAMMediaTypeFromMFMediaType` doesn't convert subtypes in that case, it's up to the color converter to do it. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10682#note_136670
This merge request was approved by Nikolay Sivov. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10682
participants (3)
-
Nikolay Sivov (@nsivov) -
Rémi Bernon -
Rémi Bernon (@rbernon)