quartz/videorenderer: Clean up VideoRenderer_GetStaticImage().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-02-10 19:22:18 -06:00 committed by Alexandre Julliard
parent 9b1ba34149
commit a4e8e4dfd9
2 changed files with 38 additions and 46 deletions

View File

@ -1117,8 +1117,8 @@ static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1; size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1;
hr = IBasicVideo_GetCurrentImage(video, &size, buffer); hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
todo_wine ok(hr == E_OUTOFMEMORY, "Got hr %#x.\n", hr); ok(hr == E_OUTOFMEMORY, "Got hr %#x.\n", hr);
todo_wine ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1, "Got size %d.\n", size); ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1, "Got size %d.\n", size);
size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2; size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2;
memset(buffer, 0xcc, sizeof(buffer)); memset(buffer, 0xcc, sizeof(buffer));

View File

@ -350,62 +350,54 @@ static HRESULT WINAPI VideoRenderer_GetSourceRect(BaseControlVideo* iface, RECT
return S_OK; return S_OK;
} }
static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo* iface, LONG *pBufferSize, LONG *pDIBImage) static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image)
{ {
VideoRendererImpl *This = impl_from_BaseControlVideo(iface); VideoRendererImpl *filter = impl_from_BaseControlVideo(iface);
AM_MEDIA_TYPE *amt = &This->renderer.sink.pin.mt; const AM_MEDIA_TYPE *mt = &filter->renderer.sink.pin.mt;
BITMAPINFOHEADER *bmiHeader; const BITMAPINFOHEADER *bih;
LONG needed_size; size_t image_size;
char *ptr; BYTE *sample_data;
FIXME("(%p/%p)->(%p, %p): partial stub\n", This, iface, pBufferSize, pDIBImage); TRACE("filter %p, size %p, image %p.\n", filter, size, image);
EnterCriticalSection(&This->renderer.filter.csFilter); EnterCriticalSection(&filter->renderer.csRenderLock);
if (!This->renderer.pMediaSample) if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo))
bih = &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader;
else /* if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2)) */
bih = &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader;
image_size = bih->biWidth * bih->biHeight * bih->biBitCount / 8;
if (!image)
{ {
LeaveCriticalSection(&This->renderer.filter.csFilter); LeaveCriticalSection(&filter->renderer.csRenderLock);
return (This->renderer.filter.state == State_Paused ? E_UNEXPECTED : VFW_E_NOT_PAUSED); *size = sizeof(BITMAPINFOHEADER) + image_size;
}
if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo))
{
bmiHeader = &((VIDEOINFOHEADER *)amt->pbFormat)->bmiHeader;
}
else if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo2))
{
bmiHeader = &((VIDEOINFOHEADER2 *)amt->pbFormat)->bmiHeader;
}
else
{
FIXME("Unknown type %s\n", debugstr_guid(&amt->subtype));
LeaveCriticalSection(&This->renderer.filter.csFilter);
return VFW_E_RUNTIME_ERROR;
}
needed_size = bmiHeader->biSize;
needed_size += IMediaSample_GetActualDataLength(This->renderer.pMediaSample);
if (!pDIBImage)
{
*pBufferSize = needed_size;
LeaveCriticalSection(&This->renderer.filter.csFilter);
return S_OK; return S_OK;
} }
if (needed_size < *pBufferSize) if (filter->renderer.filter.state != State_Paused)
{ {
ERR("Buffer too small %u/%u\n", needed_size, *pBufferSize); LeaveCriticalSection(&filter->renderer.csRenderLock);
LeaveCriticalSection(&This->renderer.filter.csFilter); return VFW_E_NOT_PAUSED;
return E_FAIL;
} }
*pBufferSize = needed_size;
memcpy(pDIBImage, bmiHeader, bmiHeader->biSize); if (!filter->renderer.pMediaSample)
IMediaSample_GetPointer(This->renderer.pMediaSample, (BYTE **)&ptr); {
memcpy((char *)pDIBImage + bmiHeader->biSize, ptr, IMediaSample_GetActualDataLength(This->renderer.pMediaSample)); LeaveCriticalSection(&filter->renderer.csRenderLock);
return E_UNEXPECTED;
}
LeaveCriticalSection(&This->renderer.filter.csFilter); if (*size < sizeof(BITMAPINFOHEADER) + image_size)
{
LeaveCriticalSection(&filter->renderer.csRenderLock);
return E_OUTOFMEMORY;
}
memcpy(image, bih, sizeof(BITMAPINFOHEADER));
IMediaSample_GetPointer(filter->renderer.pMediaSample, &sample_data);
memcpy((char *)image + sizeof(BITMAPINFOHEADER), sample_data, image_size);
LeaveCriticalSection(&filter->renderer.csRenderLock);
return S_OK; return S_OK;
} }