Commit a4e8e4df authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz/videorenderer: Clean up VideoRenderer_GetStaticImage().

parent 9b1ba341
......@@ -1117,8 +1117,8 @@ static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1;
hr = IBasicVideo_GetCurrentImage(video, &size, buffer);
todo_wine 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(hr == E_OUTOFMEMORY, "Got hr %#x.\n", hr);
ok(size == sizeof(BITMAPINFOHEADER) + 32 * 16 * 2 - 1, "Got size %d.\n", size);
size = sizeof(BITMAPINFOHEADER) + 32 * 16 * 2;
memset(buffer, 0xcc, sizeof(buffer));
......
......@@ -350,62 +350,54 @@ static HRESULT WINAPI VideoRenderer_GetSourceRect(BaseControlVideo* iface, RECT
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);
AM_MEDIA_TYPE *amt = &This->renderer.sink.pin.mt;
BITMAPINFOHEADER *bmiHeader;
LONG needed_size;
char *ptr;
VideoRendererImpl *filter = impl_from_BaseControlVideo(iface);
const AM_MEDIA_TYPE *mt = &filter->renderer.sink.pin.mt;
const BITMAPINFOHEADER *bih;
size_t image_size;
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)
{
LeaveCriticalSection(&This->renderer.filter.csFilter);
return (This->renderer.filter.state == State_Paused ? E_UNEXPECTED : VFW_E_NOT_PAUSED);
}
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 (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo))
if (!image)
{
bmiHeader = &((VIDEOINFOHEADER *)amt->pbFormat)->bmiHeader;
}
else if (IsEqualIID(&amt->formattype, &FORMAT_VideoInfo2))
{
bmiHeader = &((VIDEOINFOHEADER2 *)amt->pbFormat)->bmiHeader;
LeaveCriticalSection(&filter->renderer.csRenderLock);
*size = sizeof(BITMAPINFOHEADER) + image_size;
return S_OK;
}
else
if (filter->renderer.filter.state != State_Paused)
{
FIXME("Unknown type %s\n", debugstr_guid(&amt->subtype));
LeaveCriticalSection(&This->renderer.filter.csFilter);
return VFW_E_RUNTIME_ERROR;
LeaveCriticalSection(&filter->renderer.csRenderLock);
return VFW_E_NOT_PAUSED;
}
needed_size = bmiHeader->biSize;
needed_size += IMediaSample_GetActualDataLength(This->renderer.pMediaSample);
if (!pDIBImage)
if (!filter->renderer.pMediaSample)
{
*pBufferSize = needed_size;
LeaveCriticalSection(&This->renderer.filter.csFilter);
return S_OK;
LeaveCriticalSection(&filter->renderer.csRenderLock);
return E_UNEXPECTED;
}
if (needed_size < *pBufferSize)
if (*size < sizeof(BITMAPINFOHEADER) + image_size)
{
ERR("Buffer too small %u/%u\n", needed_size, *pBufferSize);
LeaveCriticalSection(&This->renderer.filter.csFilter);
return E_FAIL;
LeaveCriticalSection(&filter->renderer.csRenderLock);
return E_OUTOFMEMORY;
}
*pBufferSize = needed_size;
memcpy(pDIBImage, bmiHeader, bmiHeader->biSize);
IMediaSample_GetPointer(This->renderer.pMediaSample, (BYTE **)&ptr);
memcpy((char *)pDIBImage + bmiHeader->biSize, ptr, IMediaSample_GetActualDataLength(This->renderer.pMediaSample));
memcpy(image, bih, sizeof(BITMAPINFOHEADER));
IMediaSample_GetPointer(filter->renderer.pMediaSample, &sample_data);
memcpy((char *)image + sizeof(BITMAPINFOHEADER), sample_data, image_size);
LeaveCriticalSection(&This->renderer.filter.csFilter);
LeaveCriticalSection(&filter->renderer.csRenderLock);
return S_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment