From a66690d2de92e500dd0a76ad02ff2e3d23dcad0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 8 Sep 2022 09:42:32 +0200 Subject: [PATCH] mf/tests: Factor IMFTransform required attributes checks together. --- dlls/mf/tests/mf.c | 81 ++++--- dlls/mf/tests/mf_test.h | 1 + dlls/mf/tests/transform.c | 490 +++++++++++++++----------------------- 3 files changed, 237 insertions(+), 335 deletions(-) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 0d311c3f73c..14b75d52fc2 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -102,6 +102,37 @@ static HWND create_window(void) 0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL); } +#define check_handler_required_attributes(a, b) check_handler_required_attributes_(__LINE__, a, b) +static void check_handler_required_attributes_(int line, IMFMediaTypeHandler *handler, const struct attribute_desc *attributes) +{ + const struct attribute_desc *attr; + IMFMediaType *media_type; + HRESULT hr; + ULONG ref; + + hr = MFCreateMediaType(&media_type); + ok_(__FILE__, line)(hr == S_OK, "MFCreateMediaType returned hr %#lx.\n", hr); + init_media_type(media_type, attributes, -1); + + for (attr = attributes; attr && attr->key; attr++) + { + winetest_push_context("%s", debugstr_a(attr->name)); + hr = IMFMediaType_DeleteItem(media_type, attr->key); + ok_(__FILE__, line)(hr == S_OK, "DeleteItem returned %#lx\n", hr); + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type, NULL); + todo_wine_if(attr->todo) + ok_(__FILE__, line)(FAILED(hr) == attr->required, "IsMediaTypeSupported returned %#lx.\n", hr); + hr = IMFMediaType_SetItem(media_type, attr->key, &attr->value); + ok_(__FILE__, line)(hr == S_OK, "SetItem returned %#lx\n", hr); + winetest_pop_context(); + } + + hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, media_type, NULL); + ok_(__FILE__, line)(hr == S_OK, "IsMediaTypeSupported returned %#lx.\n", hr); + ref = IMFMediaType_Release(media_type); + ok_(__FILE__, line)(!ref, "Release returned %lu\n", ref); +} + static void create_descriptors(UINT enum_types_count, IMFMediaType **enum_types, const media_type_desc *current_desc, IMFPresentationDescriptor **pd, IMFStreamDescriptor **sd) { @@ -4777,24 +4808,24 @@ static void test_sar(void) { static const struct attribute_desc input_type_desc_48000[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 48000), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 8), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 8 * 48000), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float, .required = TRUE, .todo = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 48000, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (32 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (32 / 8) * 48000, .required = TRUE), {0}, }; static const struct attribute_desc input_type_desc_44100[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 8), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 8 * 44100), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float, .required = TRUE, .todo = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (32 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (32 / 8) * 44100, .required = TRUE), {0}, }; @@ -4989,27 +5020,7 @@ if (SUCCEEDED(hr)) ok(rate == 48000 || rate == 44100, "got rate %u.\n", rate); IMFMediaType_Release(mediatype); - - /* check required output media type attributes */ - - hr = MFCreateMediaType(&mediatype); - ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); - init_media_type(mediatype, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000, 2); - for (int i = 1; i < (rate == 44100 ? ARRAY_SIZE(input_type_desc_44100) : ARRAY_SIZE(input_type_desc_48000)) - 1; ++i) - { - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(hr == MF_E_INVALIDMEDIATYPE, "Unexpected hr %#lx.\n", hr); - init_media_type(mediatype, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000, i + 1); - } - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - init_media_type(mediatype, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000, -1); - hr = IMFMediaTypeHandler_IsMediaTypeSupported(handler, mediatype, NULL); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - IMFMediaType_Release(mediatype); - + check_handler_required_attributes(handler, rate == 44100 ? input_type_desc_44100 : input_type_desc_48000); hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &mediatype); ok(hr == MF_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr); diff --git a/dlls/mf/tests/mf_test.h b/dlls/mf/tests/mf_test.h index c7aebc755d3..d908acb89a4 100644 --- a/dlls/mf/tests/mf_test.h +++ b/dlls/mf/tests/mf_test.h @@ -41,6 +41,7 @@ struct attribute_desc const char *name; PROPVARIANT value; BOOL ratio; + BOOL required; BOOL todo; BOOL todo_value; }; diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 3a5126bf180..d088bead46a 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -251,6 +251,68 @@ void init_media_type(IMFMediaType *mediatype, const struct attribute_desc *desc, } } +#define check_mft_set_input_type_required(a, b) check_mft_set_input_type_required_(__LINE__, a, b) +static void check_mft_set_input_type_required_(int line, IMFTransform *transform, const struct attribute_desc *attributes) +{ + const struct attribute_desc *attr; + IMFMediaType *media_type; + HRESULT hr; + ULONG ref; + + hr = MFCreateMediaType(&media_type); + ok_(__FILE__, line)(hr == S_OK, "MFCreateMediaType returned hr %#lx.\n", hr); + init_media_type(media_type, attributes, -1); + + for (attr = attributes; attr && attr->key; attr++) + { + winetest_push_context("%s", debugstr_a(attr->name)); + hr = IMFMediaType_DeleteItem(media_type, attr->key); + ok_(__FILE__, line)(hr == S_OK, "DeleteItem returned %#lx\n", hr); + hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); + ok_(__FILE__, line)(FAILED(hr) == attr->required, "SetInputType returned %#lx.\n", hr); + hr = IMFMediaType_SetItem(media_type, attr->key, &attr->value); + ok_(__FILE__, line)(hr == S_OK, "SetItem returned %#lx\n", hr); + winetest_pop_context(); + } + + hr = IMFTransform_SetInputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); + ok_(__FILE__, line)(hr == S_OK, "SetInputType returned %#lx.\n", hr); + ref = IMFMediaType_Release(media_type); + todo_wine_if(ref == 1) + ok_(__FILE__, line)(!ref, "Release returned %lu\n", ref); +} + +#define check_mft_set_output_type_required(a, b) check_mft_set_output_type_required_(__LINE__, a, b) +static void check_mft_set_output_type_required_(int line, IMFTransform *transform, const struct attribute_desc *attributes) +{ + const struct attribute_desc *attr; + IMFMediaType *media_type; + HRESULT hr; + ULONG ref; + + hr = MFCreateMediaType(&media_type); + ok_(__FILE__, line)(hr == S_OK, "MFCreateMediaType returned hr %#lx.\n", hr); + init_media_type(media_type, attributes, -1); + + for (attr = attributes; attr && attr->key; attr++) + { + winetest_push_context("%s", debugstr_a(attr->name)); + hr = IMFMediaType_DeleteItem(media_type, attr->key); + ok_(__FILE__, line)(hr == S_OK, "DeleteItem returned %#lx\n", hr); + hr = IMFTransform_SetOutputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); + ok_(__FILE__, line)(FAILED(hr) == attr->required, "SetOutputType returned %#lx.\n", hr); + hr = IMFMediaType_SetItem(media_type, attr->key, &attr->value); + ok_(__FILE__, line)(hr == S_OK, "SetItem returned %#lx\n", hr); + winetest_pop_context(); + } + + hr = IMFTransform_SetOutputType(transform, 0, media_type, MFT_SET_TYPE_TEST_ONLY); + ok_(__FILE__, line)(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + ref = IMFMediaType_Release(media_type); + todo_wine_if(ref == 1) + ok_(__FILE__, line)(!ref, "Release returned %lu\n", ref); +} + static HRESULT WINAPI test_unk_QueryInterface(IUnknown *iface, REFIID riid, void **obj) { if (IsEqualIID(riid, &IID_IUnknown)) @@ -914,21 +976,21 @@ static void test_aac_encoder(void) static const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100, .required = TRUE), {0}, }; const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_AAC), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 12000), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_AAC, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 12000, .required = TRUE), {0}, }; @@ -994,6 +1056,8 @@ static void test_aac_encoder(void) check_interface(transform, &IID_IMFTransform, TRUE); check_interface(transform, &IID_IMediaObject, FALSE); + check_mft_set_input_type_required(transform, input_type_desc); + hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); init_media_type(media_type, input_type_desc, -1); @@ -1002,6 +1066,8 @@ static void test_aac_encoder(void) ret = IMFMediaType_Release(media_type); ok(ret == 1, "Release returned %lu\n", ret); + check_mft_set_output_type_required(transform, output_type_desc); + hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); init_media_type(media_type, output_type_desc, -1); @@ -1133,24 +1199,24 @@ static void test_aac_decoder(void) const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_AAC), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_AAC, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100, .required = TRUE), + ATTR_BLOB(MF_MT_USER_DATA, aac_codec_data, sizeof(aac_codec_data), .required = TRUE), ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100), ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 12000), ATTR_UINT32(MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, 41), ATTR_UINT32(MF_MT_AAC_PAYLOAD_TYPE, 0), - ATTR_BLOB(MF_MT_USER_DATA, aac_codec_data, sizeof(aac_codec_data)), {0}, }; static const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100, .required = TRUE), {0}, }; @@ -1232,19 +1298,11 @@ static void test_aac_decoder(void) ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %lu\n", ret); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - for (i = 1; i < ARRAY_SIZE(input_type_desc) - 1; ++i) - { - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, i + 1); - } + init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -1268,19 +1326,11 @@ static void test_aac_decoder(void) ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); ok(i == ARRAY_SIZE(expect_available_outputs), "%lu input media types\n", i); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - for (i = 1; i < ARRAY_SIZE(output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } + init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -1353,24 +1403,24 @@ static void test_wma_encoder(void) static const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 176400), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 8), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (32 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (32 / 8) * 22050, .required = TRUE), {0}, }; const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_WMAudioV8), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 4003), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, wmaenc_block_size), - ATTR_BLOB(MF_MT_USER_DATA, wma_codec_data, sizeof(wma_codec_data)), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_WMAudioV8, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 4003, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, wmaenc_block_size, .required = TRUE), + ATTR_BLOB(MF_MT_USER_DATA, wma_codec_data, sizeof(wma_codec_data), .required = TRUE), {0}, }; @@ -1411,11 +1461,20 @@ static void test_wma_encoder(void) check_interface(transform, &IID_IPropertyStore, TRUE); check_interface(transform, &IID_IPropertyBag, TRUE); + check_mft_set_input_type_required(transform, input_type_desc); + hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + ret = IMFMediaType_Release(media_type); + ok(ret == 0, "Release returned %lu\n", ret); + + check_mft_set_output_type_required(transform, output_type_desc); + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); @@ -1615,23 +1674,24 @@ static void test_wma_decoder(void) const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_WMAudioV8), - ATTR_BLOB(MF_MT_USER_DATA, wma_codec_data, sizeof(wma_codec_data)), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, wmaenc_block_size), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_WMAudioV8, .required = TRUE), + ATTR_BLOB(MF_MT_USER_DATA, wma_codec_data, sizeof(wma_codec_data), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, wmaenc_block_size, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 4003), /* not required by SetInputType, but needed for the transform to work */ {0}, }; static const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 88200), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 4), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (16 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (16 / 8) * 22050, .required = TRUE), {0}, }; @@ -1714,22 +1774,11 @@ static void test_wma_decoder(void) ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %lu\n", ret); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) - { - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, i + 1); - } + init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -1755,22 +1804,11 @@ static void test_wma_decoder(void) ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); ok(i == 2, "%lu output media types\n", i); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } + init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -1785,33 +1823,6 @@ static void test_wma_decoder(void) ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); ok(input_info.cbAlignment == 1, "got cbAlignment %#lx\n", input_info.cbAlignment); - memset(&output_info, 0xcd, sizeof(output_info)); - hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); - ok(output_info.dwFlags == 0, "got dwFlags %#lx\n", output_info.dwFlags); - todo_wine - ok(output_info.cbSize == 0, "got cbSize %#lx\n", output_info.cbSize); - ok(output_info.cbAlignment == 1, "got cbAlignment %#lx\n", output_info.cbAlignment); - - /* MF_MT_AUDIO_AVG_BYTES_PER_SECOND isn't required by SetInputType, but is needed for the transform to work */ - - hr = MFCreateMediaType(&media_type); - ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - init_media_type(media_type, input_type_desc, -1); - hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 4003); - ok(hr == S_OK, "SetUINT32 returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); - - hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "GetOutputStreamInfo returned %#lx\n", hr); - - init_media_type(media_type, output_type_desc, -1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); - ret = IMFMediaType_Release(media_type); - ok(ret == 0, "Release returned %lu\n", ret); - memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); @@ -2174,23 +2185,16 @@ static void test_h264_decoder(void) }; const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_H264), - ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height), - {0}, - }; - const struct attribute_desc minimal_output_type_desc[] = - { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_H264, .required = TRUE), ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height), {0}, }; const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), - ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height, .required = TRUE), ATTR_RATIO(MF_MT_FRAME_RATE, 60000, 1000), ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 2, 1), ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 3840), @@ -2383,19 +2387,10 @@ static void test_h264_decoder(void) ok(hr == MF_E_NO_MORE_TYPES, "GetInputAvailableType returned %#lx\n", hr); ok(i == 2 || broken(i == 1) /* Win7 */, "%lu input media types\n", i); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 2); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); @@ -2426,27 +2421,10 @@ static void test_h264_decoder(void) ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); ok(i == 5, "%lu output media types\n", i); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine - ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, minimal_output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine - ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, minimal_output_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(minimal_output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, minimal_output_type_desc, i + 1); - } - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); @@ -2907,24 +2885,24 @@ static void test_audio_convert(void) static const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 176400), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 8), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_Float, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 32, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (32 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (32 / 8) * 22050, .required = TRUE), {0}, }; const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 176400), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 4), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (16 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (16 / 8) * 44100, .required = TRUE), {0}, }; @@ -3012,22 +2990,11 @@ static void test_audio_convert(void) ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %lu\n", ret); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) - { - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, i + 1); - } + init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -3053,22 +3020,11 @@ static void test_audio_convert(void) ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); ok(i == 4, "%lu output media types\n", i); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } + init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -3386,17 +3342,17 @@ static void test_color_convert(void) static const DWORD actual_width = 96, actual_height = 96; const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height, .required = TRUE), ATTR_BLOB(MF_MT_MINIMUM_DISPLAY_APERTURE, &actual_aperture, 16), - ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height), {0}, }; const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32), - ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height, .required = TRUE), {0}, }; @@ -3482,43 +3438,21 @@ static void test_color_convert(void) ok(hr == MF_E_NO_MORE_TYPES, "GetInputAvailableType returned %#lx\n", hr); ok(i == 20, "%lu input media types\n", i); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } + init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %lu\n", ret); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) - { - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, i + 1); - } + init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -3770,18 +3704,18 @@ static void test_video_processor(void) static const DWORD actual_width = 96, actual_height = 96; const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height, .required = TRUE), ATTR_BLOB(MF_MT_MINIMUM_DISPLAY_APERTURE, &actual_aperture, 16), - ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height), {0}, }; const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), - ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height, .required = TRUE), ATTR_BLOB(MF_MT_MINIMUM_DISPLAY_APERTURE, &actual_aperture, 16), - ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height), {0}, }; @@ -4219,43 +4153,21 @@ todo_wine { ok(hr == MF_E_NO_MORE_TYPES, "GetInputAvailableType returned %#lx\n", hr); ok(i == 22 || i == 30 || broken(i == 26) /* w1064v1507 */, "%lu input media types\n", i); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) - { - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, i + 1); - } + init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); ok(ret == 1, "Release returned %lu\n", ret); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } + init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -4489,21 +4401,21 @@ static void test_mp3_decoder(void) const struct attribute_desc input_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_MP3), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_MP3, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), {0}, }; static const struct attribute_desc output_type_desc[] = { - ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio), - ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM), - ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 88200), - ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16), - ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2), - ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050), - ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 4), + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_PCM, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 2, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 22050, .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 2 * (16 / 8), .required = TRUE), + ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 2 * (16 / 8) * 22050, .required = TRUE), {0}, }; @@ -4582,22 +4494,11 @@ static void test_mp3_decoder(void) ret = IMFMediaType_Release(media_type); ok(ret == 0, "Release returned %lu\n", ret); - /* check required input media type attributes */ + check_mft_set_input_type_required(transform, input_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 1); - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) - { - hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); - init_media_type(media_type, input_type_desc, i + 1); - } + init_media_type(media_type, input_type_desc, -1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); @@ -4623,22 +4524,11 @@ static void test_mp3_decoder(void) ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr); ok(i == ARRAY_SIZE(expect_available_outputs), "%lu output media types\n", i); - /* check required output media type attributes */ + check_mft_set_output_type_required(transform, output_type_desc); hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 1); - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, 2); - for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) - { - hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); - init_media_type(media_type, output_type_desc, i + 1); - } + init_media_type(media_type, output_type_desc, -1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type);