mfplat: Add MFGetPlaneSize().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-03-09 19:39:25 +03:00 committed by Alexandre Julliard
parent 50af05674c
commit 673d984934
4 changed files with 42 additions and 7 deletions

View file

@ -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.@)
*/

View file

@ -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

View file

@ -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);
}
}
}

View file

@ -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,