IMFMediaType_(Get|Free)Representation is called by Samurai Maiden, MFInitAMMediaTypeFromMFMediaType could be useful to simplify DMO / MFT transforms implementations.
-- v4: mfplat: Implement IMFMediaType_(Get|Free)Representation. mfplat: Implement MFCreateAMMediaTypeFromMFMediaType. mfplat: Implement MFInitAMMediaTypeFromMFMediaType. mfplat: Use bits per pixel in uncompressed formats metadata. mfplat: Only convert MEDIASUBTYPE for the formats which need it. mfplat/tests: Add IMFMediaType_GetRepresentation tests. mfplat/tests: Add tests for MFCreateAMMediaTypeFromMFMediaType. mfplat/tests: Add tests for MFInitAMMediaTypeFromMFMediaType. mfplat: Add MFInitAMMediaTypeFromMFMediaType stub. mfplat: Add MFCreateAMMediaTypeFromMFMediaType stub. mfplat: Add support for internal MFVideoFormat_A2B10G10R10.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 5 +++++ dlls/mfplat/tests/mfplat.c | 11 +++++++++++ 2 files changed, 16 insertions(+)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 0b4a6fa4eaf..c989e7e08a9 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -31,6 +31,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
+/* SDK MFVideoFormat_A2R10G10B10 uses D3DFMT_A2B10G10R10, let's name it the other way */ +DEFINE_MEDIATYPE_GUID(MFVideoFormat_A2B10G10R10, D3DFMT_A2R10G10B10); + DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC1, MAKEFOURCC('I','M','C','1')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC2, MAKEFOURCC('I','M','C','2')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC3, MAKEFOURCC('I','M','C','3')); @@ -2639,6 +2642,7 @@ static const struct uncompressed_video_format video_formats[] = { &MFVideoFormat_RGB565, 2, 3, 1, 0 }, { &MFVideoFormat_RGB555, 2, 3, 1, 0 }, { &MFVideoFormat_A2R10G10B10, 4, 3, 1, 0 }, + { &MFVideoFormat_A2B10G10R10, 4, 3, 1, 0 }, { &MFVideoFormat_RGB8, 1, 3, 1, 0 }, { &MFVideoFormat_L8, 1, 3, 1, 0 }, { &MFVideoFormat_AYUV, 4, 3, 0, 1 }, @@ -3549,6 +3553,7 @@ HRESULT WINAPI MFInitVideoFormat_RGB(MFVIDEOFORMAT *format, DWORD width, DWORD h case D3DFMT_R5G6B5: case D3DFMT_X1R5G5B5: case D3DFMT_A2B10G10R10: + case D3DFMT_A2R10G10B10: case D3DFMT_P8: transfer_function = MFVideoTransFunc_sRGB; break; diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 4fcf5f19558..b44b95ff71a 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -65,6 +65,9 @@ DEFINE_GUID(DUMMY_GUID3, 0x12345678,0x1234,0x1234,0x23,0x23,0x23,0x23,0x23,0x23,
extern const CLSID CLSID_FileSchemePlugin;
+/* SDK MFVideoFormat_A2R10G10B10 uses D3DFMT_A2B10G10R10, let's name it the other way */ +DEFINE_MEDIATYPE_GUID(MFVideoFormat_A2B10G10R10, D3DFMT_A2R10G10B10); + DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC1, MAKEFOURCC('I','M','C','1')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC2, MAKEFOURCC('I','M','C','2')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC3, MAKEFOURCC('I','M','C','3')); @@ -4705,6 +4708,9 @@ image_size_tests[] = { &MFVideoFormat_A2R10G10B10, 3, 5, 60, 0, 320, 60, 64 }, { &MFVideoFormat_A2R10G10B10, 1, 1, 4, 0, 64, 4, 64 }, { &MFVideoFormat_A2R10G10B10, 320, 240, 307200, 0, 307200, 307200, 1280 }, + { &MFVideoFormat_A2B10G10R10, 3, 5, 60, 0, 320, 60, 64 }, + { &MFVideoFormat_A2B10G10R10, 1, 1, 4, 0, 64, 4, 64 }, + { &MFVideoFormat_A2B10G10R10, 320, 240, 307200, 0, 307200, 307200, 1280 }, { &MFVideoFormat_A16B16G16R16F, 3, 5, 120, 0, 320, 120, 64 }, { &MFVideoFormat_A16B16G16R16F, 1, 1, 8, 0, 64, 8, 64 }, { &MFVideoFormat_A16B16G16R16F, 320, 240, 614400, 0, 614400, 614400, 2560 }, @@ -6171,6 +6177,8 @@ static void test_MFGetStrideForBitmapInfoHeader(void) { &MFVideoFormat_ARGB32, 1, -4 }, { &MFVideoFormat_A2R10G10B10, 3, -12 }, { &MFVideoFormat_A2R10G10B10, 1, -4 }, + { &MFVideoFormat_A2B10G10R10, 3, -12 }, + { &MFVideoFormat_A2B10G10R10, 1, -4 }, { &MFVideoFormat_A16B16G16R16F, 3, -24 }, { &MFVideoFormat_A16B16G16R16F, 1, -8 },
@@ -7528,6 +7536,7 @@ static void test_MFMapDX9FormatToDXGIFormat(void) { DXGI_FORMAT_R16G16B16A16_SNORM, D3DFMT_Q16W16V16U16 }, { DXGI_FORMAT_R32G32_FLOAT, D3DFMT_G32R32F }, { DXGI_FORMAT_R10G10B10A2_UNORM, D3DFMT_A2B10G10R10 }, + { 0, D3DFMT_A2R10G10B10 }, /* doesn't map to DXGI */ { DXGI_FORMAT_R8G8B8A8_SNORM, D3DFMT_Q8W8V8U8 }, { DXGI_FORMAT_R16G16_FLOAT, D3DFMT_G16R16F }, { DXGI_FORMAT_R16G16_UNORM, D3DFMT_G16R16 }, @@ -8938,6 +8947,7 @@ static void check_video_format(const MFVIDEOFORMAT *format, unsigned int width, case D3DFMT_R5G6B5: case D3DFMT_X1R5G5B5: case D3DFMT_A2B10G10R10: + case D3DFMT_A2R10G10B10: case D3DFMT_P8: transfer_function = MFVideoTransFunc_sRGB; break; @@ -8994,6 +9004,7 @@ static void test_MFInitVideoFormat_RGB(void) D3DFMT_R5G6B5, D3DFMT_X1R5G5B5, D3DFMT_A2B10G10R10, + D3DFMT_A2R10G10B10, D3DFMT_P8, D3DFMT_L8, D3DFMT_YUY2,
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 9 +++++++++ dlls/mfplat/mfplat.spec | 2 +- include/mfapi.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index c989e7e08a9..b82c926cb4e 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -3125,6 +3125,15 @@ static void media_type_get_ratio(IMFMediaType *media_type, const GUID *attr, DWO } }
+/*********************************************************************** + * MFCreateAMMediaTypeFromMFMediaType (mfplat.@) + */ +HRESULT WINAPI MFCreateAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format, AM_MEDIA_TYPE **am_type) +{ + FIXME("%p, %s, %p stub!\n", media_type, debugstr_mf_guid(&format), am_type); + return E_NOTIMPL; +} + /*********************************************************************** * MFCreateMFVideoFormatFromMFMediaType (mfplat.@) */ diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index 2f18d6380d6..bbe938b2b2c 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -39,7 +39,7 @@ @ stub MFConvertToFP16Array @ stdcall MFCopyImage(ptr long ptr long long long) @ stdcall MFCreate2DMediaBuffer(long long long long ptr) -@ stub MFCreateAMMediaTypeFromMFMediaType +@ stdcall MFCreateAMMediaTypeFromMFMediaType(ptr int128 ptr) @ stdcall MFCreateAlignedMemoryBuffer(long long ptr) @ stdcall MFCreateAsyncResult(ptr ptr ptr ptr) rtworkq.RtwqCreateAsyncResult @ stdcall MFCreateAttributes(ptr long) diff --git a/include/mfapi.h b/include/mfapi.h index 105b093893f..bdf68adf45d 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -545,6 +545,7 @@ HRESULT WINAPI MFCreateMediaBufferFromMediaType(IMFMediaType *media_type, LONGLO HRESULT WINAPI MFCreateMediaEvent(MediaEventType type, REFGUID extended_type, HRESULT status, const PROPVARIANT *value, IMFMediaEvent **event); HRESULT WINAPI MFCreateMediaType(IMFMediaType **type); +HRESULT WINAPI MFCreateAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format_type, AM_MEDIA_TYPE **am_type); HRESULT WINAPI MFCreateMFVideoFormatFromMFMediaType(IMFMediaType *media_type, MFVIDEOFORMAT **video_format, UINT32 *size); HRESULT WINAPI MFCreateSample(IMFSample **sample); HRESULT WINAPI MFCreateTempFile(MF_FILE_ACCESSMODE accessmode, MF_FILE_OPENMODE openmode, MF_FILE_FLAGS flags,
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 9 +++++++++ dlls/mfplat/mfplat.spec | 2 +- include/mfapi.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index b82c926cb4e..fabc36dcc3c 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -3684,6 +3684,15 @@ HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, cons return hr; }
+/*********************************************************************** + * MFInitAMMediaTypeFromMFMediaType (mfplat.@) + */ +HRESULT WINAPI MFInitAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format, AM_MEDIA_TYPE *am_type) +{ + FIXME("%p, %s, %p\n", media_type, debugstr_guid(&format), am_type); + return E_NOTIMPL; +} + /*********************************************************************** * MFInitMediaTypeFromAMMediaType (mfplat.@) */ diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec index bbe938b2b2c..d7f75351960 100644 --- a/dlls/mfplat/mfplat.spec +++ b/dlls/mfplat/mfplat.spec @@ -117,7 +117,7 @@ @ stdcall MFGetWorkQueueMMCSSPriority(long ptr) rtworkq.RtwqGetWorkQueueMMCSSPriority @ stdcall MFHeapAlloc(long long str long long) @ stdcall MFHeapFree(ptr) -@ stub MFInitAMMediaTypeFromMFMediaType +@ stdcall MFInitAMMediaTypeFromMFMediaType(ptr int128 ptr) @ stdcall MFInitAttributesFromBlob(ptr ptr long) @ stdcall MFInitMediaTypeFromAMMediaType(ptr ptr) @ stub MFInitMediaTypeFromMFVideoFormat diff --git a/include/mfapi.h b/include/mfapi.h index bdf68adf45d..ef5bec16369 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -589,6 +589,7 @@ HRESULT WINAPI MFTGetInfo(CLSID clsid, WCHAR **name, MFT_REGISTER_TYPE_INFO **in MFT_REGISTER_TYPE_INFO **output_types, UINT32 *output_types_count, IMFAttributes **attributes); BOOL WINAPI MFIsFormatYUV(DWORD format); HRESULT WINAPI MFInitAttributesFromBlob(IMFAttributes *attributes, const UINT8 *buffer, UINT size); +HRESULT WINAPI MFInitAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format, AM_MEDIA_TYPE *am_type); HRESULT WINAPI MFInitMediaTypeFromAMMediaType(IMFMediaType *mediatype, const AM_MEDIA_TYPE *am_type); HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, const VIDEOINFOHEADER *vih, UINT32 size, const GUID *subtype);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 501 +++++++++++++++++++++++++++++++++++++ 1 file changed, 501 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index b44b95ff71a..5a399f39608 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -57,6 +57,7 @@ #define EXTERN_GUID DEFINE_GUID #include "mfd3d12.h" #include "wmcodecdsp.h" +#include "dvdmedia.h"
DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19); DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21); @@ -7034,6 +7035,505 @@ static void test_MFCreateMFVideoFormatFromMFMediaType(void) IMFMediaType_Release(media_type); }
+static void test_MFInitAMMediaTypeFromMFMediaType(void) +{ + static const MFVideoArea aperture = {.OffsetX = {.fract = 1, .value = 2}, .OffsetY = {.fract = 3, .value = 4}, .Area={56,78}}; + static const BYTE dummy_user_data[] = {0x01,0x02,0x03}; + + WAVEFORMATEXTENSIBLE *wave_format_ext; + VIDEOINFOHEADER *video_info; + WAVEFORMATEX *wave_format; + IMFMediaType *media_type; + AM_MEDIA_TYPE am_type; + HRESULT hr; + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + + /* test basic media type attributes mapping and valid formats */ + + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo, &am_type); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (hr != S_OK) goto skip_tests; + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type.cbFormat); + CoTaskMemFree(am_type.pbFormat); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, AM_MEDIA_TYPE_REPRESENTATION, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &GUID_NULL), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == 0, "got %lu\n", am_type.cbFormat); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_WaveFormatEx, &am_type); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER), "got %lu\n", am_type.cbFormat); + CoTaskMemFree(am_type.pbFormat); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, AM_MEDIA_TYPE_REPRESENTATION, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MFVideoFormat_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &GUID_NULL), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == 0, "got %lu\n", am_type.cbFormat); + CoTaskMemFree(am_type.pbFormat); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER), "got %lu\n", am_type.cbFormat); + CoTaskMemFree(am_type.pbFormat); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo2, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo2), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER2), "got %lu\n", am_type.cbFormat); + 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), "got %s.\n", debugstr_guid(&am_type.majortype)); + ok(IsEqualGUID(&am_type.subtype, &MFVideoFormat_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + ok(IsEqualGUID(&am_type.formattype, &FORMAT_MFVideoFormat), "got %s.\n", debugstr_guid(&am_type.formattype)); + ok(am_type.cbFormat == sizeof(MFVIDEOFORMAT), "got %lu\n", am_type.cbFormat); + CoTaskMemFree(am_type.pbFormat); + + + /* test WAVEFORMATEX mapping */ + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetBlob(media_type, &MF_MT_USER_DATA, dummy_user_data, sizeof(dummy_user_data)); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX) + sizeof(dummy_user_data), "got %lu\n", am_type.cbFormat); + wave_format = (WAVEFORMATEX *)am_type.pbFormat; + ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "got %u\n", wave_format->wFormatTag); + ok(wave_format->nChannels == 0, "got %u\n", wave_format->nChannels); + ok(wave_format->nSamplesPerSec == 0, "got %lu\n", wave_format->nSamplesPerSec); + ok(wave_format->nAvgBytesPerSec == 0, "got %lu\n", wave_format->nAvgBytesPerSec); + ok(wave_format->nBlockAlign == 0, "got %u\n", wave_format->nBlockAlign); + ok(wave_format->wBitsPerSample == 0, "got %u\n", wave_format->wBitsPerSample); + ok(wave_format->cbSize == sizeof(dummy_user_data), "got %u\n", wave_format->cbSize); + ok(!memcmp(wave_format + 1, dummy_user_data, sizeof(dummy_user_data)), "got unexpected data\n"); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type.cbFormat); + wave_format = (WAVEFORMATEX *)am_type.pbFormat; + ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "got %u\n", wave_format->wFormatTag); + ok(wave_format->nChannels == 2, "got %u\n", wave_format->nChannels); + ok(wave_format->cbSize == 0, "got %u\n", wave_format->cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, 2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 16); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type.cbFormat); + wave_format = (WAVEFORMATEX *)am_type.pbFormat; + ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "got %u\n", wave_format->wFormatTag); + ok(wave_format->wBitsPerSample == 16, "got %u\n", wave_format->wBitsPerSample); + ok(wave_format->nBlockAlign == 0, "got %u\n", wave_format->nBlockAlign); + ok(wave_format->cbSize == 0, "got %u\n", wave_format->cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, 16); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type.cbFormat); + wave_format = (WAVEFORMATEX *)am_type.pbFormat; + ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "got %u\n", wave_format->wFormatTag); + ok(wave_format->nBlockAlign == 16, "got %u\n", wave_format->nBlockAlign); + ok(wave_format->cbSize == 0, "got %u\n", wave_format->cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type.cbFormat); + wave_format = (WAVEFORMATEX *)am_type.pbFormat; + ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "got %u\n", wave_format->wFormatTag); + ok(wave_format->nSamplesPerSec == 44100, "got %lu\n", wave_format->nSamplesPerSec); + ok(wave_format->cbSize == 0, "got %u\n", wave_format->cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 176400); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type.cbFormat); + wave_format = (WAVEFORMATEX *)am_type.pbFormat; + ok(wave_format->wFormatTag == WAVE_FORMAT_PCM, "got %u\n", wave_format->wFormatTag); + ok(wave_format->nAvgBytesPerSec == 176400, "got %lu\n", wave_format->nAvgBytesPerSec); + ok(wave_format->cbSize == 0, "got %u\n", wave_format->cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, 3); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEXTENSIBLE), "got %lu\n", am_type.cbFormat); + wave_format_ext = (WAVEFORMATEXTENSIBLE *)am_type.pbFormat; + ok(wave_format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, "got %u\n", wave_format_ext->Format.wFormatTag); + ok(wave_format_ext->Format.nChannels == 3, "got %u\n", wave_format_ext->Format.nChannels); + ok(IsEqualGUID(&wave_format_ext->SubFormat, &MFAudioFormat_PCM), + "got %s\n", debugstr_guid(&wave_format_ext->SubFormat)); + ok(wave_format_ext->dwChannelMask == 7, "got %#lx\n", wave_format_ext->dwChannelMask); + ok(wave_format_ext->Samples.wSamplesPerBlock == 0, "got %u\n", + wave_format_ext->Samples.wSamplesPerBlock); + ok(wave_format_ext->Format.cbSize == sizeof(*wave_format_ext) - sizeof(*wave_format), + "got %u\n", wave_format_ext->Format.cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_CHANNEL_MASK, 3); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEXTENSIBLE), "got %lu\n", am_type.cbFormat); + wave_format_ext = (WAVEFORMATEXTENSIBLE *)am_type.pbFormat; + ok(wave_format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, + "got %u\n", wave_format_ext->Format.wFormatTag); + ok(IsEqualGUID(&wave_format_ext->SubFormat, &MFAudioFormat_PCM), + "got %s\n", debugstr_guid(&wave_format_ext->SubFormat)); + ok(wave_format_ext->dwChannelMask == 3, "got %#lx\n", wave_format_ext->dwChannelMask); + ok(wave_format_ext->Samples.wSamplesPerBlock == 0, "got %u\n", + wave_format_ext->Samples.wSamplesPerBlock); + ok(wave_format_ext->Format.cbSize == sizeof(*wave_format_ext) - sizeof(*wave_format), + "got %u\n", wave_format_ext->Format.cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, 3); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_BLOCK, 4); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(WAVEFORMATEXTENSIBLE), "got %lu\n", am_type.cbFormat); + wave_format_ext = (WAVEFORMATEXTENSIBLE *)am_type.pbFormat; + ok(wave_format_ext->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE, + "got %u\n", wave_format_ext->Format.wFormatTag); + ok(IsEqualGUID(&wave_format_ext->SubFormat, &MFAudioFormat_PCM), + "got %s\n", debugstr_guid(&wave_format_ext->SubFormat)); + ok(wave_format_ext->dwChannelMask == 0, "got %#lx\n", wave_format_ext->dwChannelMask); + ok(wave_format_ext->Samples.wSamplesPerBlock == 4, "got %u\n", + wave_format_ext->Samples.wSamplesPerBlock); + ok(wave_format_ext->Format.cbSize == sizeof(*wave_format_ext) - sizeof(*wave_format), + "got %u\n", wave_format_ext->Format.cbSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + + /* test VIDEOINFOHEADER mapping */ + + 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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetBlob(media_type, &MF_MT_USER_DATA, dummy_user_data, sizeof(dummy_user_data)); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER) + sizeof(dummy_user_data), "got %lu\n", am_type.cbFormat); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->rcSource.right == 0, "got %lu\n", video_info->rcSource.right); + ok(video_info->rcSource.bottom == 0, "got %lu\n", video_info->rcSource.bottom); + ok(video_info->rcTarget.right == 0, "got %lu\n", video_info->rcTarget.right); + ok(video_info->rcTarget.bottom == 0, "got %lu\n", video_info->rcTarget.bottom); + ok(video_info->dwBitRate == 0, "got %lu\n", video_info->dwBitRate); + ok(video_info->dwBitErrorRate == 0, "got %lu\n", video_info->dwBitErrorRate); + ok(video_info->AvgTimePerFrame == 0, "got %I64d\n", video_info->AvgTimePerFrame); + ok(video_info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER) + sizeof(dummy_user_data), + "got %lu\n", video_info->bmiHeader.biSize); + ok(video_info->bmiHeader.biWidth == 0, "got %lu\n", video_info->bmiHeader.biWidth); + ok(video_info->bmiHeader.biHeight == 0, "got %lu\n", video_info->bmiHeader.biHeight); + ok(video_info->bmiHeader.biPlanes == 1, "got %u\n", video_info->bmiHeader.biPlanes); + ok(video_info->bmiHeader.biBitCount == 32, "got %u\n", video_info->bmiHeader.biBitCount); + ok(video_info->bmiHeader.biCompression == BI_RGB, "got %lu\n", video_info->bmiHeader.biCompression); + ok(video_info->bmiHeader.biSizeImage == 0, "got %lu\n", video_info->bmiHeader.biSizeImage); + ok(!memcmp(video_info + 1, dummy_user_data, sizeof(dummy_user_data)), + "got unexpected data\n"); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.bFixedSizeSamples == 1, "got %u.\n", am_type.bFixedSizeSamples); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_SAMPLE_SIZE, 123456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(am_type.lSampleSize == 123456, "got %lu.\n", am_type.lSampleSize); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER), "got %lu\n", video_info->bmiHeader.biSize); + ok(video_info->bmiHeader.biBitCount == 32, "got %u\n", video_info->bmiHeader.biBitCount); + ok(video_info->bmiHeader.biCompression == BI_RGB, "got %lu\n", video_info->bmiHeader.biCompression); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB565); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER), "got %lu\n", video_info->bmiHeader.biSize); + ok(video_info->bmiHeader.biBitCount == 16, "got %u\n", video_info->bmiHeader.biBitCount); + ok(video_info->bmiHeader.biCompression == BI_BITFIELDS, "got %lu\n", video_info->bmiHeader.biCompression); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_NV12); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER), "got %lu\n", video_info->bmiHeader.biSize); + ok(video_info->bmiHeader.biBitCount == 12, "got %u\n", video_info->bmiHeader.biBitCount); + ok(video_info->bmiHeader.biCompression == MFVideoFormat_NV12.Data1, "got %lu\n", video_info->bmiHeader.biCompression); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_WMV2); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER), "got %lu\n", video_info->bmiHeader.biSize); + ok(video_info->bmiHeader.biBitCount == 0, "got %u\n", video_info->bmiHeader.biBitCount); + ok(video_info->bmiHeader.biCompression == MFVideoFormat_WMV2.Data1, "got %lu\n", video_info->bmiHeader.biCompression); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_NV12); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_RATE, (UINT64)123 << 32 | 456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->AvgTimePerFrame == 37073171, "got %I64d\n", video_info->AvgTimePerFrame); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_NV12); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AVG_BITRATE, 123456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, 654321); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->dwBitRate == 123456, "got %lu\n", video_info->dwBitRate); + ok(video_info->dwBitErrorRate == 654321, "got %lu\n", video_info->dwBitErrorRate); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_NV12); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_SAMPLE_SIZE, 123456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biSizeImage == 123456, "got %lu\n", video_info->bmiHeader.biSizeImage); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)123 << 32 | 456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biWidth == 123, "got %lu\n", video_info->bmiHeader.biWidth); + ok(video_info->bmiHeader.biHeight == 456, "got %lu\n", video_info->bmiHeader.biHeight); + ok(video_info->bmiHeader.biSizeImage == 224352, "got %lu\n", video_info->bmiHeader.biSizeImage); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)123 << 32 | 456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetBlob(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, (BYTE *)&aperture, sizeof(aperture)); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_SAMPLE_SIZE, 123456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->rcSource.left == 0, "got %lu\n", video_info->rcSource.left); + ok(video_info->rcSource.right == 0, "got %lu\n", video_info->rcSource.right); + ok(video_info->rcSource.top == 0, "got %lu\n", video_info->rcSource.top); + ok(video_info->rcSource.bottom == 0, "got %lu\n", video_info->rcSource.bottom); + ok(video_info->rcTarget.left == 0, "got %lu\n", video_info->rcTarget.left); + ok(video_info->rcTarget.right == 0, "got %lu\n", video_info->rcTarget.right); + ok(video_info->rcTarget.top == 0, "got %lu\n", video_info->rcTarget.top); + ok(video_info->rcTarget.bottom == 0, "got %lu\n", video_info->rcTarget.bottom); + ok(video_info->bmiHeader.biWidth == 123, "got %lu\n", video_info->bmiHeader.biWidth); + ok(video_info->bmiHeader.biHeight == 456, "got %lu\n", video_info->bmiHeader.biHeight); + ok(video_info->bmiHeader.biSizeImage == 224352, "got %lu\n", video_info->bmiHeader.biSizeImage); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)123 << 32 | 456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, -984); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biWidth == 246, "got %lu\n", video_info->bmiHeader.biWidth); + ok(video_info->bmiHeader.biHeight == 456, "got %ld\n", video_info->bmiHeader.biHeight); + ok(video_info->bmiHeader.biSizeImage == 448704, "got %lu\n", video_info->bmiHeader.biSizeImage); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_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, &MFVideoFormat_RGB32); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)123 << 32 | 456); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, 984); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + video_info = (VIDEOINFOHEADER *)am_type.pbFormat; + ok(video_info->bmiHeader.biWidth == 246, "got %lu\n", video_info->bmiHeader.biWidth); + ok(video_info->bmiHeader.biHeight == -456, "got %ld\n", video_info->bmiHeader.biHeight); + ok(video_info->bmiHeader.biSizeImage == 448704, "got %lu\n", video_info->bmiHeader.biSizeImage); + CoTaskMemFree(am_type.pbFormat); + IMFMediaType_DeleteAllItems(media_type); + +skip_tests: + IMFMediaType_Release(media_type); +} + static void test_MFCreateDXSurfaceBuffer(void) { IDirect3DSurface9 *backbuffer = NULL, *surface; @@ -9778,6 +10278,7 @@ START_TEST(mfplat) test_MFCreateMediaBufferFromMediaType(); test_MFInitMediaTypeFromWaveFormatEx(); test_MFCreateMFVideoFormatFromMFMediaType(); + test_MFInitAMMediaTypeFromMFMediaType(); test_MFCreateDXSurfaceBuffer(); test_MFCreateTrackedSample(); test_MFFrameRateToAverageTimePerFrame();
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 5a399f39608..f5cfe9cb4ee 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7534,6 +7534,44 @@ skip_tests: IMFMediaType_Release(media_type); }
+static void test_MFCreateAMMediaTypeFromMFMediaType(void) +{ + IMFMediaType *media_type; + AM_MEDIA_TYPE *am_type; + HRESULT hr; + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + + hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (hr != S_OK) goto skip_tests; + ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type->majortype)); + ok(IsEqualGUID(&am_type->subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type->subtype)); + ok(IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type->formattype)); + ok(am_type->cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type->cbFormat); + CoTaskMemFree(am_type->pbFormat); + CoTaskMemFree(am_type); + +skip_tests: + IMFMediaType_Release(media_type); +} + static void test_MFCreateDXSurfaceBuffer(void) { IDirect3DSurface9 *backbuffer = NULL, *surface; @@ -10279,6 +10317,7 @@ START_TEST(mfplat) test_MFInitMediaTypeFromWaveFormatEx(); test_MFCreateMFVideoFormatFromMFMediaType(); test_MFInitAMMediaTypeFromMFMediaType(); + test_MFCreateAMMediaTypeFromMFMediaType(); test_MFCreateDXSurfaceBuffer(); test_MFCreateTrackedSample(); test_MFFrameRateToAverageTimePerFrame();
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index f5cfe9cb4ee..36f2d76401a 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7572,6 +7572,81 @@ skip_tests: IMFMediaType_Release(media_type); }
+static void test_IMFMediaType_GetRepresentation(void) +{ + WAVEFORMATEX wfx = {.wFormatTag = WAVE_FORMAT_PCM}; + IMFMediaType *media_type; + AM_MEDIA_TYPE *am_type; + HRESULT hr; + + hr = MFCreateMediaType(&media_type); + ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr); + + hr = IMFMediaType_GetRepresentation(media_type, GUID_NULL, (void **)&am_type); + todo_wine ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); + todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, FORMAT_VideoInfo, (void **)&am_type); + todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (hr != S_OK) goto skip_tests; + ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type->majortype)); + ok(IsEqualGUID(&am_type->subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type->subtype)); + ok(IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type->formattype)); + ok(am_type->cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type->cbFormat); + hr = IMFMediaType_FreeRepresentation(media_type, IID_IUnknown /* invalid format */, am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFMediaType_Release(media_type); + + hr = MFCreateAudioMediaType(&wfx, (IMFAudioMediaType **)&media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, GUID_NULL, (void **)&am_type); + ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, FORMAT_VideoInfo, (void **)&am_type); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type->majortype)); + ok(IsEqualGUID(&am_type->subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type->subtype)); + ok(IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type->formattype)); + ok(am_type->cbFormat == sizeof(WAVEFORMATEX), "got %lu\n", am_type->cbFormat); + hr = IMFMediaType_FreeRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFMediaType_Release(media_type); + + hr = MFCreateVideoMediaTypeFromSubtype(&MFVideoFormat_RGB32, (IMFVideoMediaType **)&media_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, GUID_NULL, (void **)&am_type); + ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, FORMAT_WaveFormatEx, (void **)&am_type); + ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type->majortype)); + ok(IsEqualGUID(&am_type->subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type->subtype)); + ok(IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo), "got %s.\n", debugstr_guid(&am_type->formattype)); + ok(am_type->cbFormat == sizeof(VIDEOINFOHEADER), "got %lu\n", am_type->cbFormat); + hr = IMFMediaType_FreeRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, am_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + +skip_tests: + IMFMediaType_Release(media_type); +} + static void test_MFCreateDXSurfaceBuffer(void) { IDirect3DSurface9 *backbuffer = NULL, *surface; @@ -10318,6 +10393,7 @@ START_TEST(mfplat) test_MFCreateMFVideoFormatFromMFMediaType(); test_MFInitAMMediaTypeFromMFMediaType(); test_MFCreateAMMediaTypeFromMFMediaType(); + test_IMFMediaType_GetRepresentation(); test_MFCreateDXSurfaceBuffer(); test_MFCreateTrackedSample(); test_MFFrameRateToAverageTimePerFrame();
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 48 +++++++++++++++++++---------------- dlls/mfplat/tests/mfplat.c | 52 +++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 23 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index fabc36dcc3c..1707df87f6d 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -31,6 +31,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
+DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB1, D3DFMT_A1); +DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB4, MAKEFOURCC('4','P','x','x')); +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);
@@ -3605,31 +3609,31 @@ static HRESULT mf_get_stride_for_bitmap_info_header(DWORD fourcc, const BITMAPIN
static const GUID * get_mf_subtype_for_am_subtype(const GUID *subtype) { - static const GUID null; - + 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; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB32)) + if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB1555)) + return &MFVideoFormat_ARGB1555; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB4444)) + return &MFVideoFormat_ARGB4444; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_ARGB32)) return &MFVideoFormat_ARGB32; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_I420)) - return &MFVideoFormat_I420; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_AYUV)) - return &MFVideoFormat_AYUV; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_YV12)) - return &MFVideoFormat_YV12; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_YUY2)) - return &MFVideoFormat_YUY2; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_UYVY)) - return &MFVideoFormat_UYVY; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_YVYU)) - return &MFVideoFormat_YVYU; - else if (IsEqualGUID(subtype, &MEDIASUBTYPE_NV12)) - return &MFVideoFormat_NV12; - else - { - FIXME("Unknown subtype %s.\n", debugstr_guid(subtype)); - return &null; - } + if (IsEqualGUID(subtype, &MEDIASUBTYPE_A2R10G10B10)) + return &MFVideoFormat_A2B10G10R10; + if (IsEqualGUID(subtype, &MEDIASUBTYPE_A2B10G10R10)) + return &MFVideoFormat_A2R10G10B10; + return subtype; }
/*********************************************************************** diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 36f2d76401a..51ec8f6653b 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -66,14 +66,38 @@ DEFINE_GUID(DUMMY_GUID3, 0x12345678,0x1234,0x1234,0x23,0x23,0x23,0x23,0x23,0x23,
extern const CLSID CLSID_FileSchemePlugin;
+DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_Base,0); + +DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB1, D3DFMT_A1); +DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB4, MAKEFOURCC('4','P','x','x')); +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(MEDIASUBTYPE_h264,MAKEFOURCC('h','2','6','4')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_MP3,WAVE_FORMAT_MPEGLAYER3); + DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC1, MAKEFOURCC('I','M','C','1')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC2, MAKEFOURCC('I','M','C','2')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC3, MAKEFOURCC('I','M','C','3')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC4, MAKEFOURCC('I','M','C','4'));
+DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_AVC1,MAKEFOURCC('A','V','C','1')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_MP42,MAKEFOURCC('M','P','4','2')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_mp42,MAKEFOURCC('m','p','4','2')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_MPG4,MAKEFOURCC('M','P','G','4')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_mpg4,MAKEFOURCC('m','p','g','4')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_P422,MAKEFOURCC('P','4','2','2')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_wmva,MAKEFOURCC('w','m','v','a')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_WMVB,MAKEFOURCC('W','M','V','B')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_wmvb,MAKEFOURCC('w','m','v','b')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_wmvp,MAKEFOURCC('w','m','v','p')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_wmvr,MAKEFOURCC('w','m','v','r')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_wvp2,MAKEFOURCC('w','v','p','2')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_X264,MAKEFOURCC('X','2','6','4')); +DEFINE_MEDIATYPE_GUID(MEDIASUBTYPE_x264,MAKEFOURCC('x','2','6','4')); + static BOOL is_win8_plus;
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) @@ -9868,6 +9892,22 @@ static void test_MFInitMediaTypeFromAMMediaType(void) 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 }, @@ -9875,7 +9915,15 @@ static void test_MFInitMediaTypeFromAMMediaType(void) { &MEDIASUBTYPE_UYVY, &MFVideoFormat_UYVY }, { &MEDIASUBTYPE_YVYU, &MFVideoFormat_YVYU }, { &MEDIASUBTYPE_NV12, &MFVideoFormat_NV12 }, - { &MEDIASUBTYPE_ARGB32, &MFVideoFormat_ARGB32 }, + + /* 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 }, }; unsigned int i;
@@ -9999,6 +10047,7 @@ static void test_MFInitMediaTypeFromAMMediaType(void) vih.bmiHeader.biHeight = 24; for (i = 0; i < ARRAY_SIZE(guid_types); ++i) { + winetest_push_context("%s", debugstr_guid(guid_types[i].am_type)); memcpy(&mt.subtype, guid_types[i].am_type, sizeof(GUID));
hr = MFInitMediaTypeFromAMMediaType(media_type, &mt); @@ -10010,6 +10059,7 @@ static void test_MFInitMediaTypeFromAMMediaType(void) 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)); + winetest_pop_context(); }
IMFMediaType_Release(media_type);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 66 ++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 33 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 1707df87f6d..6eb3d875f10 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -2625,7 +2625,7 @@ HRESULT WINAPI MFCreatePresentationDescriptor(DWORD count, IMFStreamDescriptor * struct uncompressed_video_format { const GUID *subtype; - unsigned char bytes_per_pixel; + unsigned char bpp; unsigned char alignment; unsigned char bottom_up; unsigned char yuv; @@ -2640,36 +2640,36 @@ static int __cdecl uncompressed_video_format_compare(const void *a, const void *
static const struct uncompressed_video_format video_formats[] = { - { &MFVideoFormat_RGB24, 3, 3, 1, 0 }, - { &MFVideoFormat_ARGB32, 4, 3, 1, 0 }, - { &MFVideoFormat_RGB32, 4, 3, 1, 0 }, - { &MFVideoFormat_RGB565, 2, 3, 1, 0 }, - { &MFVideoFormat_RGB555, 2, 3, 1, 0 }, - { &MFVideoFormat_A2R10G10B10, 4, 3, 1, 0 }, - { &MFVideoFormat_A2B10G10R10, 4, 3, 1, 0 }, - { &MFVideoFormat_RGB8, 1, 3, 1, 0 }, - { &MFVideoFormat_L8, 1, 3, 1, 0 }, - { &MFVideoFormat_AYUV, 4, 3, 0, 1 }, - { &MFVideoFormat_I420, 1, 0, 0, 1 }, - { &MFVideoFormat_IMC1, 2, 3, 0, 1 }, - { &MFVideoFormat_IMC2, 1, 0, 0, 1 }, - { &MFVideoFormat_IMC3, 2, 3, 0, 1 }, - { &MFVideoFormat_IMC4, 1, 0, 0, 1 }, - { &MFVideoFormat_IYUV, 1, 0, 0, 1 }, - { &MFVideoFormat_NV11, 1, 0, 0, 1 }, - { &MFVideoFormat_NV12, 1, 0, 0, 1 }, - { &MFVideoFormat_D16, 2, 3, 0, 0 }, - { &MFVideoFormat_L16, 2, 3, 0, 0 }, - { &MFVideoFormat_UYVY, 2, 0, 0, 1 }, - { &MFVideoFormat_YUY2, 2, 0, 0, 1 }, - { &MFVideoFormat_YV12, 1, 0, 0, 1 }, - { &MFVideoFormat_YVYU, 2, 0, 0, 1 }, - { &MFVideoFormat_A16B16G16R16F, 8, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB8, 1, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB565, 2, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB555, 2, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB24, 3, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB32, 4, 3, 1, 0 }, + { &MFVideoFormat_RGB24, 24, 3, 1, 0 }, + { &MFVideoFormat_ARGB32, 32, 3, 1, 0 }, + { &MFVideoFormat_RGB32, 32, 3, 1, 0 }, + { &MFVideoFormat_RGB565, 16, 3, 1, 0 }, + { &MFVideoFormat_RGB555, 16, 3, 1, 0 }, + { &MFVideoFormat_A2R10G10B10, 32, 3, 1, 0 }, + { &MFVideoFormat_A2B10G10R10, 32, 3, 1, 0 }, + { &MFVideoFormat_RGB8, 8, 3, 1, 0 }, + { &MFVideoFormat_L8, 8, 3, 1, 0 }, + { &MFVideoFormat_AYUV, 32, 3, 0, 1 }, + { &MFVideoFormat_I420, 12, 0, 0, 1 }, + { &MFVideoFormat_IMC1, 16, 3, 0, 1 }, + { &MFVideoFormat_IMC2, 12, 0, 0, 1 }, + { &MFVideoFormat_IMC3, 16, 3, 0, 1 }, + { &MFVideoFormat_IMC4, 12, 0, 0, 1 }, + { &MFVideoFormat_IYUV, 12, 0, 0, 1 }, + { &MFVideoFormat_NV11, 12, 0, 0, 1 }, + { &MFVideoFormat_NV12, 12, 0, 0, 1 }, + { &MFVideoFormat_D16, 16, 3, 0, 0 }, + { &MFVideoFormat_L16, 16, 3, 0, 0 }, + { &MFVideoFormat_UYVY, 16, 0, 0, 1 }, + { &MFVideoFormat_YUY2, 16, 0, 0, 1 }, + { &MFVideoFormat_YV12, 12, 0, 0, 1 }, + { &MFVideoFormat_YVYU, 16, 0, 0, 1 }, + { &MFVideoFormat_A16B16G16R16F, 64, 3, 1, 0 }, + { &MEDIASUBTYPE_RGB8, 8, 3, 1, 0 }, + { &MEDIASUBTYPE_RGB565, 16, 3, 1, 0 }, + { &MEDIASUBTYPE_RGB555, 16, 3, 1, 0 }, + { &MEDIASUBTYPE_RGB24, 24, 3, 1, 0 }, + { &MEDIASUBTYPE_RGB32, 32, 3, 1, 0 }, };
static struct uncompressed_video_format *mf_get_video_format(const GUID *subtype) @@ -2680,7 +2680,7 @@ static struct uncompressed_video_format *mf_get_video_format(const GUID *subtype
static unsigned int mf_get_stride_for_format(const struct uncompressed_video_format *format, unsigned int width) { - return (width * format->bytes_per_pixel + format->alignment) & ~format->alignment; + return (width * (format->bpp / 8) + format->alignment) & ~format->alignment; }
unsigned int mf_format_get_stride(const GUID *subtype, unsigned int width, BOOL *is_yuv) @@ -2755,7 +2755,7 @@ HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height case D3DFMT_L8: case D3DFMT_L16: case D3DFMT_D16: - *size = width * format->bytes_per_pixel * height; + *size = width * (format->bpp / 8) * height; break; default: stride = mf_get_stride_for_format(format, width);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 317 +++++++++++++++++++++++++++++++++---- dlls/mfplat/tests/mfplat.c | 20 ++- 2 files changed, 294 insertions(+), 43 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 6eb3d875f10..bb7383960c8 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -19,6 +19,7 @@ #define COBJMACROS
#include "mfplat_private.h" +#include <math.h>
#include "dxva2api.h" #include "uuids.h" @@ -31,6 +32,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
+DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); + DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB1, D3DFMT_A1); DEFINE_MEDIATYPE_GUID(MFVideoFormat_RGB4, MAKEFOURCC('4','P','x','x')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_ARGB1555, D3DFMT_A1R5G5B5); @@ -43,6 +46,46 @@ DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC2, MAKEFOURCC('I','M','C','2')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC3, MAKEFOURCC('I','M','C','3')); DEFINE_MEDIATYPE_GUID(MFVideoFormat_IMC4, MAKEFOURCC('I','M','C','4'));
+static const UINT32 default_channel_mask[7] = +{ + 0, + SPEAKER_FRONT_LEFT, + SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, + SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER, + KSAUDIO_SPEAKER_QUAD, + KSAUDIO_SPEAKER_QUAD | SPEAKER_FRONT_CENTER, + KSAUDIO_SPEAKER_5POINT1, +}; + +static GUID get_am_subtype_for_mf_subtype(GUID subtype) +{ + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB1)) + return MEDIASUBTYPE_RGB1; + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB4)) + return MEDIASUBTYPE_RGB4; + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB8)) + return MEDIASUBTYPE_RGB8; + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB555)) + return MEDIASUBTYPE_RGB555; + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB565)) + return MEDIASUBTYPE_RGB565; + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB24)) + return MEDIASUBTYPE_RGB24; + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB32)) + return MEDIASUBTYPE_RGB32; + if (IsEqualGUID(&subtype, &MFVideoFormat_ARGB1555)) + return MEDIASUBTYPE_ARGB1555; + if (IsEqualGUID(&subtype, &MFVideoFormat_ARGB4444)) + return MEDIASUBTYPE_ARGB4444; + if (IsEqualGUID(&subtype, &MFVideoFormat_ARGB32)) + return MEDIASUBTYPE_ARGB32; + if (IsEqualGUID(&subtype, &MFVideoFormat_A2B10G10R10)) + return MEDIASUBTYPE_A2R10G10B10; + if (IsEqualGUID(&subtype, &MFVideoFormat_A2R10G10B10)) + return MEDIASUBTYPE_A2B10G10R10; + return subtype; +} + struct media_type { struct attributes attributes; @@ -2629,6 +2672,7 @@ struct uncompressed_video_format unsigned char alignment; unsigned char bottom_up; unsigned char yuv; + int compression; };
static int __cdecl uncompressed_video_format_compare(const void *a, const void *b) @@ -2640,36 +2684,36 @@ static int __cdecl uncompressed_video_format_compare(const void *a, const void *
static const struct uncompressed_video_format video_formats[] = { - { &MFVideoFormat_RGB24, 24, 3, 1, 0 }, - { &MFVideoFormat_ARGB32, 32, 3, 1, 0 }, - { &MFVideoFormat_RGB32, 32, 3, 1, 0 }, - { &MFVideoFormat_RGB565, 16, 3, 1, 0 }, - { &MFVideoFormat_RGB555, 16, 3, 1, 0 }, - { &MFVideoFormat_A2R10G10B10, 32, 3, 1, 0 }, - { &MFVideoFormat_A2B10G10R10, 32, 3, 1, 0 }, - { &MFVideoFormat_RGB8, 8, 3, 1, 0 }, - { &MFVideoFormat_L8, 8, 3, 1, 0 }, - { &MFVideoFormat_AYUV, 32, 3, 0, 1 }, - { &MFVideoFormat_I420, 12, 0, 0, 1 }, - { &MFVideoFormat_IMC1, 16, 3, 0, 1 }, - { &MFVideoFormat_IMC2, 12, 0, 0, 1 }, - { &MFVideoFormat_IMC3, 16, 3, 0, 1 }, - { &MFVideoFormat_IMC4, 12, 0, 0, 1 }, - { &MFVideoFormat_IYUV, 12, 0, 0, 1 }, - { &MFVideoFormat_NV11, 12, 0, 0, 1 }, - { &MFVideoFormat_NV12, 12, 0, 0, 1 }, - { &MFVideoFormat_D16, 16, 3, 0, 0 }, - { &MFVideoFormat_L16, 16, 3, 0, 0 }, - { &MFVideoFormat_UYVY, 16, 0, 0, 1 }, - { &MFVideoFormat_YUY2, 16, 0, 0, 1 }, - { &MFVideoFormat_YV12, 12, 0, 0, 1 }, - { &MFVideoFormat_YVYU, 16, 0, 0, 1 }, - { &MFVideoFormat_A16B16G16R16F, 64, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB8, 8, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB565, 16, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB555, 16, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB24, 24, 3, 1, 0 }, - { &MEDIASUBTYPE_RGB32, 32, 3, 1, 0 }, + { &MFVideoFormat_RGB24, 24, 3, 1, 0, BI_RGB }, + { &MFVideoFormat_ARGB32, 32, 3, 1, 0, BI_RGB }, + { &MFVideoFormat_RGB32, 32, 3, 1, 0, BI_RGB }, + { &MFVideoFormat_RGB565, 16, 3, 1, 0, BI_BITFIELDS }, + { &MFVideoFormat_RGB555, 16, 3, 1, 0, BI_RGB }, + { &MFVideoFormat_A2R10G10B10, 32, 3, 1, 0, -1 }, + { &MFVideoFormat_A2B10G10R10, 32, 3, 1, 0, -1 }, + { &MFVideoFormat_RGB8, 8, 3, 1, 0, BI_RGB }, + { &MFVideoFormat_L8, 8, 3, 1, 0, -1 }, + { &MFVideoFormat_AYUV, 32, 3, 0, 1, -1 }, + { &MFVideoFormat_I420, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_IMC1, 16, 3, 0, 1, -1 }, + { &MFVideoFormat_IMC2, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_IMC3, 16, 3, 0, 1, -1 }, + { &MFVideoFormat_IMC4, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_IYUV, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_NV11, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_NV12, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_D16, 16, 3, 0, 0, -1 }, + { &MFVideoFormat_L16, 16, 3, 0, 0, -1 }, + { &MFVideoFormat_UYVY, 16, 0, 0, 1, -1 }, + { &MFVideoFormat_YUY2, 16, 0, 0, 1, -1 }, + { &MFVideoFormat_YV12, 12, 0, 0, 1, -1 }, + { &MFVideoFormat_YVYU, 16, 0, 0, 1, -1 }, + { &MFVideoFormat_A16B16G16R16F, 64, 3, 1, 0, -1 }, + { &MEDIASUBTYPE_RGB8, 8, 3, 1, 0, BI_RGB }, + { &MEDIASUBTYPE_RGB565, 16, 3, 1, 0, BI_BITFIELDS }, + { &MEDIASUBTYPE_RGB555, 16, 3, 1, 0, BI_RGB }, + { &MEDIASUBTYPE_RGB24, 24, 3, 1, 0, BI_RGB }, + { &MEDIASUBTYPE_RGB32, 32, 3, 1, 0, BI_RGB }, };
static struct uncompressed_video_format *mf_get_video_format(const GUID *subtype) @@ -3688,13 +3732,222 @@ HRESULT WINAPI MFInitMediaTypeFromVideoInfoHeader(IMFMediaType *media_type, cons return hr; }
+static HRESULT init_am_media_type_audio_format(AM_MEDIA_TYPE *am_type, UINT32 user_size, IMFMediaType *media_type) +{ + UINT32 num_channels, value; + HRESULT hr; + + if (IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo) + || IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo2) + || IsEqualGUID(&am_type->formattype, &FORMAT_MFVideoFormat)) + return E_INVALIDARG; + + if (IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx) + || IsEqualGUID(&am_type->formattype, &GUID_NULL)) + { + WAVEFORMATEX *format; + + if (FAILED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, &num_channels))) + num_channels = 0; + + if (SUCCEEDED(IMFMediaType_GetItem(media_type, &MF_MT_AUDIO_CHANNEL_MASK, NULL)) + || SUCCEEDED(IMFMediaType_GetItem(media_type, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, NULL)) + || SUCCEEDED(IMFMediaType_GetItem(media_type, &MF_MT_AUDIO_SAMPLES_PER_BLOCK, NULL)) + || num_channels > 2) + { + WAVEFORMATEXTENSIBLE *format_ext; + + am_type->cbFormat = sizeof(*format_ext) + user_size; + if (!(am_type->pbFormat = CoTaskMemAlloc(am_type->cbFormat))) + return E_OUTOFMEMORY; + format_ext = (WAVEFORMATEXTENSIBLE *)am_type->pbFormat; + memset(format_ext, 0, sizeof(*format_ext)); + + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_CHANNEL_MASK, &value))) + format_ext->dwChannelMask = value; + else if (num_channels < ARRAY_SIZE(default_channel_mask)) + format_ext->dwChannelMask = default_channel_mask[num_channels]; + + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, &value))) + format_ext->Samples.wValidBitsPerSample = value; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_BLOCK, &value))) + format_ext->Samples.wSamplesPerBlock = value; + format_ext->SubFormat = am_type->subtype; + + format = &format_ext->Format; + format->wFormatTag = WAVE_FORMAT_EXTENSIBLE; + format->cbSize = sizeof(*format_ext) - sizeof(*format) + user_size; + + if (user_size && FAILED(hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, + (BYTE *)(format_ext + 1), user_size, NULL))) + return hr; + } + else + { + am_type->cbFormat = sizeof(*format) + user_size; + if (!(am_type->pbFormat = CoTaskMemAlloc(am_type->cbFormat))) + return E_OUTOFMEMORY; + format = (WAVEFORMATEX *)am_type->pbFormat; + memset(format, 0, sizeof(*format)); + + format->wFormatTag = am_type->subtype.Data1; + format->cbSize = user_size; + + if (user_size && FAILED(hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, + (BYTE *)(format + 1), user_size, NULL))) + return hr; + } + + format->nChannels = num_channels; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &value))) + format->nSamplesPerSec = value; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &value))) + format->nAvgBytesPerSec = value; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &value))) + format->nBlockAlign = value; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &value))) + format->wBitsPerSample = value; + + am_type->subtype = get_am_subtype_for_mf_subtype(am_type->subtype); + am_type->formattype = FORMAT_WaveFormatEx; + } + else + { + WARN("Unknown format %s\n", debugstr_mf_guid(&am_type->formattype)); + am_type->formattype = GUID_NULL; + } + + return S_OK; +} + +static HRESULT init_am_media_type_video_format(AM_MEDIA_TYPE *am_type, UINT32 user_size, IMFMediaType *media_type) +{ + UINT32 image_size, bitrate, sample_size; + UINT64 frame_size, frame_rate; + INT32 width, height; + HRESULT hr; + + if (IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx)) + return E_INVALIDARG; + + if (IsEqualGUID(&am_type->formattype, &FORMAT_MFVideoFormat)) + return MFCreateMFVideoFormatFromMFMediaType(media_type, (MFVIDEOFORMAT **)&am_type->pbFormat, + (UINT32 *)&am_type->cbFormat); + + if (IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo) + || IsEqualGUID(&am_type->formattype, &GUID_NULL)) + { + struct uncompressed_video_format *video_format = mf_get_video_format(&am_type->subtype); + VIDEOINFOHEADER *format; + + am_type->cbFormat = sizeof(*format) + user_size; + if (!(am_type->pbFormat = CoTaskMemAlloc(am_type->cbFormat))) + return E_OUTOFMEMORY; + format = (VIDEOINFOHEADER *)am_type->pbFormat; + memset(format, 0, sizeof(*format)); + + format->bmiHeader.biSize = sizeof(format->bmiHeader) + user_size; + format->bmiHeader.biPlanes = 1; + format->bmiHeader.biBitCount = video_format ? video_format->bpp : 0; + + if (video_format && video_format->compression != -1) + format->bmiHeader.biCompression = video_format->compression; + else + format->bmiHeader.biCompression = am_type->subtype.Data1; + + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BITRATE, &bitrate))) + format->dwBitRate = bitrate; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AVG_BIT_ERROR_RATE, &bitrate))) + format->dwBitErrorRate = bitrate; + if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &frame_rate)) && (frame_rate >> 32)) + format->AvgTimePerFrame = round(10000000. * (UINT32)frame_rate / (frame_rate >> 32)); + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &sample_size))) + format->bmiHeader.biSizeImage = sample_size; + + if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &frame_size))) + { + BOOL bottom_up = format->bmiHeader.biCompression == BI_RGB || format->bmiHeader.biCompression == BI_BITFIELDS; + + if (FAILED(IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, (UINT32 *)&width))) + width = (frame_size >> 32) * (bottom_up ? -1 : 1); + else if (video_format) + width /= video_format->bpp / 8; + height = (UINT32)frame_size; + + format->bmiHeader.biWidth = abs(width); + format->bmiHeader.biHeight = height * (bottom_up && width >= 0 ? -1 : 1); + + if (SUCCEEDED(MFCalculateImageSize(&am_type->subtype, abs(width), height, &image_size))) + format->bmiHeader.biSizeImage = image_size; + } + + if (user_size && FAILED(hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, + (BYTE *)(format + 1), user_size, NULL))) + return hr; + + am_type->formattype = FORMAT_VideoInfo; + am_type->subtype = get_am_subtype_for_mf_subtype(am_type->subtype); + } + else if (IsEqualGUID(&am_type->formattype, &FORMAT_VideoInfo2)) + { + FIXME("Not implemented!\n"); + am_type->formattype = GUID_NULL; + return E_NOTIMPL; + } + else + { + WARN("Unknown format %s\n", debugstr_mf_guid(&am_type->formattype)); + am_type->formattype = GUID_NULL; + } + + return S_OK; +} + /*********************************************************************** * MFInitAMMediaTypeFromMFMediaType (mfplat.@) */ HRESULT WINAPI MFInitAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format, AM_MEDIA_TYPE *am_type) { - FIXME("%p, %s, %p\n", media_type, debugstr_guid(&format), am_type); - return E_NOTIMPL; + UINT32 value, user_size; + HRESULT hr; + + TRACE("%p, %s, %p.\n", media_type, debugstr_mf_guid(&format), am_type); + + memset(am_type, 0, sizeof(*am_type)); + am_type->formattype = format; + + if (FAILED(hr = IMFMediaType_GetMajorType(media_type, &am_type->majortype)) + || FAILED(hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &am_type->subtype))) + goto done; + + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, &value))) + am_type->bFixedSizeSamples = value; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, &value))) + am_type->lSampleSize = value; + + if (FAILED(hr = IMFMediaType_GetBlob(media_type, &MF_MT_USER_DATA, NULL, 0, &user_size)) + && hr != E_NOT_SUFFICIENT_BUFFER) + user_size = 0; + + if (IsEqualGUID(&am_type->majortype, &MFMediaType_Audio)) + hr = init_am_media_type_audio_format(am_type, user_size, media_type); + else if (IsEqualGUID(&am_type->majortype, &MFMediaType_Video)) + hr = init_am_media_type_video_format(am_type, user_size, media_type); + else + { + FIXME("Not implemented!\n"); + hr = E_NOTIMPL; + } + +done: + if (FAILED(hr)) + { + CoTaskMemFree(am_type->pbFormat); + am_type->pbFormat = NULL; + am_type->cbFormat = 0; + } + + return hr; }
/*********************************************************************** diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 51ec8f6653b..d597ab8b7c2 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7077,25 +7077,24 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) /* test basic media type attributes mapping and valid formats */
hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo, &am_type); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr != S_OK) goto skip_tests; + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type.majortype)); ok(IsEqualGUID(&am_type.subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type.subtype)); ok(IsEqualGUID(&am_type.formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type.formattype)); @@ -7138,11 +7137,11 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER), "got %lu\n", am_type.cbFormat); CoTaskMemFree(am_type.pbFormat); hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_VideoInfo2, &am_type); - ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&am_type.majortype, &MFMediaType_Video), "got %s.\n", debugstr_guid(&am_type.majortype)); - ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); - ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo2), "got %s.\n", debugstr_guid(&am_type.formattype)); - ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER2), "got %lu\n", am_type.cbFormat); + todo_wine ok(IsEqualGUID(&am_type.subtype, &MEDIASUBTYPE_RGB32), "got %s.\n", debugstr_guid(&am_type.subtype)); + todo_wine ok(IsEqualGUID(&am_type.formattype, &FORMAT_VideoInfo2), "got %s.\n", debugstr_guid(&am_type.formattype)); + todo_wine ok(am_type.cbFormat == sizeof(VIDEOINFOHEADER2), "got %lu\n", am_type.cbFormat); CoTaskMemFree(am_type.pbFormat); hr = MFInitAMMediaTypeFromMFMediaType(media_type, FORMAT_MFVideoFormat, &am_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); @@ -7554,7 +7553,6 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) CoTaskMemFree(am_type.pbFormat); IMFMediaType_DeleteAllItems(media_type);
-skip_tests: IMFMediaType_Release(media_type); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 18 ++++++++++++++++-- dlls/mfplat/tests/mfplat.c | 10 ++++------ 2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index bb7383960c8..5467241712e 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -3178,8 +3178,22 @@ static void media_type_get_ratio(IMFMediaType *media_type, const GUID *attr, DWO */ HRESULT WINAPI MFCreateAMMediaTypeFromMFMediaType(IMFMediaType *media_type, GUID format, AM_MEDIA_TYPE **am_type) { - FIXME("%p, %s, %p stub!\n", media_type, debugstr_mf_guid(&format), am_type); - return E_NOTIMPL; + AM_MEDIA_TYPE *mt; + HRESULT hr; + + TRACE("%p, %s, %p.\n", media_type, debugstr_mf_guid(&format), am_type); + + *am_type = NULL; + if (!(mt = CoTaskMemAlloc(sizeof(*mt)))) + return E_OUTOFMEMORY; + if (FAILED(hr = MFInitAMMediaTypeFromMFMediaType(media_type, format, mt))) + { + CoTaskMemFree(mt); + return hr; + } + + *am_type = mt; + return hr; }
/*********************************************************************** diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index d597ab8b7c2..1565434cc2c 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7566,23 +7566,22 @@ static void test_MFCreateAMMediaTypeFromMFMediaType(void) ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr);
hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = MFCreateAMMediaTypeFromMFMediaType(media_type, GUID_NULL, &am_type); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr != S_OK) goto skip_tests; + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type->majortype)); ok(IsEqualGUID(&am_type->subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type->subtype)); ok(IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type->formattype)); @@ -7590,7 +7589,6 @@ static void test_MFCreateAMMediaTypeFromMFMediaType(void) CoTaskMemFree(am_type->pbFormat); CoTaskMemFree(am_type);
-skip_tests: IMFMediaType_Release(media_type); }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mfplat/mediatype.c | 48 +++++++++++++++++++++++++++----------- dlls/mfplat/tests/mfplat.c | 14 +++++------ 2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 5467241712e..2ba967c6719 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -634,16 +634,30 @@ static HRESULT WINAPI mediatype_IsEqual(IMFMediaType *iface, IMFMediaType *type,
static HRESULT WINAPI mediatype_GetRepresentation(IMFMediaType *iface, GUID guid, void **representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation);
- return E_NOTIMPL; + if (IsEqualGUID(&guid, &AM_MEDIA_TYPE_REPRESENTATION)) + return MFCreateAMMediaTypeFromMFMediaType(iface, GUID_NULL, (AM_MEDIA_TYPE **)representation); + + if (IsEqualGUID(&guid, &FORMAT_WaveFormatEx) + || IsEqualGUID(&guid, &FORMAT_VideoInfo) + || IsEqualGUID(&guid, &FORMAT_VideoInfo2) + || IsEqualGUID(&guid, &FORMAT_MFVideoFormat)) + return MFCreateAMMediaTypeFromMFMediaType(iface, guid, (AM_MEDIA_TYPE **)representation); + + FIXME("Format %s not implemented!\n", debugstr_guid(&guid)); + return MF_E_UNSUPPORTED_REPRESENTATION; }
static HRESULT WINAPI mediatype_FreeRepresentation(IMFMediaType *iface, GUID guid, void *representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + AM_MEDIA_TYPE *am_type = representation;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + + CoTaskMemFree(am_type->pbFormat); + CoTaskMemFree(am_type); + return S_OK; }
static const IMFMediaTypeVtbl mediatypevtbl = @@ -1009,16 +1023,18 @@ static HRESULT WINAPI video_mediatype_IsEqual(IMFVideoMediaType *iface, IMFMedia
static HRESULT WINAPI video_mediatype_GetRepresentation(IMFVideoMediaType *iface, GUID guid, void **representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation);
- return E_NOTIMPL; + if (IsEqualGUID(&guid, &FORMAT_WaveFormatEx)) + return MF_E_UNSUPPORTED_REPRESENTATION; + + return mediatype_GetRepresentation((IMFMediaType *)iface, guid, representation); }
static HRESULT WINAPI video_mediatype_FreeRepresentation(IMFVideoMediaType *iface, GUID guid, void *representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); - - return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + return mediatype_FreeRepresentation((IMFMediaType *)iface, guid, representation); }
static const MFVIDEOFORMAT * WINAPI video_mediatype_GetVideoFormat(IMFVideoMediaType *iface) @@ -1410,16 +1426,20 @@ static HRESULT WINAPI audio_mediatype_IsEqual(IMFAudioMediaType *iface, IMFMedia
static HRESULT WINAPI audio_mediatype_GetRepresentation(IMFAudioMediaType *iface, GUID guid, void **representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation);
- return E_NOTIMPL; + if (IsEqualGUID(&guid, &FORMAT_VideoInfo) + || IsEqualGUID(&guid, &FORMAT_VideoInfo2) + || IsEqualGUID(&guid, &FORMAT_MFVideoFormat)) + return E_INVALIDARG; + + return mediatype_GetRepresentation((IMFMediaType *)iface, guid, representation); }
static HRESULT WINAPI audio_mediatype_FreeRepresentation(IMFAudioMediaType *iface, GUID guid, void *representation) { - FIXME("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); - - return E_NOTIMPL; + TRACE("%p, %s, %p.\n", iface, debugstr_guid(&guid), representation); + return mediatype_FreeRepresentation((IMFMediaType *)iface, guid, representation); }
static const WAVEFORMATEX * WINAPI audio_mediatype_GetAudioFormat(IMFAudioMediaType *iface) diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 1565434cc2c..7fab1598181 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7603,27 +7603,26 @@ static void test_IMFMediaType_GetRepresentation(void) ok(hr == S_OK, "Failed to create media type, hr %#lx.\n", hr);
hr = IMFMediaType_GetRepresentation(media_type, GUID_NULL, (void **)&am_type); - todo_wine ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_UNSUPPORTED_REPRESENTATION, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, FORMAT_VideoInfo, (void **)&am_type); - todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); + ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr); hr = IMFMediaType_GetRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, (void **)&am_type); - todo_wine ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - if (hr != S_OK) goto skip_tests; + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(IsEqualGUID(&am_type->majortype, &MFMediaType_Audio), "got %s.\n", debugstr_guid(&am_type->majortype)); ok(IsEqualGUID(&am_type->subtype, &MFAudioFormat_PCM), "got %s.\n", debugstr_guid(&am_type->subtype)); ok(IsEqualGUID(&am_type->formattype, &FORMAT_WaveFormatEx), "got %s.\n", debugstr_guid(&am_type->formattype)); @@ -7663,7 +7662,6 @@ static void test_IMFMediaType_GetRepresentation(void) hr = IMFMediaType_FreeRepresentation(media_type, AM_MEDIA_TYPE_REPRESENTATION, am_type); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
-skip_tests: IMFMediaType_Release(media_type); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=140169
Your paranoid android.
=== debian11b (64 bit WoW report) ===
Report validation errors: mfmediaengine:mfmediaengine crashed (80000101)
This merge request was approved by Nikolay Sivov.