From 3e9cee050f801ab3cd69378d168f5efd51862f0b Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Fri, 11 Apr 2008 15:10:19 -0700 Subject: [PATCH] quartz: Add VIDEOINFOHEADER2 support to VideoRenderer. --- dlls/quartz/videorenderer.c | 74 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index f363b82ed1d..f0a73d70b74 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -35,7 +35,9 @@ #include "evcode.h" #include "strmif.h" #include "ddraw.h" +#include "dvdmedia.h" +#include "assert.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -263,7 +265,6 @@ static const IMemInputPinVtbl MemInputPin_Vtbl = static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, DWORD size) { - VIDEOINFOHEADER* format; AM_MEDIA_TYPE amt; HRESULT hr = S_OK; DDSURFACEDESC sdesc; @@ -271,6 +272,7 @@ static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, int height; LPBYTE palette = NULL; HDC hDC; + BITMAPINFOHEADER *bmiHeader; TRACE("%p %p %d\n", This, data, size); @@ -280,23 +282,39 @@ static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, ERR("Unable to retrieve media type\n"); return hr; } - format = (VIDEOINFOHEADER*)amt.pbFormat; - TRACE("biSize = %d\n", format->bmiHeader.biSize); - TRACE("biWidth = %d\n", format->bmiHeader.biWidth); - TRACE("biHeight = %d\n", format->bmiHeader.biHeight); - TRACE("biPlanes = %d\n", format->bmiHeader.biPlanes); - TRACE("biBitCount = %d\n", format->bmiHeader.biBitCount); - TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(format->bmiHeader.biCompression), 4)); - TRACE("biSizeImage = %d\n", format->bmiHeader.biSizeImage); + 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)); + return VFW_E_RUNTIME_ERROR; + } - width = format->bmiHeader.biWidth; - height = format->bmiHeader.biHeight; - palette = ((LPBYTE)&format->bmiHeader) + format->bmiHeader.biSize; + + TRACE("biSize = %d\n", bmiHeader->biSize); + TRACE("biWidth = %d\n", bmiHeader->biWidth); + TRACE("biHeight = %d\n", bmiHeader->biHeight); + TRACE("biPlanes = %d\n", bmiHeader->biPlanes); + TRACE("biBitCount = %d\n", bmiHeader->biBitCount); + TRACE("biCompression = %s\n", debugstr_an((LPSTR)&(bmiHeader->biCompression), 4)); + TRACE("biSizeImage = %d\n", bmiHeader->biSizeImage); + + width = bmiHeader->biWidth; + height = bmiHeader->biHeight; + palette = ((LPBYTE)bmiHeader) + bmiHeader->biSize; if (!This->init) { - /* Honor previously set WindowPos */ + if (!This->WindowPos.right || !This->WindowPos.bottom) + This->WindowPos = This->SourceRect; + TRACE("WindowPos: %d %d %d %d\n", This->WindowPos.left, This->WindowPos.top, This->WindowPos.right, This->WindowPos.bottom); SetWindowPos(This->hWnd, NULL, This->WindowPos.left, @@ -304,8 +322,9 @@ static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, This->WindowPos.right - This->WindowPos.left, This->WindowPos.bottom - This->WindowPos.top, SWP_NOZORDER|SWP_NOMOVE); + GetClientRect(This->hWnd, &This->DestRect); - This->init = TRUE; + This->init = TRUE; } hDC = GetDC(This->hWnd); @@ -321,10 +340,9 @@ static DWORD VideoRenderer_SendSampleData(VideoRendererImpl* This, LPBYTE data, StretchDIBits(hDC, This->DestRect.left, This->DestRect.top, This->DestRect.right -This->DestRect.left, This->DestRect.bottom - This->DestRect.top, This->SourceRect.left, This->SourceRect.top, This->SourceRect.right - This->SourceRect.left, This->SourceRect.bottom - This->SourceRect.top, - data, (BITMAPINFO*)&format->bmiHeader, DIB_RGB_COLORS, SRCCOPY); + data, (BITMAPINFO *)bmiHeader, DIB_RGB_COLORS, SRCCOPY); ReleaseDC(This->hWnd, hDC); - if (This->AutoShow) ShowWindow(This->hWnd, SW_SHOW); @@ -385,17 +403,29 @@ static HRESULT VideoRenderer_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8)) { VideoRendererImpl* This = (VideoRendererImpl*) iface; - VIDEOINFOHEADER* format = (VIDEOINFOHEADER*)pmt->pbFormat; - if (!IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) + if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) + { + VIDEOINFOHEADER *format = (VIDEOINFOHEADER *)pmt->pbFormat; + This->SourceRect.left = 0; + This->SourceRect.top = 0; + This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth; + This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight; + } + else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) + { + VIDEOINFOHEADER2 *format2 = (VIDEOINFOHEADER2 *)pmt->pbFormat; + + This->SourceRect.left = 0; + This->SourceRect.top = 0; + This->SourceRect.right = This->VideoWidth = format2->bmiHeader.biWidth; + This->SourceRect.bottom = This->VideoHeight = format2->bmiHeader.biHeight; + } + else { WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype)); return S_FALSE; } - This->SourceRect.left = 0; - This->SourceRect.top = 0; - This->SourceRect.right = This->VideoWidth = format->bmiHeader.biWidth; - This->SourceRect.bottom = This->VideoHeight = format->bmiHeader.biHeight; return S_OK; } return S_FALSE;