Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 2 +- dlls/mfplat/tests/mfplat.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 71bae4c42f..7206cf6d5a 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -340,7 +340,7 @@ static HRESULT memory_2d_buffer_lock(struct memory_buffer *buffer, BYTE **scanli else { ++buffer->_2d.locks; - *scanline0 = buffer->data; + *scanline0 = buffer->_2d.scanline0; *pitch = buffer->_2d.pitch; if (buffer_start) *buffer_start = buffer->data; diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 8e9bf8102a..497c451f72 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -4694,7 +4694,7 @@ static void test_MFCreate2DMediaBuffer(void) IMF2DBuffer2 *_2dbuffer2; IMF2DBuffer *_2dbuffer; IMFMediaBuffer *buffer; - int i, pitch; + int i, pitch, pitch2; HRESULT hr; BOOL ret;
@@ -4898,6 +4898,12 @@ static void test_MFCreate2DMediaBuffer(void)
hr = IMF2DBuffer_Lock2D(_2dbuffer, &data, &pitch); ok(hr == S_OK, "Failed to lock buffer, hr %#x.\n", hr); + + hr = IMF2DBuffer_GetScanline0AndPitch(_2dbuffer, &data2, &pitch2); + ok(hr == S_OK, "Failed to get scanline, hr %#x.\n", hr); + ok(data2 == data, "Unexpected data pointer.\n"); + ok(pitch == pitch2, "Unexpected pitch.\n"); + hr = IMF2DBuffer_Unlock2D(_2dbuffer); ok(hr == S_OK, "Failed to unlock buffer, hr %#x.\n", hr);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/mediatype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 77753cc499..5995454326 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -1782,7 +1782,7 @@ static int __cdecl uncompressed_video_format_compare(const void *a, const void *
static const struct uncompressed_video_format video_formats[] = { - { &MFVideoFormat_RGB24, 3, 3, 1, 0 }, + { &MFVideoFormat_RGB24, 4, 3, 1, 0 }, { &MFVideoFormat_ARGB32, 4, 3, 1, 0 }, { &MFVideoFormat_RGB32, 4, 3, 1, 0 }, { &MFVideoFormat_RGB565, 2, 3, 1, 0 },
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 7206cf6d5a..7039f93f57 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -613,7 +613,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo object->_2d.width = width * bpp; object->_2d.height = height; object->_2d.pitch = bottom_up ? -pitch : pitch; - object->_2d.scanline0 = bottom_up ? object->data + object->_2d.width * (object->_2d.height - 1) : object->data; + object->_2d.scanline0 = bottom_up ? object->data + pitch * (object->_2d.height - 1) : object->data;
*buffer = &object->IMFMediaBuffer_iface;
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 8 ++++---- dlls/mfplat/mediatype.c | 4 ++-- dlls/mfplat/mfplat_private.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 7039f93f57..65c23101e7 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -544,7 +544,7 @@ static HRESULT create_1d_buffer(DWORD max_length, DWORD alignment, IMFMediaBuffe
static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bottom_up, IMFMediaBuffer **buffer) { - unsigned int bpp, max_length, plane_size; + unsigned int stride, max_length, plane_size; struct memory_buffer *object; unsigned int row_alignment; GUID subtype; @@ -560,7 +560,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo memcpy(&subtype, &MFVideoFormat_Base, sizeof(subtype)); subtype.Data1 = fourcc;
- if (!(bpp = mf_format_get_bpp(&subtype, &is_yuv))) + if (!(stride = mf_format_get_stride(&subtype, width, &is_yuv))) return MF_E_INVALIDMEDIATYPE;
if (is_yuv && bottom_up) @@ -586,7 +586,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo row_alignment = MF_64_BYTE_ALIGNMENT; }
- pitch = ALIGN_SIZE(width * bpp, row_alignment); + pitch = ALIGN_SIZE(stride, row_alignment);
switch (fourcc) { @@ -610,7 +610,7 @@ static HRESULT create_2d_buffer(DWORD width, DWORD height, DWORD fourcc, BOOL bo
object->IMF2DBuffer2_iface.lpVtbl = &memory_2d_buffer_vtbl; object->_2d.plane_size = plane_size; - object->_2d.width = width * bpp; + object->_2d.width = stride; object->_2d.height = height; object->_2d.pitch = bottom_up ? -pitch : pitch; object->_2d.scanline0 = bottom_up ? object->data + pitch * (object->_2d.height - 1) : object->data; diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index 5995454326..196d803722 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -1815,14 +1815,14 @@ static unsigned int mf_get_stride_for_format(const struct uncompressed_video_for return (width * format->bytes_per_pixel + format->alignment) & ~format->alignment; }
-unsigned int mf_format_get_bpp(const GUID *subtype, BOOL *is_yuv) +unsigned int mf_format_get_stride(const GUID *subtype, unsigned int width, BOOL *is_yuv) { struct uncompressed_video_format *format = mf_get_video_format(subtype);
if (format) { *is_yuv = format->yuv; - return format->bytes_per_pixel; + return mf_get_stride_for_format(format, width); }
return 0; diff --git a/dlls/mfplat/mfplat_private.h b/dlls/mfplat/mfplat_private.h index 15d81a65b9..ad4958465a 100644 --- a/dlls/mfplat/mfplat_private.h +++ b/dlls/mfplat/mfplat_private.h @@ -115,7 +115,7 @@ static inline BOOL mf_array_reserve(void **elements, size_t *capacity, size_t co return TRUE; }
-extern unsigned int mf_format_get_bpp(const GUID *subtype, BOOL *is_yuv) DECLSPEC_HIDDEN; +extern unsigned int mf_format_get_stride(const GUID *subtype, unsigned int width, BOOL *is_yuv) DECLSPEC_HIDDEN;
static inline const char *debugstr_propvar(const PROPVARIANT *v) {
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/mfplat/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 65c23101e7..ea89bcb1f5 100644 --- a/dlls/mfplat/buffer.c +++ b/dlls/mfplat/buffer.c @@ -503,7 +503,7 @@ static const IMF2DBuffer2Vtbl memory_2d_buffer_vtbl = static HRESULT memory_buffer_init(struct memory_buffer *buffer, DWORD max_length, DWORD alignment, const IMFMediaBufferVtbl *vtbl) { - buffer->data = heap_alloc(ALIGN_SIZE(max_length, alignment)); + buffer->data = heap_alloc_zero(ALIGN_SIZE(max_length, alignment)); if (!buffer->data) return E_OUTOFMEMORY;