From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/transform.c | 53 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index deec2c7dd92..16b8416b4ae 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -310,6 +310,30 @@ void check_attributes_(const char *file, int line, IMFAttributes *attributes, } }
+static void set_attribute_desc(struct attribute_desc *desc, const struct attribute_desc *to_set, int count) +{ + static const struct attribute_desc empty = {0}; + int i, j; + + for (i = 0; i < count; ++i) + { + for (j = 0; desc[j].key; ++j) + { + if (IsEqualGUID(desc[j].key, to_set[i].key)) + { + desc[j] = to_set[i]; + break; + } + } + + if (!desc[j].key) + { + desc[j] = to_set[i]; + desc[j + 1] = empty; + } + } +} + struct transform_info { const WCHAR *name; @@ -3886,6 +3910,14 @@ static void test_h264_encoder(void) ATTR_UINT32(test_attr_guid, 0), {0}, }; + static const struct attribute_desc to_set_attributes[] = + { + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width * 2, actual_height * 2), + ATTR_RATIO(MF_MT_FRAME_RATE, 10, 1), + ATTR_UINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_MixedInterlaceOrProgressive), + ATTR_UINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_Normal), + ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 2, 1), + }; const struct attribute_desc expect_input_type_desc[] = { ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), @@ -3907,9 +3939,10 @@ static void test_h264_encoder(void) ATTR_UINT32(test_attr_guid, 0), {0}, }; - static const MFT_OUTPUT_STREAM_INFO expect_output_info = {.cbSize = 0x8000}; + static const MFT_OUTPUT_STREAM_INFO expect_output_info[] = {{.cbSize = 0x8000}, {.cbSize = 0x10e00}}; MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_H264}; MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_NV12}; + media_type_desc type_desc; IMFMediaType *media_type; IMFTransform *transform; HRESULT hr; @@ -3970,7 +4003,7 @@ static void test_h264_encoder(void) check_mft_set_output_type_required(transform, output_type_desc); check_mft_set_output_type(transform, output_type_desc, S_OK); check_mft_get_output_current_type(transform, expect_output_type_desc); - check_mft_get_output_stream_info(transform, S_OK, &expect_output_info); + check_mft_get_output_stream_info(transform, S_OK, &expect_output_info[0]);
/* Input types can now be enumerated. */ i = -1; @@ -3993,6 +4026,22 @@ static void test_h264_encoder(void) check_mft_get_input_current_type(transform, expect_input_type_desc); check_mft_get_input_stream_info(transform, S_OK, NULL);
+ /* Input type attributes should match output type attributes. */ + for (i = 0; i < ARRAY_SIZE(to_set_attributes); ++i) + { + winetest_push_context("attr %lu", i); + memcpy(type_desc, input_type_desc, sizeof(input_type_desc)); + set_attribute_desc(type_desc, &to_set_attributes[i], 1); + check_mft_set_input_type(transform, type_desc, MF_E_INVALIDMEDIATYPE); + winetest_pop_context(); + } + + /* Output info cbSize will change if we change output type attributes. */ + memcpy(type_desc, output_type_desc, sizeof(output_type_desc)); + set_attribute_desc(type_desc, to_set_attributes, ARRAY_SIZE(to_set_attributes)); + check_mft_set_output_type(transform, type_desc, S_OK); + check_mft_get_output_stream_info(transform, S_OK, &expect_output_info[1]); + ret = IMFTransform_Release(transform); ok(ret == 0, "Release returned %lu\n", ret);