diff --git a/dlls/mfplat/buffer.c b/dlls/mfplat/buffer.c index 7039f93f576..65c23101e78 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 59954543261..196d8037226 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 15d81a65b91..ad4958465a5 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) {