winegstreamer: Implement H264 decoder SetInputType.

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>
This commit is contained in:
Rémi Bernon 2022-03-14 12:09:05 +01:00 committed by Alexandre Julliard
parent 2d7c37da49
commit dfce20f343
2 changed files with 36 additions and 5 deletions

View File

@ -6737,7 +6737,6 @@ static void test_h264_decoder(void)
hr = MFCreateMediaType(&media_type);
ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr);
hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
todo_wine
ok(hr == E_INVALIDARG, "SetInputType returned %#lx.\n", hr);
init_media_type(media_type, input_type_desc, 1);
hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
@ -6745,10 +6744,8 @@ static void test_h264_decoder(void)
ok(hr == MF_E_INVALIDMEDIATYPE, "SetInputType returned %#lx.\n", hr);
init_media_type(media_type, input_type_desc, 2);
hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
todo_wine
ok(hr == S_OK, "SetInputType returned %#lx.\n", hr);
ret = IMFMediaType_Release(media_type);
todo_wine
ok(ret == 1, "Release returned %lu\n", ret);
flags = MFT_OUTPUT_STREAM_WHOLE_SAMPLES | MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER | MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE;

View File

@ -28,10 +28,17 @@
WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
static const GUID *const h264_decoder_input_types[] =
{
&MFVideoFormat_H264,
&MFVideoFormat_H264_ES,
};
struct h264_decoder
{
IMFTransform IMFTransform_iface;
LONG refcount;
IMFMediaType *input_type;
};
static struct h264_decoder *impl_from_IMFTransform(IMFTransform *iface)
@ -77,7 +84,11 @@ static ULONG WINAPI transform_Release(IMFTransform *iface)
TRACE("iface %p decreasing refcount to %lu.\n", decoder, refcount);
if (!refcount)
{
if (decoder->input_type)
IMFMediaType_Release(decoder->input_type);
free(decoder);
}
return refcount;
}
@ -163,8 +174,31 @@ static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWOR
static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
{
FIXME("iface %p, id %#lx, type %p, flags %#lx stub!\n", iface, id, type, flags);
return E_NOTIMPL;
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
GUID major, subtype;
HRESULT hr;
ULONG i;
TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) ||
FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
return E_INVALIDARG;
if (!IsEqualGUID(&major, &MFMediaType_Video))
return MF_E_INVALIDMEDIATYPE;
for (i = 0; i < ARRAY_SIZE(h264_decoder_input_types); ++i)
if (IsEqualGUID(&subtype, h264_decoder_input_types[i]))
break;
if (i == ARRAY_SIZE(h264_decoder_input_types))
return MF_E_INVALIDMEDIATYPE;
if (decoder->input_type)
IMFMediaType_Release(decoder->input_type);
IMFMediaType_AddRef((decoder->input_type = type));
return S_OK;
}
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)