[PATCH v2 0/2] MR10666: mf/tests: Check some IMFTransform / IMediaObject interop.
-- v2: mf/tests: Check color converter IMFTransform / IMediaObject interop. mf/tests: Check resampler IMFTransform / IMediaObject interop. https://gitlab.winehq.org/wine/wine/-/merge_requests/10666
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/mf/tests/transform.c | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 87d0e275082..992f34baa66 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -6211,7 +6211,9 @@ static void test_audio_convert(void) IMFMediaType *media_type; IMFTransform *transform; const BYTE *audio_data; + DMO_MEDIA_TYPE dmo_mt; ULONG audio_data_len; + IMediaObject *dmo; ULONG i, ret, ref; HRESULT hr; @@ -6274,6 +6276,32 @@ static void test_audio_convert(void) check_mft_set_input_type(transform, input_type_desc, S_OK); check_mft_get_input_current_type_(__LINE__, transform, expect_input_type_desc, FALSE, TRUE); + + hr = IMFTransform_QueryInterface(transform, &IID_IMediaObject, (void **)&dmo); + ok(hr == S_OK, "QueryInterface returned %#lx\n", hr); + + memset(&dmo_mt, 0, sizeof(dmo_mt)); + hr = IMediaObject_GetInputCurrentType(dmo, 0, &dmo_mt); + todo_wine ok(hr == S_OK, "GetInputCurrentType returned %#lx\n", hr); + todo_wine ok(IsEqualGUID(&dmo_mt.formattype, &FORMAT_WaveFormatEx), "got format %s\n", debugstr_guid(&dmo_mt.formattype)); + todo_wine ok(dmo_mt.cbFormat >= sizeof(WAVEFORMATEX), "got cbFormat %#lx\n", dmo_mt.cbFormat); + + hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &dmo_mt, &media_type); + todo_wine ok(hr == S_OK, "MFCreateMediaTypeFromRepresentation returned %#lx\n", hr); + if (hr == S_OK) + { + check_media_type(media_type, expect_input_type_desc, -1); + IMFMediaType_Release(media_type); + + hr = IMediaObject_SetInputType(dmo, 0, &dmo_mt, 0); + ok(hr == S_OK, "SetInputType returned %#lx\n", hr); + check_mft_get_input_current_type_(__LINE__, transform, expect_input_type_desc, FALSE, TRUE); + } + + MoFreeMediaType(&dmo_mt); + IMediaObject_Release(dmo); + + check_mft_get_input_stream_info(transform, MF_E_TRANSFORM_TYPE_NOT_SET, NULL); check_mft_get_output_stream_info(transform, MF_E_TRANSFORM_TYPE_NOT_SET, NULL); @@ -6300,6 +6328,32 @@ static void test_audio_convert(void) /* setting the input type does not set the output type to null */ check_mft_get_output_current_type_(__LINE__, transform, expect_output_type_desc, FALSE, TRUE); + + hr = IMFTransform_QueryInterface(transform, &IID_IMediaObject, (void **)&dmo); + ok(hr == S_OK, "QueryInterface returned %#lx\n", hr); + + memset(&dmo_mt, 0, sizeof(dmo_mt)); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &dmo_mt); + todo_wine ok(hr == S_OK, "GetOutputCurrentType returned %#lx\n", hr); + todo_wine ok(IsEqualGUID(&dmo_mt.formattype, &FORMAT_WaveFormatEx), "got format %s\n", debugstr_guid(&dmo_mt.formattype)); + todo_wine ok(dmo_mt.cbFormat >= sizeof(WAVEFORMATEX), "got cbFormat %#lx\n", dmo_mt.cbFormat); + + hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &dmo_mt, &media_type); + todo_wine ok(hr == S_OK, "MFCreateMediaTypeFromRepresentation returned %#lx\n", hr); + if (hr == S_OK) + { + check_media_type(media_type, expect_output_type_desc, -1); + IMFMediaType_Release(media_type); + + hr = IMediaObject_SetOutputType(dmo, 0, &dmo_mt, 0); + ok(hr == S_OK, "SetOutputType returned %#lx\n", hr); + check_mft_get_output_current_type_(__LINE__, transform, expect_output_type_desc, FALSE, TRUE); + } + + MoFreeMediaType(&dmo_mt); + IMediaObject_Release(dmo); + + check_mft_get_input_stream_info(transform, S_OK, &input_info); check_mft_get_output_stream_info(transform, S_OK, &output_info); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10666
From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/mf/tests/transform.c | 126 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 992f34baa66..2e33e298cf3 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -57,7 +57,13 @@ DEFINE_GUID(DMOVideoFormat_RGB565,D3DFMT_R5G6B5,0x524f,0x11ce,0x9f,0x53,0x00,0x2 DEFINE_GUID(DMOVideoFormat_RGB8,D3DFMT_P8,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70); DEFINE_GUID(MFAudioFormat_RAW_AAC1,WAVE_FORMAT_RAW_AAC1,0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71); DEFINE_GUID(MFVideoFormat_WMV_Unknown,0x7ce12ca9,0xbfbf,0x43d9,0x9d,0x00,0x82,0xb8,0xed,0x54,0x31,0x6b); +DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB1, D3DFMT_A1); +DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB4, MAKEFOURCC('4','P','x','x')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_ABGR32,D3DFMT_A8B8G8R8); +DEFINE_MEDIATYPE_GUID(MFVideoFormat_ARGB1555, D3DFMT_A1R5G5B5); +DEFINE_MEDIATYPE_GUID(MFVideoFormat_ARGB4444, D3DFMT_A4R4G4B4); +/* SDK MFVideoFormat_A2R10G10B10 uses D3DFMT_A2B10G10R10, let's name it the other way */ +DEFINE_MEDIATYPE_GUID(MFVideoFormat_A2B10G10R10, D3DFMT_A2R10G10B10); DEFINE_MEDIATYPE_GUID(MFVideoFormat_P208,MAKEFOURCC('P','2','0','8')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_VC1S,MAKEFOURCC('V','C','1','S')); @@ -65,6 +71,64 @@ DEFINE_GUID(mft_output_sample_incomplete,0xffffff,0xffff,0xffff,0xff,0xff,0xff,0 static const GUID test_attr_guid = {0xdeadbeef}; +static BOOL is_dmo_subtype(const GUID *subtype) +{ + if (IsEqualGUID(subtype, &MFVideoFormat_RGB1)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_RGB4)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_RGB8)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_RGB555)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_RGB565)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_RGB24)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_RGB32)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_ARGB1555)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_ARGB4444)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_ARGB32)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_A2B10G10R10)) + return FALSE; + if (IsEqualGUID(subtype, &MFVideoFormat_A2R10G10B10)) + return FALSE; + return TRUE; +} + +static const GUID * get_mf_subtype_for_am_subtype(const GUID *subtype) +{ + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB1)) + return &MFVideoFormat_RGB1; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB4)) + return &MFVideoFormat_RGB4; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB8)) + return &MFVideoFormat_RGB8; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB555)) + return &MFVideoFormat_RGB555; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB565)) + return &MFVideoFormat_RGB565; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB24)) + return &MFVideoFormat_RGB24; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_RGB32)) + return &MFVideoFormat_RGB32; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB1555)) + return &MFVideoFormat_ARGB1555; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB4444)) + return &MFVideoFormat_ARGB4444; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB32)) + return &MFVideoFormat_ARGB32; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_A2R10G10B10)) + return &MFVideoFormat_A2B10G10R10; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_A2B10G10R10)) + return &MFVideoFormat_A2R10G10B10; + return subtype; +} + struct media_buffer { IMediaBuffer IMediaBuffer_iface; @@ -9026,6 +9090,8 @@ static void test_color_convert(BOOL use_2d_buffer) ULONG nv12frame_data_len; IMFMediaType *media_type; IMFTransform *transform; + DMO_MEDIA_TYPE dmo_mt; + IMediaObject *dmo; ULONG i, ret, ref; HRESULT hr; @@ -9095,6 +9161,36 @@ static void test_color_convert(BOOL use_2d_buffer) check_mft_set_input_type(transform, input_type_desc, S_OK); check_mft_get_input_current_type_(__LINE__, transform, expect_input_type_desc, FALSE, TRUE); + + hr = IMFTransform_QueryInterface(transform, &IID_IMediaObject, (void **)&dmo); + ok(hr == S_OK, "QueryInterface returned %#lx\n", hr); + + memset(&dmo_mt, 0, sizeof(dmo_mt)); + hr = IMediaObject_GetInputCurrentType(dmo, 0, &dmo_mt); + todo_wine ok(hr == S_OK, "GetInputCurrentType returned %#lx\n", hr); + todo_wine ok(IsEqualGUID(&dmo_mt.formattype, &FORMAT_MFVideoFormat), "got format %s\n", debugstr_guid(&dmo_mt.formattype)); + todo_wine ok(dmo_mt.cbFormat == sizeof(MFVIDEOFORMAT), "got cbFormat %#lx\n", dmo_mt.cbFormat); + ok(is_dmo_subtype(&dmo_mt.subtype), "got subtype %s\n", debugstr_guid(&dmo_mt.subtype)); + + hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &dmo_mt, &media_type); + todo_wine ok(hr == S_OK, "MFCreateMediaTypeFromRepresentation returned %#lx\n", hr); + if (hr == S_OK) + { + /* MFCreateMediaTypeFromRepresentation automatically converts MF to DMO media types */ + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, get_mf_subtype_for_am_subtype(&dmo_mt.subtype)); + ok(hr == S_OK, "SetGUID returned %#lx\n", hr); + check_media_type(media_type, expect_input_type_desc, -1); + IMFMediaType_Release(media_type); + + hr = IMediaObject_SetInputType(dmo, 0, &dmo_mt, 0); + ok(hr == S_OK, "SetInputType returned %#lx\n", hr); + check_mft_get_input_current_type_(__LINE__, transform, expect_input_type_desc, FALSE, TRUE); + } + + MoFreeMediaType(&dmo_mt); + IMediaObject_Release(dmo); + + for (i = 0; i < ARRAY_SIZE(color_conversion_tests); i++) { /* flipped sample tests apply only to 2D buffers */ @@ -9106,6 +9202,36 @@ static void test_color_convert(BOOL use_2d_buffer) check_mft_set_output_type(transform, color_conversion_tests[i].output_type_desc, S_OK); check_mft_get_output_current_type_(__LINE__, transform, color_conversion_tests[i].expect_output_type_desc, FALSE, TRUE); + + hr = IMFTransform_QueryInterface(transform, &IID_IMediaObject, (void **)&dmo); + ok(hr == S_OK, "QueryInterface returned %#lx\n", hr); + + memset(&dmo_mt, 0, sizeof(dmo_mt)); + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &dmo_mt); + todo_wine ok(hr == S_OK, "GetOutputCurrentType returned %#lx\n", hr); + todo_wine ok(IsEqualGUID(&dmo_mt.formattype, &FORMAT_MFVideoFormat), "got format %s\n", debugstr_guid(&dmo_mt.formattype)); + todo_wine ok(dmo_mt.cbFormat == sizeof(MFVIDEOFORMAT), "got cbFormat %#lx\n", dmo_mt.cbFormat); + ok(is_dmo_subtype(&dmo_mt.subtype), "got subtype %s\n", debugstr_guid(&dmo_mt.subtype)); + + hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, &dmo_mt, &media_type); + todo_wine ok(hr == S_OK, "MFCreateMediaTypeFromRepresentation returned %#lx\n", hr); + if (hr == S_OK) + { + /* MFCreateMediaTypeFromRepresentation automatically converts MF to DMO media types */ + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, get_mf_subtype_for_am_subtype(&dmo_mt.subtype)); + ok(hr == S_OK, "SetGUID returned %#lx\n", hr); + check_media_type(media_type, color_conversion_tests[i].expect_output_type_desc, -1); + IMFMediaType_Release(media_type); + + hr = IMediaObject_SetOutputType(dmo, 0, &dmo_mt, 0); + ok(hr == S_OK, "SetOutputType returned %#lx\n", hr); + check_mft_get_output_current_type_(__LINE__, transform, color_conversion_tests[i].expect_output_type_desc, FALSE, TRUE); + } + + MoFreeMediaType(&dmo_mt); + IMediaObject_Release(dmo); + + check_mft_get_input_stream_info(transform, S_OK, &input_info); check_mft_get_output_stream_info(transform, S_OK, &output_info); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10666
v2: Add some RGB subtype checks and fixups. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10666#note_136273
This merge request was approved by Nikolay Sivov. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10666
participants (3)
-
Nikolay Sivov (@nsivov) -
Rémi Bernon -
Rémi Bernon (@rbernon)