From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/transform.c | 24 ------------- dlls/winegstreamer/wmv_decoder.c | 58 ++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 26 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index b29b050bb5f..3fd74c23222 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -4659,10 +4659,8 @@ static void test_wmv_decoder_media_object(void) /* Test setting the type. */ init_dmo_media_type_video(input_type, subtype, 96, 96); hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr); hr = IMediaObject_SetInputType(media_object, 0, input_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr); header->dwBitRate = 0xdeadbeef; header->dwBitErrorRate = 0xdeadbeef; @@ -4673,113 +4671,92 @@ static void test_wmv_decoder_media_object(void) header->bmiHeader.biXPelsPerMeter = 0xdead; header->bmiHeader.biYPelsPerMeter = 0xdead; hr = IMediaObject_SetInputType(media_object, 0, input_type, 0); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test invalid major type. */ init_dmo_media_type_video(input_type, subtype, 96, 96); input_type->majortype = MFMediaType_Default; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test invalid subtype. */ init_dmo_media_type_video(input_type, &MEDIASUBTYPE_None, 96, 96); hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test invalid format type. */ init_dmo_media_type_video(input_type, subtype, 96, 96); input_type->formattype = FORMAT_None; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test invalid format size. */ init_dmo_media_type_video(input_type, subtype, 96, 96); input_type->cbFormat = 1; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test NULL format pointer. */ init_dmo_media_type_video(input_type, subtype, 96, 96); input_type->pbFormat = NULL; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test video header struct size. */ init_dmo_media_type_video(input_type, subtype, 96, 96); header->bmiHeader.biSize = 0; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biSize = 1; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biSize = 0xdeadbeef; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test width. */ init_dmo_media_type_video(input_type, subtype, 96, 96); header->bmiHeader.biWidth = 0; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biWidth = -1; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biWidth = 4096 + 1; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biWidth = 4096; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test height. */ init_dmo_media_type_video(input_type, subtype, 96, 96); header->bmiHeader.biHeight = 0; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biHeight = 4096 + 1; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biHeight = 4096; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biHeight = -4096; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr);
/* Test compression. */ init_dmo_media_type_video(input_type, subtype, 96, 96); header->bmiHeader.biCompression = 0; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biCompression = 1; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biCompression = 2; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr); header->bmiHeader.biCompression = 0xdeadbeef; hr = IMediaObject_SetInputType(media_object, 0, input_type, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == S_OK, "SetInputType returned unexpected hr %#lx.\n", hr);
winetest_pop_context(); @@ -4801,7 +4778,6 @@ static void test_wmv_decoder_media_object(void) type = NULL;
hr = IMediaObject_SetInputType(media_object, test->stream_index, type, test->flags); - todo_wine ok(hr == test->hr, "SetInputType returned unexpected hr %#lx, expected %#lx.\n", hr, test->hr);
winetest_pop_context(); diff --git a/dlls/winegstreamer/wmv_decoder.c b/dlls/winegstreamer/wmv_decoder.c index 96a2839660a..c42795b2e37 100644 --- a/dlls/winegstreamer/wmv_decoder.c +++ b/dlls/winegstreamer/wmv_decoder.c @@ -55,6 +55,9 @@ struct wmv_decoder IPropertyStore IPropertyStore_iface; IUnknown *outer; LONG refcount; + + DMO_MEDIA_TYPE input_type; + VIDEOINFOHEADER input_info; };
static inline struct wmv_decoder *impl_from_IUnknown(IUnknown *iface) @@ -392,8 +395,59 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index, const DMO_MEDIA_TYPE *type, DWORD flags) { - FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface, index, type, flags); - return E_NOTIMPL; + struct wmv_decoder *decoder = impl_from_IMediaObject(iface); + VIDEOINFOHEADER *info; + unsigned int i; + + TRACE("iface %p, index %lu, type %p, flags %#lx.\n", iface, index, type, flags); + + if (index > 0) + return DMO_E_INVALIDSTREAMINDEX; + + if (!type) + { + if (flags & DMO_SET_TYPEF_CLEAR) + { + memset(&decoder->input_type, 0, sizeof(decoder->input_type)); + memset(&decoder->input_info, 0, sizeof(decoder->input_info)); + return S_OK; + } + return DMO_E_TYPE_NOT_ACCEPTED; + } + + if (!IsEqualGUID(&type->majortype, &MEDIATYPE_Video) + || !IsEqualGUID(&type->formattype, &FORMAT_VideoInfo) + || !type->pbFormat + || type->cbFormat != sizeof(*info)) + return DMO_E_TYPE_NOT_ACCEPTED; + + for (i = 0; i < ARRAY_SIZE(wmv_decoder_input_types); ++i) + { + if (IsEqualGUID(&type->subtype, wmv_decoder_input_types[i])) + break; + } + if (i == ARRAY_SIZE(wmv_decoder_input_types)) + return DMO_E_TYPE_NOT_ACCEPTED; + + info = (VIDEOINFOHEADER *)type->pbFormat; + if (info->bmiHeader.biSize != sizeof(info->bmiHeader) + || !info->bmiHeader.biWidth + || !info->bmiHeader.biHeight + || !info->bmiHeader.biCompression + || info->bmiHeader.biWidth > 4096 + || info->bmiHeader.biHeight > 4096 + || info->bmiHeader.biWidth < 0 + || info->bmiHeader.biHeight < -4096) + return DMO_E_TYPE_NOT_ACCEPTED; + + if (!(flags & DMO_SET_TYPEF_TEST_ONLY)) + { + memcpy(&decoder->input_type, type, sizeof(*type)); + decoder->input_type.pbFormat = (BYTE *)&decoder->input_info; + memcpy(&decoder->input_info, type, sizeof(*info)); + } + + return S_OK; }
static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD index,