Module: wine Branch: master Commit: c94c464920dbda6d5471d30d33a448aba4d71d80 URL: https://gitlab.winehq.org/wine/wine/-/commit/c94c464920dbda6d5471d30d33a448a...
Author: Rémi Bernon rbernon@codeweavers.com Date: Sat Feb 17 16:56:57 2024 +0100
mfplat/mediatype: Set rcSource and rcTarget if stride differs from width.
---
dlls/mfplat/mediatype.c | 23 +++++++++++++++-------- dlls/mfplat/tests/mfplat.c | 12 ------------ 2 files changed, 15 insertions(+), 20 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c index c9ca4c471e7..6ed23c0ef6a 100644 --- a/dlls/mfplat/mediatype.c +++ b/dlls/mfplat/mediatype.c @@ -3923,9 +3923,8 @@ static HRESULT init_am_media_type_audio_format(AM_MEDIA_TYPE *am_type, UINT32 us static void init_video_info_header2(VIDEOINFOHEADER2 *vih, const GUID *subtype, IMFMediaType *media_type) { struct uncompressed_video_format *video_format = mf_get_video_format(subtype); - UINT32 image_size, bitrate, sample_size; + UINT32 image_size, bitrate, sample_size, width, height; UINT64 frame_size, frame_rate; - INT32 width, height;
vih->bmiHeader.biSize = sizeof(vih->bmiHeader); vih->bmiHeader.biPlanes = 1; @@ -3948,18 +3947,26 @@ static void init_video_info_header2(VIDEOINFOHEADER2 *vih, const GUID *subtype, if (SUCCEEDED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &frame_size))) { BOOL bottom_up = vih->bmiHeader.biCompression == BI_RGB || vih->bmiHeader.biCompression == BI_BITFIELDS; + INT32 stride;
- if (FAILED(IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, (UINT32 *)&width))) - width = (frame_size >> 32) * (bottom_up ? -1 : 1); + width = frame_size >> 32; + if (FAILED(IMFMediaType_GetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, (UINT32 *)&stride))) + stride = width * (bottom_up ? -1 : 1); else if (video_format) - width /= video_format->bpp / 8; + stride /= video_format->bpp / 8; height = (UINT32)frame_size;
- vih->bmiHeader.biWidth = abs(width); - vih->bmiHeader.biHeight = height * (bottom_up && width >= 0 ? -1 : 1); + vih->bmiHeader.biWidth = abs(stride); + vih->bmiHeader.biHeight = height * (bottom_up && stride >= 0 ? -1 : 1);
- if (SUCCEEDED(MFCalculateImageSize(subtype, abs(width), height, &image_size))) + if (SUCCEEDED(MFCalculateImageSize(subtype, abs(stride), height, &image_size))) vih->bmiHeader.biSizeImage = image_size; + + if (vih->bmiHeader.biWidth > width) + { + vih->rcSource.right = vih->rcTarget.right = width; + vih->rcSource.bottom = vih->rcTarget.bottom = height; + } } }
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index c1cedec16c4..7277346ebfe 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7619,16 +7619,12 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); video_info = (VIDEOINFOHEADER *)am_type.pbFormat; ok(video_info->rcSource.left == 0, "got %lu\n", video_info->rcSource.left); - todo_wine ok(video_info->rcSource.right == 123, "got %lu\n", video_info->rcSource.right); ok(video_info->rcSource.top == 0, "got %lu\n", video_info->rcSource.top); - todo_wine ok(video_info->rcSource.bottom == 456, "got %lu\n", video_info->rcSource.bottom); ok(video_info->rcTarget.left == 0, "got %lu\n", video_info->rcTarget.left); - todo_wine ok(video_info->rcTarget.right == 123, "got %lu\n", video_info->rcTarget.right); ok(video_info->rcTarget.top == 0, "got %lu\n", video_info->rcTarget.top); - todo_wine ok(video_info->rcTarget.bottom == 456, "got %lu\n", video_info->rcTarget.bottom); ok(video_info->bmiHeader.biWidth == 246, "got %lu\n", video_info->bmiHeader.biWidth); ok(video_info->bmiHeader.biHeight == 456, "got %ld\n", video_info->bmiHeader.biHeight); @@ -7642,16 +7638,12 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); video_info = (VIDEOINFOHEADER *)am_type.pbFormat; ok(video_info->rcSource.left == 0, "got %lu\n", video_info->rcSource.left); - todo_wine ok(video_info->rcSource.right == 123, "got %lu\n", video_info->rcSource.right); ok(video_info->rcSource.top == 0, "got %lu\n", video_info->rcSource.top); - todo_wine ok(video_info->rcSource.bottom == 456, "got %lu\n", video_info->rcSource.bottom); ok(video_info->rcTarget.left == 0, "got %lu\n", video_info->rcTarget.left); - todo_wine ok(video_info->rcTarget.right == 123, "got %lu\n", video_info->rcTarget.right); ok(video_info->rcTarget.top == 0, "got %lu\n", video_info->rcTarget.top); - todo_wine ok(video_info->rcTarget.bottom == 456, "got %lu\n", video_info->rcTarget.bottom); ok(video_info->bmiHeader.biWidth == 246, "got %lu\n", video_info->bmiHeader.biWidth); ok(video_info->bmiHeader.biHeight == -456, "got %ld\n", video_info->bmiHeader.biHeight); @@ -7674,16 +7666,12 @@ static void test_MFInitAMMediaTypeFromMFMediaType(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); video_info = (VIDEOINFOHEADER *)am_type.pbFormat; ok(video_info->rcSource.left == 0, "got %lu\n", video_info->rcSource.left); - todo_wine ok(video_info->rcSource.right == 123, "got %lu\n", video_info->rcSource.right); ok(video_info->rcSource.top == 0, "got %lu\n", video_info->rcSource.top); - todo_wine ok(video_info->rcSource.bottom == 456, "got %lu\n", video_info->rcSource.bottom); ok(video_info->rcTarget.left == 0, "got %lu\n", video_info->rcTarget.left); - todo_wine ok(video_info->rcTarget.right == 123, "got %lu\n", video_info->rcTarget.right); ok(video_info->rcTarget.top == 0, "got %lu\n", video_info->rcTarget.top); - todo_wine ok(video_info->rcTarget.bottom == 456, "got %lu\n", video_info->rcTarget.bottom); ok(video_info->bmiHeader.biWidth == 246, "got %lu\n", video_info->bmiHeader.biWidth); ok(video_info->bmiHeader.biHeight == 456, "got %ld\n", video_info->bmiHeader.biHeight);