Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com>
---
v2:
* Remove the multiplier
* The missing test cases will be reinsterted in a later commit
---
dlls/mfplat/buffer.c | 22 ++++++++++++++++++---
dlls/mfplat/tests/mfplat.c | 40 ++++++++++++++++----------------------
2 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c
index eada3df18ad..39407ccc9e2 100644
--- a/dlls/mfplat/buffer.c
+++ b/dlls/mfplat/buffer.c
@@ -1351,8 +1351,25 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
if (is_yuv && bottom_up)
return MF_E_INVALIDMEDIATYPE;
- if (FAILED(hr = MFGetPlaneSize(fourcc, width, height, &plane_size)))
- return hr;
+ switch (fourcc)
+ {
+ case MAKEFOURCC('I','M','C','1'):
+ case MAKEFOURCC('I','M','C','3'):
+ plane_size = stride * height * 2;
+ break;
+ case MAKEFOURCC('I','M','C','2'):
+ case MAKEFOURCC('I','M','C','4'):
+ plane_size = stride * 3 / 2 * height;
+ break;
+ case MAKEFOURCC('N','V','1','2'):
+ case MAKEFOURCC('Y','V','1','2'):
+ case MAKEFOURCC('I','4','2','0'):
+ case MAKEFOURCC('I','Y','U','V'):
+ plane_size = stride * height * 3 / 2;
+ break;
+ default:
+ plane_size = stride * height;
+ }
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
@@ -1377,7 +1394,6 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
case MAKEFOURCC('I','M','C','1'):
case MAKEFOURCC('I','M','C','3'):
max_length = pitch * height * 2;
- plane_size *= 2;
break;
case MAKEFOURCC('N','V','1','2'):
case MAKEFOURCC('Y','V','1','2'):
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 67cf8954c36..6ad667a7404 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -5723,48 +5723,49 @@ static void test_MFCreate2DMediaBuffer(void)
unsigned int fourcc;
unsigned int contiguous_length;
int pitch;
- unsigned int plane_multiplier;
unsigned int max_length;
} _2d_buffer_tests[] =
{
- { 2, 2, MAKEFOURCC('N','V','1','2'), 6, 64, 0, 192 },
+ { 2, 2, MAKEFOURCC('N','V','1','2'), 6, 64, 192 },
{ 4, 2, MAKEFOURCC('N','V','1','2'), 12, 64 },
{ 2, 4, MAKEFOURCC('N','V','1','2'), 12, 64 },
{ 1, 3, MAKEFOURCC('N','V','1','2'), 4, 64 },
- { 4, 16, MAKEFOURCC('N','V','1','2'), 96, 64, 0, 1536 },
+ { 4, 16, MAKEFOURCC('N','V','1','2'), 96, 64, 1536 },
- { 2, 2, MAKEFOURCC('I','M','C','2'), 6, 128, 0, 384 },
+ { 2, 2, MAKEFOURCC('I','M','C','2'), 6, 128, 384 },
{ 4, 2, MAKEFOURCC('I','M','C','2'), 12, 128 },
{ 2, 4, MAKEFOURCC('I','M','C','2'), 12, 128 },
+ { 3, 5, MAKEFOURCC('I','M','C','2'), 20, 128 },
{ 2, 2, MAKEFOURCC('I','M','C','4'), 6, 128 },
{ 4, 2, MAKEFOURCC('I','M','C','4'), 12, 128 },
{ 2, 4, MAKEFOURCC('I','M','C','4'), 12, 128 },
+ { 3, 5, MAKEFOURCC('I','M','C','4'), 20, 128 },
- { 4, 2, MAKEFOURCC('I','M','C','1'), 32, 128, 2 },
- { 4, 4, MAKEFOURCC('I','M','C','1'), 64, 128, 2 },
- { 4, 16, MAKEFOURCC('I','M','C','1'), 256, 128, 2, 4096 },
- { 4, 20, MAKEFOURCC('I','M','C','1'), 320, 128, 2 },
+ { 4, 2, MAKEFOURCC('I','M','C','1'), 32, 128 },
+ { 4, 4, MAKEFOURCC('I','M','C','1'), 64, 128 },
+ { 4, 16, MAKEFOURCC('I','M','C','1'), 256, 128, 4096 },
+ { 4, 20, MAKEFOURCC('I','M','C','1'), 320, 128 },
- { 4, 2, MAKEFOURCC('I','M','C','3'), 32, 128, 2 },
- { 4, 4, MAKEFOURCC('I','M','C','3'), 64, 128, 2 },
- { 4, 16, MAKEFOURCC('I','M','C','3'), 256, 128, 2, 4096 },
- { 4, 20, MAKEFOURCC('I','M','C','3'), 320, 128, 2 },
+ { 4, 2, MAKEFOURCC('I','M','C','3'), 32, 128 },
+ { 4, 4, MAKEFOURCC('I','M','C','3'), 64, 128 },
+ { 4, 16, MAKEFOURCC('I','M','C','3'), 256, 128, 4096 },
+ { 4, 20, MAKEFOURCC('I','M','C','3'), 320, 128 },
{ 4, 2, MAKEFOURCC('Y','V','1','2'), 12, 128 },
{ 4, 4, MAKEFOURCC('Y','V','1','2'), 24, 128 },
- { 4, 16, MAKEFOURCC('Y','V','1','2'), 96, 128, 0, 3072 },
+ { 4, 16, MAKEFOURCC('Y','V','1','2'), 96, 128, 3072 },
{ 4, 2, MAKEFOURCC('A','Y','U','V'), 32, 64 },
{ 4, 4, MAKEFOURCC('A','Y','U','V'), 64, 64 },
- { 4, 16, MAKEFOURCC('A','Y','U','V'), 256, 64, 0, 1024 },
+ { 4, 16, MAKEFOURCC('A','Y','U','V'), 256, 64, 1024 },
{ 4, 2, MAKEFOURCC('Y','U','Y','2'), 16, 64 },
{ 4, 4, MAKEFOURCC('Y','U','Y','2'), 32, 64 },
- { 4, 16, MAKEFOURCC('Y','U','Y','2'), 128, 64, 0, 1024 },
+ { 4, 16, MAKEFOURCC('Y','U','Y','2'), 128, 64, 1024 },
{ 4, 2, MAKEFOURCC('U','Y','V','Y'), 16, 64 },
{ 4, 4, MAKEFOURCC('U','Y','V','Y'), 32, 64 },
- { 4, 16, MAKEFOURCC('U','Y','V','Y'), 128, 64, 0, 1024 },
+ { 4, 16, MAKEFOURCC('U','Y','V','Y'), 128, 64, 1024 },
{ 2, 4, D3DFMT_A8R8G8B8, 32, 64 },
{ 1, 4, D3DFMT_A8R8G8B8, 16, 64 },
@@ -5998,13 +5999,6 @@ static void test_MFCreate2DMediaBuffer(void)
hr = IMFMediaBuffer_Unlock(buffer);
ok(hr == S_OK, "Failed to unlock buffer, hr %#lx.\n", hr);
- hr = pMFGetPlaneSize(ptr->fourcc, ptr->width, ptr->height, &length2);
- ok(hr == S_OK, "Failed to get plane size, hr %#lx.\n", hr);
- if (ptr->plane_multiplier)
- length2 *= ptr->plane_multiplier;
- ok(length2 == length, "%d: contiguous length %lu does not match plane size %lu, %u x %u, format %s.\n", i, length,
- length2, ptr->width, ptr->height, wine_dbgstr_an((char *)&ptr->fourcc, 4));
-
hr = IMF2DBuffer_Lock2D(_2dbuffer, &data, &pitch);
ok(hr == S_OK, "Failed to lock buffer, hr %#lx.\n", hr);
--
2.36.1