Commit 5668c1ce authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat: Added MFMapDX9FormatToDXGIFormat().

parent 50c66e0a
......@@ -3316,3 +3316,91 @@ DWORD WINAPI MFMapDXGIFormatToDX9Format(DXGI_FORMAT dxgi_format)
return 0;
}
}
/***********************************************************************
* MFMapDX9FormatToDXGIFormat (mfplat.@)
*/
DXGI_FORMAT WINAPI MFMapDX9FormatToDXGIFormat(DWORD format)
{
switch (format)
{
case D3DFMT_A32B32G32R32F:
return DXGI_FORMAT_R32G32B32A32_FLOAT;
case D3DFMT_A16B16G16R16F:
return DXGI_FORMAT_R16G16B16A16_FLOAT;
case D3DFMT_A16B16G16R16:
return DXGI_FORMAT_R16G16B16A16_UNORM;
case D3DFMT_Q16W16V16U16:
return DXGI_FORMAT_R16G16B16A16_SNORM;
case D3DFMT_G32R32F:
return DXGI_FORMAT_R32G32_FLOAT;
case D3DFMT_A2B10G10R10:
return DXGI_FORMAT_R10G10B10A2_UNORM;
case D3DFMT_Q8W8V8U8:
return DXGI_FORMAT_R8G8B8A8_SNORM;
case D3DFMT_G16R16F:
return DXGI_FORMAT_R16G16_FLOAT;
case D3DFMT_G16R16:
return DXGI_FORMAT_R16G16_UNORM;
case D3DFMT_V16U16:
return DXGI_FORMAT_R16G16_SNORM;
case D3DFMT_D32F_LOCKABLE:
return DXGI_FORMAT_D32_FLOAT;
case D3DFMT_R32F:
return DXGI_FORMAT_R32_FLOAT;
case D3DFMT_D24S8:
return DXGI_FORMAT_D24_UNORM_S8_UINT;
case D3DFMT_V8U8:
return DXGI_FORMAT_R8G8_SNORM;
case D3DFMT_R16F:
return DXGI_FORMAT_R16_FLOAT;
case D3DFMT_L16:
return DXGI_FORMAT_R16_UNORM;
case D3DFMT_L8:
return DXGI_FORMAT_R8_UNORM;
case D3DFMT_A8:
return DXGI_FORMAT_A8_UNORM;
case D3DFMT_DXT1:
return DXGI_FORMAT_BC1_UNORM;
case D3DFMT_DXT2:
return DXGI_FORMAT_BC2_UNORM;
case D3DFMT_DXT4:
return DXGI_FORMAT_BC3_UNORM;
case D3DFMT_A8R8G8B8:
return DXGI_FORMAT_B8G8R8A8_UNORM;
case D3DFMT_X8R8G8B8:
return DXGI_FORMAT_B8G8R8X8_UNORM;
case MAKEFOURCC('A','Y','U','V'):
return DXGI_FORMAT_AYUV;
case MAKEFOURCC('Y','4','1','0'):
return DXGI_FORMAT_Y410;
case MAKEFOURCC('Y','4','1','6'):
return DXGI_FORMAT_Y416;
case MAKEFOURCC('N','V','1','2'):
return DXGI_FORMAT_NV12;
case MAKEFOURCC('P','0','1','0'):
return DXGI_FORMAT_P010;
case MAKEFOURCC('P','0','1','6'):
return DXGI_FORMAT_P016;
case MAKEFOURCC('4','2','0','O'):
return DXGI_FORMAT_420_OPAQUE;
case D3DFMT_YUY2:
return DXGI_FORMAT_YUY2;
case MAKEFOURCC('Y','2','1','0'):
return DXGI_FORMAT_Y210;
case MAKEFOURCC('Y','2','1','6'):
return DXGI_FORMAT_Y216;
case MAKEFOURCC('N','V','1','1'):
return DXGI_FORMAT_NV11;
case MAKEFOURCC('A','I','4','4'):
return DXGI_FORMAT_AI44;
case MAKEFOURCC('I','A','4','4'):
return DXGI_FORMAT_IA44;
case D3DFMT_P8:
return DXGI_FORMAT_P8;
case D3DFMT_A8P8:
return DXGI_FORMAT_A8P8;
default:
return DXGI_FORMAT_UNKNOWN;
}
}
......@@ -131,6 +131,7 @@
@ stdcall MFJoinWorkQueue(long long ptr) rtworkq.RtwqJoinWorkQueue
@ stdcall MFLockPlatform() rtworkq.RtwqLockPlatform
@ stdcall MFLockWorkQueue(long) rtworkq.RtwqLockWorkQueue
@ stdcall MFMapDX9FormatToDXGIFormat(long)
@ stdcall MFMapDXGIFormatToDX9Format(long)
@ stdcall MFPutWaitingWorkItem(long long ptr ptr) rtworkq.RtwqPutWaitingWorkItem
@ stdcall MFPutWorkItem(long ptr ptr)
......
......@@ -131,6 +131,7 @@ static HRESULT (WINAPI *pMFCreateMediaBufferFromMediaType)(IMFMediaType *media_t
static HRESULT (WINAPI *pMFCreateDXSurfaceBuffer)(REFIID riid, IUnknown *surface, BOOL bottom_up, IMFMediaBuffer **buffer);
static HRESULT (WINAPI *pMFCreateTrackedSample)(IMFTrackedSample **sample);
static DWORD (WINAPI *pMFMapDXGIFormatToDX9Format)(DXGI_FORMAT dxgi_format);
static DXGI_FORMAT (WINAPI *pMFMapDX9FormatToDXGIFormat)(DWORD format);
static HRESULT (WINAPI *pMFCreateVideoSampleAllocatorEx)(REFIID riid, void **allocator);
static HRESULT (WINAPI *pMFCreateDXGISurfaceBuffer)(REFIID riid, IUnknown *surface, UINT subresource, BOOL bottomup,
IMFMediaBuffer **buffer);
......@@ -800,6 +801,7 @@ static void init_functions(void)
X(MFCreateVideoSampleAllocatorEx);
X(MFGetPlaneSize);
X(MFGetStrideForBitmapInfoHeader);
X(MFMapDX9FormatToDXGIFormat);
X(MFMapDXGIFormatToDX9Format);
X(MFPutWaitingWorkItem);
X(MFRegisterLocalByteStreamHandler);
......@@ -6038,6 +6040,71 @@ static void test_MFMapDXGIFormatToDX9Format(void)
}
}
static void test_MFMapDX9FormatToDXGIFormat(void)
{
static const struct format_pair
{
DXGI_FORMAT dxgi_format;
DWORD d3d9_format;
}
formats_map[] =
{
{ DXGI_FORMAT_R32G32B32A32_FLOAT, D3DFMT_A32B32G32R32F },
{ DXGI_FORMAT_R16G16B16A16_FLOAT, D3DFMT_A16B16G16R16F },
{ DXGI_FORMAT_R16G16B16A16_UNORM, D3DFMT_A16B16G16R16 },
{ DXGI_FORMAT_R16G16B16A16_SNORM, D3DFMT_Q16W16V16U16 },
{ DXGI_FORMAT_R32G32_FLOAT, D3DFMT_G32R32F },
{ DXGI_FORMAT_R10G10B10A2_UNORM, D3DFMT_A2B10G10R10 },
{ DXGI_FORMAT_R8G8B8A8_SNORM, D3DFMT_Q8W8V8U8 },
{ DXGI_FORMAT_R16G16_FLOAT, D3DFMT_G16R16F },
{ DXGI_FORMAT_R16G16_UNORM, D3DFMT_G16R16 },
{ DXGI_FORMAT_R16G16_SNORM, D3DFMT_V16U16 },
{ DXGI_FORMAT_D32_FLOAT, D3DFMT_D32F_LOCKABLE },
{ DXGI_FORMAT_R32_FLOAT, D3DFMT_R32F },
{ DXGI_FORMAT_D24_UNORM_S8_UINT, D3DFMT_D24S8 },
{ DXGI_FORMAT_R8G8_SNORM, D3DFMT_V8U8 },
{ DXGI_FORMAT_R16_FLOAT, D3DFMT_R16F },
{ DXGI_FORMAT_R16_UNORM, D3DFMT_L16 },
{ DXGI_FORMAT_R8_UNORM, D3DFMT_L8 },
{ DXGI_FORMAT_A8_UNORM, D3DFMT_A8 },
{ DXGI_FORMAT_BC1_UNORM, D3DFMT_DXT1 },
{ DXGI_FORMAT_BC2_UNORM, D3DFMT_DXT2 },
{ DXGI_FORMAT_BC3_UNORM, D3DFMT_DXT4 },
{ DXGI_FORMAT_B8G8R8A8_UNORM, D3DFMT_A8R8G8B8 },
{ DXGI_FORMAT_B8G8R8X8_UNORM, D3DFMT_X8R8G8B8 },
{ DXGI_FORMAT_AYUV, MAKEFOURCC('A','Y','U','V') },
{ DXGI_FORMAT_Y410, MAKEFOURCC('Y','4','1','0') },
{ DXGI_FORMAT_Y416, MAKEFOURCC('Y','4','1','6') },
{ DXGI_FORMAT_NV12, MAKEFOURCC('N','V','1','2') },
{ DXGI_FORMAT_P010, MAKEFOURCC('P','0','1','0') },
{ DXGI_FORMAT_P016, MAKEFOURCC('P','0','1','6') },
{ DXGI_FORMAT_420_OPAQUE, MAKEFOURCC('4','2','0','O') },
{ DXGI_FORMAT_YUY2, D3DFMT_YUY2 },
{ DXGI_FORMAT_Y210, MAKEFOURCC('Y','2','1','0') },
{ DXGI_FORMAT_Y216, MAKEFOURCC('Y','2','1','6') },
{ DXGI_FORMAT_NV11, MAKEFOURCC('N','V','1','1') },
{ DXGI_FORMAT_AI44, MAKEFOURCC('A','I','4','4') },
{ DXGI_FORMAT_IA44, MAKEFOURCC('I','A','4','4') },
{ DXGI_FORMAT_P8, D3DFMT_P8 },
{ DXGI_FORMAT_A8P8, D3DFMT_A8P8 },
};
DXGI_FORMAT format;
unsigned int i;
if (!pMFMapDX9FormatToDXGIFormat)
{
win_skip("MFMapDX9FormatToDXGIFormat() is not available.\n");
return;
}
for (i = 0; i < ARRAY_SIZE(formats_map); ++i)
{
format = pMFMapDX9FormatToDXGIFormat(formats_map[i].d3d9_format);
ok(format == formats_map[i].dxgi_format, "Unexpected DXGI format %#x, d3d9 format %#x.\n",
format, formats_map[i].d3d9_format);
}
}
static HRESULT WINAPI test_notify_callback_QueryInterface(IMFVideoSampleAllocatorNotify *iface,
REFIID riid, void **obj)
{
......@@ -6506,6 +6573,7 @@ START_TEST(mfplat)
test_MFMapDXGIFormatToDX9Format();
test_dxgi_surface_buffer();
test_sample_allocator();
test_MFMapDX9FormatToDXGIFormat();
CoUninitialize();
}
......@@ -553,6 +553,7 @@ HRESULT WINAPI MFInitAttributesFromBlob(IMFAttributes *attributes, const UINT8 *
HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WAVEFORMATEX *format, UINT32 size);
HRESULT WINAPI MFInvokeCallback(IMFAsyncResult *result);
HRESULT WINAPI MFLockPlatform(void);
DXGI_FORMAT WINAPI MFMapDX9FormatToDXGIFormat(DWORD format);
DWORD WINAPI MFMapDXGIFormatToDX9Format(DXGI_FORMAT dxgi_format);
HRESULT WINAPI MFPutWaitingWorkItem(HANDLE event, LONG priority, IMFAsyncResult *result, MFWORKITEM_KEY *key);
HRESULT WINAPI MFPutWorkItem(DWORD queue, IMFAsyncCallback *callback, IUnknown *state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment