Module: wine Branch: master Commit: 6f22111a9f630dd823cbb1bc9700f63f87b24419 URL: https://gitlab.winehq.org/wine/wine/-/commit/6f22111a9f630dd823cbb1bc9700f63...
Author: Ziqing Hui zhui@codeweavers.com Date: Fri Jun 28 14:14:30 2024 +0800
winegstreamer/video_encoder: Implement SetInputType.
---
dlls/winegstreamer/video_encoder.c | 56 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/dlls/winegstreamer/video_encoder.c b/dlls/winegstreamer/video_encoder.c index b374b919f92..a78cbfffdc5 100644 --- a/dlls/winegstreamer/video_encoder.c +++ b/dlls/winegstreamer/video_encoder.c @@ -43,6 +43,7 @@ struct video_encoder const GUID *const *output_types; UINT output_type_count;
+ IMFMediaType *input_type; IMFMediaType *output_type;
IMFAttributes *attributes; @@ -91,6 +92,8 @@ static ULONG WINAPI transform_Release(IMFTransform *iface)
if (!refcount) { + if (encoder->input_type) + IMFMediaType_Release(encoder->input_type); if (encoder->output_type) IMFMediaType_Release(encoder->output_type); IMFAttributes_Release(encoder->attributes); @@ -238,8 +241,52 @@ 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.\n", iface, id, type, flags); - return E_NOTIMPL; + struct video_encoder *encoder = impl_from_IMFTransform(iface); + GUID major, subtype; + UINT64 ratio; + ULONG i; + + TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags); + + if (!type) + { + if (encoder->input_type) + { + IMFMediaType_Release(encoder->input_type); + encoder->input_type = NULL; + } + + return S_OK; + } + + if (!encoder->output_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || + FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) + return E_INVALIDARG; + + if (!IsEqualGUID(&major, &MFMediaType_Video)) + return MF_E_INVALIDMEDIATYPE; + + for (i = 0; i < encoder->input_type_count; ++i) + if (IsEqualGUID(&subtype, encoder->input_types[i])) + break; + if (i == encoder->input_type_count) + return MF_E_INVALIDMEDIATYPE; + + if (FAILED(IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &ratio)) + || FAILED(IMFMediaType_GetUINT64(type, &MF_MT_FRAME_RATE, &ratio))) + return MF_E_INVALIDMEDIATYPE; + + if (flags & MFT_SET_TYPE_TEST_ONLY) + return S_OK; + + if (encoder->input_type) + IMFMediaType_Release(encoder->input_type); + IMFMediaType_AddRef((encoder->input_type = type)); + + return S_OK; }
static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) @@ -254,6 +301,11 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
if (!type) { + if (encoder->input_type) + { + IMFMediaType_Release(encoder->input_type); + encoder->input_type = NULL; + } if (encoder->output_type) { IMFMediaType_Release(encoder->output_type);