Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/videorenderer.c | 85 +++++++++++++------------------------ 1 file changed, 30 insertions(+), 55 deletions(-)
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 54a646fbc04..77afc9fcef5 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -79,6 +79,14 @@ static inline struct video_renderer *impl_from_BaseControlVideo(BaseControlVideo return CONTAINING_RECORD(iface, struct video_renderer, baseControlVideo); }
+static const BITMAPINFOHEADER *get_bitmap_header(const AM_MEDIA_TYPE *mt) +{ + if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; + else + return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; +} + static void VideoRenderer_AutoShowWindow(struct video_renderer *This) { if (!This->init && (!This->WindowPos.right || !This->WindowPos.top)) @@ -144,9 +152,7 @@ static HRESULT WINAPI VideoRenderer_ShouldDrawSampleNow(struct strmbase_renderer static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *iface, IMediaSample *pSample) { struct video_renderer *filter = impl_from_strmbase_renderer(iface); - const AM_MEDIA_TYPE *mt = &filter->renderer.sink.pin.mt; LPBYTE pbSrcStream = NULL; - BITMAPINFOHEADER *bih; HRESULT hr; HDC dc;
@@ -159,11 +165,6 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa return hr; }
- if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) - bih = &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; - else - bih = &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; - dc = GetDC(filter->baseControlWindow.hwnd); StretchDIBits(dc, filter->DestRect.left, filter->DestRect.top, filter->DestRect.right - filter->DestRect.left, @@ -171,7 +172,7 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa filter->SourceRect.left, filter->SourceRect.top, filter->SourceRect.right - filter->SourceRect.left, filter->SourceRect.bottom - filter->SourceRect.top, - pbSrcStream, (BITMAPINFO *)bih, DIB_RGB_COLORS, SRCCOPY); + pbSrcStream, (BITMAPINFO *)get_bitmap_header(&filter->renderer.sink.pin.mt), DIB_RGB_COLORS, SRCCOPY); ReleaseDC(filter->baseControlWindow.hwnd, dc);
if (filter->renderer.filter.state == State_Paused) @@ -190,53 +191,31 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa return S_OK; }
-static HRESULT WINAPI VideoRenderer_CheckMediaType(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *pmt) +static HRESULT WINAPI VideoRenderer_CheckMediaType(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt) { - struct video_renderer *This = impl_from_strmbase_renderer(iface); + struct video_renderer *filter = impl_from_strmbase_renderer(iface); + const BITMAPINFOHEADER *bitmap_header;
- if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Video)) + if (!IsEqualGUID(&mt->majortype, &MEDIATYPE_Video)) return S_FALSE;
- if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB32) || - IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB24) || - IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB565) || - IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_RGB8)) - { - LONG height; + if (!IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB32) + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB24) + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB565) + && !IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_RGB8)) + return S_FALSE;
- 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; - height = format->bmiHeader.biHeight; - if (height < 0) - This->SourceRect.bottom = This->VideoHeight = -height; - else - This->SourceRect.bottom = This->VideoHeight = height; - } - 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; - height = format2->bmiHeader.biHeight; - if (height < 0) - This->SourceRect.bottom = This->VideoHeight = -height; - else - This->SourceRect.bottom = This->VideoHeight = height; - } - else - { - WARN("Format type %s not supported\n", debugstr_guid(&pmt->formattype)); - return S_FALSE; - } - return S_OK; - } - return S_FALSE; + if (!IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo) + && !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2)) + return S_FALSE; + + bitmap_header = get_bitmap_header(mt); + + filter->VideoWidth = bitmap_header->biWidth; + filter->VideoHeight = abs(bitmap_header->biHeight); + SetRect(&filter->SourceRect, 0, 0, filter->VideoWidth, filter->VideoHeight); + + return S_OK; }
static void video_renderer_destroy(struct strmbase_renderer *iface) @@ -360,7 +339,6 @@ static HRESULT WINAPI VideoRenderer_GetSourceRect(BaseControlVideo* iface, RECT static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image) { struct video_renderer *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; @@ -369,10 +347,7 @@ static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG
EnterCriticalSection(&filter->renderer.csRenderLock);
- if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) - bih = &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; - else /* if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2)) */ - bih = &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; + bih = get_bitmap_header(&filter->renderer.sink.pin.mt); image_size = bih->biWidth * bih->biHeight * bih->biBitCount / 8;
if (!image)
Filter state should not be modified in IPin::QueryAccept().
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/videorenderer.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 77afc9fcef5..15a7d59eb1e 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -193,9 +193,6 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa
static HRESULT WINAPI VideoRenderer_CheckMediaType(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt) { - struct video_renderer *filter = impl_from_strmbase_renderer(iface); - const BITMAPINFOHEADER *bitmap_header; - if (!IsEqualGUID(&mt->majortype, &MEDIATYPE_Video)) return S_FALSE;
@@ -209,12 +206,6 @@ static HRESULT WINAPI VideoRenderer_CheckMediaType(struct strmbase_renderer *ifa && !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2)) return S_FALSE;
- bitmap_header = get_bitmap_header(mt); - - filter->VideoWidth = bitmap_header->biWidth; - filter->VideoHeight = abs(bitmap_header->biHeight); - SetRect(&filter->SourceRect, 0, 0, filter->VideoWidth, filter->VideoHeight); - return S_OK; }
@@ -285,6 +276,18 @@ static void video_renderer_init_stream(struct strmbase_renderer *iface) VideoRenderer_AutoShowWindow(filter); }
+static HRESULT video_renderer_connect(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt) +{ + struct video_renderer *filter = impl_from_strmbase_renderer(iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(mt); + + filter->VideoWidth = bitmap_header->biWidth; + filter->VideoHeight = abs(bitmap_header->biHeight); + SetRect(&filter->SourceRect, 0, 0, filter->VideoWidth, filter->VideoHeight); + + return S_OK; +} + static RECT video_renderer_get_default_rect(struct video_window *iface) { struct video_renderer *This = impl_from_video_window(iface); @@ -321,6 +324,7 @@ static const struct strmbase_renderer_ops renderer_ops = .renderer_destroy = video_renderer_destroy, .renderer_query_interface = video_renderer_query_interface, .renderer_pin_query_interface = video_renderer_pin_query_interface, + .renderer_connect = video_renderer_connect, };
static const struct video_window_ops window_ops =
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/filtergraph.c | 4 +- dlls/quartz/tests/videorenderer.c | 30 +++++++-------- dlls/quartz/videorenderer.c | 62 +++++-------------------------- 3 files changed, 26 insertions(+), 70 deletions(-)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index af659a99066..9aad1899793 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -246,8 +246,8 @@ static void test_basic_video(IFilterGraph2 *graph) ok(hr == S_OK, "Cannot get destination position returned: %x\n", hr); ok(left == 0, "expected 0, got %d\n", left); ok(top == 0, "expected 0, got %d\n", top); - todo_wine ok(width == window_width, "expected %d, got %d\n", window_width, width); - todo_wine ok(height == video_height, "expected %d, got %d\n", video_height, height); + ok(width == window_width, "expected %d, got %d\n", window_width, width); + ok(height == video_height, "expected %d, got %d\n", video_height, height);
hr = IBasicVideo_SetDestinationPosition(pbv, 0, 0, 0, 0); ok(hr==E_INVALIDARG, "IBasicVideo_SetDestinationPosition returned: %x\n", hr); diff --git a/dlls/quartz/tests/videorenderer.c b/dlls/quartz/tests/videorenderer.c index 90d1e019324..b116b044b4a 100644 --- a/dlls/quartz/tests/videorenderer.c +++ b/dlls/quartz/tests/videorenderer.c @@ -1855,21 +1855,21 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(height == expect_height, "Got height %d.\n", height); hr = IVideoWindow_GetWindowPosition(window, &left, &top, &width, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 0, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(width == expect_width, "Got width %d.\n", width); + ok(height == expect_height, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 0, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == expect_width, "Got window right %d.\n", rect.right); - todo_wine ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom); + ok(rect.right == expect_width, "Got window right %d.\n", rect.right); + ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_put_Left(window, 10); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1882,21 +1882,21 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(height == expect_height, "Got height %d.\n", height); hr = IVideoWindow_GetWindowPosition(window, &left, &top, &width, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 10, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(width == expect_width, "Got width %d.\n", width); + ok(height == expect_height, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 10, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); - todo_wine ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom); + ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); + ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_put_Height(window, 200); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1909,7 +1909,7 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(height == 200, "Got height %d.\n", height); @@ -1917,12 +1917,12 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 10, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); ok(height == 200, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 10, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); + ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); ok(rect.bottom == 200, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_SetWindowPosition(window, 100, 200, 300, 400); diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 15a7d59eb1e..15e05f48a89 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -44,11 +44,8 @@ struct video_renderer
IOverlay IOverlay_iface;
- BOOL init; - RECT SourceRect; RECT DestRect; - RECT WindowPos; LONG VideoWidth; LONG VideoHeight; LONG FullScreenMode; @@ -89,53 +86,6 @@ static const BITMAPINFOHEADER *get_bitmap_header(const AM_MEDIA_TYPE *mt)
static void VideoRenderer_AutoShowWindow(struct video_renderer *This) { - if (!This->init && (!This->WindowPos.right || !This->WindowPos.top)) - { - DWORD style = GetWindowLongW(This->baseControlWindow.hwnd, GWL_STYLE); - DWORD style_ex = GetWindowLongW(This->baseControlWindow.hwnd, GWL_EXSTYLE); - - if (!This->WindowPos.right) - { - if (This->DestRect.right) - { - This->WindowPos.left = This->DestRect.left; - This->WindowPos.right = This->DestRect.right; - } - else - { - This->WindowPos.left = This->SourceRect.left; - This->WindowPos.right = This->SourceRect.right; - } - } - if (!This->WindowPos.bottom) - { - if (This->DestRect.bottom) - { - This->WindowPos.top = This->DestRect.top; - This->WindowPos.bottom = This->DestRect.bottom; - } - else - { - This->WindowPos.top = This->SourceRect.top; - This->WindowPos.bottom = This->SourceRect.bottom; - } - } - - AdjustWindowRectEx(&This->WindowPos, style, FALSE, style_ex); - - TRACE("WindowPos: %s\n", wine_dbgstr_rect(&This->WindowPos)); - SetWindowPos(This->baseControlWindow.hwnd, NULL, - This->WindowPos.left, - This->WindowPos.top, - This->WindowPos.right - This->WindowPos.left, - This->WindowPos.bottom - This->WindowPos.top, - SWP_NOZORDER|SWP_NOMOVE|SWP_DEFERERASE); - - GetClientRect(This->baseControlWindow.hwnd, &This->DestRect); - } - else if (!This->init) - This->DestRect = This->WindowPos; - This->init = TRUE; if (This->baseControlWindow.AutoShow) ShowWindow(This->baseControlWindow.hwnd, SW_SHOW); } @@ -280,10 +230,18 @@ static HRESULT video_renderer_connect(struct strmbase_renderer *iface, const AM_ { struct video_renderer *filter = impl_from_strmbase_renderer(iface); const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(mt); + HWND window = filter->baseControlWindow.hwnd; + RECT rect;
filter->VideoWidth = bitmap_header->biWidth; filter->VideoHeight = abs(bitmap_header->biHeight); - SetRect(&filter->SourceRect, 0, 0, filter->VideoWidth, filter->VideoHeight); + SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight); + filter->SourceRect = filter->DestRect = rect; + + AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE, + GetWindowLongW(window, GWL_EXSTYLE)); + SetWindowPos(window, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
return S_OK; } @@ -511,7 +469,6 @@ static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG f SetWindowPos(filter->baseControlWindow.hwnd, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW); GetWindowRect(filter->baseControlWindow.hwnd, &filter->DestRect); - filter->WindowPos = filter->DestRect; } else { @@ -521,7 +478,6 @@ static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG f GetClientRect(filter->baseControlWindow.hwnd, &filter->DestRect); SetWindowPos(filter->baseControlWindow.hwnd, 0, filter->DestRect.left, filter->DestRect.top, filter->DestRect.right, filter->DestRect.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); - filter->WindowPos = filter->DestRect; } filter->FullScreenMode = fullscreen;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/vmr9.c | 62 ++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 46 deletions(-)
diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 8ef8fc07e3e..c43260b05d0 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -45,6 +45,14 @@ static inline const char *debugstr_normalized_rect(const VMR9NormalizedRect *rec return wine_dbg_sprintf("(%.8e,%.8e)-(%.8e,%.8e)", rect->left, rect->top, rect->right, rect->bottom); }
+static const BITMAPINFOHEADER *get_bitmap_header(const AM_MEDIA_TYPE *mt) +{ + if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; + else + return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; +} + struct quartz_vmr { struct strmbase_renderer renderer; @@ -210,31 +218,14 @@ static inline struct quartz_vmr *impl_from_IBaseFilter(IBaseFilter *iface) static DWORD VMR9_SendSampleData(struct quartz_vmr *This, VMR9PresentationInfo *info, LPBYTE data, DWORD size) { - AM_MEDIA_TYPE *amt; + const BITMAPINFOHEADER *bmiHeader = get_bitmap_header(&This->renderer.sink.pin.mt); HRESULT hr = S_OK; int width; int height; - BITMAPINFOHEADER *bmiHeader; D3DLOCKED_RECT lock;
TRACE("%p %p %d\n", This, data, size);
- amt = &This->renderer.sink.pin.mt; - - 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 = bmiHeader->biWidth; height = bmiHeader->biHeight;
@@ -347,8 +338,6 @@ static HRESULT WINAPI VMR9_DoRenderSample(struct strmbase_renderer *iface, IMedi
static HRESULT WINAPI VMR9_CheckMediaType(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt) { - const VIDEOINFOHEADER *vih; - if (!IsEqualIID(&mt->majortype, &MEDIATYPE_Video) || !mt->pbFormat) return S_FALSE;
@@ -356,9 +345,7 @@ static HRESULT WINAPI VMR9_CheckMediaType(struct strmbase_renderer *iface, const && !IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2)) return S_FALSE;
- vih = (VIDEOINFOHEADER *)mt->pbFormat; - - if (vih->bmiHeader.biCompression != BI_RGB) + if (get_bitmap_header(mt)->biCompression != BI_RGB) return S_FALSE; return S_OK; } @@ -530,26 +517,13 @@ static HRESULT WINAPI VMR9_ShouldDrawSampleNow(struct strmbase_renderer *iface, static HRESULT vmr_connect(struct strmbase_renderer *iface, const AM_MEDIA_TYPE *mt) { struct quartz_vmr *filter = impl_from_IBaseFilter(&iface->filter.IBaseFilter_iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(mt); HRESULT hr;
- if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) - { - VIDEOINFOHEADER *format = (VIDEOINFOHEADER *)mt->pbFormat; - - filter->bmiheader = format->bmiHeader; - filter->VideoWidth = format->bmiHeader.biWidth; - filter->VideoHeight = format->bmiHeader.biHeight; - SetRect(&filter->source_rect, 0, 0, filter->VideoWidth, filter->VideoHeight); - } - else if (IsEqualIID(&mt->formattype, &FORMAT_VideoInfo2)) - { - VIDEOINFOHEADER2 *format = (VIDEOINFOHEADER2 *)mt->pbFormat; - - filter->bmiheader = format->bmiHeader; - filter->VideoWidth = format->bmiHeader.biWidth; - filter->VideoHeight = format->bmiHeader.biHeight; - SetRect(&filter->source_rect, 0, 0, filter->VideoWidth, filter->VideoHeight); - } + filter->bmiheader = *bitmap_header; + filter->VideoWidth = bitmap_header->biWidth; + filter->VideoHeight = bitmap_header->biHeight; + SetRect(&filter->source_rect, 0, 0, filter->VideoWidth, filter->VideoHeight);
if (filter->mode || SUCCEEDED(hr = IVMRFilterConfig9_SetRenderingMode(&filter->IVMRFilterConfig9_iface, VMR9Mode_Windowed))) @@ -732,7 +706,6 @@ static HRESULT WINAPI VMR9_GetSourceRect(BaseControlVideo* This, RECT *pSourceRe static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image) { struct quartz_vmr *filter = impl_from_BaseControlVideo(iface); - const AM_MEDIA_TYPE *mt = &filter->renderer.sink.pin.mt; IDirect3DSurface9 *rt = NULL, *surface = NULL; D3DLOCKED_RECT locked_rect; IDirect3DDevice9 *device; @@ -747,10 +720,7 @@ static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, L EnterCriticalSection(&filter->renderer.csRenderLock); device = filter->allocator_d3d9_dev;
- if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) - bih = ((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; - else if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo2)) - bih = ((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; + bih = *get_bitmap_header(&filter->renderer.sink.pin.mt); bih.biSizeImage = bih.biWidth * bih.biHeight * bih.biBitCount / 8;
if (!image)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/tests/vmr7.c | 30 +++++++++++++++--------------- dlls/quartz/tests/vmr9.c | 30 +++++++++++++++--------------- dlls/quartz/vmr9.c | 19 +++++++++---------- 3 files changed, 39 insertions(+), 40 deletions(-)
diff --git a/dlls/quartz/tests/vmr7.c b/dlls/quartz/tests/vmr7.c index 26324a36b16..c7e11593d23 100644 --- a/dlls/quartz/tests/vmr7.c +++ b/dlls/quartz/tests/vmr7.c @@ -1825,21 +1825,21 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(height == expect_height, "Got height %d.\n", height); hr = IVideoWindow_GetWindowPosition(window, &left, &top, &width, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 0, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(width == expect_width, "Got width %d.\n", width); + ok(height == expect_height, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 0, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == expect_width, "Got window right %d.\n", rect.right); - todo_wine ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom); + ok(rect.right == expect_width, "Got window right %d.\n", rect.right); + ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_put_Left(window, 10); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1852,21 +1852,21 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(height == expect_height, "Got height %d.\n", height); hr = IVideoWindow_GetWindowPosition(window, &left, &top, &width, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 10, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(width == expect_width, "Got width %d.\n", width); + ok(height == expect_height, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 10, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); - todo_wine ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom); + ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); + ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_put_Height(window, 200); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -1879,7 +1879,7 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(height == 200, "Got height %d.\n", height); @@ -1887,12 +1887,12 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 10, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); ok(height == 200, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 10, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); + ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); ok(rect.bottom == 200, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_SetWindowPosition(window, 100, 200, 300, 400); diff --git a/dlls/quartz/tests/vmr9.c b/dlls/quartz/tests/vmr9.c index 189b7d4f892..003088f8d7d 100644 --- a/dlls/quartz/tests/vmr9.c +++ b/dlls/quartz/tests/vmr9.c @@ -2067,21 +2067,21 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(height == expect_height, "Got height %d.\n", height); hr = IVideoWindow_GetWindowPosition(window, &left, &top, &width, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 0, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(width == expect_width, "Got width %d.\n", width); + ok(height == expect_height, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 0, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == expect_width, "Got window right %d.\n", rect.right); - todo_wine ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom); + ok(rect.right == expect_width, "Got window right %d.\n", rect.right); + ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_put_Left(window, 10); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -2094,21 +2094,21 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(height == expect_height, "Got height %d.\n", height); hr = IVideoWindow_GetWindowPosition(window, &left, &top, &width, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 10, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); - todo_wine ok(height == expect_height, "Got height %d.\n", height); + ok(width == expect_width, "Got width %d.\n", width); + ok(height == expect_height, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 10, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); - todo_wine ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom); + ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); + ok(rect.bottom == expect_height, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_put_Height(window, 200); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -2121,7 +2121,7 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(top == 0, "Got top %d.\n", top); hr = IVideoWindow_get_Width(window, &width); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); hr = IVideoWindow_get_Height(window, &height); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(height == 200, "Got height %d.\n", height); @@ -2129,12 +2129,12 @@ static void test_video_window_position(IVideoWindow *window, HWND hwnd, HWND our ok(hr == S_OK, "Got hr %#x.\n", hr); ok(left == 10, "Got left %d.\n", left); ok(top == 0, "Got top %d.\n", top); - todo_wine ok(width == expect_width, "Got width %d.\n", width); + ok(width == expect_width, "Got width %d.\n", width); ok(height == 200, "Got height %d.\n", height); GetWindowRect(hwnd, &rect); ok(rect.left == 10, "Got window left %d.\n", rect.left); ok(rect.top == 0, "Got window top %d.\n", rect.top); - todo_wine ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); + ok(rect.right == 10 + expect_width, "Got window right %d.\n", rect.right); ok(rect.bottom == 200, "Got window bottom %d.\n", rect.bottom);
hr = IVideoWindow_SetWindowPosition(window, 100, 200, 300, 400); diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index c43260b05d0..2cec590545c 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -381,9 +381,7 @@ static HRESULT initialize_device(struct quartz_vmr *filter, VMR9AllocationInfo * } }
- SetRect(&filter->source_rect, 0, 0, filter->bmiheader.biWidth, filter->bmiheader.biHeight); filter->num_surfaces = buffer_count; - return hr; }
@@ -483,14 +481,7 @@ static void vmr_start_stream(struct strmbase_renderer *iface) TRACE("(%p)\n", This);
IVMRImagePresenter9_StartPresenting(This->presenter, This->cookie); - SetWindowPos(This->baseControlWindow.hwnd, NULL, - This->source_rect.left, - This->source_rect.top, - This->source_rect.right - This->source_rect.left, - This->source_rect.bottom - This->source_rect.top, - SWP_NOZORDER|SWP_NOMOVE|SWP_DEFERERASE); ShowWindow(This->baseControlWindow.hwnd, SW_SHOW); - GetClientRect(This->baseControlWindow.hwnd, &This->target_rect); SetEvent(This->run_event); }
@@ -518,12 +509,20 @@ static HRESULT vmr_connect(struct strmbase_renderer *iface, const AM_MEDIA_TYPE { struct quartz_vmr *filter = impl_from_IBaseFilter(&iface->filter.IBaseFilter_iface); const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(mt); + HWND window = filter->baseControlWindow.hwnd; HRESULT hr; + RECT rect;
filter->bmiheader = *bitmap_header; filter->VideoWidth = bitmap_header->biWidth; filter->VideoHeight = bitmap_header->biHeight; - SetRect(&filter->source_rect, 0, 0, filter->VideoWidth, filter->VideoHeight); + SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight); + filter->source_rect = filter->target_rect = rect; + + AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE, + GetWindowLongW(window, GWL_EXSTYLE)); + SetWindowPos(window, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
if (filter->mode || SUCCEEDED(hr = IVMRFilterConfig9_SetRenderingMode(&filter->IVMRFilterConfig9_iface, VMR9Mode_Windowed)))