Module: wine Branch: master Commit: a419ff8b6fcb53abf258129c9647ecff1626b01c URL: https://source.winehq.org/git/wine.git/?a=commit;h=a419ff8b6fcb53abf258129c9...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Feb 22 16:47:21 2022 +0100
mf/tests: Add some H264 decoder Process(Input|Output) tests.
The h264data.bin resource has been generated with:
gst-launch-1.0 videotestsrc num-buffers=60 ! \ video/x-raw,format=I420,width=78,height=74,framerate=30000/1001 ! \ videoconvert ! x264enc ! filesink location=dlls/mf/tests/h264data.bin
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45988 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47084 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49715 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52183 Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mf/tests/h264data.bin | Bin 0 -> 49137 bytes dlls/mf/tests/mf.c | 95 ++++++++++++++++++++++++++++++++++++++++++++- dlls/mf/tests/resource.rc | 3 ++ 3 files changed, 97 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/tests/h264data.bin b/dlls/mf/tests/h264data.bin new file mode 100644 index 00000000000..d014052ca49 Binary files /dev/null and b/dlls/mf/tests/h264data.bin differ diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 6dabae1deb0..e0793152d74 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -6369,6 +6369,27 @@ failed: CoUninitialize(); }
+#define next_h264_sample(a, b) next_h264_sample_(__LINE__, a, b) +static IMFSample *next_h264_sample_(int line, const BYTE **h264_buf, ULONG *h264_len) +{ + const BYTE *sample_data; + + ok_(__FILE__, line)(*h264_len > 4, "invalid h264 length\n"); + ok_(__FILE__, line)(*(UINT32 *)*h264_buf == 0x01000000, "invalid h264 buffer\n"); + sample_data = *h264_buf; + + (*h264_len) -= 4; + (*h264_buf) += 4; + + while (*h264_len >= 4 && *(UINT32 *)*h264_buf != 0x01000000) + { + (*h264_len)--; + (*h264_buf)++; + } + + return create_sample(sample_data, *h264_buf - sample_data); +} + static void test_h264_decoder(void) { static const media_type_desc transform_inputs[] = @@ -6534,10 +6555,16 @@ static void test_h264_decoder(void) MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; MFT_OUTPUT_STREAM_INFO output_info; MFT_INPUT_STREAM_INFO input_info; + MFT_OUTPUT_DATA_BUFFER output; + const BYTE *h264_encoded_data; + ULONG h264_encoded_data_len; IMFMediaType *media_type; IMFTransform *transform; - ULONG flags, i, ret; + ULONG i, ret, flags; + IMFSample *sample; + HRSRC resource; GUID class_id; + DWORD status; HRESULT hr;
hr = CoInitialize(NULL); @@ -6723,8 +6750,74 @@ static void test_h264_decoder(void) todo_wine ok(output_info.cbAlignment == 0, "got cbAlignment %#x\n", output_info.cbAlignment);
+ resource = FindResourceW(NULL, L"h264data.bin", (const WCHAR *)RT_RCDATA); + ok(resource != 0, "FindResourceW failed, error %u\n", GetLastError()); + h264_encoded_data = LockResource(LoadResource(GetModuleHandleW(NULL), resource)); + h264_encoded_data_len = SizeofResource(GetModuleHandleW(NULL), resource); + + /* As output_info.dwFlags doesn't have MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES + * IMFTransform_ProcessOutput needs a sample or returns an error */ + + status = 0; + memset(&output, 0, sizeof(output)); + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); + todo_wine + ok(hr == E_INVALIDARG || hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#x\n", hr); + ok(output.dwStreamID == 0, "got dwStreamID %u\n", output.dwStreamID); + ok(!output.pSample, "got pSample %p\n", output.pSample); + ok(output.dwStatus == 0, "got dwStatus %#x\n", output.dwStatus); + ok(!output.pEvents, "got pEvents %p\n", output.pEvents); + ok(status == 0, "got status %#x\n", status); + + sample = next_h264_sample(&h264_encoded_data, &h264_encoded_data_len); + while (1) + { + status = 0; + memset(&output, 0, sizeof(output)); + output.pSample = create_sample(NULL, output_info.cbSize); + hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); + if (hr != MF_E_TRANSFORM_NEED_MORE_INPUT) break; + ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#x\n", hr); + ok(output.dwStreamID == 0, "got dwStreamID %u\n", output.dwStreamID); + ok(!!output.pSample, "got pSample %p\n", output.pSample); + ok(output.dwStatus == 0, "got dwStatus %#x\n", output.dwStatus); + ok(!output.pEvents, "got pEvents %p\n", output.pEvents); + ok(status == 0, "got status %#x\n", status); + check_sample(output.pSample, NULL, 0, NULL); + ret = IMFSample_Release(output.pSample); + ok(ret == 0, "Release returned %u\n", ret); + + while (h264_encoded_data_len > 4) + { + hr = IMFTransform_ProcessInput(transform, 0, sample, 0); + if (FAILED(hr)) break; + ok(hr == S_OK, "ProcessInput returned %#x\n", hr); + ret = IMFSample_Release(sample); + ok(ret <= 1, "Release returned %u\n", ret); + sample = next_h264_sample(&h264_encoded_data, &h264_encoded_data_len); + } + ok(hr == MF_E_NOTACCEPTING, "ProcessInput returned %#x\n", hr); + EXPECT_REF(sample, 1); + } + todo_wine + ok(hr == MF_E_TRANSFORM_STREAM_CHANGE, "ProcessOutput returned %#x\n", hr); + ok(output.dwStreamID == 0, "got dwStreamID %u\n", output.dwStreamID); + ok(!!output.pSample, "got pSample %p\n", output.pSample); + todo_wine + ok(output.dwStatus == MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE, + "got dwStatus %#x\n", output.dwStatus); + ok(!output.pEvents, "got pEvents %p\n", output.pEvents); + todo_wine + ok(status == MFT_PROCESS_OUTPUT_STATUS_NEW_STREAMS, + "got status %#x\n", status); + check_sample(output.pSample, NULL, 0, NULL); + ret = IMFSample_Release(output.pSample); + ok(ret == 0, "Release returned %u\n", ret); + ret = IMFTransform_Release(transform); ok(ret == 0, "Release returned %u\n", ret); + ret = IMFSample_Release(sample); + ok(ret == 0, "Release returned %u\n", ret);
failed: CoUninitialize(); diff --git a/dlls/mf/tests/resource.rc b/dlls/mf/tests/resource.rc index 931139c741a..17adc3ed46c 100644 --- a/dlls/mf/tests/resource.rc +++ b/dlls/mf/tests/resource.rc @@ -22,3 +22,6 @@
/* @makedep: wmadata.bin */ wmadata.bin RCDATA wmadata.bin + +/* @makedep: h264data.bin */ +h264data.bin RCDATA h264data.bin