From 6163b3331fbca57af1ff8ba530927086d360589b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 7 Oct 2020 11:40:22 +0300 Subject: [PATCH] evr/presenter: Initialize aspect ratio mode. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/evr/presenter.c | 28 ++++++++++++++++++++++++---- dlls/evr/tests/evr.c | 32 ++++++++++++++++++++++++++++++++ include/evr.idl | 9 +++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/dlls/evr/presenter.c b/dlls/evr/presenter.c index ecfa9234426..8fcd6d58b3c 100644 --- a/dlls/evr/presenter.c +++ b/dlls/evr/presenter.c @@ -64,6 +64,7 @@ struct video_presenter DWORD rendering_prefs; SIZE native_size; SIZE native_ratio; + unsigned int ar_mode; unsigned int state; CRITICAL_SECTION cs; }; @@ -669,16 +670,34 @@ static HRESULT WINAPI video_presenter_control_GetVideoPosition(IMFVideoDisplayCo static HRESULT WINAPI video_presenter_control_SetAspectRatioMode(IMFVideoDisplayControl *iface, DWORD mode) { - FIXME("%p, %d.\n", iface, mode); + struct video_presenter *presenter = impl_from_IMFVideoDisplayControl(iface); - return E_NOTIMPL; + TRACE("%p, %#x.\n", iface, mode); + + if (mode & ~MFVideoARMode_Mask) + return E_INVALIDARG; + + EnterCriticalSection(&presenter->cs); + presenter->ar_mode = mode; + LeaveCriticalSection(&presenter->cs); + + return S_OK; } static HRESULT WINAPI video_presenter_control_GetAspectRatioMode(IMFVideoDisplayControl *iface, DWORD *mode) { - FIXME("%p, %p.\n", iface, mode); + struct video_presenter *presenter = impl_from_IMFVideoDisplayControl(iface); - return E_NOTIMPL; + TRACE("%p, %p.\n", iface, mode); + + if (!mode) + return E_POINTER; + + EnterCriticalSection(&presenter->cs); + *mode = presenter->ar_mode; + LeaveCriticalSection(&presenter->cs); + + return S_OK; } static HRESULT WINAPI video_presenter_control_SetVideoWindow(IMFVideoDisplayControl *iface, HWND window) @@ -969,6 +988,7 @@ HRESULT evr_presenter_create(IUnknown *outer, void **out) object->outer_unk = outer ? outer : &object->IUnknown_inner; object->refcount = 1; object->src_rect.right = object->src_rect.bottom = 1.0f; + object->ar_mode = MFVideoARMode_PreservePicture | MFVideoARMode_PreservePixel; InitializeCriticalSection(&object->cs); if (FAILED(hr = DXVA2CreateDirect3DDeviceManager9(&object->reset_token, &object->device_manager))) diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index e7eabc5971a..3ae36d9b5df 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -1654,6 +1654,37 @@ static void test_presenter_native_video_size(void) IMFTransform_Release(mixer); } +static void test_presenter_ar_mode(void) +{ + IMFVideoDisplayControl *display_control; + HRESULT hr; + DWORD mode; + + hr = MFCreateVideoPresenter(NULL, &IID_IDirect3DDevice9, &IID_IMFVideoDisplayControl, (void **)&display_control); + ok(hr == S_OK, "Failed to create default presenter, hr %#x.\n", hr); + + hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, NULL); + ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr); + + mode = 0; + hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, &mode); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(mode == (MFVideoARMode_PreservePicture | MFVideoARMode_PreservePixel), "Unexpected mode %#x.\n", mode); + + hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, 0x100); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IMFVideoDisplayControl_SetAspectRatioMode(display_control, MFVideoARMode_Mask); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + mode = 0; + hr = IMFVideoDisplayControl_GetAspectRatioMode(display_control, &mode); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(mode == MFVideoARMode_Mask, "Unexpected mode %#x.\n", mode); + + IMFVideoDisplayControl_Release(display_control); +} + static void test_mixer_output_rectangle(void) { IMFVideoMixerControl *mixer_control; @@ -1836,6 +1867,7 @@ START_TEST(evr) test_MFCreateVideoSampleAllocator(); test_presenter_video_position(); test_presenter_native_video_size(); + test_presenter_ar_mode(); test_mixer_output_rectangle(); test_mixer_zorder(); diff --git a/include/evr.idl b/include/evr.idl index c2178835383..413f5af1d47 100644 --- a/include/evr.idl +++ b/include/evr.idl @@ -228,6 +228,15 @@ interface IMFDesiredSample : IUnknown void Clear(); } +typedef enum MFVideoAspectRatioMode +{ + MFVideoARMode_None = 0x00000000, + MFVideoARMode_PreservePicture = 0x00000001, + MFVideoARMode_PreservePixel = 0x00000002, + MFVideoARMode_NonLinearStretch = 0x00000004, + MFVideoARMode_Mask = 0x00000007, +} MFVideoAspectRatioMode; + [ object, uuid(a490b1e4-ab84-4d31-a1b2-181e03b1077a),