Nikolay Sivov : mfplat: Implement MFInitVideoFormat_RGB().
Alexandre Julliard
julliard at winehq.org
Mon May 31 15:58:39 CDT 2021
Module: wine
Branch: master
Commit: 31f4ad064ee49c472725960a4599399609279977
URL: https://source.winehq.org/git/wine.git/?a=commit;h=31f4ad064ee49c472725960a4599399609279977
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon May 31 13:31:15 2021 +0300
mfplat: Implement MFInitVideoFormat_RGB().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/evr/evr.spec | 2 +-
dlls/mfplat/mediatype.c | 52 ++++++++++++++++++++++
dlls/mfplat/mfplat.spec | 2 +-
dlls/mfplat/tests/mfplat.c | 106 +++++++++++++++++++++++++++++++++++++++++++++
include/mfapi.h | 1 +
5 files changed, 161 insertions(+), 2 deletions(-)
diff --git a/dlls/evr/evr.spec b/dlls/evr/evr.spec
index 67eee3122cf..a655e1cdd07 100644
--- a/dlls/evr/evr.spec
+++ b/dlls/evr/evr.spec
@@ -24,5 +24,5 @@
@ stub MFGetStrideForBitmapInfoHeader
@ stub MFGetUncompressedVideoFormat
@ stub MFInitVideoFormat
-@ stub MFInitVideoFormat_RGB
+@ stdcall -import MFInitVideoFormat_RGB(ptr long long long)
@ stub MFIsFormatYUV
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c
index 61f1a75d90b..4f24ccbd237 100644
--- a/dlls/mfplat/mediatype.c
+++ b/dlls/mfplat/mediatype.c
@@ -3443,3 +3443,55 @@ DXGI_FORMAT WINAPI MFMapDX9FormatToDXGIFormat(DWORD format)
return DXGI_FORMAT_UNKNOWN;
}
}
+
+/***********************************************************************
+ * MFInitVideoFormat_RGB (mfplat.@)
+ */
+HRESULT WINAPI MFInitVideoFormat_RGB(MFVIDEOFORMAT *format, DWORD width, DWORD height, DWORD d3dformat)
+{
+ unsigned int transfer_function;
+
+ TRACE("%p, %u, %u, %#x.\n", format, width, height, d3dformat);
+
+ if (!format)
+ return E_INVALIDARG;
+
+ if (!d3dformat) d3dformat = D3DFMT_X8R8G8B8;
+
+ switch (d3dformat)
+ {
+ case D3DFMT_X8R8G8B8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_A8R8G8B8:
+ case D3DFMT_R5G6B5:
+ case D3DFMT_X1R5G5B5:
+ case D3DFMT_A2B10G10R10:
+ case D3DFMT_P8:
+ transfer_function = MFVideoTransFunc_sRGB;
+ break;
+ default:
+ transfer_function = MFVideoTransFunc_10;
+ }
+
+ memset(format, 0, sizeof(*format));
+ format->dwSize = sizeof(*format);
+ format->videoInfo.dwWidth = width;
+ format->videoInfo.dwHeight = height;
+ format->videoInfo.PixelAspectRatio.Numerator = 1;
+ format->videoInfo.PixelAspectRatio.Denominator = 1;
+ format->videoInfo.InterlaceMode = MFVideoInterlace_Progressive;
+ format->videoInfo.TransferFunction = transfer_function;
+ format->videoInfo.ColorPrimaries = MFVideoPrimaries_BT709;
+ format->videoInfo.SourceLighting = MFVideoLighting_office;
+ format->videoInfo.FramesPerSecond.Numerator = 60;
+ format->videoInfo.FramesPerSecond.Denominator = 1;
+ format->videoInfo.NominalRange = MFNominalRange_Normal;
+ format->videoInfo.GeometricAperture.Area.cx = width;
+ format->videoInfo.GeometricAperture.Area.cy = height;
+ format->videoInfo.MinimumDisplayAperture = format->videoInfo.GeometricAperture;
+ memcpy(&format->guidFormat, &MFVideoFormat_Base, sizeof(format->guidFormat));
+ format->guidFormat.Data1 = d3dformat;
+ format->surfaceInfo.Format = d3dformat;
+
+ return S_OK;
+}
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec
index 9a78c2fb0bc..6cc3fb07105 100644
--- a/dlls/mfplat/mfplat.spec
+++ b/dlls/mfplat/mfplat.spec
@@ -127,7 +127,7 @@
@ stub MFInitMediaTypeFromVideoInfoHeader
@ stdcall MFInitMediaTypeFromWaveFormatEx(ptr ptr long)
@ stub MFInitVideoFormat
-@ stub MFInitVideoFormat_RGB
+@ stdcall MFInitVideoFormat_RGB(ptr long long long)
@ stdcall MFInvokeCallback(ptr)
@ stub MFJoinIoPort
@ stdcall MFJoinWorkQueue(long long ptr) rtworkq.RtwqJoinWorkQueue
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 65ab72bd57b..ae9bd60c6df 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -264,6 +264,7 @@ static HRESULT (WINAPI *pMFCreateVideoMediaTypeFromSubtype)(const GUID *subtype,
static HRESULT (WINAPI *pMFLockSharedWorkQueue)(const WCHAR *name, LONG base_priority, DWORD *taskid, DWORD *queue);
static HRESULT (WINAPI *pMFLockDXGIDeviceManager)(UINT *token, IMFDXGIDeviceManager **manager);
static HRESULT (WINAPI *pMFUnlockDXGIDeviceManager)(void);
+static HRESULT (WINAPI *pMFInitVideoFormat_RGB)(MFVIDEOFORMAT *format, DWORD width, DWORD height, DWORD d3dformat);
static HWND create_window(void)
{
@@ -937,6 +938,7 @@ static void init_functions(void)
X(MFCreateVideoSampleAllocatorEx);
X(MFGetPlaneSize);
X(MFGetStrideForBitmapInfoHeader);
+ X(MFInitVideoFormat_RGB);
X(MFLockDXGIDeviceManager);
X(MFLockSharedWorkQueue);
X(MFMapDX9FormatToDXGIFormat);
@@ -7206,6 +7208,109 @@ static void test_shared_dxgi_device_manager(void)
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
}
+static void check_video_format(const MFVIDEOFORMAT *format, unsigned int width, unsigned int height,
+ DWORD d3dformat)
+{
+ unsigned int transfer_function;
+ GUID guid;
+
+ if (!d3dformat) d3dformat = D3DFMT_X8R8G8B8;
+
+ switch (d3dformat)
+ {
+ case D3DFMT_X8R8G8B8:
+ case D3DFMT_R8G8B8:
+ case D3DFMT_A8R8G8B8:
+ case D3DFMT_R5G6B5:
+ case D3DFMT_X1R5G5B5:
+ case D3DFMT_A2B10G10R10:
+ case D3DFMT_P8:
+ transfer_function = MFVideoTransFunc_sRGB;
+ break;
+ default:
+ transfer_function = MFVideoTransFunc_10;
+ }
+
+ memcpy(&guid, &MFVideoFormat_Base, sizeof(guid));
+ guid.Data1 = d3dformat;
+
+ ok(format->dwSize == sizeof(*format), "Unexpected format size.\n");
+ ok(format->videoInfo.dwWidth == width, "Unexpected width %u.\n", format->videoInfo.dwWidth);
+ ok(format->videoInfo.dwHeight == height, "Unexpected height %u.\n", format->videoInfo.dwHeight);
+ ok(format->videoInfo.PixelAspectRatio.Numerator == 1 &&
+ format->videoInfo.PixelAspectRatio.Denominator == 1, "Unexpected PAR.\n");
+ ok(format->videoInfo.SourceChromaSubsampling == MFVideoChromaSubsampling_Unknown, "Unexpected chroma subsampling.\n");
+ ok(format->videoInfo.InterlaceMode == MFVideoInterlace_Progressive, "Unexpected interlace mode %u.\n",
+ format->videoInfo.InterlaceMode);
+ ok(format->videoInfo.TransferFunction == transfer_function, "Unexpected transfer function %u.\n",
+ format->videoInfo.TransferFunction);
+ ok(format->videoInfo.ColorPrimaries == MFVideoPrimaries_BT709, "Unexpected color primaries %u.\n",
+ format->videoInfo.ColorPrimaries);
+ ok(format->videoInfo.TransferMatrix == MFVideoTransferMatrix_Unknown, "Unexpected transfer matrix.\n");
+ ok(format->videoInfo.SourceLighting == MFVideoLighting_office, "Unexpected source lighting %u.\n",
+ format->videoInfo.SourceLighting);
+ ok(format->videoInfo.FramesPerSecond.Numerator == 60 &&
+ format->videoInfo.FramesPerSecond.Denominator == 1, "Unexpected frame rate %u/%u.\n",
+ format->videoInfo.FramesPerSecond.Numerator, format->videoInfo.FramesPerSecond.Denominator);
+ ok(format->videoInfo.NominalRange == MFNominalRange_Normal, "Unexpected nominal range %u.\n",
+ format->videoInfo.NominalRange);
+ ok(format->videoInfo.GeometricAperture.Area.cx == width && format->videoInfo.GeometricAperture.Area.cy == height,
+ "Unexpected geometric aperture.\n");
+ ok(!memcmp(&format->videoInfo.GeometricAperture, &format->videoInfo.MinimumDisplayAperture, sizeof(MFVideoArea)),
+ "Unexpected minimum display aperture.\n");
+ ok(format->videoInfo.PanScanAperture.Area.cx == 0 && format->videoInfo.PanScanAperture.Area.cy == 0,
+ "Unexpected geometric aperture.\n");
+ ok(format->videoInfo.VideoFlags == 0, "Unexpected video flags.\n");
+ ok(IsEqualGUID(&format->guidFormat, &guid), "Unexpected format guid %s.\n", wine_dbgstr_guid(&format->guidFormat));
+ ok(format->compressedInfo.AvgBitrate == 0, "Unexpected bitrate.\n");
+ ok(format->compressedInfo.AvgBitErrorRate == 0, "Unexpected error bitrate.\n");
+ ok(format->compressedInfo.MaxKeyFrameSpacing == 0, "Unexpected MaxKeyFrameSpacing.\n");
+ ok(format->surfaceInfo.Format == d3dformat, "Unexpected format %u.\n", format->surfaceInfo.Format);
+ ok(format->surfaceInfo.PaletteEntries == 0, "Unexpected palette size %u.\n", format->surfaceInfo.PaletteEntries);
+}
+
+static void test_MFInitVideoFormat_RGB(void)
+{
+ static const DWORD formats[] =
+ {
+ 0, /* same D3DFMT_X8R8G8B8 */
+ D3DFMT_X8R8G8B8,
+ D3DFMT_R8G8B8,
+ D3DFMT_A8R8G8B8,
+ D3DFMT_R5G6B5,
+ D3DFMT_X1R5G5B5,
+ D3DFMT_A2B10G10R10,
+ D3DFMT_P8,
+ D3DFMT_L8,
+ D3DFMT_YUY2,
+ D3DFMT_DXT1,
+ D3DFMT_D16,
+ D3DFMT_L16,
+ D3DFMT_A16B16G16R16F,
+ };
+ MFVIDEOFORMAT format;
+ unsigned int i;
+ HRESULT hr;
+
+ if (!pMFInitVideoFormat_RGB)
+ {
+ win_skip("MFInitVideoFormat_RGB is not available.\n");
+ return;
+ }
+
+ hr = pMFInitVideoFormat_RGB(NULL, 64, 32, 0);
+ ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
+ {
+ memset(&format, 0, sizeof(format));
+ hr = pMFInitVideoFormat_RGB(&format, 64, 32, formats[i]);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ if (SUCCEEDED(hr))
+ check_video_format(&format, 64, 32, formats[i]);
+ }
+}
+
START_TEST(mfplat)
{
char **argv;
@@ -7272,6 +7377,7 @@ START_TEST(mfplat)
test_MFMapDX9FormatToDXGIFormat();
test_MFllMulDiv();
test_shared_dxgi_device_manager();
+ test_MFInitVideoFormat_RGB();
CoUninitialize();
}
diff --git a/include/mfapi.h b/include/mfapi.h
index a3945bd3a7d..e4a1f6a3dc0 100644
--- a/include/mfapi.h
+++ b/include/mfapi.h
@@ -552,6 +552,7 @@ HRESULT WINAPI MFTEnumEx(GUID category, UINT32 flags, const MFT_REGISTER_TYPE_IN
UINT32 *pcount);
HRESULT WINAPI MFInitAttributesFromBlob(IMFAttributes *attributes, const UINT8 *buffer, UINT size);
HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WAVEFORMATEX *format, UINT32 size);
+HRESULT WINAPI MFInitVideoFormat_RGB(MFVIDEOFORMAT *format, DWORD width, DWORD height, DWORD d3dformat);
HRESULT WINAPI MFInvokeCallback(IMFAsyncResult *result);
LONGLONG WINAPI MFllMulDiv(LONGLONG val, LONGLONG num, LONGLONG denom, LONGLONG factor);
HRESULT WINAPI MFLockDXGIDeviceManager(UINT *token, IMFDXGIDeviceManager **manager);
More information about the wine-cvs
mailing list