From: R��mi Bernon rbernon@codeweavers.com
--- dlls/mf/tests/mf.c | 60 +-- dlls/winegstreamer/Makefile.in | 1 + dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/mfplat.c | 289 ------------ dlls/winegstreamer/video_processor.c | 668 +++++++++++++++++++++++++++ 5 files changed, 673 insertions(+), 346 deletions(-) create mode 100644 dlls/winegstreamer/video_processor.c
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index f2815f05ff2..4e928b13816 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -8603,14 +8603,12 @@ todo_wine { ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputStatus(transform, 0, &flags); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputStreamAttributes(transform, 0, &attributes); ok(hr == E_NOTIMPL, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputStatus(transform, &flags); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputStreamAttributes(transform, 0, &attributes); @@ -8622,38 +8620,30 @@ todo_wine { IMFAttributes_Release(attributes2);
hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); - todo_wine ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputCurrentType(transform, 0, &media_type); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputCurrentType(transform, 1, &media_type); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type); - todo_wine ok(hr == MF_E_TRANSFORM_TYPE_NOT_SET, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetOutputCurrentType(transform, 1, &media_type); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
hr = IMFTransform_GetInputStreamInfo(transform, 1, &input_info); - todo_wine ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
memset(&input_info, 0xcc, sizeof(input_info)); hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); -todo_wine { ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); ok(input_info.dwFlags == 0, "Unexpected flag %#lx.\n", input_info.dwFlags); ok(input_info.cbSize == 0, "Unexpected size %lu.\n", input_info.cbSize); ok(input_info.cbMaxLookahead == 0, "Unexpected lookahead length %lu.\n", input_info.cbMaxLookahead); ok(input_info.cbAlignment == 0, "Unexpected alignment %lu.\n", input_info.cbAlignment); -} hr = MFCreateMediaEvent(MEUnknown, &GUID_NULL, S_OK, NULL, &event); ok(hr == S_OK, "Failed to create event object, hr %#lx.\n", hr); hr = IMFTransform_ProcessEvent(transform, 0, event); @@ -8668,7 +8658,6 @@ todo_wine { { if (FAILED(hr = IMFTransform_GetInputAvailableType(transform, 0, i, &media_type))) { - todo_wine ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#lx.\n", hr); break; } @@ -8751,22 +8740,18 @@ todo_wine { ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr);
hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "Failed to set input type, hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_RGB32); ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr);
hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "Failed to set output type, hr %#lx.\n", hr);
memset(&output_info, 0, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == S_OK, "Failed to get stream info, hr %#lx.\n", hr); ok(output_info.dwFlags == 0, "Unexpected flags %#lx.\n", output_info.dwFlags); - todo_wine ok(output_info.cbSize > 0, "Unexpected size %lu.\n", output_info.cbSize); ok(output_info.cbAlignment == 0, "Unexpected alignment %lu.\n", output_info.cbAlignment);
@@ -8862,43 +8847,30 @@ todo_wine {
memset(&input_info, 0xcd, sizeof(input_info)); hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - todo_wine ok(hr == S_OK, "GetInputStreamInfo returned %#lx\n", hr); - todo_wine ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); - todo_wine ok(input_info.dwFlags == 0, "got dwFlags %#lx\n", input_info.dwFlags); - todo_wine ok(input_info.cbSize == 0, "got cbSize %#lx\n", input_info.cbSize); - todo_wine ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); - todo_wine ok(input_info.cbAlignment == 0, "got cbAlignment %#lx\n", input_info.cbAlignment);
memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); - todo_wine ok(output_info.dwFlags == 0, "got dwFlags %#lx\n", output_info.dwFlags); - todo_wine ok(output_info.cbSize == 0, "got cbSize %#lx\n", output_info.cbSize); - todo_wine ok(output_info.cbAlignment == 0, "got cbAlignment %#lx\n", output_info.cbAlignment);
hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); - todo_wine ok(hr == MF_E_NO_MORE_TYPES, "GetOutputAvailableType returned %#lx\n", hr);
hr = IMFTransform_GetInputAvailableType(transform, 0, 23, &media_type); - todo_wine ok(hr == S_OK || hr == MF_E_NO_MORE_TYPES /* w8 */, "GetOutputAvailableType returned %#lx\n", hr); if (hr == MF_E_NO_MORE_TYPES) expect_available_inputs = expect_available_inputs_w8; else { hr = IMFTransform_GetInputAvailableType(transform, 0, 27, &media_type); - todo_wine ok(hr == S_OK || broken(hr == MF_E_NO_MORE_TYPES) /* w1064v1507 */, "GetOutputAvailableType returned %#lx\n", hr); if (hr == MF_E_NO_MORE_TYPES) expect_available_inputs = expect_available_inputs_w10 + 3; @@ -8943,6 +8915,7 @@ todo_wine { ok(hr == S_OK, "GetOutputAvailableType returned %#lx.\n", hr); hr = IMFMediaType_IsEqual(media_type, media_type2, &flags); ok(hr == S_OK, "IsEqual returned %#lx.\n", hr); + IMFMediaType_Release(media_type2);
ret = IMFMediaType_Release(media_type); ok(ret == 1, "Release returned %lu\n", ret); @@ -8970,9 +8943,7 @@ todo_wine {
winetest_pop_context(); } - todo_wine ok(hr == MF_E_NO_MORE_TYPES, "GetInputAvailableType returned %#lx\n", hr); - todo_wine ok(i == 22 || i == 30 || broken(i == 26) /* w1064v1507 */, "%lu input media types\n", i);
/* check required input media type attributes */ @@ -8980,25 +8951,20 @@ todo_wine { hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, 1); hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, 2); for (i = 2; i < ARRAY_SIZE(input_type_desc) - 1; ++i) { hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetInputType returned %#lx.\n", hr); init_media_type(media_type, input_type_desc, i + 1); } hr = IMFTransform_SetInputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); - todo_wine ok(ret == 1, "Release returned %lu\n", ret);
/* check required output media type attributes */ @@ -9006,51 +8972,36 @@ todo_wine { hr = MFCreateMediaType(&media_type); ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == E_INVALIDARG, "SetOutputType returned %#lx.\n", hr); init_media_type(media_type, output_type_desc, 1); hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr); init_media_type(media_type, output_type_desc, 2); for (i = 2; i < ARRAY_SIZE(output_type_desc) - 1; ++i) { hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == MF_E_ATTRIBUTENOTFOUND, "SetOutputType returned %#lx.\n", hr); init_media_type(media_type, output_type_desc, i + 1); } hr = IMFTransform_SetOutputType(transform, 0, media_type, 0); - todo_wine ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); ret = IMFMediaType_Release(media_type); - todo_wine ok(ret == 1, "Release returned %lu\n", ret);
memset(&input_info, 0xcd, sizeof(input_info)); hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); - todo_wine ok(hr == S_OK, "GetInputStreamInfo returned %#lx\n", hr); - todo_wine ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); - todo_wine ok(input_info.dwFlags == 0, "got dwFlags %#lx\n", input_info.dwFlags); - todo_wine ok(input_info.cbSize == actual_width * actual_height * 3 / 2, "got cbSize %#lx\n", input_info.cbSize); - todo_wine ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); - todo_wine ok(input_info.cbAlignment == 0, "got cbAlignment %#lx\n", input_info.cbAlignment);
memset(&output_info, 0xcd, sizeof(output_info)); hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); - todo_wine ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); - todo_wine ok(output_info.dwFlags == 0, "got dwFlags %#lx\n", output_info.dwFlags); - todo_wine ok(output_info.cbSize == actual_width * actual_height * 4, "got cbSize %#lx\n", output_info.cbSize); - todo_wine ok(output_info.cbAlignment == 0, "got cbAlignment %#lx\n", output_info.cbAlignment);
resource = FindResourceW(NULL, L"nv12frame.bin", (const WCHAR *)RT_RCDATA); @@ -9065,13 +9016,10 @@ todo_wine { hr = IMFSample_SetSampleDuration(sample, 10000000); ok(hr == S_OK, "SetSampleDuration returned %#lx\n", hr); hr = IMFTransform_ProcessInput(transform, 0, sample, 0); - todo_wine ok(hr == S_OK, "ProcessInput returned %#lx\n", hr); hr = IMFTransform_ProcessInput(transform, 0, sample, 0); - todo_wine ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#lx\n", hr); hr = IMFTransform_ProcessMessage(transform, MFT_MESSAGE_COMMAND_DRAIN, 0); - todo_wine ok(hr == S_OK, "ProcessMessage returned %#lx\n", hr); ret = IMFSample_Release(sample); ok(ret <= 1, "Release returned %ld\n", ret); @@ -9080,7 +9028,6 @@ todo_wine { ok(resource != 0, "FindResourceW failed, error %lu\n", GetLastError()); rgb32_data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); rgb32_data_len = SizeofResource(GetModuleHandleW(NULL), resource); - todo_wine ok(rgb32_data_len == output_info.cbSize, "got length %lu\n", rgb32_data_len);
/* and generate a new one as well in a temporary directory */ @@ -9094,11 +9041,9 @@ todo_wine { memset(&output, 0, sizeof(output)); output.pSample = sample; hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); - todo_wine ok(hr == S_OK || broken(hr == MF_E_SHUTDOWN) /* w8 */, "ProcessOutput returned %#lx\n", hr); if (hr != S_OK) { - todo_wine win_skip("ProcessOutput returned MF_E_SHUTDOWN, skipping tests.\n"); CloseHandle(output_file); goto skip_output; @@ -9127,10 +9072,11 @@ todo_wine { IMFMediaBuffer_Release(buffer);
/* w1064v1809 ignores MF_MT_MINIMUM_DISPLAY_APERTURE and resizes the frame */ + todo_wine ok(tmp == 0xcd || broken(tmp == 0x00), "got %#x\n", tmp); if (tmp == 0x00) win_skip("Frame got resized, skipping output comparison\n"); - else + else if (tmp == 0xcd) /* Wine doesn't flip the frame, yet */ check_sample_rgb32(sample, rgb32_data, output_file); rgb32_data_len -= output_info.cbSize; rgb32_data += output_info.cbSize; diff --git a/dlls/winegstreamer/Makefile.in b/dlls/winegstreamer/Makefile.in index 1cdad72cbcb..791b9bfd547 100644 --- a/dlls/winegstreamer/Makefile.in +++ b/dlls/winegstreamer/Makefile.in @@ -15,6 +15,7 @@ C_SRCS = \ quartz_parser.c \ quartz_transform.c \ resampler.c \ + video_processor.c \ wg_allocator.c \ wg_format.c \ wg_parser.c \ diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 7b8f05dc09c..11e0a0ceca7 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -141,6 +141,7 @@ HRESULT wg_transform_read_quartz(struct wg_transform *transform, struct wg_sampl HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj);
HRESULT h264_decoder_create(REFIID riid, void **ret); +HRESULT video_processor_create(REFIID riid, void **ret);
struct wm_stream { diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c index 9c27c5c7d60..55f9ae6323d 100644 --- a/dlls/winegstreamer/mfplat.c +++ b/dlls/winegstreamer/mfplat.c @@ -37,269 +37,6 @@ DEFINE_GUID(DMOVideoFormat_RGB565,D3DFMT_R5G6B5,0x524f,0x11ce,0x9f,0x53,0x00,0x2 DEFINE_GUID(DMOVideoFormat_RGB555,D3DFMT_X1R5G5B5,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70); DEFINE_GUID(DMOVideoFormat_RGB8,D3DFMT_P8,0x524f,0x11ce,0x9f,0x53,0x00,0x20,0xaf,0x0b,0xa7,0x70);
-struct video_processor -{ - IMFTransform IMFTransform_iface; - LONG refcount; - IMFAttributes *attributes; - IMFAttributes *output_attributes; -}; - -static struct video_processor *impl_video_processor_from_IMFTransform(IMFTransform *iface) -{ - return CONTAINING_RECORD(iface, struct video_processor, IMFTransform_iface); -} - -static HRESULT WINAPI video_processor_QueryInterface(IMFTransform *iface, REFIID riid, void **obj) -{ - TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj); - - if (IsEqualIID(riid, &IID_IMFTransform) || - IsEqualIID(riid, &IID_IUnknown)) - { - *obj = iface; - IMFTransform_AddRef(iface); - return S_OK; - } - - WARN("Unsupported %s.\n", debugstr_guid(riid)); - *obj = NULL; - return E_NOINTERFACE; -} - -static ULONG WINAPI video_processor_AddRef(IMFTransform *iface) -{ - struct video_processor *transform = impl_video_processor_from_IMFTransform(iface); - ULONG refcount = InterlockedIncrement(&transform->refcount); - - TRACE("%p, refcount %lu.\n", iface, refcount); - - return refcount; -} - -static ULONG WINAPI video_processor_Release(IMFTransform *iface) -{ - struct video_processor *transform = impl_video_processor_from_IMFTransform(iface); - ULONG refcount = InterlockedDecrement(&transform->refcount); - - TRACE("%p, refcount %lu.\n", iface, refcount); - - if (!refcount) - { - if (transform->attributes) - IMFAttributes_Release(transform->attributes); - if (transform->output_attributes) - IMFAttributes_Release(transform->output_attributes); - free(transform); - } - - return refcount; -} - -static HRESULT WINAPI video_processor_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, DWORD *input_maximum, - DWORD *output_minimum, DWORD *output_maximum) -{ - TRACE("%p, %p, %p, %p, %p.\n", iface, input_minimum, input_maximum, output_minimum, output_maximum); - - *input_minimum = *input_maximum = *output_minimum = *output_maximum = 1; - - return S_OK; -} - -static HRESULT WINAPI video_processor_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs) -{ - TRACE("%p, %p, %p.\n", iface, inputs, outputs); - - *inputs = *outputs = 1; - - return S_OK; -} - -static HRESULT WINAPI video_processor_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs, - DWORD output_size, DWORD *outputs) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetAttributes(IMFTransform *iface, IMFAttributes **attributes) -{ - struct video_processor *transform = impl_video_processor_from_IMFTransform(iface); - - TRACE("%p, %p.\n", iface, attributes); - - *attributes = transform->attributes; - IMFAttributes_AddRef(*attributes); - - return S_OK; -} - -static HRESULT WINAPI video_processor_GetInputStreamAttributes(IMFTransform *iface, DWORD id, - IMFAttributes **attributes) -{ - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, - IMFAttributes **attributes) -{ - struct video_processor *transform = impl_video_processor_from_IMFTransform(iface); - - TRACE("%p, %lu, %p.\n", iface, id, attributes); - - *attributes = transform->output_attributes; - IMFAttributes_AddRef(*attributes); - - return S_OK; -} - -static HRESULT WINAPI video_processor_DeleteInputStream(IMFTransform *iface, DWORD id) -{ - TRACE("%p, %lu.\n", iface, id); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids) -{ - TRACE("%p, %lu, %p.\n", iface, streams, ids); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index, - IMFMediaType **type) -{ - FIXME("%p, %lu, %lu, %p.\n", iface, id, index, type); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index, - IMFMediaType **type) -{ - FIXME("%p, %lu, %lu, %p.\n", iface, id, index, type); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) -{ - FIXME("%p, %lu, %p, %#lx.\n", iface, id, type, flags); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) -{ - FIXME("%p, %lu, %p, %#lx.\n", iface, id, type, flags); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) -{ - FIXME("%p, %lu, %p.\n", iface, id, type); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) -{ - FIXME("%p, %lu, %p.\n", iface, id, type); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags) -{ - FIXME("%p, %lu, %p.\n", iface, id, flags); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_GetOutputStatus(IMFTransform *iface, DWORD *flags) -{ - FIXME("%p, %p.\n", iface, flags); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper) -{ - FIXME("%p, %s, %s.\n", iface, wine_dbgstr_longlong(lower), wine_dbgstr_longlong(upper)); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event) -{ - TRACE("%p, %lu, %p.\n", iface, id, event); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param) -{ - FIXME("%p, %u, %#Ix.\n", iface, message, param); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags) -{ - FIXME("%p, %lu, %p, %#lx.\n", iface, id, sample, flags); - - return E_NOTIMPL; -} - -static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count, - MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) -{ - FIXME("%p, %#lx, %lu, %p, %p.\n", iface, flags, count, samples, status); - - return E_NOTIMPL; -} - -static const IMFTransformVtbl video_processor_vtbl = -{ - video_processor_QueryInterface, - video_processor_AddRef, - video_processor_Release, - video_processor_GetStreamLimits, - video_processor_GetStreamCount, - video_processor_GetStreamIDs, - video_processor_GetInputStreamInfo, - video_processor_GetOutputStreamInfo, - video_processor_GetAttributes, - video_processor_GetInputStreamAttributes, - video_processor_GetOutputStreamAttributes, - video_processor_DeleteInputStream, - video_processor_AddInputStreams, - video_processor_GetInputAvailableType, - video_processor_GetOutputAvailableType, - video_processor_SetInputType, - video_processor_SetOutputType, - video_processor_GetInputCurrentType, - video_processor_GetOutputCurrentType, - video_processor_GetInputStatus, - video_processor_GetOutputStatus, - video_processor_SetOutputBounds, - video_processor_ProcessEvent, - video_processor_ProcessMessage, - video_processor_ProcessInput, - video_processor_ProcessOutput, -}; - struct class_factory { IClassFactory IClassFactory_iface; @@ -376,32 +113,6 @@ static const IClassFactoryVtbl class_factory_vtbl = class_factory_LockServer, };
-static HRESULT video_processor_create(REFIID riid, void **ret) -{ - struct video_processor *object; - HRESULT hr; - - if (!(object = calloc(1, sizeof(*object)))) - return E_OUTOFMEMORY; - - object->IMFTransform_iface.lpVtbl = &video_processor_vtbl; - object->refcount = 1; - - if (FAILED(hr = MFCreateAttributes(&object->attributes, 0))) - goto failed; - - if (FAILED(hr = MFCreateAttributes(&object->output_attributes, 0))) - goto failed; - - *ret = &object->IMFTransform_iface; - return S_OK; - -failed: - - IMFTransform_Release(&object->IMFTransform_iface); - return hr; -} - static const GUID CLSID_GStreamerByteStreamHandler = {0x317df618, 0x5e5a, 0x468a, {0x9f, 0x15, 0xd8, 0x27, 0xa9, 0xa0, 0x81, 0x62}};
static const struct class_object diff --git a/dlls/winegstreamer/video_processor.c b/dlls/winegstreamer/video_processor.c new file mode 100644 index 00000000000..a271ca9231f --- /dev/null +++ b/dlls/winegstreamer/video_processor.c @@ -0,0 +1,668 @@ +/* Copyright 2022 R��mi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "gst_private.h" + +#include "mfapi.h" +#include "mferror.h" +#include "mfobjects.h" +#include "mftransform.h" +#include "wmcodecdsp.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mfplat); +WINE_DECLARE_DEBUG_CHANNEL(winediag); + +static const GUID *const input_types[] = +{ + &MFVideoFormat_IYUV, + &MFVideoFormat_YV12, + &MFVideoFormat_NV12, + &MFVideoFormat_420O, + &MFVideoFormat_UYVY, + &MFVideoFormat_YUY2, + &MEDIASUBTYPE_P208, + &MFVideoFormat_NV11, + &MFVideoFormat_AYUV, + &MFVideoFormat_ARGB32, + &MFVideoFormat_RGB32, + &MFVideoFormat_RGB24, + &MFVideoFormat_I420, + &MFVideoFormat_YVYU, + &MFVideoFormat_RGB555, + &MFVideoFormat_RGB565, + &MFVideoFormat_RGB8, + &MFVideoFormat_Y216, + &MFVideoFormat_v410, + &MFVideoFormat_Y41P, + &MFVideoFormat_Y41T, + &MFVideoFormat_Y42T, +}; +static const GUID *const output_types[] = +{ + &MFVideoFormat_YUY2, + &MFVideoFormat_IYUV, + &MFVideoFormat_I420, + &MFVideoFormat_NV12, + &MFVideoFormat_RGB24, + &MFVideoFormat_ARGB32, + &MFVideoFormat_RGB32, + &MFVideoFormat_YV12, + &MFVideoFormat_AYUV, + &MFVideoFormat_RGB555, + &MFVideoFormat_RGB565, +}; + +struct video_processor +{ + IMFTransform IMFTransform_iface; + LONG refcount; + + IMFMediaType *input_type; + IMFMediaType *output_type; + IMFAttributes *attributes; + IMFAttributes *output_attributes; + + struct wg_transform *wg_transform; + struct wg_sample_queue *wg_sample_queue; +}; + +static HRESULT try_create_wg_transform(struct video_processor *impl) +{ + struct wg_format input_format, output_format; + + if (impl->wg_transform) + wg_transform_destroy(impl->wg_transform); + impl->wg_transform = NULL; + + mf_media_type_to_wg_format(impl->input_type, &input_format); + if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + return MF_E_INVALIDMEDIATYPE; + + mf_media_type_to_wg_format(impl->output_type, &output_format); + if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + return MF_E_INVALIDMEDIATYPE; + + if (!(impl->wg_transform = wg_transform_create(&input_format, &output_format))) + return E_FAIL; + + return S_OK; +} + +static struct video_processor *impl_from_IMFTransform(IMFTransform *iface) +{ + return CONTAINING_RECORD(iface, struct video_processor, IMFTransform_iface); +} + +static HRESULT WINAPI video_processor_QueryInterface(IMFTransform *iface, REFIID iid, void **out) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IMFTransform)) + *out = &impl->IMFTransform_iface; + else + { + *out = NULL; + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*out); + return S_OK; +} + +static ULONG WINAPI video_processor_AddRef(IMFTransform *iface) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + ULONG refcount = InterlockedIncrement(&impl->refcount); + + TRACE("iface %p increasing refcount to %lu.\n", iface, refcount); + + return refcount; +} + +static ULONG WINAPI video_processor_Release(IMFTransform *iface) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + ULONG refcount = InterlockedDecrement(&impl->refcount); + + TRACE("iface %p decreasing refcount to %lu.\n", iface, refcount); + + if (!refcount) + { + if (impl->wg_transform) + wg_transform_destroy(impl->wg_transform); + if (impl->input_type) + IMFMediaType_Release(impl->input_type); + if (impl->output_type) + IMFMediaType_Release(impl->output_type); + if (impl->attributes) + IMFAttributes_Release(impl->attributes); + if (impl->output_attributes) + IMFAttributes_Release(impl->output_attributes); + + wg_sample_queue_destroy(impl->wg_sample_queue); + free(impl); + } + + return refcount; +} + +static HRESULT WINAPI video_processor_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, + DWORD *input_maximum, DWORD *output_minimum, DWORD *output_maximum) +{ + TRACE("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p.\n", + iface, input_minimum, input_maximum, output_minimum, output_maximum); + *input_minimum = *input_maximum = *output_minimum = *output_maximum = 1; + return S_OK; +} + +static HRESULT WINAPI video_processor_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs) +{ + TRACE("iface %p, inputs %p, outputs %p.\n", iface, inputs, outputs); + *inputs = *outputs = 1; + return S_OK; +} + +static HRESULT WINAPI video_processor_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs, + DWORD output_size, DWORD *outputs) +{ + FIXME("iface %p, input_size %lu, inputs %p, output_size %lu, outputs %p stub!\n", iface, + input_size, inputs, output_size, outputs); + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + UINT32 sample_size; + UINT64 framesize; + GUID subtype; + HRESULT hr; + + TRACE("iface %p, id %#lx, info %p.\n", iface, id, info); + + if (id) + return MF_E_INVALIDSTREAMNUMBER; + + if (impl->input_type && SUCCEEDED(hr = IMFMediaType_GetGUID(impl->input_type, &MF_MT_SUBTYPE, &subtype)) + && SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->input_type, &MF_MT_FRAME_SIZE, &framesize))) + MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size); + else + sample_size = 0; + + info->dwFlags = 0; + info->cbSize = sample_size; + info->cbAlignment = 0; + info->hnsMaxLatency = 0; + info->cbMaxLookahead = 0; + + return S_OK; +} + +static HRESULT WINAPI video_processor_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + UINT32 sample_size; + UINT64 framesize; + GUID subtype; + HRESULT hr; + + TRACE("iface %p, id %#lx, info %p.\n", iface, id, info); + + if (id) + return MF_E_INVALIDSTREAMNUMBER; + + if (impl->output_type && SUCCEEDED(hr = IMFMediaType_GetGUID(impl->output_type, &MF_MT_SUBTYPE, &subtype)) + && SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->output_type, &MF_MT_FRAME_SIZE, &framesize))) + MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size); + else + sample_size = 0; + + info->dwFlags = 0; + info->cbSize = sample_size; + info->cbAlignment = 0; + + return S_OK; +} + +static HRESULT WINAPI video_processor_GetAttributes(IMFTransform *iface, IMFAttributes **attributes) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + + FIXME("iface %p, attributes %p stub!\n", iface, attributes); + + IMFAttributes_AddRef((*attributes = impl->attributes)); + return S_OK; +} + +static HRESULT WINAPI video_processor_GetInputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) +{ + FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes); + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + + FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes); + + IMFAttributes_AddRef((*attributes = impl->output_attributes)); + return S_OK; +} + +static HRESULT WINAPI video_processor_DeleteInputStream(IMFTransform *iface, DWORD id) +{ + FIXME("iface %p, id %#lx stub!\n", iface, id); + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids) +{ + FIXME("iface %p, streams %lu, ids %p stub!\n", iface, streams, ids); + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index, + IMFMediaType **type) +{ + IMFMediaType *media_type; + const GUID *subtype; + HRESULT hr; + + TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type); + + *type = NULL; + + if (index >= ARRAY_SIZE(input_types)) + return MF_E_NO_MORE_TYPES; + subtype = input_types[index]; + + if (FAILED(hr = MFCreateMediaType(&media_type))) + return hr; + + if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video))) + goto done; + if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, subtype))) + goto done; + + IMFMediaType_AddRef((*type = media_type)); + +done: + IMFMediaType_Release(media_type); + return hr; +} + +static HRESULT WINAPI video_processor_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index, + IMFMediaType **type) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + IMFMediaType *media_type; + UINT64 frame_size; + GUID subtype; + HRESULT hr; + + TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type); + + *type = NULL; + + if (!impl->input_type) + return MF_E_NO_MORE_TYPES; + + if (FAILED(hr = IMFMediaType_GetGUID(impl->input_type, &MF_MT_SUBTYPE, &subtype)) + || FAILED(hr = IMFMediaType_GetUINT64(impl->input_type, &MF_MT_FRAME_SIZE, &frame_size))) + return hr; + + if (index > ARRAY_SIZE(output_types)) + return MF_E_NO_MORE_TYPES; + if (index > 0) + subtype = *output_types[index - 1]; + + if (FAILED(hr = MFCreateMediaType(&media_type))) + return hr; + + if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video))) + goto done; + if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &subtype))) + goto done; + if (FAILED(hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, frame_size))) + goto done; + + IMFMediaType_AddRef((*type = media_type)); + +done: + IMFMediaType_Release(media_type); + return hr; +} + +static HRESULT WINAPI video_processor_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + GUID major, subtype; + UINT64 frame_size; + HRESULT hr; + ULONG i; + + TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags); + + if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) + || !IsEqualGUID(&major, &MFMediaType_Video)) + return E_INVALIDARG; + if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(hr = IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &frame_size))) + return hr; + + for (i = 0; i < ARRAY_SIZE(input_types); ++i) + if (IsEqualGUID(&subtype, input_types[i])) + break; + if (i == ARRAY_SIZE(input_types)) + return MF_E_INVALIDMEDIATYPE; + + if (impl->input_type) + IMFMediaType_Release(impl->input_type); + IMFMediaType_AddRef((impl->input_type = type)); + + if (impl->output_type && FAILED(hr = try_create_wg_transform(impl))) + { + IMFMediaType_Release(impl->input_type); + impl->input_type = NULL; + } + + return hr; +} + +static HRESULT WINAPI video_processor_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + GUID major, subtype; + UINT64 frame_size; + HRESULT hr; + ULONG i; + + TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags); + + if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) + || !IsEqualGUID(&major, &MFMediaType_Video)) + return E_INVALIDARG; + if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) + return MF_E_INVALIDMEDIATYPE; + if (FAILED(hr = IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &frame_size))) + return hr; + + for (i = 0; i < ARRAY_SIZE(output_types); ++i) + if (IsEqualGUID(&subtype, output_types[i])) + break; + if (i == ARRAY_SIZE(output_types)) + return MF_E_INVALIDMEDIATYPE; + + if (impl->output_type) + IMFMediaType_Release(impl->output_type); + IMFMediaType_AddRef((impl->output_type = type)); + + if (impl->input_type && FAILED(hr = try_create_wg_transform(impl))) + { + IMFMediaType_Release(impl->output_type); + impl->output_type = NULL; + } + + return hr; +} + +static HRESULT WINAPI video_processor_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + HRESULT hr; + + TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); + + if (id != 0) + return MF_E_INVALIDSTREAMNUMBER; + + if (!impl->input_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = MFCreateMediaType(type))) + return hr; + + if (FAILED(hr = IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)*type))) + IMFMediaType_Release(*type); + + return hr; +} + +static HRESULT WINAPI video_processor_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + HRESULT hr; + + TRACE("iface %p, id %#lx, type %p.\n", iface, id, type); + + if (id != 0) + return MF_E_INVALIDSTREAMNUMBER; + + if (!impl->output_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = MFCreateMediaType(type))) + return hr; + + if (FAILED(hr = IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)*type))) + IMFMediaType_Release(*type); + + return hr; +} + +static HRESULT WINAPI video_processor_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + + FIXME("iface %p, id %#lx, flags %p stub!\n", iface, id, flags); + + if (!impl->input_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + *flags = MFT_INPUT_STATUS_ACCEPT_DATA; + return S_OK; +} + +static HRESULT WINAPI video_processor_GetOutputStatus(IMFTransform *iface, DWORD *flags) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + + FIXME("iface %p, flags %p stub!\n", iface, flags); + + if (!impl->output_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper) +{ + FIXME("iface %p, lower %I64d, upper %I64d stub!\n", iface, lower, upper); + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event) +{ + FIXME("iface %p, id %#lx, event %p stub!\n", iface, id, event); + return E_NOTIMPL; +} + +static HRESULT WINAPI video_processor_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param) +{ + FIXME("iface %p, message %#x, param %#Ix stub!\n", iface, message, param); + return S_OK; +} + +static HRESULT WINAPI video_processor_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + struct wg_sample *wg_sample; + MFT_INPUT_STREAM_INFO info; + HRESULT hr; + + TRACE("iface %p, id %#lx, sample %p, flags %#lx.\n", iface, id, sample, flags); + + if (FAILED(hr = IMFTransform_GetInputStreamInfo(iface, 0, &info))) + return hr; + + if (!impl->wg_transform) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = wg_sample_create_mf(sample, &wg_sample))) + return hr; + + return wg_transform_push_mf(impl->wg_transform, wg_sample, + impl->wg_sample_queue); +} + +static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count, + MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) +{ + struct video_processor *impl = impl_from_IMFTransform(iface); + MFT_OUTPUT_STREAM_INFO info; + struct wg_sample *wg_sample; + HRESULT hr; + + TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status); + + if (count != 1) + return E_INVALIDARG; + + if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info))) + return hr; + + if (!impl->wg_transform) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + samples[0].dwStatus = 0; + if (!samples[0].pSample) return E_INVALIDARG; + + if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample))) + return hr; + + if (wg_sample->max_size < info.cbSize) + { + wg_sample_release(wg_sample); + return MF_E_BUFFERTOOSMALL; + } + + if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, wg_sample, NULL))) + wg_sample_queue_flush(impl->wg_sample_queue, false); + wg_sample_release(wg_sample); + + if (hr == MF_E_TRANSFORM_STREAM_CHANGE) + { + FIXME("Unexpected stream format change!\n"); + samples[0].dwStatus |= MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE; + } + + return hr; +} + +static const IMFTransformVtbl video_processor_vtbl = +{ + video_processor_QueryInterface, + video_processor_AddRef, + video_processor_Release, + video_processor_GetStreamLimits, + video_processor_GetStreamCount, + video_processor_GetStreamIDs, + video_processor_GetInputStreamInfo, + video_processor_GetOutputStreamInfo, + video_processor_GetAttributes, + video_processor_GetInputStreamAttributes, + video_processor_GetOutputStreamAttributes, + video_processor_DeleteInputStream, + video_processor_AddInputStreams, + video_processor_GetInputAvailableType, + video_processor_GetOutputAvailableType, + video_processor_SetInputType, + video_processor_SetOutputType, + video_processor_GetInputCurrentType, + video_processor_GetOutputCurrentType, + video_processor_GetInputStatus, + video_processor_GetOutputStatus, + video_processor_SetOutputBounds, + video_processor_ProcessEvent, + video_processor_ProcessMessage, + video_processor_ProcessInput, + video_processor_ProcessOutput, +}; + +HRESULT video_processor_create(REFIID riid, void **ret) +{ + static const struct wg_format input_format = + { + .major_type = WG_MAJOR_TYPE_VIDEO, + .u.video = + { + .format = WG_VIDEO_FORMAT_I420, + .width = 1920, + .height = 1080, + }, + }; + static const struct wg_format output_format = + { + .major_type = WG_MAJOR_TYPE_VIDEO, + .u.video = + { + .format = WG_VIDEO_FORMAT_NV12, + .width = 1920, + .height = 1080, + }, + }; + struct wg_transform *transform; + struct video_processor *impl; + HRESULT hr; + + TRACE("riid %s, ret %p.\n", debugstr_guid(riid), ret); + + if (!(transform = wg_transform_create(&input_format, &output_format))) + { + ERR_(winediag)("GStreamer doesn't support video conversion, please install appropriate plugins.\n"); + return E_FAIL; + } + wg_transform_destroy(transform); + + if (!(impl = calloc(1, sizeof(*impl)))) + return E_OUTOFMEMORY; + + if (FAILED(hr = MFCreateAttributes(&impl->attributes, 0))) + goto failed; + if (FAILED(hr = MFCreateAttributes(&impl->output_attributes, 0))) + goto failed; + if (FAILED(hr = wg_sample_queue_create(&impl->wg_sample_queue))) + goto failed; + + impl->IMFTransform_iface.lpVtbl = &video_processor_vtbl; + impl->refcount = 1; + + *ret = &impl->IMFTransform_iface; + TRACE("Created %p\n", *ret); + return S_OK; + +failed: + free(impl); + return hr; +}