[PATCH 3/3] mfplat: Add MFGetPlaneSize().
Nikolay Sivov
nsivov at codeweavers.com
Mon Mar 9 11:39:25 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/mfplat/mediatype.c | 32 ++++++++++++++++++++++++++------
dlls/mfplat/mfplat.spec | 2 +-
dlls/mfplat/tests/mfplat.c | 14 ++++++++++++++
include/mfapi.h | 1 +
4 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c
index 69b302ca89..6b67f5b33c 100644
--- a/dlls/mfplat/mediatype.c
+++ b/dlls/mfplat/mediatype.c
@@ -1737,10 +1737,7 @@ static int __cdecl uncompressed_video_format_compare(const void *a, const void *
return memcmp(guid, format->subtype, sizeof(*guid));
}
-/***********************************************************************
- * MFCalculateImageSize (mfplat.@)
- */
-HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height, UINT32 *size)
+static HRESULT mf_get_image_size(REFGUID subtype, unsigned int width, unsigned int height, unsigned int *size)
{
static const struct uncompressed_video_format video_formats[] =
{
@@ -1755,8 +1752,6 @@ HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height
};
struct uncompressed_video_format *format;
- TRACE("%s, %u, %u, %p.\n", debugstr_mf_guid(subtype), width, height, size);
-
format = bsearch(subtype, video_formats, ARRAY_SIZE(video_formats), sizeof(*video_formats),
uncompressed_video_format_compare);
if (format)
@@ -1771,6 +1766,31 @@ HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height
return format ? S_OK : E_INVALIDARG;
}
+/***********************************************************************
+ * MFCalculateImageSize (mfplat.@)
+ */
+HRESULT WINAPI MFCalculateImageSize(REFGUID subtype, UINT32 width, UINT32 height, UINT32 *size)
+{
+ TRACE("%s, %u, %u, %p.\n", debugstr_mf_guid(subtype), width, height, size);
+
+ return mf_get_image_size(subtype, width, height, size);
+}
+
+/***********************************************************************
+ * MFGetPlaneSize (mfplat.@)
+ */
+HRESULT WINAPI MFGetPlaneSize(DWORD format, DWORD width, DWORD height, DWORD *size)
+{
+ GUID subtype;
+
+ TRACE("%#x, %u, %u, %p.\n", format, width, height, size);
+
+ memcpy(&subtype, &MFVideoFormat_Base, sizeof(subtype));
+ subtype.Data1 = format;
+
+ return mf_get_image_size(&subtype, width, height, size);
+}
+
/***********************************************************************
* MFCompareFullToPartialMediaType (mfplat.@)
*/
diff --git a/dlls/mfplat/mfplat.spec b/dlls/mfplat/mfplat.spec
index 7e3bd4571c..1e11a1fc2a 100644
--- a/dlls/mfplat/mfplat.spec
+++ b/dlls/mfplat/mfplat.spec
@@ -96,7 +96,7 @@
@ stub MFGetConfigurationString
@ stub MFGetMFTMerit
@ stub MFGetNumericNameFromSockaddr
-@ stub MFGetPlaneSize
+@ stdcall MFGetPlaneSize(long long long ptr)
@ stub MFGetPlatform
@ stdcall MFGetPluginControl(ptr)
@ stub MFGetPrivateWorkqueues
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index a93bbfe7f1..36fe9dc831 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -91,6 +91,7 @@ static HRESULT (WINAPI *pMFTUnregisterLocalByCLSID)(CLSID clsid);
static HRESULT (WINAPI *pMFAllocateWorkQueueEx)(MFASYNC_WORKQUEUE_TYPE queue_type, DWORD *queue);
static HRESULT (WINAPI *pMFTEnumEx)(GUID category, UINT32 flags, const MFT_REGISTER_TYPE_INFO *input_type,
const MFT_REGISTER_TYPE_INFO *output_type, IMFActivate ***activate, UINT32 *count);
+static HRESULT (WINAPI *pMFGetPlaneSize)(DWORD format, DWORD width, DWORD height, DWORD *size);
static const WCHAR fileschemeW[] = L"file://";
@@ -662,6 +663,7 @@ static void init_functions(void)
X(MFCreateSourceResolver);
X(MFCreateMFByteStreamOnStream);
X(MFCreateTransformActivate);
+ X(MFGetPlaneSize);
X(MFHeapAlloc);
X(MFHeapFree);
X(MFPutWaitingWorkItem);
@@ -3184,6 +3186,9 @@ static void test_MFCalculateImageSize(void)
UINT32 size;
HRESULT hr;
+ if (!pMFGetPlaneSize)
+ win_skip("MFGetPlaneSize() is not available.\n");
+
size = 1;
hr = MFCalculateImageSize(&IID_IUnknown, 1, 1, &size);
ok(hr == E_INVALIDARG || broken(hr == S_OK) /* Vista */, "Unexpected hr %#x.\n", hr);
@@ -3200,6 +3205,15 @@ static void test_MFCalculateImageSize(void)
ok(hr == S_OK || (is_broken && hr == E_INVALIDARG), "%u: failed to calculate image size, hr %#x.\n", i, hr);
ok(size == image_size_tests[i].size, "%u: unexpected image size %u, expected %u.\n", i, size,
image_size_tests[i].size);
+
+ if (pMFGetPlaneSize)
+ {
+ hr = pMFGetPlaneSize(image_size_tests[i].subtype->Data1, image_size_tests[i].width, image_size_tests[i].height,
+ &size);
+ ok(hr == S_OK, "%u: failed to get plane size, hr %#x.\n", i, hr);
+ ok(size == image_size_tests[i].size, "%u: unexpected plane size %u, expected %u.\n", i, size,
+ image_size_tests[i].size);
+ }
}
}
diff --git a/include/mfapi.h b/include/mfapi.h
index 6636057daa..38577cfe62 100644
--- a/include/mfapi.h
+++ b/include/mfapi.h
@@ -421,6 +421,7 @@ void * WINAPI MFHeapAlloc(SIZE_T size, ULONG flags, char *file, int line, EAllo
void WINAPI MFHeapFree(void *ptr);
HRESULT WINAPI MFGetAttributesAsBlob(IMFAttributes *attributes, UINT8 *buffer, UINT size);
HRESULT WINAPI MFGetAttributesAsBlobSize(IMFAttributes *attributes, UINT32 *size);
+HRESULT WINAPI MFGetPlaneSize(DWORD format, DWORD width, DWORD height, DWORD *size);
HRESULT WINAPI MFGetTimerPeriodicity(DWORD *periodicity);
HRESULT WINAPI MFTEnum(GUID category, UINT32 flags, MFT_REGISTER_TYPE_INFO *input_type,
MFT_REGISTER_TYPE_INFO *output_type, IMFAttributes *attributes,
--
2.25.1
More information about the wine-devel
mailing list