Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/mfreadwrite/tests/mfplat.c | 157 ++++++++++++++++++++++++++++---- 1 file changed, 139 insertions(+), 18 deletions(-)
diff --git a/dlls/mfreadwrite/tests/mfplat.c b/dlls/mfreadwrite/tests/mfplat.c index 3f5e20f844b..c24582c12b5 100644 --- a/dlls/mfreadwrite/tests/mfplat.c +++ b/dlls/mfreadwrite/tests/mfplat.c @@ -1347,15 +1347,21 @@ struct video_format UINT32 stride; };
-static void test_video_media_type(const char *resource_name, IMFMediaType *media_type, struct video_format *expect) +static void test_video_media_type(const char *resource_name, IMFMediaType *media_type, struct video_format *expect, BOOL actual) { UINT32 uint32_value, buffer_value_size, width = expect->width, height = expect->height; BOOL is_h264 = IsEqualGUID(&expect->subtype, &MFVideoFormat_H264); - BYTE buffer_value[512]; + UINT32 buffer_value[64]; UINT64 uint64_value; GUID guid_value; HRESULT hr;
+ if (actual) + { + width = (width + 0xf) & ~0xf; + height = (height + 0xf) & ~0xf; + } + memset(&guid_value, 0xcd, sizeof(guid_value)); hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &guid_value); ok(hr == S_OK, "missing MF_MT_MAJOR_TYPE, hr %#x\n", hr); @@ -1426,9 +1432,9 @@ static void test_video_media_type(const char *resource_name, IMFMediaType *media ok(uint32_value == width * height * 3 / 2, "got MF_MT_SAMPLE_SIZE %u\n", uint32_value); }
- hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, buffer_value, sizeof(buffer_value), &buffer_value_size); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_USER_DATA, hr %#x\n", hr); - hr = IMFMediaType_GetBlob(media_type, &MF_MT_WRAPPED_TYPE, buffer_value, sizeof(buffer_value), &buffer_value_size); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_WRAPPED_TYPE, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_WRAPPED_TYPE, hr %#x\n", hr);
uint32_value = 0xdeadbeef; @@ -1480,11 +1486,30 @@ static void test_video_media_type(const char *resource_name, IMFMediaType *media uint64_value = 0xdeadbeefdeadbeefull; hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &uint64_value); ok(hr == S_OK, "missing MF_MT_FRAME_SIZE, hr %#x\n", hr); + todo_wine_if(actual) ok((uint64_value >> 32) == width, "got MF_MT_FRAME_SIZE %I64x\n", uint64_value); + todo_wine_if(actual) ok((uint64_value & 0xffffffff) == height, "got MF_MT_FRAME_SIZE %I64x\n", uint64_value);
- hr = IMFMediaType_GetBlob(media_type, &MF_MT_GEOMETRIC_APERTURE, buffer_value, sizeof(buffer_value), &buffer_value_size); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_GEOMETRIC_APERTURE, hr %#x\n", hr); + buffer_value_size = 0xdeadbeef; + memset(buffer_value, 0xcd, sizeof(buffer_value)); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_GEOMETRIC_APERTURE, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_GEOMETRIC_APERTURE, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_GEOMETRIC_APERTURE, hr %#x\n", hr); + todo_wine + ok(buffer_value_size == 16, "got MF_MT_GEOMETRIC_APERTURE length %u\n", buffer_value_size); + todo_wine + ok(buffer_value[0] == 0, "got MF_MT_GEOMETRIC_APERTURE[0] %u\n", buffer_value[0]); + todo_wine + ok(buffer_value[1] == 0, "got MF_MT_GEOMETRIC_APERTURE[1] %u\n", buffer_value[1]); + todo_wine + ok(buffer_value[2] == expect->width, "got MF_MT_GEOMETRIC_APERTURE[2] %u\n", buffer_value[2]); + todo_wine + ok(buffer_value[3] == expect->height, "got MF_MT_GEOMETRIC_APERTURE[3] %u\n", buffer_value[3]); + }
uint32_value = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_INTERLACE_MODE, &uint32_value); @@ -1495,12 +1520,30 @@ static void test_video_media_type(const char *resource_name, IMFMediaType *media
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_MAX_KEYFRAME_SPACING, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_MAX_KEYFRAME_SPACING, hr %#x\n", hr); - hr = IMFMediaType_GetBlob(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, buffer_value, sizeof(buffer_value), &buffer_value_size); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_MINIMUM_DISPLAY_APERTURE, hr %#x\n", hr);
buffer_value_size = 0xdeadbeef; memset(buffer_value, 0xcd, sizeof(buffer_value)); - hr = IMFMediaType_GetBlob(media_type, &MF_MT_MPEG_SEQUENCE_HEADER, buffer_value, sizeof(buffer_value), &buffer_value_size); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_MINIMUM_DISPLAY_APERTURE, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_MINIMUM_DISPLAY_APERTURE, hr %#x\n", hr); + todo_wine + ok(buffer_value_size == 16, "got MF_MT_MINIMUM_DISPLAY_APERTURE length %u\n", buffer_value_size); + todo_wine + ok(buffer_value[0] == 0, "got MF_MT_MINIMUM_DISPLAY_APERTURE[0] %u\n", buffer_value[0]); + todo_wine + ok(buffer_value[1] == 0, "got MF_MT_MINIMUM_DISPLAY_APERTURE[1] %u\n", buffer_value[1]); + todo_wine + ok(buffer_value[2] == expect->width, "got MF_MT_MINIMUM_DISPLAY_APERTURE[2] %u\n", buffer_value[2]); + todo_wine + ok(buffer_value[3] == expect->height, "got MF_MT_MINIMUM_DISPLAY_APERTURE[3] %u\n", buffer_value[3]); + } + + buffer_value_size = 0xdeadbeef; + memset(buffer_value, 0xcd, sizeof(buffer_value)); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_MPEG_SEQUENCE_HEADER, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); if (!is_h264) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_MPEG_SEQUENCE_HEADER, hr %#x\n", hr); else { @@ -1541,10 +1584,29 @@ static void test_video_media_type(const char *resource_name, IMFMediaType *media ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_ORIGINAL_4CC, hr %#x\n", hr); hr = IMFMediaType_GetUINT32(media_type, &MF_MT_PAD_CONTROL_FLAGS, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_PAD_CONTROL_FLAGS, hr %#x\n", hr); - hr = IMFMediaType_GetBlob(media_type, &MF_MT_PALETTE, buffer_value, sizeof(buffer_value), &buffer_value_size); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_PALETTE, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_PALETTE, hr %#x\n", hr); - hr = IMFMediaType_GetBlob(media_type, &MF_MT_PAN_SCAN_APERTURE, buffer_value, sizeof(buffer_value), &buffer_value_size); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_PAN_SCAN_APERTURE, hr %#x\n", hr); + + buffer_value_size = 0xdeadbeef; + memset(buffer_value, 0xcd, sizeof(buffer_value)); + hr = IMFMediaType_GetBlob(media_type, &MF_MT_PAN_SCAN_APERTURE, (BYTE *)buffer_value, sizeof(buffer_value), &buffer_value_size); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_PAN_SCAN_APERTURE, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_PAN_SCAN_APERTURE, hr %#x\n", hr); + todo_wine + ok(buffer_value_size == 16, "got MF_MT_PAN_SCAN_APERTURE length %u\n", buffer_value_size); + todo_wine + ok(buffer_value[0] == 0, "got MF_MT_PAN_SCAN_APERTURE[0] %u\n", buffer_value[0]); + todo_wine + ok(buffer_value[1] == 0, "got MF_MT_PAN_SCAN_APERTURE[1] %u\n", buffer_value[1]); + todo_wine + ok(buffer_value[2] == expect->width, "got MF_MT_PAN_SCAN_APERTURE[2] %u\n", buffer_value[2]); + todo_wine + ok(buffer_value[3] == expect->height, "got MF_MT_PAN_SCAN_APERTURE[3] %u\n", buffer_value[3]); + } + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_PAN_SCAN_ENABLED, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_PAN_SCAN_ENABLED, hr %#x\n", hr);
@@ -1557,26 +1619,63 @@ static void test_video_media_type(const char *resource_name, IMFMediaType *media
hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SOURCE_CONTENT_HINT, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_SOURCE_CONTENT_HINT, hr %#x\n", hr); + + uint32_value = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_TRANSFER_FUNCTION, &uint32_value); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_TRANSFER_FUNCTION, hr %#x\n", hr); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_TRANSFER_FUNCTION, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_TRANSFER_FUNCTION, hr %#x\n", hr); + todo_wine + ok(uint32_value == MFVideoTransFunc_709, "got MF_MT_TRANSFER_FUNCTION %u\n", uint32_value); + } + hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_3D, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_3D, hr %#x\n", hr); hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_CHROMA_SITING, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_CHROMA_SITING, hr %#x\n", hr); hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_LIGHTING, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_LIGHTING, hr %#x\n", hr); + + uint32_value = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_NOMINAL_RANGE, &uint32_value); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_NOMINAL_RANGE, hr %#x\n", hr); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_NOMINAL_RANGE, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_VIDEO_NOMINAL_RANGE, hr %#x\n", hr); + todo_wine + ok(uint32_value == MFNominalRange_Wide, "got MF_MT_VIDEO_NOMINAL_RANGE %u\n", uint32_value); + } + + uint32_value = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_PRIMARIES, &uint32_value); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_PRIMARIES, hr %#x\n", hr); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_PRIMARIES, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_VIDEO_PRIMARIES, hr %#x\n", hr); + todo_wine + ok(uint32_value == MFVideoPrimaries_SMPTE170M, "got MF_MT_VIDEO_PRIMARIES %u\n", uint32_value); + }
uint32_value = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_VIDEO_ROTATION, &uint32_value); ok(hr == S_OK || hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_VIDEO_ROTATION, hr %#x\n", hr); if (hr == S_OK) ok(uint32_value == 0, "got MF_MT_VIDEO_ROTATION %u\n", uint32_value);
+ uint32_value = 0xdeadbeef; hr = IMFMediaType_GetUINT32(media_type, &MF_MT_YUV_MATRIX, &uint32_value); - ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_YUV_MATRIX, hr %#x\n", hr); + if (!actual) ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_MT_YUV_MATRIX, hr %#x\n", hr); + else + { + todo_wine + ok(hr == S_OK, "missing MF_MT_YUV_MATRIX, hr %#x\n", hr); + todo_wine + ok(uint32_value == MFVideoTransferMatrix_BT601, "got MF_MT_YUV_MATRIX %u\n", uint32_value); + } + hr = IMFMediaType_GetUINT32(media_type, &MF_XVP_CALLER_ALLOCATES_OUTPUT, &uint32_value); ok(hr == MF_E_ATTRIBUTENOTFOUND, "got MF_XVP_CALLER_ALLOCATES_OUTPUT, hr %#x\n", hr); hr = IMFMediaType_GetUINT32(media_type, &MF_XVP_DISABLE_FRC, &uint32_value); @@ -1624,6 +1723,8 @@ static void test_media_types(void) IMFMediaType *media_type; IMFSourceReader *reader; IMFByteStream *stream; + IMFSample *sample; + DWORD flags; HRESULT hr;
if (!pMFCreateMFByteStreamOnStream) @@ -1696,6 +1797,17 @@ static void test_media_types(void) winetest_pop_context(); IMFMediaType_Release(media_type);
+ hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &flags, NULL, &sample); + ok(hr == S_OK, "Failed to read sample, hr %#x\n", hr); + IMFSample_Release(sample); + + hr = IMFSourceReader_GetCurrentMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, &media_type); + ok(hr == S_OK, "Failed to get current mediatype, hr %#x.\n", hr); + winetest_push_context("actual audio %u", j); + test_audio_media_type(tests[i].resource, media_type, &test_audio_formats[j]); + winetest_pop_context(); + IMFMediaType_Release(media_type); + IMFSourceReader_Release(reader); IMFByteStream_Release(stream); } @@ -1715,7 +1827,7 @@ static void test_media_types(void) hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, &media_type); ok(hr == S_OK, "Failed to get native mediatype, hr %#x.\n", hr); winetest_push_context("native video"); - test_video_media_type(tests[i].resource, media_type, &tests[i].video_format); + test_video_media_type(tests[i].resource, media_type, &tests[i].video_format, FALSE); IMFMediaType_Release(media_type); winetest_pop_context();
@@ -1740,10 +1852,19 @@ static void test_media_types(void) hr = IMFSourceReader_GetCurrentMediaType(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM, &media_type); ok(hr == S_OK, "Failed to get current mediatype, hr %#x.\n", hr); winetest_push_context("current video %u", j); - test_video_media_type(tests[i].resource, media_type, &test_video_formats[j]); + test_video_media_type(tests[i].resource, media_type, &test_video_formats[j], FALSE); winetest_pop_context(); IMFMediaType_Release(media_type);
+ hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, &flags, NULL, &sample); + ok(hr == S_OK, "Failed to read sample, hr %#x\n", hr); + IMFSample_Release(sample); + + hr = IMFSourceReader_GetCurrentMediaType(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM, &media_type); + ok(hr == S_OK, "Failed to get current mediatype, hr %#x.\n", hr); + winetest_push_context("actual video %u", j); + test_video_media_type(tests[i].resource, media_type, &test_video_formats[j], TRUE); + IMFSourceReader_Release(reader); IMFByteStream_Release(stream); }