From: Ziqing Hui zhui@codeweavers.com
--- dlls/winegstreamer/video_encoder.c | 67 +++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-)
diff --git a/dlls/winegstreamer/video_encoder.c b/dlls/winegstreamer/video_encoder.c index 0c54bc543a2..b374b919f92 100644 --- a/dlls/winegstreamer/video_encoder.c +++ b/dlls/winegstreamer/video_encoder.c @@ -38,6 +38,8 @@ struct video_encoder IMFTransform IMFTransform_iface; LONG refcount;
+ const GUID *const *input_types; + UINT input_type_count; const GUID *const *output_types; UINT output_type_count;
@@ -174,8 +176,51 @@ static HRESULT WINAPI transform_AddInputStreams(IMFTransform *iface, DWORD strea static HRESULT WINAPI transform_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index, IMFMediaType **type) { - FIXME("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type); - return E_NOTIMPL; + struct video_encoder *encoder = impl_from_IMFTransform(iface); + IMFVideoMediaType *input_type; + UINT64 ratio; + UINT32 value; + HRESULT hr; + + TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type); + + *type = NULL; + + if (!encoder->output_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + if (index >= encoder->input_type_count) + return MF_E_NO_MORE_TYPES; + + if (!(hr = MFCreateVideoMediaTypeFromSubtype(encoder->input_types[index], &input_type))) + return hr; + + if (FAILED(hr = IMFMediaType_GetUINT64(encoder->output_type, &MF_MT_FRAME_SIZE, &ratio)) + || FAILED(hr = IMFVideoMediaType_SetUINT64(input_type, &MF_MT_FRAME_SIZE, ratio))) + goto done; + + if (FAILED(hr = IMFMediaType_GetUINT64(encoder->output_type, &MF_MT_FRAME_RATE, &ratio)) + || FAILED(hr = IMFVideoMediaType_SetUINT64(input_type, &MF_MT_FRAME_RATE, ratio))) + goto done; + + if (FAILED(hr = IMFMediaType_GetUINT32(encoder->output_type, &MF_MT_INTERLACE_MODE, &value)) + || FAILED(hr = IMFVideoMediaType_SetUINT32(input_type, &MF_MT_INTERLACE_MODE, value))) + goto done; + + if (FAILED(IMFMediaType_GetUINT32(encoder->output_type, &MF_MT_VIDEO_NOMINAL_RANGE, &value))) + value = MFNominalRange_Wide; + if (FAILED(hr = IMFVideoMediaType_SetUINT32(input_type, &MF_MT_VIDEO_NOMINAL_RANGE, value))) + goto done; + + if (FAILED(IMFMediaType_GetUINT64(encoder->output_type, &MF_MT_PIXEL_ASPECT_RATIO, &ratio))) + ratio = (UINT64)1 << 32 | 1; + if (FAILED(hr = IMFVideoMediaType_SetUINT64(input_type, &MF_MT_PIXEL_ASPECT_RATIO, ratio))) + goto done; + + IMFMediaType_AddRef((*type = (IMFMediaType *)input_type)); + +done: + IMFVideoMediaType_Release(input_type); + return hr; }
static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWORD id, @@ -345,8 +390,8 @@ static const IMFTransformVtbl transform_vtbl = transform_ProcessOutput, };
-static HRESULT video_encoder_create(const GUID *const *output_types, UINT output_type_count, - struct video_encoder **out) +static HRESULT video_encoder_create(const GUID *const *input_types, UINT input_type_count, + const GUID *const *output_types, UINT output_type_count, struct video_encoder **out) { struct video_encoder *encoder; HRESULT hr; @@ -357,6 +402,8 @@ static HRESULT video_encoder_create(const GUID *const *output_types, UINT output encoder->IMFTransform_iface.lpVtbl = &transform_vtbl; encoder->refcount = 1;
+ encoder->input_types = input_types; + encoder->input_type_count = input_type_count; encoder->output_types = output_types; encoder->output_type_count = output_type_count;
@@ -376,6 +423,14 @@ failed: return hr; }
+static const GUID *const h264_encoder_input_types[] = +{ + &MFVideoFormat_IYUV, + &MFVideoFormat_YV12, + &MFVideoFormat_NV12, + &MFVideoFormat_YUY2, +}; + static const GUID *const h264_encoder_output_types[] = { &MFVideoFormat_H264, @@ -406,8 +461,8 @@ HRESULT h264_encoder_create(REFIID riid, void **out) return hr; }
- if (FAILED(hr = video_encoder_create(h264_encoder_output_types, ARRAY_SIZE(h264_encoder_output_types), - &encoder))) + if (FAILED(hr = video_encoder_create(h264_encoder_input_types, ARRAY_SIZE(h264_encoder_input_types), + h264_encoder_output_types, ARRAY_SIZE(h264_encoder_output_types), &encoder))) return hr;
TRACE("Created h264 encoder transform %p.\n", &encoder->IMFTransform_iface);
From: Ziqing Hui zhui@codeweavers.com
--- 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);
From: Ziqing Hui zhui@codeweavers.com
--- dlls/winegstreamer/video_encoder.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/winegstreamer/video_encoder.c b/dlls/winegstreamer/video_encoder.c index a78cbfffdc5..cfdd5be9d50 100644 --- a/dlls/winegstreamer/video_encoder.c +++ b/dlls/winegstreamer/video_encoder.c @@ -349,8 +349,19 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) { - FIXME("iface %p, id %#lx, type %p\n", iface, id, type); - return E_NOTIMPL; + struct video_encoder *encoder = impl_from_IMFTransform(iface); + HRESULT hr; + + TRACE("iface %p, id %#lx, type %p\n", iface, id, type); + + if (!encoder->input_type) + return MF_E_TRANSFORM_TYPE_NOT_SET; + + if (FAILED(hr = MFCreateMediaType(type))) + return hr; + + return IMFMediaType_CopyAllItems(encoder->input_type, (IMFAttributes *)*type); + }
static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146675
Your paranoid android.
=== debian11b (64 bit WoW report) ===
kernel32: comm.c:1574: Test failed: AbortWaitCts hComPortEvent failed comm.c:1586: Test failed: Unexpected time 1001, expected around 500
This merge request was approved by Rémi Bernon.