Module: wine Branch: master Commit: 61783928625e35b1088e7c75674150a0fc4e3ee7 URL: https://gitlab.winehq.org/wine/wine/-/commit/61783928625e35b1088e7c75674150a...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Sep 6 07:51:15 2022 +0200
winegstreamer: Better implement H264 MFT GetAttributes and GetOutputStreamAttributes.
---
dlls/mf/tests/transform.c | 1 - dlls/winegstreamer/h264_decoder.c | 53 +++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 9756cd29070..c5dbea290bc 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -2326,7 +2326,6 @@ static void test_h264_decoder(void) hr = IMFAttributes_SetUINT32(attributes, &MF_LOW_LATENCY, 1); ok(hr == S_OK, "SetUINT32 returned %#lx\n", hr); ret = IMFAttributes_Release(attributes); - todo_wine ok(ret == 1, "Release returned %ld\n", ret);
/* no output type is available before an input type is set */ diff --git a/dlls/winegstreamer/h264_decoder.c b/dlls/winegstreamer/h264_decoder.c index c6098aee302..3e29a7bafd9 100644 --- a/dlls/winegstreamer/h264_decoder.c +++ b/dlls/winegstreamer/h264_decoder.c @@ -47,6 +47,9 @@ struct h264_decoder { IMFTransform IMFTransform_iface; LONG refcount; + + IMFAttributes *attributes; + IMFAttributes *output_attributes; IMFMediaType *input_type; IMFMediaType *output_type;
@@ -238,6 +241,10 @@ static ULONG WINAPI transform_Release(IMFTransform *iface) IMFMediaType_Release(decoder->input_type); if (decoder->output_type) IMFMediaType_Release(decoder->output_type); + if (decoder->output_attributes) + IMFAttributes_Release(decoder->output_attributes); + if (decoder->attributes) + IMFAttributes_Release(decoder->attributes);
wg_sample_queue_destroy(decoder->wg_sample_queue); free(decoder); @@ -305,8 +312,15 @@ static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD i
static HRESULT WINAPI transform_GetAttributes(IMFTransform *iface, IMFAttributes **attributes) { - FIXME("iface %p, attributes %p stub!\n", iface, attributes); - return MFCreateAttributes(attributes, 0); + struct h264_decoder *decoder = impl_from_IMFTransform(iface); + + FIXME("iface %p, attributes %p semi-stub!\n", iface, attributes); + + if (!attributes) + return E_POINTER; + + IMFAttributes_AddRef((*attributes = decoder->attributes)); + return S_OK; }
static HRESULT WINAPI transform_GetInputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) @@ -315,11 +329,19 @@ static HRESULT WINAPI transform_GetInputStreamAttributes(IMFTransform *iface, DW return E_NOTIMPL; }
-static HRESULT WINAPI transform_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, - IMFAttributes **attributes) +static HRESULT WINAPI transform_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes) { - FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes); - return E_NOTIMPL; + struct h264_decoder *decoder = impl_from_IMFTransform(iface); + + FIXME("iface %p, id %#lx, attributes %p semi-stub!\n", iface, id, attributes); + + if (!attributes) + return E_POINTER; + if (id) + return MF_E_INVALIDSTREAMNUMBER; + + IMFAttributes_AddRef((*attributes = decoder->output_attributes)); + return S_OK; }
static HRESULT WINAPI transform_DeleteInputStream(IMFTransform *iface, DWORD id) @@ -708,13 +730,24 @@ HRESULT h264_decoder_create(REFIID riid, void **ret) decoder->wg_format.u.video.fps_n = 30000; decoder->wg_format.u.video.fps_d = 1001;
+ if (FAILED(hr = MFCreateAttributes(&decoder->attributes, 16))) + goto failed; + if (FAILED(hr = IMFAttributes_SetUINT32(decoder->attributes, &MF_LOW_LATENCY, 0))) + goto failed; + if (FAILED(hr = MFCreateAttributes(&decoder->output_attributes, 0))) + goto failed; if (FAILED(hr = wg_sample_queue_create(&decoder->wg_sample_queue))) - { - free(decoder); - return hr; - } + goto failed;
*ret = &decoder->IMFTransform_iface; TRACE("Created decoder %p\n", *ret); return S_OK; + +failed: + if (decoder->output_attributes) + IMFAttributes_Release(decoder->output_attributes); + if (decoder->attributes) + IMFAttributes_Release(decoder->attributes); + free(decoder); + return hr; }