From: Elizabeth Figura <zfigura(a)codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59097 --- dlls/amstream/ddrawstream.c | 17 ++++++++++++++++- dlls/amstream/tests/amstream.c | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 40e7fab1e79..29e17f54542 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1537,8 +1537,10 @@ static HRESULT WINAPI ddraw_mem_allocator_GetBuffer(IMemAllocator *iface, } sample->surface_desc.dwSize = sizeof(DDSURFACEDESC); + /* Don't pass the sample rect here; the upstream filter is expected to + * deal with it. */ if ((FAILED(hr = IDirectDrawSurface_Lock(sample->surface, - &sample->rect, &sample->surface_desc, DDLOCK_WAIT, NULL)))) + NULL, &sample->surface_desc, DDLOCK_WAIT, NULL)))) { LeaveCriticalSection(&stream->cs); return hr; @@ -2282,12 +2284,23 @@ static HRESULT WINAPI media_sample_SetActualDataLength(IMediaSample *iface, LONG static HRESULT WINAPI media_sample_GetMediaType(IMediaSample *iface, AM_MEDIA_TYPE **ret_mt) { struct ddraw_sample *sample = impl_from_IMediaSample(iface); + VIDEOINFOHEADER *video_info; TRACE("sample %p, ret_mt %p.\n", sample, ret_mt); + /* Note that this usually matches the media type we pass to QueryAccept(), + * but not if there's a sub-rect. + * That's amstream just breaking the DirectShow rules. + * The type we pass to QueryAccept() just uses the size of the sub-rect for + * everything. The type we return from GetMediaType() uses the size of the + * surface for everything except rcSource/rcTarget. */ if (!(*ret_mt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)))) return E_OUTOFMEMORY; set_mt_from_desc(*ret_mt, &sample->surface_desc, sample->surface_desc.lPitch); + video_info = (VIDEOINFOHEADER *)(*ret_mt)->pbFormat; + SetRect(&video_info->rcSource, 0, 0, sample->rect.right - sample->rect.left, + sample->rect.bottom - sample->rect.top); + video_info->rcTarget = sample->rect; return S_OK; } @@ -2458,6 +2471,8 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw IDirectDrawStreamSample_Release(&object->IDirectDrawStreamSample_iface); return hr; } + + SetRect(&object->rect, 0, 0, desc.dwWidth, desc.dwHeight); } *ddraw_stream_sample = &object->IDirectDrawStreamSample_iface; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index a650a5ca6c2..55a46f60027 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -9251,7 +9251,7 @@ static void test_ddrawstream_mem_allocator(void) "Got format type %s.\n", debugstr_guid(&sample_mt->formattype)); ok(!sample_mt->pUnk, "Got pUnk %p.\n", sample_mt->pUnk); ok(sample_mt->cbFormat == sizeof(VIDEOINFO), "Got format size %lu.\n", sample_mt->cbFormat); - todo_wine ok(!memcmp(sample_mt->pbFormat, &expect_video_info, sizeof(VIDEOINFO)), "Format blocks didn't match.\n"); + ok(!memcmp(sample_mt->pbFormat, &expect_video_info, sizeof(VIDEOINFO)), "Format blocks didn't match.\n"); ref = IMediaSample_Release(media_sample1); ok(!ref, "Got refcount %ld.\n", ref); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9718