From: Ziqing Hui zhui@codeweavers.com
--- dlls/mf/tests/transform.c | 145 +++++++++++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index f1d7ffbc071..8e3827409e1 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -55,6 +55,105 @@ DEFINE_GUID(MFVideoFormat_WMV_Unknown,0x7ce12ca9,0xbfbf,0x43d9,0x9d,0x00,0x82,0x
DEFINE_GUID(mft_output_sample_incomplete,0xffffff,0xffff,0xffff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff);
+struct buffer_impl +{ + IMediaBuffer IMediaBuffer_iface; + LONG refcount; + BYTE *data; + DWORD length; + DWORD max_length; +}; + +static inline struct buffer_impl *impl_from_IMediaBuffer(IMediaBuffer *iface) +{ + return CONTAINING_RECORD(iface, struct buffer_impl, IMediaBuffer_iface); +} + +static HRESULT WINAPI buffer_impl_QueryInterface(IMediaBuffer *iface, REFIID iid, void **obj) +{ + if (IsEqualIID(iid, &IID_IMediaBuffer) + || IsEqualIID(iid, &IID_IUnknown)) + { + *obj = iface; + return S_OK; + } + return E_NOINTERFACE; +} + +static ULONG WINAPI buffer_impl_AddRef(IMediaBuffer *iface) +{ + struct buffer_impl *buffer = impl_from_IMediaBuffer(iface); + return InterlockedIncrement(&buffer->refcount); +} + +static ULONG WINAPI buffer_impl_Release(IMediaBuffer *iface) +{ + struct buffer_impl *buffer = impl_from_IMediaBuffer(iface); + ULONG ref = InterlockedDecrement(&buffer->refcount); + if (!ref) + { + free(buffer->data); + free(buffer); + } + return ref; +} + +static HRESULT WINAPI buffer_impl_SetLength(IMediaBuffer *iface, DWORD length) +{ + struct buffer_impl *buffer = impl_from_IMediaBuffer(iface); + if (length > buffer->max_length) + return E_INVALIDARG; + buffer->length = length; + return S_OK; +} + +static HRESULT WINAPI buffer_impl_GetMaxLength(IMediaBuffer *iface, DWORD *max_length) +{ + struct buffer_impl *buffer = impl_from_IMediaBuffer(iface); + if (!max_length) + return E_POINTER; + *max_length = buffer->max_length; + return S_OK; +} + +static HRESULT WINAPI buffer_impl_GetBufferAndLength(IMediaBuffer *iface, BYTE **data, DWORD *length) +{ + struct buffer_impl *buffer = impl_from_IMediaBuffer(iface); + if (!data || ! length) + return E_POINTER; + *data = buffer->data; + *length = buffer->length; + return S_OK; +} + +static IMediaBufferVtbl buffer_impl_vtbl = { + buffer_impl_QueryInterface, + buffer_impl_AddRef, + buffer_impl_Release, + buffer_impl_SetLength, + buffer_impl_GetMaxLength, + buffer_impl_GetBufferAndLength, +}; + +HRESULT buffer_impl_create(DWORD max_length, struct buffer_impl **ret) +{ + struct buffer_impl *buffer; + + if (!(buffer = calloc(1, sizeof(*buffer)))) + return E_OUTOFMEMORY; + if (!(buffer->data = calloc(max_length, sizeof(*buffer->data)))) + { + free(buffer); + return E_OUTOFMEMORY; + } + buffer->IMediaBuffer_iface.lpVtbl = &buffer_impl_vtbl; + buffer->refcount = 1; + buffer->length = 0; + buffer->max_length = max_length; + *ret = buffer; + return S_OK; +} + static BOOL is_compressed_subtype(const GUID *subtype) { if (IsEqualGUID(subtype, &MEDIASUBTYPE_WMV1) @@ -332,6 +431,7 @@ static void init_dmo_media_type_video(DMO_MEDIA_TYPE *media_type, header->bmiHeader.biSize = sizeof(header->bmiHeader); header->bmiHeader.biWidth = width; header->bmiHeader.biHeight = height; + header->bmiHeader.biPlanes = 1; header->bmiHeader.biBitCount = subtype_to_bpp(subtype); header->bmiHeader.biCompression = subtype_to_compression(subtype);
@@ -1523,7 +1623,6 @@ static void check_dmo_set_output_type(IMediaObject *media_object, const GUID *su } }
- static HRESULT WINAPI test_unk_QueryInterface(IUnknown *iface, REFIID riid, void **obj) { if (IsEqualIID(riid, &IID_IUnknown)) @@ -5058,10 +5157,14 @@ static void test_wmv_decoder_media_object(void) {MFMediaType_Video, MEDIASUBTYPE_RGB555, TRUE, FALSE, 512, FORMAT_VideoInfo, NULL, 88, (BYTE *)&expected_output_info[11]}, {MFMediaType_Video, MEDIASUBTYPE_RGB8, TRUE, FALSE, 256, FORMAT_VideoInfo, NULL, 1112, (BYTE *)&expected_output_info[12]}, }; + const DWORD data_width = 96, data_height = 96; const POINT test_size[] = {{16, 16}, {96, 96}, {320, 240}}; - DWORD in_count, out_count, size, expected_size, alignment; + DWORD in_count, out_count, size, expected_size, alignment, wmv_data_length, status; + struct buffer_impl *input_media_buffer, *output_media_buffer; + DMO_OUTPUT_DATA_BUFFER output_data_buffer; DMO_MEDIA_TYPE media_type, *type; IMediaObject *media_object; + const BYTE *wmv_data; char buffer[1024]; ULONG ret, i, j; HRESULT hr; @@ -5185,6 +5288,44 @@ static void test_wmv_decoder_media_object(void) winetest_pop_context(); }
+ /* Test ProcessInput. */ + load_resource(L"wmvencdata.bin", &wmv_data, &wmv_data_length); + wmv_data_length = *((DWORD *)wmv_data); + wmv_data += sizeof(DWORD); + hr = buffer_impl_create(wmv_data_length, &input_media_buffer); + ok(hr == S_OK, "Failed to create input media buffer.\n"); + memcpy(input_media_buffer->data, wmv_data, wmv_data_length); + input_media_buffer->length = wmv_data_length; + + init_dmo_media_type_video(type, &MEDIASUBTYPE_WMV1, data_width, data_height); + hr = IMediaObject_SetInputType(media_object, 0, type, 0); + ok(hr == S_OK, "SetInputType returned %#lx.\n", hr); + init_dmo_media_type_video(type, &MEDIASUBTYPE_NV12, data_width, data_height); + hr = IMediaObject_SetOutputType(media_object, 0, type, 0); + ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr); + + hr = IMediaObject_ProcessInput(media_object, 0, &input_media_buffer->IMediaBuffer_iface, 0, 0, 0); + todo_wine + ok(hr == S_OK, "ProcessInput returned %#lx.\n", hr); + + /* Test ProcessOutput. */ + hr = IMediaObject_GetOutputSizeInfo(media_object, 0, &size, &alignment); + ok(hr == S_OK, "GetOutputSizeInfo returned %#lx.\n", hr); + hr = buffer_impl_create(size, &output_media_buffer); + ok(hr == S_OK, "Failed to create output media buffer.\n"); + output_data_buffer.pBuffer = &output_media_buffer->IMediaBuffer_iface; + output_data_buffer.dwStatus = 0xdeadbeef; + output_data_buffer.rtTimestamp = 0xdeadbeef; + output_data_buffer.rtTimelength = 0xdeadbeef; + hr = IMediaObject_ProcessOutput(media_object, 0, 1, &output_data_buffer, &status); + todo_wine + ok(hr == S_OK, "ProcessOutput returned %#lx.\n", hr); + + ret = IMediaBuffer_Release(&output_media_buffer->IMediaBuffer_iface); + ok(ret == 0, "Release returned %lu\n", ret); + ret = IMediaBuffer_Release(&input_media_buffer->IMediaBuffer_iface); + ok(ret == 0, "Release returned %lu\n", ret); + ret = IMediaObject_Release(media_object); ok(ret == 0, "Release returned %lu\n", ret); CoUninitialize();