Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/mfplat/buffer.c | 22 +++++++++++++++++++--- dlls/mfplat/tests/mfplat.c | 9 ++------- 2 files changed, 21 insertions(+), 10 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 28b89de4b1f..8fddef8fd40 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -5736,9 +5736,11 @@ static void test_MFCreate2DMediaBuffer(void) { 2, 2, MAKEFOURCC('I','M','C','2'), 6, 128, 0, 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 }, @@ -5998,13 +6000,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);