From: Rémi Bernon rbernon@codeweavers.com
--- dlls/mf/tests/mf.c | 267 ++++++++++++++++++++++++++- dlls/mf/tests/mf_test.h | 43 ++++- dlls/mf/tests/nv12frame-grabber.bmp | Bin 0 -> 22582 bytes dlls/mf/tests/resource.rc | 17 ++ dlls/mf/tests/rgb32frame-grabber.bmp | Bin 0 -> 16438 bytes dlls/mf/tests/test.mp4 | Bin 0 -> 3983 bytes dlls/mf/tests/transform.c | 100 ++++------ 7 files changed, 361 insertions(+), 66 deletions(-) create mode 100644 dlls/mf/tests/nv12frame-grabber.bmp create mode 100644 dlls/mf/tests/rgb32frame-grabber.bmp create mode 100644 dlls/mf/tests/test.mp4
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 28e62b858d8..c9f8fe96f8b 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -102,6 +102,36 @@ static HWND create_window(void) 0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL); }
+static IMFSample *create_sample(const BYTE *data, ULONG size) +{ + IMFMediaBuffer *media_buffer; + IMFSample *sample; + DWORD length; + BYTE *buffer; + HRESULT hr; + ULONG ret; + + hr = MFCreateSample(&sample); + ok(hr == S_OK, "MFCreateSample returned %#lx\n", hr); + hr = MFCreateMemoryBuffer(size, &media_buffer); + ok(hr == S_OK, "MFCreateMemoryBuffer returned %#lx\n", hr); + hr = IMFMediaBuffer_Lock(media_buffer, &buffer, NULL, &length); + ok(hr == S_OK, "Lock returned %#lx\n", hr); + ok(length == 0, "got length %lu\n", length); + if (!data) memset(buffer, 0xcd, size); + else memcpy(buffer, data, size); + hr = IMFMediaBuffer_Unlock(media_buffer); + ok(hr == S_OK, "Unlock returned %#lx\n", hr); + hr = IMFMediaBuffer_SetCurrentLength(media_buffer, data ? size : 0); + ok(hr == S_OK, "SetCurrentLength returned %#lx\n", hr); + hr = IMFSample_AddBuffer(sample, media_buffer); + ok(hr == S_OK, "AddBuffer returned %#lx\n", hr); + ret = IMFMediaBuffer_Release(media_buffer); + ok(ret == 1, "Release returned %lu\n", ret); + + return sample; +} + #define check_handler_required_attributes(a, b) check_handler_required_attributes_(__LINE__, a, b) static void check_handler_required_attributes_(int line, IMFMediaTypeHandler *handler, const struct attribute_desc *attributes) { @@ -1879,6 +1909,51 @@ static HRESULT wait_media_event_(int line, IMFMediaSession *session, IMFAsyncCal return status; }
+static IMFMediaSource *create_media_source(const WCHAR *name, const WCHAR *mime) +{ + IMFSourceResolver *resolver; + IMFAttributes *attributes; + const BYTE *resource_data; + MF_OBJECT_TYPE obj_type; + IMFMediaSource *source; + IMFByteStream *stream; + ULONG resource_len; + HRSRC resource; + HRESULT hr; + + resource = FindResourceW(NULL, name, (const WCHAR *)RT_RCDATA); + ok(resource != 0, "FindResourceW %s failed, error %lu\n", debugstr_w(name), GetLastError()); + resource_data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); + resource_len = SizeofResource(GetModuleHandleW(NULL), resource); + + hr = MFCreateTempFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_DELETE_IF_EXIST, MF_FILEFLAGS_NONE, &stream); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFByteStream_Write(stream, resource_data, resource_len, &resource_len); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFByteStream_SetCurrentPosition(stream, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFByteStream_QueryInterface(stream, &IID_IMFAttributes, (void **)&attributes); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFAttributes_SetString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, mime); + ok(hr == S_OK, "Failed to set string value, hr %#lx.\n", hr); + IMFAttributes_Release(attributes); + + hr = MFCreateSourceResolver(&resolver); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL, MF_RESOLUTION_MEDIASOURCE, NULL, + &obj_type, (IUnknown **)&source); + ok(hr == S_OK || broken(hr == MF_E_UNSUPPORTED_BYTESTREAM_TYPE), "Unexpected hr %#lx.\n", hr); + IMFSourceResolver_Release(resolver); + IMFByteStream_Release(stream); + + if (FAILED(hr)) + return NULL; + + ok(obj_type == MF_OBJECT_MEDIASOURCE, "got %d\n", obj_type); + return source; +} + static void test_media_session_events(void) { static const media_type_desc audio_float_44100 = @@ -2547,6 +2622,10 @@ struct test_grabber_callback { IMFSampleGrabberSinkCallback IMFSampleGrabberSinkCallback_iface; LONG refcount; + + IMFCollection *samples; + HANDLE ready_event; + HANDLE done_event; };
static struct test_grabber_callback *impl_from_IMFSampleGrabberSinkCallback(IMFSampleGrabberSinkCallback *iface) @@ -2581,7 +2660,14 @@ static ULONG WINAPI test_grabber_callback_Release(IMFSampleGrabberSinkCallback * ULONG refcount = InterlockedDecrement(&grabber->refcount);
if (!refcount) + { + IMFCollection_Release(grabber->samples); + if (grabber->ready_event) + CloseHandle(grabber->ready_event); + if (grabber->done_event) + CloseHandle(grabber->done_event); free(grabber); + }
return refcount; } @@ -2620,7 +2706,30 @@ static HRESULT WINAPI test_grabber_callback_OnSetPresentationClock(IMFSampleGrab static HRESULT WINAPI test_grabber_callback_OnProcessSample(IMFSampleGrabberSinkCallback *iface, REFGUID major_type, DWORD sample_flags, LONGLONG sample_time, LONGLONG sample_duration, const BYTE *buffer, DWORD sample_size) { - return E_NOTIMPL; + struct test_grabber_callback *grabber = CONTAINING_RECORD(iface, struct test_grabber_callback, IMFSampleGrabberSinkCallback_iface); + IMFSample *sample; + HRESULT hr; + DWORD res; + + if (!grabber->ready_event) + return E_NOTIMPL; + + sample = create_sample(buffer, sample_size); + hr = IMFSample_SetSampleFlags(sample, sample_flags); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + /* FIXME: sample time is inconsistent across windows versions, ignore it */ + hr = IMFSample_SetSampleTime(sample, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFSample_SetSampleDuration(sample, sample_duration); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFCollection_AddElement(grabber->samples, (IUnknown *)sample); + IMFSample_Release(sample); + + SetEvent(grabber->ready_event); + res = WaitForSingleObject(grabber->done_event, 1000); + ok(!res, "WaitForSingleObject returned %#lx", res); + + return S_OK; }
static HRESULT WINAPI test_grabber_callback_OnShutdown(IMFSampleGrabberSinkCallback *iface) @@ -2646,12 +2755,15 @@ static const IMFSampleGrabberSinkCallbackVtbl test_grabber_callback_vtbl = static IMFSampleGrabberSinkCallback *create_test_grabber_callback(void) { struct test_grabber_callback *grabber; + HRESULT hr;
if (!(grabber = calloc(1, sizeof(*grabber)))) return NULL;
grabber->IMFSampleGrabberSinkCallback_iface.lpVtbl = &test_grabber_callback_vtbl; grabber->refcount = 1; + hr = MFCreateCollection(&grabber->samples); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
return &grabber->IMFSampleGrabberSinkCallback_iface; } @@ -4538,6 +4650,157 @@ static void test_sample_grabber_is_mediatype_supported(void) IMFSampleGrabberSinkCallback_Release(grabber_callback); }
+static void test_sample_grabber_orientation(GUID subtype) +{ + media_type_desc video_rgb32_desc = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + ATTR_GUID(MF_MT_SUBTYPE, subtype), + }; + + struct test_grabber_callback *grabber_callback; + IMFTopologyNode *src_node, *sink_node; + IMFPresentationDescriptor *pd; + IMFAsyncCallback *callback; + IMFActivate *sink_activate; + IMFMediaType *output_type; + IMFMediaSession *session; + IMFStreamDescriptor *sd; + IMFMediaSource *source; + IMFTopology *topology; + PROPVARIANT propvar; + BOOL selected; + HRESULT hr; + DWORD res; + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr); + + if (!(source = create_media_source(L"test.mp4", L"video/mp4"))) + { + win_skip("MP4 media source is not supported, skipping tests.\n"); + return; + } + + callback = create_test_callback(); + grabber_callback = impl_from_IMFSampleGrabberSinkCallback(create_test_grabber_callback()); + + grabber_callback->ready_event = CreateEventW(NULL, FALSE, FALSE, NULL); + ok(!!grabber_callback->ready_event, "CreateEventW failed, error %lu\n", GetLastError()); + grabber_callback->done_event = CreateEventW(NULL, FALSE, FALSE, NULL); + ok(!!grabber_callback->done_event, "CreateEventW failed, error %lu\n", GetLastError()); + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Startup failure, hr %#lx.\n", hr); + + hr = MFCreateMediaSession(NULL, &session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = MFCreateTopologyNode(MF_TOPOLOGY_OUTPUT_NODE, &sink_node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = MFCreateTopologyNode(MF_TOPOLOGY_SOURCESTREAM_NODE, &src_node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = MFCreateTopology(&topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFTopology_AddNode(topology, sink_node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFTopology_AddNode(topology, src_node); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFTopologyNode_ConnectOutput(src_node, 0, sink_node, 0); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaSource_CreatePresentationDescriptor(source, &pd); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFPresentationDescriptor_GetStreamDescriptorByIndex(pd, 0, &selected, &sd); + ok(selected, "got selected %u.\n", !!selected); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + init_source_node(source, -1, src_node, pd, sd); + IMFTopologyNode_Release(src_node); + IMFPresentationDescriptor_Release(pd); + IMFStreamDescriptor_Release(sd); + + hr = MFCreateMediaType(&output_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + init_media_type(output_type, video_rgb32_desc, -1); + hr = MFCreateSampleGrabberSinkActivate(output_type, &grabber_callback->IMFSampleGrabberSinkCallback_iface, &sink_activate); + ok(hr == S_OK, "Failed to create grabber sink, hr %#lx.\n", hr); + IMFMediaType_Release(output_type); + + hr = IMFTopologyNode_SetObject(sink_node, (IUnknown *)sink_activate); + ok(hr == S_OK, "Failed to set object, hr %#lx.\n", hr); + hr = IMFTopologyNode_SetUINT32(sink_node, &MF_TOPONODE_CONNECT_METHOD, MF_CONNECT_ALLOW_DECODER); + ok(hr == S_OK, "Failed to set connect method, hr %#lx.\n", hr); + IMFTopologyNode_Release(sink_node); + + hr = IMFTopology_SetUINT32(topology, &MF_TOPOLOGY_ENUMERATE_SOURCE_TYPES, TRUE); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaSession_SetTopology(session, 0, topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFTopology_Release(topology); + + propvar.vt = VT_EMPTY; + hr = IMFMediaSession_Start(session, &GUID_NULL, &propvar); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + res = WaitForSingleObject(grabber_callback->ready_event, 5000); + ok(!res, "WaitForSingleObject returned %#lx\n", res); + CloseHandle(grabber_callback->ready_event); + grabber_callback->ready_event = NULL; + + if (IsEqualGUID(&subtype, &MFVideoFormat_RGB32)) + { + const struct buffer_desc buffer_desc_rgb32 = + { + .length = 64 * 64 * 4, .compare = compare_rgb32, .dump = dump_rgb32, .rect = {.right = 64, .bottom = 64}, + }; + const struct sample_desc sample_desc_rgb32 = + { + .sample_duration = 333667, .buffer_count = 1, .buffers = &buffer_desc_rgb32, + }; + check_mf_sample_collection(grabber_callback->samples, &sample_desc_rgb32, L"rgb32frame-grabber.bmp"); + } + else if (IsEqualGUID(&subtype, &MFVideoFormat_NV12)) + { + const struct buffer_desc buffer_desc_nv12 = + { + .length = 64 * 64 * 3 / 2, .compare = compare_nv12, .dump = dump_nv12, .rect = {.right = 64, .bottom = 64}, + }; + const struct sample_desc sample_desc_nv12 = + { + .sample_duration = 333667, .buffer_count = 1, .buffers = &buffer_desc_nv12, + }; + check_mf_sample_collection(grabber_callback->samples, &sample_desc_nv12, L"nv12frame-grabber.bmp"); + } + + SetEvent(grabber_callback->done_event); + + hr = IMFMediaSession_ClearTopologies(session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_Close(session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = wait_media_event(session, callback, MESessionClosed, 1000, &propvar); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(propvar.vt == VT_EMPTY, "got vt %u\n", propvar.vt); + + hr = IMFMediaSession_Shutdown(session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSource_Shutdown(source); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFActivate_ShutdownObject(sink_activate); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + IMFActivate_Release(sink_activate); + IMFMediaSession_Release(session); + IMFMediaSource_Release(source); + + hr = MFShutdown(); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + IMFSampleGrabberSinkCallback_Release(&grabber_callback->IMFSampleGrabberSinkCallback_iface); +} + static void test_quality_manager(void) { IMFPresentationClock *clock; @@ -6239,6 +6502,8 @@ START_TEST(mf) test_presentation_clock(); test_sample_grabber(); test_sample_grabber_is_mediatype_supported(); + test_sample_grabber_orientation(MFVideoFormat_RGB32); + test_sample_grabber_orientation(MFVideoFormat_NV12); test_quality_manager(); test_sar(); test_evr(); diff --git a/dlls/mf/tests/mf_test.h b/dlls/mf/tests/mf_test.h index d908acb89a4..7973e007a68 100644 --- a/dlls/mf/tests/mf_test.h +++ b/dlls/mf/tests/mf_test.h @@ -53,7 +53,44 @@ typedef struct attribute_desc media_type_desc[32]; #define ATTR_RATIO(k, n, d, ...) {.key = &k, .name = #k, {.vt = VT_UI8, .uhVal = {.HighPart = n, .LowPart = d}}, .ratio = TRUE, __VA_ARGS__ } #define ATTR_UINT64(k, v, ...) {.key = &k, .name = #k, {.vt = VT_UI8, .uhVal = {.QuadPart = v}}, __VA_ARGS__ }
-#define check_media_type(a, b, c) check_attributes_(__LINE__, (IMFAttributes *)a, b, c) -#define check_attributes(a, b, c) check_attributes_(__LINE__, a, b, c) -extern void check_attributes_(int line, IMFAttributes *attributes, const struct attribute_desc *desc, ULONG limit); +#define check_media_type(a, b, c) check_attributes_(__FILE__, __LINE__, (IMFAttributes *)a, b, c) +#define check_attributes(a, b, c) check_attributes_(__FILE__, __LINE__, a, b, c) +extern void check_attributes_(const char *file, int line, IMFAttributes *attributes, + const struct attribute_desc *desc, ULONG limit); extern void init_media_type(IMFMediaType *mediatype, const struct attribute_desc *desc, ULONG limit); + +typedef DWORD (*compare_cb)(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect); +extern DWORD compare_nv12(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect); +extern DWORD compare_i420(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect); +extern DWORD compare_rgb32(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect); +extern DWORD compare_pcm16(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect); + +typedef void (*dump_cb)(const BYTE *data, DWORD length, const RECT *rect, HANDLE output); +extern void dump_rgb32(const BYTE *data, DWORD length, const RECT *rect, HANDLE output); +extern void dump_nv12(const BYTE *data, DWORD length, const RECT *rect, HANDLE output); +extern void dump_i420(const BYTE *data, DWORD length, const RECT *rect, HANDLE output); + +struct buffer_desc +{ + DWORD length; + BOOL todo_length; + compare_cb compare; + dump_cb dump; + RECT rect; +}; + +struct sample_desc +{ + const struct attribute_desc *attributes; + LONGLONG sample_time; + LONGLONG sample_duration; + DWORD buffer_count; + const struct buffer_desc *buffers; + DWORD repeat_count; + BOOL todo_length; + LONGLONG todo_time; +}; + +#define check_mf_sample_collection(a, b, c) check_mf_sample_collection_(__FILE__, __LINE__, a, b, c) +extern DWORD check_mf_sample_collection_(const char *file, int line, IMFCollection *samples, + const struct sample_desc *expect_samples, const WCHAR *expect_data_filename); diff --git a/dlls/mf/tests/nv12frame-grabber.bmp b/dlls/mf/tests/nv12frame-grabber.bmp new file mode 100644 index 0000000000000000000000000000000000000000..2acd5d9992330c5b71afd7ffb5d34a3770eb1dee GIT binary patch literal 22582 zcmeIwp%H^n5QJe$z~VBf(7@A76ea>o2?%PyBB2Nbr64H)i@?yq<qZ=PeIjE2z1cTd zcD~m;l*yeC-)C(3ZIV3VS4?@oKhN3sM%e%Z7{CAqFd$~28tfGA7XMwk>0}#a0}NmQ z0~o-7l!0YVjj{m-Fn|FJU_i`3m)RoRG5))BLvABw0}NmQ0~o-7l!12Ljj{m-Fn|FJ zU_i{kbXY6gI{v$Ko6Bm-1{lBq1~7mDDFemT8D#?uU;qOczyJm?pkv@9EZ|sRBP`%p zU?D8vSYRY9;8>s~EZ|t6CM@7spdc*p#|3)vRD<u*N&Dth`?}0`A=kcj*S_iSU2|#Q I)p4E$KCEGdKL7v#
literal 0 HcmV?d00001
diff --git a/dlls/mf/tests/resource.rc b/dlls/mf/tests/resource.rc index 43493319046..2c846c32de5 100644 --- a/dlls/mf/tests/resource.rc +++ b/dlls/mf/tests/resource.rc @@ -58,6 +58,10 @@ h264data.bin RCDATA h264data.bin /* @makedep: nv12frame.bmp */ nv12frame.bmp RCDATA nv12frame.bmp
+/* Generated from running the tests on Windows */ +/* @makedep: nv12frame-grabber.bmp */ +nv12frame-grabber.bmp RCDATA nv12frame-grabber.bmp + /* Generated from running the tests on Windows */ /* @makedep: i420frame.bmp */ i420frame.bmp RCDATA i420frame.bmp @@ -69,3 +73,16 @@ rgb32frame.bmp RCDATA rgb32frame.bmp /* Generated from running the tests on Windows */ /* @makedep: rgb32frame-vp.bmp */ rgb32frame-vp.bmp RCDATA rgb32frame-vp.bmp + +/* Generated from running the tests on Windows */ +/* @makedep: rgb32frame-grabber.bmp */ +rgb32frame-grabber.bmp RCDATA rgb32frame-grabber.bmp + +/* Generated with: + * gst-launch-1.0 videotestsrc num-buffers=60 pattern=smpte100 ! \ + * video/x-raw,format=I420,width=64,height=64,framerate=30000/1001 ! \ + * videoflip method=clockwise ! videoconvert ! \ + * x264enc ! mp4mux ! filesink location=dlls/mf/tests/test.mp4 + */ +/* @makedep: test.mp4 */ +test.mp4 RCDATA test.mp4 diff --git a/dlls/mf/tests/rgb32frame-grabber.bmp b/dlls/mf/tests/rgb32frame-grabber.bmp new file mode 100644 index 0000000000000000000000000000000000000000..b5a5960b96481bd01a5cc1a1fe9358127ca370bb GIT binary patch literal 16438 zcmeI&JxW7C6o%n9h=OPq5K*x35A0LNprtlhf-6X$CL72CbO&~pqN~s*DT8qVYDCc7 zJ03zB*YKW!XSnS-=NlL<)4gnWSgv;LC!w<f`|%a4v)un}bzPIP2bqD)KxV*~ftOM+ zn@0U+w^6@Y@9P7zi|;vRlnS$Ey}-;o`>eg<u*}r#8F(rK%(|~b%;Nfs+2pr{nR)hE zJG_^Mnmq##WfQZzvW408Cz$QV?+>%nA21{CzbSi=8E|Hxf8WRK`0WU@@y-OZ(bWjE zikg%?$P73$@Vrqlo36$CAF-Qe!K_ET{}DT9ju~<LG23Q=nR)hEd&R-}OwFEw$Grh& dXACi`8(=o3g_(KwS-bn}=lpa2nE`hO{s5dR2pIqX
literal 0 HcmV?d00001
diff --git a/dlls/mf/tests/test.mp4 b/dlls/mf/tests/test.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..752d860008d472a1bfb26a1a97ef0c9b36ab2ba5 GIT binary patch literal 3983 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 JJHR;<_)p|_beRAE
literal 0 HcmV?d00001
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 9b30b9cafda..c78370db44f 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -84,7 +84,8 @@ static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOO IUnknown_Release(unk); }
-void check_attributes_(int line, IMFAttributes *attributes, const struct attribute_desc *desc, ULONG limit) +void check_attributes_(const char *file, int line, IMFAttributes *attributes, + const struct attribute_desc *desc, ULONG limit) { char buffer[256], *buf = buffer; PROPVARIANT value; @@ -95,7 +96,7 @@ void check_attributes_(int line, IMFAttributes *attributes, const struct attribu { hr = IMFAttributes_GetItem(attributes, desc[i].key, &value); todo_wine_if(desc[i].todo) - ok_(__FILE__, line)(hr == S_OK, "%s missing, hr %#lx\n", debugstr_a(desc[i].name), hr); + ok_(file, line)(hr == S_OK, "%s missing, hr %#lx\n", debugstr_a(desc[i].name), hr); if (hr != S_OK) continue;
switch (value.vt) @@ -122,7 +123,7 @@ void check_attributes_(int line, IMFAttributes *attributes, const struct attribu
ret = PropVariantCompareEx(&value, &desc[i].value, 0, 0); todo_wine_if(desc[i].todo_value) - ok_(__FILE__, line)(ret == 0, "%s mismatch, type %u, value %s\n", + ok_(file, line)(ret == 0, "%s mismatch, type %u, value %s\n", debugstr_a(desc[i].name), value.vt, buffer); } } @@ -367,9 +368,7 @@ static HRESULT check_mft_process_output_(int line, IMFTransform *transform, IMFS return ret; }
-typedef DWORD (*compare_cb)(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect); - -static DWORD compare_nv12(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) +DWORD compare_nv12(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) { DWORD x, y, size, diff = 0, width = (rect->right + 0xf) & ~0xf, height = (rect->bottom + 0xf) & ~0xf;
@@ -403,7 +402,7 @@ static DWORD compare_nv12(const BYTE *data, DWORD *length, const RECT *rect, con return diff * 100 / 256 / size; }
-static DWORD compare_i420(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) +DWORD compare_i420(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) { DWORD i, x, y, size, diff = 0, width = (rect->right + 0xf) & ~0xf, height = (rect->bottom + 0xf) & ~0xf;
@@ -436,7 +435,7 @@ static DWORD compare_i420(const BYTE *data, DWORD *length, const RECT *rect, con return diff * 100 / 256 / size; }
-static DWORD compare_rgb32(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) +DWORD compare_rgb32(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) { DWORD x, y, size, diff = 0, width = (rect->right + 0xf) & ~0xf, height = (rect->bottom + 0xf) & ~0xf;
@@ -461,7 +460,7 @@ static DWORD compare_rgb32(const BYTE *data, DWORD *length, const RECT *rect, co return diff * 100 / 256 / size; }
-static DWORD compare_pcm16(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) +DWORD compare_pcm16(const BYTE *data, DWORD *length, const RECT *rect, const BYTE *expect) { const INT16 *data_pcm = (INT16 *)data, *expect_pcm = (INT16 *)expect; DWORD i, size = *length / 2, diff = 0; @@ -482,9 +481,7 @@ static DWORD compare_bytes(const BYTE *data, DWORD *length, const RECT *rect, co return diff * 100 / 256 / size; }
-typedef void (*dump_cb)(const BYTE *data, DWORD length, const RECT *rect, HANDLE output); - -static void dump_rgb32(const BYTE *data, DWORD length, const RECT *rect, HANDLE output) +void dump_rgb32(const BYTE *data, DWORD length, const RECT *rect, HANDLE output) { DWORD width = (rect->right + 0xf) & ~0xf, height = (rect->bottom + 0xf) & ~0xf; static const char magic[2] = "BM"; @@ -517,7 +514,7 @@ static void dump_rgb32(const BYTE *data, DWORD length, const RECT *rect, HANDLE ok(written == length, "written %lu bytes\n", written); }
-static void dump_nv12(const BYTE *data, DWORD length, const RECT *rect, HANDLE output) +void dump_nv12(const BYTE *data, DWORD length, const RECT *rect, HANDLE output) { DWORD written, x, y, width = (rect->right + 0xf) & ~0xf, height = (rect->bottom + 0xf) & ~0xf; BYTE *rgb32_data = malloc(width * height * 4), *rgb32 = rgb32_data; @@ -539,7 +536,7 @@ static void dump_nv12(const BYTE *data, DWORD length, const RECT *rect, HANDLE o ok(written == length, "written %lu bytes\n", written); }
-static void dump_i420(const BYTE *data, DWORD length, const RECT *rect, HANDLE output) +void dump_i420(const BYTE *data, DWORD length, const RECT *rect, HANDLE output) { DWORD written, x, y, width = (rect->right + 0xf) & ~0xf, height = (rect->bottom + 0xf) & ~0xf; BYTE *rgb32_data = malloc(width * height * 4), *rgb32 = rgb32_data; @@ -561,27 +558,6 @@ static void dump_i420(const BYTE *data, DWORD length, const RECT *rect, HANDLE o ok(written == length, "written %lu bytes\n", written); }
-struct buffer_desc -{ - DWORD length; - BOOL todo_length; - compare_cb compare; - dump_cb dump; - RECT rect; -}; - -struct sample_desc -{ - const struct attribute_desc *attributes; - LONGLONG sample_time; - LONGLONG sample_duration; - DWORD buffer_count; - const struct buffer_desc *buffers; - DWORD repeat_count; - BOOL todo_length; - LONGLONG todo_time; -}; - typedef void (*enum_mf_media_buffers_cb)(IMFMediaBuffer *buffer, const struct buffer_desc *desc, void *context); static void enum_mf_media_buffers(IMFSample *sample, const struct sample_desc *sample_desc, enum_mf_media_buffers_cb callback, void *context) @@ -682,8 +658,8 @@ static void dump_mf_sample_collection(IMFCollection *samples, const struct sampl CloseHandle(output); }
-#define check_mf_media_buffer(a, b, c) check_mf_media_buffer_(__LINE__, a, b, c) -static DWORD check_mf_media_buffer_(int line, IMFMediaBuffer *buffer, const struct buffer_desc *expect, +#define check_mf_media_buffer(a, b, c) check_mf_media_buffer_(__FILE__, __LINE__, a, b, c) +static DWORD check_mf_media_buffer_(const char *file, int line, IMFMediaBuffer *buffer, const struct buffer_desc *expect, const BYTE **expect_data, DWORD *expect_data_len) { DWORD length, diff = 0; @@ -691,20 +667,20 @@ static DWORD check_mf_media_buffer_(int line, IMFMediaBuffer *buffer, const stru BYTE *data;
hr = IMFMediaBuffer_Lock(buffer, &data, NULL, &length); - ok_(__FILE__, line)(hr == S_OK, "Lock returned %#lx\n", hr); + ok_(file, line)(hr == S_OK, "Lock returned %#lx\n", hr); todo_wine_if(expect->todo_length) - ok_(__FILE__, line)(length == expect->length, "got length %#lx\n", length); + ok_(file, line)(length == expect->length, "got length %#lx\n", length);
if (*expect_data_len < length) todo_wine_if(expect->todo_length) - ok_(__FILE__, line)(0, "missing %#lx bytes\n", length - *expect_data_len); + ok_(file, line)(0, "missing %#lx bytes\n", length - *expect_data_len); else if (!expect->compare) diff = compare_bytes(data, &length, NULL, *expect_data); else diff = expect->compare(data, &length, &expect->rect, *expect_data);
hr = IMFMediaBuffer_Unlock(buffer); - ok_(__FILE__, line)(hr == S_OK, "Unlock returned %#lx\n", hr); + ok_(file, line)(hr == S_OK, "Unlock returned %#lx\n", hr);
*expect_data = *expect_data + min(length, *expect_data_len); *expect_data_len = *expect_data_len - min(length, *expect_data_len); @@ -718,63 +694,64 @@ struct check_mf_sample_context const BYTE *data; DWORD data_len; DWORD diff; + const char *file; int line; };
static void check_mf_sample_buffer(IMFMediaBuffer *buffer, const struct buffer_desc *expect, void *context) { struct check_mf_sample_context *ctx = context; - ctx->diff += check_mf_media_buffer_(ctx->line, buffer, expect, &ctx->data, &ctx->data_len); + ctx->diff += check_mf_media_buffer_(ctx->file, ctx->line, buffer, expect, &ctx->data, &ctx->data_len); ctx->total_length += expect->length; }
-#define check_mf_sample(a, b, c, d) check_mf_sample_(__LINE__, a, b, c, d) -static DWORD check_mf_sample_(int line, IMFSample *sample, const struct sample_desc *expect, +#define check_mf_sample(a, b, c, d) check_mf_sample_(__FILE__, __LINE__, a, b, c, d) +static DWORD check_mf_sample_(const char *file, int line, IMFSample *sample, const struct sample_desc *expect, const BYTE **expect_data, DWORD *expect_data_len) { - struct check_mf_sample_context ctx = {.data = *expect_data, .data_len = *expect_data_len, .line = line}; + struct check_mf_sample_context ctx = {.data = *expect_data, .data_len = *expect_data_len, .file = file, .line = line}; DWORD buffer_count, total_length, sample_flags; LONGLONG timestamp; HRESULT hr;
if (expect->attributes) - check_attributes_(line, (IMFAttributes *)sample, expect->attributes, -1); + check_attributes_(file, line, (IMFAttributes *)sample, expect->attributes, -1);
buffer_count = 0xdeadbeef; hr = IMFSample_GetBufferCount(sample, &buffer_count); - ok_(__FILE__, line)(hr == S_OK, "GetBufferCount returned %#lx\n", hr); - ok_(__FILE__, line)(buffer_count == expect->buffer_count, + ok_(file, line)(hr == S_OK, "GetBufferCount returned %#lx\n", hr); + ok_(file, line)(buffer_count == expect->buffer_count, "got %lu buffers\n", buffer_count);
sample_flags = 0xdeadbeef; hr = IMFSample_GetSampleFlags(sample, &sample_flags); - ok_(__FILE__, line)(hr == S_OK, "GetSampleFlags returned %#lx\n", hr); - ok_(__FILE__, line)(sample_flags == 0, + ok_(file, line)(hr == S_OK, "GetSampleFlags returned %#lx\n", hr); + ok_(file, line)(sample_flags == 0, "got sample flags %#lx\n", sample_flags);
timestamp = 0xdeadbeef; hr = IMFSample_GetSampleTime(sample, ×tamp); - ok_(__FILE__, line)(hr == S_OK, "GetSampleTime returned %#lx\n", hr); + ok_(file, line)(hr == S_OK, "GetSampleTime returned %#lx\n", hr); todo_wine_if(expect->todo_time && timestamp == expect->todo_time) - ok_(__FILE__, line)(llabs(timestamp - expect->sample_time) <= 50, + ok_(file, line)(llabs(timestamp - expect->sample_time) <= 50, "got sample time %I64d\n", timestamp);
timestamp = 0xdeadbeef; hr = IMFSample_GetSampleDuration(sample, ×tamp); - ok_(__FILE__, line)(hr == S_OK, "GetSampleDuration returned %#lx\n", hr); + ok_(file, line)(hr == S_OK, "GetSampleDuration returned %#lx\n", hr); todo_wine_if(expect->todo_length) - ok_(__FILE__, line)(llabs(timestamp - expect->sample_duration) <= 1, + ok_(file, line)(llabs(timestamp - expect->sample_duration) <= 1, "got sample duration %I64d\n", timestamp);
enum_mf_media_buffers(sample, expect, check_mf_sample_buffer, &ctx);
total_length = 0xdeadbeef; hr = IMFSample_GetTotalLength(sample, &total_length); - ok_(__FILE__, line)(hr == S_OK, "GetTotalLength returned %#lx\n", hr); + ok_(file, line)(hr == S_OK, "GetTotalLength returned %#lx\n", hr); todo_wine_if(expect->todo_length) - ok_(__FILE__, line)(total_length == ctx.total_length, + ok_(file, line)(total_length == ctx.total_length, "got total length %#lx\n", total_length); - ok_(__FILE__, line)(*expect_data_len >= ctx.total_length, + ok_(file, line)(*expect_data_len >= ctx.total_length, "missing %#lx data\n", ctx.total_length - *expect_data_len);
*expect_data = *expect_data + min(total_length, *expect_data_len); @@ -786,14 +763,13 @@ static DWORD check_mf_sample_(int line, IMFSample *sample, const struct sample_d static void check_mf_sample_collection_enum(IMFSample *sample, const struct sample_desc *expect, void *context) { struct check_mf_sample_context *ctx = context; - ctx->diff += check_mf_sample_(ctx->line, sample, expect, &ctx->data, &ctx->data_len); + ctx->diff += check_mf_sample_(ctx->file, ctx->line, sample, expect, &ctx->data, &ctx->data_len); }
-#define check_mf_sample_collection(a, b, c) check_mf_sample_collection_(__LINE__, a, b, c) -static DWORD check_mf_sample_collection_(int line, IMFCollection *samples, +DWORD check_mf_sample_collection_(const char *file, int line, IMFCollection *samples, const struct sample_desc *expect_samples, const WCHAR *expect_data_filename) { - struct check_mf_sample_context ctx = {.line = line}; + struct check_mf_sample_context ctx = {.file = file, .line = line}; DWORD count; HRESULT hr;
@@ -803,7 +779,7 @@ static DWORD check_mf_sample_collection_(int line, IMFCollection *samples, dump_mf_sample_collection(samples, expect_samples, expect_data_filename);
hr = IMFCollection_GetElementCount(samples, &count); - ok_(__FILE__, line)(hr == S_OK, "GetElementCount returned %#lx\n", hr); + ok_(file, line)(hr == S_OK, "GetElementCount returned %#lx\n", hr);
return ctx.diff / count; }