Module: wine Branch: master Commit: 2fef494765deccb98258d749e876e663081e90e1 URL: https://gitlab.winehq.org/wine/wine/-/commit/2fef494765deccb98258d749e876e66...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon May 6 11:42:50 2024 +0200
winegstreamer: Enforce default stride presence in the video processor.
---
dlls/mf/tests/transform.c | 1 - dlls/winegstreamer/video_processor.c | 40 +++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index febb1e33365..38e31af97c1 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -9377,7 +9377,6 @@ static void test_video_processor_with_dxgi_manager(void) IMFSample_Release(output.pSample);
ret = check_mf_sample_collection(output_samples, &output_sample_desc_rgb32, L"rgb32frame.bmp"); - todo_wine /* FIXME: video process vertically flips the frame... */ ok(ret <= 5, "got %lu%% diff\n", ret);
for (i = 0; i < 9; i++) diff --git a/dlls/winegstreamer/video_processor.c b/dlls/winegstreamer/video_processor.c index 6cc504727a9..2461140ab21 100644 --- a/dlls/winegstreamer/video_processor.c +++ b/dlls/winegstreamer/video_processor.c @@ -91,9 +91,36 @@ struct video_processor IMFVideoSampleAllocatorEx *allocator; };
+static HRESULT normalize_stride(IMFMediaType *media_type, BOOL bottom_up, IMFMediaType **ret) +{ + MFVIDEOFORMAT *format; + LONG stride; + UINT32 size; + HRESULT hr; + + if (SUCCEEDED(hr = IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, (UINT32 *)&stride))) + { + *ret = media_type; + IMFMediaType_AddRef(media_type); + return hr; + } + + if (SUCCEEDED(hr = MFCreateMFVideoFormatFromMFMediaType(media_type, &format, &size))) + { + if (bottom_up) format->videoInfo.VideoFlags |= MFVideoFlag_BottomUpLinearRep; + hr = MFCreateVideoMediaType(format, (IMFVideoMediaType **)ret); + CoTaskMemFree(format); + } + + return hr; +} + static HRESULT try_create_wg_transform(struct video_processor *impl) { + BOOL bottom_up = !impl->device_manager; /* when not D3D-enabled, the transform outputs bottom up RGB buffers */ + IMFMediaType *input_type, *output_type; struct wg_transform_attrs attrs = {0}; + HRESULT hr;
if (impl->wg_transform) { @@ -101,7 +128,18 @@ static HRESULT try_create_wg_transform(struct video_processor *impl) impl->wg_transform = 0; }
- return wg_transform_create_mf(impl->input_type, impl->output_type, &attrs, &impl->wg_transform); + if (FAILED(hr = normalize_stride(impl->input_type, bottom_up, &input_type))) + return hr; + if (FAILED(hr = normalize_stride(impl->output_type, bottom_up, &output_type))) + { + IMFMediaType_Release(input_type); + return hr; + } + hr = wg_transform_create_mf(input_type, output_type, &attrs, &impl->wg_transform); + IMFMediaType_Release(output_type); + IMFMediaType_Release(input_type); + + return hr; }
static HRESULT video_processor_init_allocator(struct video_processor *processor)