mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-03 02:08:29 +00:00
mfplat/tests: Add more tests for compressed formats.
This commit is contained in:
parent
31be907221
commit
e72f8b08e2
|
@ -41,6 +41,7 @@
|
|||
#include "uuids.h"
|
||||
#include "evr.h"
|
||||
#include "mfmediaengine.h"
|
||||
#include "codecapi.h"
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
|
@ -154,6 +155,70 @@ static void check_service_interface_(unsigned int line, void *iface_ptr, REFGUID
|
|||
IUnknown_Release(unk);
|
||||
}
|
||||
|
||||
struct attribute_desc
|
||||
{
|
||||
const GUID *key;
|
||||
const char *name;
|
||||
PROPVARIANT value;
|
||||
BOOL ratio;
|
||||
BOOL required;
|
||||
BOOL todo;
|
||||
BOOL todo_value;
|
||||
};
|
||||
|
||||
#define ATTR_GUID(k, g, ...) {.key = &k, .name = #k, {.vt = VT_CLSID, .puuid = (GUID *)&g}, __VA_ARGS__ }
|
||||
#define ATTR_UINT32(k, v, ...) {.key = &k, .name = #k, {.vt = VT_UI4, .ulVal = v}, __VA_ARGS__ }
|
||||
#define ATTR_BLOB(k, p, n, ...) {.key = &k, .name = #k, {.vt = VT_VECTOR | VT_UI1, .caub = {.pElems = (void *)p, .cElems = n}}, __VA_ARGS__ }
|
||||
#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_(__FILE__, __LINE__, (IMFAttributes *)a, b, c)
|
||||
|
||||
static void check_attributes_(const char *file, int line, IMFAttributes *attributes,
|
||||
const struct attribute_desc *desc, ULONG limit)
|
||||
{
|
||||
char buffer[1024], *buf = buffer;
|
||||
PROPVARIANT value;
|
||||
int i, j, ret;
|
||||
HRESULT hr;
|
||||
|
||||
for (i = 0; i < limit && desc[i].key; ++i)
|
||||
{
|
||||
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);
|
||||
if (hr != S_OK) continue;
|
||||
|
||||
switch (value.vt)
|
||||
{
|
||||
default: sprintf(buffer, "??"); break;
|
||||
case VT_CLSID: sprintf(buffer, "%s", debugstr_guid(value.puuid)); break;
|
||||
case VT_UI4: sprintf(buffer, "%lu", value.ulVal); break;
|
||||
case VT_UI8:
|
||||
if (desc[i].ratio)
|
||||
sprintf(buffer, "%lu:%lu", value.uhVal.HighPart, value.uhVal.LowPart);
|
||||
else
|
||||
sprintf(buffer, "%I64u", value.uhVal.QuadPart);
|
||||
break;
|
||||
case VT_VECTOR | VT_UI1:
|
||||
buf += sprintf(buf, "size %lu, data {", value.caub.cElems);
|
||||
for (j = 0; j < 128 && j < value.caub.cElems; ++j)
|
||||
buf += sprintf(buf, "0x%02x,", value.caub.pElems[j]);
|
||||
if (value.caub.cElems > 128)
|
||||
buf += sprintf(buf, "...}");
|
||||
else
|
||||
buf += sprintf(buf - (j ? 1 : 0), "}");
|
||||
break;
|
||||
}
|
||||
|
||||
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",
|
||||
debugstr_a(desc[i].name), value.vt, buffer);
|
||||
PropVariantClear(&value);
|
||||
}
|
||||
}
|
||||
|
||||
struct d3d9_surface_readback
|
||||
{
|
||||
IDirect3DSurface9 *surface, *readback_surface;
|
||||
|
@ -939,6 +1004,182 @@ static HRESULT WINAPI bytestream_wrapper_Close(IMFByteStream *iface)
|
|||
return bytestream_vtbl_orig->Close(iface);
|
||||
}
|
||||
|
||||
static void test_compressed_media_types(IMFSourceResolver *resolver)
|
||||
{
|
||||
static const BYTE aac_data[] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x12, 0x08, 0x56, 0xe5, 0x00,
|
||||
};
|
||||
static const BYTE wma2_data[] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0};
|
||||
|
||||
static const struct
|
||||
{
|
||||
const WCHAR *filename;
|
||||
const WCHAR *mime;
|
||||
struct attribute_desc type[20];
|
||||
}
|
||||
tests[] =
|
||||
{
|
||||
{
|
||||
L"test-h264.mp4",
|
||||
L"video/mp4",
|
||||
{
|
||||
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
|
||||
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_H264, .todo_value = TRUE),
|
||||
ATTR_GUID(MF_MT_AM_FORMAT_TYPE, FORMAT_MPEG2Video, .todo = TRUE),
|
||||
ATTR_RATIO(MF_MT_FRAME_SIZE, 320, 240),
|
||||
ATTR_RATIO(MF_MT_FRAME_RATE, 30, 1),
|
||||
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_MPEG2_PROFILE, eAVEncH264VProfile_High, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_MPEG2_LEVEL, eAVEncH264VLevel2, .todo = TRUE),
|
||||
},
|
||||
},
|
||||
{
|
||||
L"test-aac.mp4",
|
||||
L"video/mp4",
|
||||
{
|
||||
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio),
|
||||
ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_AAC, .todo_value = TRUE),
|
||||
ATTR_GUID(MF_MT_AM_FORMAT_TYPE, FORMAT_WaveFormatEx, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1),
|
||||
ATTR_UINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16, .todo_value = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100),
|
||||
ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 9180, .todo_value = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_AVG_BITRATE, 73440, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, 0, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_AAC_PAYLOAD_TYPE, 0, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
|
||||
ATTR_BLOB(MF_MT_USER_DATA, aac_data, sizeof(aac_data), .todo = TRUE),
|
||||
},
|
||||
},
|
||||
{
|
||||
L"test-wmv1.wmv",
|
||||
L"video/x-ms-wmv",
|
||||
{
|
||||
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
|
||||
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_WMV1, .todo_value = TRUE),
|
||||
ATTR_RATIO(MF_MT_FRAME_SIZE, 320, 240),
|
||||
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1, .todo = TRUE),
|
||||
},
|
||||
},
|
||||
{
|
||||
L"test-wma2.wmv",
|
||||
L"video/x-ms-wmv",
|
||||
{
|
||||
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio),
|
||||
ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_WMAudioV8, .todo_value = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1),
|
||||
ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100),
|
||||
ATTR_UINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 16000, .todo_value = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 743, .todo_value = TRUE),
|
||||
ATTR_BLOB(MF_MT_USER_DATA, wma2_data, sizeof(wma2_data), .todo = TRUE),
|
||||
},
|
||||
},
|
||||
{
|
||||
L"test-mp3.mp4",
|
||||
L"video/mp4",
|
||||
{
|
||||
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio),
|
||||
ATTR_GUID(MF_MT_SUBTYPE, MFAudioFormat_MP3, .todo_value = TRUE),
|
||||
ATTR_GUID(MF_MT_AM_FORMAT_TYPE, FORMAT_WaveFormatEx, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_AUDIO_NUM_CHANNELS, 1),
|
||||
ATTR_UINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100),
|
||||
ATTR_UINT32(MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
|
||||
},
|
||||
},
|
||||
{
|
||||
L"test-i420.avi",
|
||||
L"video/avi",
|
||||
{
|
||||
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
|
||||
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_I420),
|
||||
ATTR_RATIO(MF_MT_FRAME_SIZE, 32, 24),
|
||||
ATTR_RATIO(MF_MT_FRAME_RATE, 30, 1),
|
||||
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1, .todo = TRUE),
|
||||
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
|
||||
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 32),
|
||||
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1, .todo = TRUE),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(tests); ++i)
|
||||
{
|
||||
IMFPresentationDescriptor *descriptor;
|
||||
IMFMediaTypeHandler *handler;
|
||||
IMFAttributes *attributes;
|
||||
IMFMediaType *media_type;
|
||||
IMFStreamDescriptor *sd;
|
||||
MF_OBJECT_TYPE obj_type;
|
||||
IMFMediaSource *source;
|
||||
IMFByteStream *stream;
|
||||
BOOL ret, selected;
|
||||
WCHAR *filename;
|
||||
DWORD count;
|
||||
HRESULT hr;
|
||||
|
||||
winetest_push_context("%s", debugstr_w(tests[i].filename));
|
||||
|
||||
filename = load_resource(tests[i].filename);
|
||||
|
||||
hr = MFCreateFile(MF_ACCESSMODE_READ, MF_OPENMODE_FAIL_IF_NOT_EXIST, MF_FILEFLAGS_NONE, filename, &stream);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
|
||||
hr = IMFByteStream_QueryInterface(stream, &IID_IMFAttributes, (void **)&attributes);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
hr = IMFAttributes_SetString(attributes, &MF_BYTESTREAM_CONTENT_TYPE, tests[i].mime);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
IMFAttributes_Release(attributes);
|
||||
|
||||
hr = IMFSourceResolver_CreateObjectFromByteStream(resolver, stream, NULL,
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &obj_type, (IUnknown **)&source);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
ok(obj_type == MF_OBJECT_MEDIASOURCE, "Got type %#x.\n", obj_type);
|
||||
|
||||
hr = IMFMediaSource_CreatePresentationDescriptor(source, &descriptor);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
|
||||
hr = IMFPresentationDescriptor_GetStreamDescriptorCount(descriptor, &count);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
ok(count == 1, "Got count %lu.\n", count);
|
||||
|
||||
hr = IMFPresentationDescriptor_GetStreamDescriptorByIndex(descriptor, 0, &selected, &sd);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
ok(selected == TRUE, "Got selected %d.\n", selected);
|
||||
|
||||
hr = IMFStreamDescriptor_GetMediaTypeHandler(sd, &handler);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
|
||||
hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &media_type);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
|
||||
check_media_type(media_type, tests[i].type, -1);
|
||||
|
||||
IMFMediaType_Release(media_type);
|
||||
|
||||
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count);
|
||||
ok(hr == S_OK, "Got hr %#lx.\n", hr);
|
||||
todo_wine ok(count == 1, "Got type count %lu.\n", count);
|
||||
|
||||
IMFMediaTypeHandler_Release(handler);
|
||||
IMFStreamDescriptor_Release(sd);
|
||||
|
||||
IMFPresentationDescriptor_Release(descriptor);
|
||||
IMFMediaSource_Release(source);
|
||||
IMFByteStream_Release(stream);
|
||||
|
||||
ret = DeleteFileW(filename);
|
||||
ok(ret, "Failed to delete %s, error %lu.\n", debugstr_w(filename), GetLastError());
|
||||
|
||||
winetest_pop_context();
|
||||
}
|
||||
}
|
||||
|
||||
static void test_source_resolver(void)
|
||||
{
|
||||
struct test_callback *callback, *callback2;
|
||||
|
@ -967,6 +1208,7 @@ static void test_source_resolver(void)
|
|||
float rate;
|
||||
UINT32 rotation;
|
||||
ULONG refcount;
|
||||
BOOL ret;
|
||||
|
||||
if (!pMFCreateSourceResolver)
|
||||
{
|
||||
|
@ -1341,6 +1583,11 @@ static void test_source_resolver(void)
|
|||
|
||||
IMFSchemeHandler_Release(scheme_handler);
|
||||
|
||||
ret = DeleteFileW(filename);
|
||||
ok(ret, "Failed to delete %s, error %lu.\n", debugstr_w(filename), GetLastError());
|
||||
|
||||
test_compressed_media_types(resolver);
|
||||
|
||||
if (do_uninit)
|
||||
CoUninitialize();
|
||||
|
||||
|
@ -1351,8 +1598,6 @@ static void test_source_resolver(void)
|
|||
|
||||
IMFAsyncCallback_Release(&callback->IMFAsyncCallback_iface);
|
||||
IMFAsyncCallback_Release(&callback2->IMFAsyncCallback_iface);
|
||||
|
||||
DeleteFileW(filename);
|
||||
}
|
||||
|
||||
static void init_functions(void)
|
||||
|
|
|
@ -22,3 +22,27 @@
|
|||
|
||||
/* @makedep: test.mp4 */
|
||||
test.mp4 RCDATA test.mp4
|
||||
|
||||
/* gst-launch-1.0 videotestsrc num-buffers=5 ! video/x-raw,format=I420 ! videoconvert ! x264enc ! mp4mux ! filesink location=test-h264.mp4 */
|
||||
/* @makedep: test-h264.mp4 */
|
||||
test-h264.mp4 RCDATA test-h264.mp4
|
||||
|
||||
/* gst-launch-1.0 audiotestsrc num-buffers=5 ! audioconvert ! avenc_aac ! mp4mux ! filesink location=test-aac.mp4 */
|
||||
/* @makedep: test-aac.mp4 */
|
||||
test-aac.mp4 RCDATA test-aac.mp4
|
||||
|
||||
/* gst-launch-1.0 videotestsrc num-buffers=5 ! videoconvert ! avenc_wmv1 ! asfmux ! filesink location=test-wmv1.wmv */
|
||||
/* @makedep: test-wmv1.wmv */
|
||||
test-wmv1.wmv RCDATA test-wmv1.wmv
|
||||
|
||||
/* gst-launch-1.0 audiotestsrc num-buffers=5 ! audioconvert ! avenc_wmav2 ! asfmux ! filesink location=test-wma2.wmv */
|
||||
/* @makedep: test-wma2.wmv */
|
||||
test-wma2.wmv RCDATA test-wma2.wmv
|
||||
|
||||
/* gst-launch-1.0 audiotestsrc num-buffers=5 ! audioconvert ! lamemp3enc ! mp4mux ! filesink location=test-mp3.mp4 */
|
||||
/* @makedep: test-mp3.mp4 */
|
||||
test-mp3.mp4 RCDATA test-mp3.mp4
|
||||
|
||||
/* gst-launch-1.0 videotestsrc num-buffers=5 ! video/x-raw,format=I420,width=32,height=24 ! avimux ! filesink location=test-i420.avi */
|
||||
/* @makedep: test-i420.avi */
|
||||
test-i420.avi RCDATA test-i420.avi
|
||||
|
|
BIN
dlls/mfplat/tests/test-aac.mp4
Normal file
BIN
dlls/mfplat/tests/test-aac.mp4
Normal file
Binary file not shown.
BIN
dlls/mfplat/tests/test-h264.mp4
Normal file
BIN
dlls/mfplat/tests/test-h264.mp4
Normal file
Binary file not shown.
BIN
dlls/mfplat/tests/test-i420.avi
Normal file
BIN
dlls/mfplat/tests/test-i420.avi
Normal file
Binary file not shown.
BIN
dlls/mfplat/tests/test-mp3.mp4
Normal file
BIN
dlls/mfplat/tests/test-mp3.mp4
Normal file
Binary file not shown.
BIN
dlls/mfplat/tests/test-wma2.wmv
Normal file
BIN
dlls/mfplat/tests/test-wma2.wmv
Normal file
Binary file not shown.
BIN
dlls/mfplat/tests/test-wmv1.wmv
Normal file
BIN
dlls/mfplat/tests/test-wmv1.wmv
Normal file
Binary file not shown.
Loading…
Reference in a new issue