Nikolay Sivov : mfplat: Fix packed byte width calculation for 2D buffer.
Alexandre Julliard
julliard at winehq.org
Thu Mar 19 16:27:47 CDT 2020
Module: wine
Branch: master
Commit: 2863eb0251dfea273dcbe1adb39a8138422173af
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2863eb0251dfea273dcbe1adb39a8138422173af
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Mar 19 15:07:40 2020 +0300
mfplat: Fix packed byte width calculation for 2D buffer.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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)
{
More information about the wine-cvs
mailing list