From: "Rémi Bernon" Subject: [PATCH v4 1/3] winegstreamer: Implement WMA decoder Process(Input|Output) error checks. Message-Id: <20220314134323.2710670-1-rbernon@codeweavers.com> Date: Mon, 14 Mar 2022 14:43:21 +0100 Checking that WMA decoder ignores any incorrectly sized input sample. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: Rémi Bernon Signed-off-by: Zebediah Figura Signed-off-by: Nikolay Sivov --- v4: * Rebase to fix the H264 decoder conflict in PATCH 2, * Kept the signoffs. dlls/mf/tests/mf.c | 23 +++++++++++++--------- dlls/winegstreamer/wma_decoder.c | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index 880fbc9fc3f..de72ad5a6e7 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -6035,6 +6035,7 @@ static void test_wma_decoder(void) MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Audio, MFAudioFormat_WMAudioV8}; MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Audio, MFAudioFormat_Float}; MFT_OUTPUT_STREAM_INFO output_info; + MFT_OUTPUT_DATA_BUFFER outputs[2]; MFT_INPUT_STREAM_INFO input_info; MFT_OUTPUT_DATA_BUFFER output; const BYTE *wma_encoded_data; @@ -6212,7 +6213,7 @@ static void test_wma_decoder(void) ok(hr == S_OK, "ProcessInput returned %#lx\n", hr); ret = IMFSample_Release(sample); ok(ret == 0, "Release returned %lu\n", ret); - sample = create_sample(wma_encoded_data + wma_block_size, wma_block_size - wma_block_size / 2); + sample = create_sample(wma_encoded_data, wma_block_size + 1); hr = IMFTransform_ProcessInput(transform, 0, sample, 0); todo_wine ok(hr == S_OK, "ProcessInput returned %#lx\n", hr); @@ -6235,16 +6236,13 @@ static void test_wma_decoder(void) status = 0xdeadbeef; memset(&output, 0, sizeof(output)); hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); - todo_wine ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); ok(output.dwStreamID == 0, "got dwStreamID %lu\n", output.dwStreamID); ok(!output.pSample, "got pSample %p\n", output.pSample); - todo_wine ok(output.dwStatus == MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE || broken(output.dwStatus == (MFT_OUTPUT_DATA_BUFFER_INCOMPLETE|MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE)) /* Win7 */, "got dwStatus %#lx\n", output.dwStatus); ok(!output.pEvents, "got pEvents %p\n", output.pEvents); - todo_wine ok(status == 0, "got status %#lx\n", status); sample = create_sample(wma_encoded_data, wma_block_size); @@ -6257,16 +6255,25 @@ static void test_wma_decoder(void) status = 0xdeadbeef; memset(&output, 0, sizeof(output)); hr = IMFTransform_ProcessOutput(transform, 0, 1, &output, &status); - todo_wine ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); ok(!output.pSample, "got pSample %p\n", output.pSample); - todo_wine ok(output.dwStatus == MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE || broken(output.dwStatus == (MFT_OUTPUT_DATA_BUFFER_INCOMPLETE|MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE)) /* Win7 */, "got dwStatus %#lx\n", output.dwStatus); - todo_wine ok(status == 0, "got status %#lx\n", status); + status = 0xdeadbeef; + memset(&output, 0, sizeof(output)); + output_info.cbSize = sizeof(wma_decoded_data); + sample = create_sample(NULL, output_info.cbSize); + outputs[0].pSample = sample; + sample = create_sample(NULL, output_info.cbSize); + outputs[1].pSample = sample; + hr = IMFTransform_ProcessOutput(transform, 0, 2, outputs, &status); + ok(hr == E_INVALIDARG, "ProcessOutput returned %#lx\n", hr); + IMFSample_Release(outputs[0].pSample); + IMFSample_Release(outputs[1].pSample); + i = 1; status = 0xdeadbeef; output_info.cbSize = sizeof(wma_decoded_data); @@ -6337,7 +6344,6 @@ static void test_wma_decoder(void) ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); ok(output.pSample == sample, "got pSample %p\n", output.pSample); ok(output.dwStatus == 0, "got dwStatus %#lx\n", output.dwStatus); - todo_wine ok(status == 0, "got status %#lx\n", status); ret = IMFSample_Release(sample); ok(ret == 0, "Release returned %lu\n", ret); @@ -6353,7 +6359,6 @@ static void test_wma_decoder(void) ok(output.dwStatus == 0 || broken(output.dwStatus == (MFT_OUTPUT_DATA_BUFFER_INCOMPLETE|7)) /* Win7 */, "got dwStatus %#lx\n", output.dwStatus); - todo_wine ok(status == 0, "got status %#lx\n", status); check_sample(sample, NULL, 0, NULL); ret = IMFSample_Release(sample); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index 6c198706944..a35da1cdc70 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -520,14 +520,47 @@ static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_ static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags) { + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + MFT_INPUT_STREAM_INFO info; + HRESULT hr; + FIXME("iface %p, id %lu, sample %p, flags %#lx stub!\n", iface, id, sample, flags); + + if (!decoder->wg_transform) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = IMFTransform_GetInputStreamInfo(iface, 0, &info))) + return hr; + return E_NOTIMPL; } static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count, MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) { + struct wma_decoder *decoder = impl_from_IMFTransform(iface); + MFT_OUTPUT_STREAM_INFO info; + HRESULT hr; + FIXME("iface %p, flags %#lx, count %lu, samples %p, status %p stub!\n", iface, flags, count, samples, status); + + if (count > 1) + return E_INVALIDARG; + + if (!decoder->wg_transform) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info))) + return hr; + + *status = 0; + samples[0].dwStatus = 0; + if (!samples[0].pSample) + { + samples[0].dwStatus = MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE; + return MF_E_TRANSFORM_NEED_MORE_INPUT; + } + return E_NOTIMPL; } -- 2.35.1