Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/videorenderer.c | 57 +++++++++++++++++++------------------ dlls/quartz/vmr9.c | 46 +++++++++++++++--------------- 2 files changed, 52 insertions(+), 51 deletions(-)
diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 15e05f48a89..6e31e196951 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -39,7 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(quartz); struct video_renderer { struct strmbase_renderer renderer; - struct video_window baseControlWindow; + struct video_window window; BaseControlVideo baseControlVideo;
IOverlay IOverlay_iface; @@ -58,7 +58,7 @@ struct video_renderer
static inline struct video_renderer *impl_from_video_window(struct video_window *iface) { - return CONTAINING_RECORD(iface, struct video_renderer, baseControlWindow); + return CONTAINING_RECORD(iface, struct video_renderer, window); }
static inline struct video_renderer *impl_from_strmbase_renderer(struct strmbase_renderer *iface) @@ -68,7 +68,7 @@ static inline struct video_renderer *impl_from_strmbase_renderer(struct strmbase
static inline struct video_renderer *impl_from_IVideoWindow(IVideoWindow *iface) { - return CONTAINING_RECORD(iface, struct video_renderer, baseControlWindow.IVideoWindow_iface); + return CONTAINING_RECORD(iface, struct video_renderer, window.IVideoWindow_iface); }
static inline struct video_renderer *impl_from_BaseControlVideo(BaseControlVideo *iface) @@ -86,8 +86,8 @@ static const BITMAPINFOHEADER *get_bitmap_header(const AM_MEDIA_TYPE *mt)
static void VideoRenderer_AutoShowWindow(struct video_renderer *This) { - if (This->baseControlWindow.AutoShow) - ShowWindow(This->baseControlWindow.hwnd, SW_SHOW); + if (This->window.AutoShow) + ShowWindow(This->window.hwnd, SW_SHOW); }
static HRESULT WINAPI VideoRenderer_ShouldDrawSampleNow(struct strmbase_renderer *filter, @@ -115,7 +115,7 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa return hr; }
- dc = GetDC(filter->baseControlWindow.hwnd); + dc = GetDC(filter->window.hwnd); StretchDIBits(dc, filter->DestRect.left, filter->DestRect.top, filter->DestRect.right - filter->DestRect.left, filter->DestRect.bottom - filter->DestRect.top, @@ -123,7 +123,7 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa filter->SourceRect.right - filter->SourceRect.left, filter->SourceRect.bottom - filter->SourceRect.top, pbSrcStream, (BITMAPINFO *)get_bitmap_header(&filter->renderer.sink.pin.mt), DIB_RGB_COLORS, SRCCOPY); - ReleaseDC(filter->baseControlWindow.hwnd, dc); + ReleaseDC(filter->window.hwnd, dc);
if (filter->renderer.filter.state == State_Paused) { @@ -163,7 +163,7 @@ static void video_renderer_destroy(struct strmbase_renderer *iface) { struct video_renderer *filter = impl_from_strmbase_renderer(iface);
- video_window_cleanup(&filter->baseControlWindow); + video_window_cleanup(&filter->window); CloseHandle(filter->run_event); strmbase_renderer_cleanup(&filter->renderer); free(filter); @@ -178,7 +178,7 @@ static HRESULT video_renderer_query_interface(struct strmbase_renderer *iface, R if (IsEqualGUID(iid, &IID_IBasicVideo)) *out = &filter->baseControlVideo.IBasicVideo_iface; else if (IsEqualGUID(iid, &IID_IVideoWindow)) - *out = &filter->baseControlWindow.IVideoWindow_iface; + *out = &filter->window.IVideoWindow_iface; else return E_NOINTERFACE;
@@ -212,9 +212,9 @@ static void video_renderer_stop_stream(struct strmbase_renderer *iface)
TRACE("(%p)->()\n", This);
- if (This->baseControlWindow.AutoShow) + if (This->window.AutoShow) /* Black it out */ - RedrawWindow(This->baseControlWindow.hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE); + RedrawWindow(This->window.hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
ResetEvent(This->run_event); } @@ -230,7 +230,7 @@ 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; + HWND window = filter->window.hwnd; RECT rect;
filter->VideoWidth = bitmap_header->biWidth; @@ -404,7 +404,7 @@ static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(BaseControlVideo* iface struct video_renderer *This = impl_from_BaseControlVideo(iface); RECT rect;
- if (!GetClientRect(This->baseControlWindow.hwnd, &rect)) + if (!GetClientRect(This->window.hwnd, &rect)) return E_FAIL;
SetRect(&This->DestRect, 0, 0, rect.right, rect.bottom); @@ -457,26 +457,27 @@ static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface, static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG fullscreen) { struct video_renderer *filter = impl_from_IVideoWindow(iface); + HWND window = filter->window.hwnd;
FIXME("filter %p, fullscreen %d.\n", filter, fullscreen);
if (fullscreen) { - filter->saved_style = GetWindowLongW(filter->baseControlWindow.hwnd, GWL_STYLE); - ShowWindow(filter->baseControlWindow.hwnd, SW_HIDE); - SetParent(filter->baseControlWindow.hwnd, NULL); - SetWindowLongW(filter->baseControlWindow.hwnd, GWL_STYLE, WS_POPUP); - SetWindowPos(filter->baseControlWindow.hwnd, HWND_TOP, 0, 0, + filter->saved_style = GetWindowLongW(window, GWL_STYLE); + ShowWindow(window, SW_HIDE); + SetParent(window, NULL); + SetWindowLongW(window, GWL_STYLE, WS_POPUP); + SetWindowPos(window, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW); - GetWindowRect(filter->baseControlWindow.hwnd, &filter->DestRect); + GetWindowRect(window, &filter->DestRect); } else { - ShowWindow(filter->baseControlWindow.hwnd, SW_HIDE); - SetParent(filter->baseControlWindow.hwnd, filter->baseControlWindow.hwndOwner); - SetWindowLongW(filter->baseControlWindow.hwnd, GWL_STYLE, filter->saved_style); - GetClientRect(filter->baseControlWindow.hwnd, &filter->DestRect); - SetWindowPos(filter->baseControlWindow.hwnd, 0, filter->DestRect.left, filter->DestRect.top, + ShowWindow(window, SW_HIDE); + SetParent(window, filter->window.hwndOwner); + SetWindowLongW(window, GWL_STYLE, filter->saved_style); + GetClientRect(window, &filter->DestRect); + SetWindowPos(window, 0, filter->DestRect.left, filter->DestRect.top, filter->DestRect.right, filter->DestRect.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); } filter->FullScreenMode = fullscreen; @@ -593,7 +594,7 @@ static HRESULT WINAPI overlay_GetWindowHandle(IOverlay *iface, HWND *window)
TRACE("filter %p, window %p.\n", filter, window);
- *window = filter->baseControlWindow.hwnd; + *window = filter->window.hwnd; return S_OK; }
@@ -649,14 +650,14 @@ HRESULT video_renderer_create(IUnknown *outer, IUnknown **out) strmbase_renderer_init(&object->renderer, outer, &CLSID_VideoRenderer, L"In", &renderer_ops); object->IOverlay_iface.lpVtbl = &overlay_vtbl;
- video_window_init(&object->baseControlWindow, &IVideoWindow_VTable, + video_window_init(&object->window, &IVideoWindow_VTable, &object->renderer.filter, &object->renderer.sink.pin, &window_ops); basic_video_init(&object->baseControlVideo, &object->renderer.filter, &object->renderer.sink.pin, &renderer_BaseControlVideoFuncTable);
- if (FAILED(hr = video_window_create_window(&object->baseControlWindow))) + if (FAILED(hr = video_window_create_window(&object->window))) { - video_window_cleanup(&object->baseControlWindow); + video_window_cleanup(&object->window); strmbase_renderer_cleanup(&object->renderer); free(object); return hr; diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 2cec590545c..8fdcb3809be 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -56,7 +56,7 @@ static const BITMAPINFOHEADER *get_bitmap_header(const AM_MEDIA_TYPE *mt) struct quartz_vmr { struct strmbase_renderer renderer; - struct video_window baseControlWindow; + struct video_window window; BaseControlVideo baseControlVideo;
IAMCertifiedOutputProtection IAMCertifiedOutputProtection_iface; @@ -119,7 +119,7 @@ static inline BOOL is_vmr9(const struct quartz_vmr *filter)
static inline struct quartz_vmr *impl_from_video_window(struct video_window *iface) { - return CONTAINING_RECORD(iface, struct quartz_vmr, baseControlWindow); + return CONTAINING_RECORD(iface, struct quartz_vmr, window); }
static inline struct quartz_vmr *impl_from_BaseControlVideo(BaseControlVideo *cvid) @@ -415,7 +415,7 @@ static HRESULT allocate_surfaces(struct quartz_vmr *filter, const AM_MEDIA_TYPE };
TRACE("Initializing in mode %u, our window %p, clipping window %p.\n", - filter->mode, filter->baseControlWindow.hwnd, filter->hWndClippingWindow); + filter->mode, filter->window.hwnd, filter->hWndClippingWindow);
if (filter->mode == VMR9Mode_Windowless && !filter->hWndClippingWindow) return S_OK; @@ -481,7 +481,7 @@ static void vmr_start_stream(struct strmbase_renderer *iface) TRACE("(%p)\n", This);
IVMRImagePresenter9_StartPresenting(This->presenter, This->cookie); - ShowWindow(This->baseControlWindow.hwnd, SW_SHOW); + ShowWindow(This->window.hwnd, SW_SHOW); SetEvent(This->run_event); }
@@ -509,7 +509,7 @@ 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; + HWND window = filter->window.hwnd; HRESULT hr; RECT rect;
@@ -567,7 +567,7 @@ static void vmr_destroy(struct strmbase_renderer *iface) { struct quartz_vmr *filter = impl_from_IBaseFilter(&iface->filter.IBaseFilter_iface);
- video_window_cleanup(&filter->baseControlWindow); + video_window_cleanup(&filter->window);
/* Devil May Cry 3 releases the IVMRSurfaceAllocatorNotify9 interface from * TerminateDevice(). Artificially increase the reference count so that we @@ -601,7 +601,7 @@ static HRESULT vmr_query_interface(struct strmbase_renderer *iface, REFIID iid, struct quartz_vmr *filter = impl_from_IBaseFilter(&iface->filter.IBaseFilter_iface);
if (IsEqualGUID(iid, &IID_IVideoWindow)) - *out = &filter->baseControlWindow.IVideoWindow_iface; + *out = &filter->window.IVideoWindow_iface; else if (IsEqualGUID(iid, &IID_IBasicVideo)) *out = &filter->baseControlVideo.IBasicVideo_iface; else if (IsEqualGUID(iid, &IID_IAMCertifiedOutputProtection)) @@ -824,7 +824,7 @@ static HRESULT WINAPI VMR9_SetDefaultTargetRect(BaseControlVideo* This) RECT rect; struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
- if (!GetClientRect(pVMR9->baseControlWindow.hwnd, &rect)) + if (!GetClientRect(pVMR9->window.hwnd, &rect)) return E_FAIL;
SetRect(&pVMR9->target_rect, 0, 0, rect.right, rect.bottom); @@ -1598,7 +1598,7 @@ static HRESULT WINAPI VMR7WindowlessControl_SetVideoPosition(IVMRWindowlessContr { This->target_rect = *dest; FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest)); - SetWindowPos(This->baseControlWindow.hwnd, NULL, + SetWindowPos(This->window.hwnd, NULL, dest->left, dest->top, dest->right - dest->left, dest->bottom-dest->top, SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_NOREDRAW); } @@ -1799,7 +1799,7 @@ static HRESULT WINAPI VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessContr { This->target_rect = *dest; FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest)); - SetWindowPos(This->baseControlWindow.hwnd, NULL, + SetWindowPos(This->window.hwnd, NULL, dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top, SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOOWNERZORDER | SWP_NOREDRAW); } @@ -1874,7 +1874,7 @@ static HRESULT WINAPI VMR9WindowlessControl_RepaintVideo(IVMRWindowlessControl9 FIXME("(%p/%p)->(...) semi-stub\n", iface, This);
EnterCriticalSection(&This->renderer.filter.csFilter); - if (hwnd != This->hWndClippingWindow && hwnd != This->baseControlWindow.hwnd) + if (hwnd != This->hWndClippingWindow && hwnd != This->window.hwnd) { ERR("Not handling changing windows yet!!!\n"); LeaveCriticalSection(&This->renderer.filter.csFilter); @@ -1889,7 +1889,7 @@ static HRESULT WINAPI VMR9WindowlessControl_RepaintVideo(IVMRWindowlessControl9 }
/* Windowless extension */ - hr = IDirect3DDevice9_Present(This->allocator_d3d9_dev, NULL, NULL, This->baseControlWindow.hwnd, NULL); + hr = IDirect3DDevice9_Present(This->allocator_d3d9_dev, NULL, NULL, This->window.hwnd, NULL); LeaveCriticalSection(&This->renderer.filter.csFilter);
return hr; @@ -2348,7 +2348,7 @@ static HRESULT WINAPI overlay_GetWindowHandle(IOverlay *iface, HWND *window)
TRACE("filter %p, window %p.\n", filter, window);
- *window = filter->baseControlWindow.hwnd; + *window = filter->window.hwnd; return S_OK; }
@@ -2423,12 +2423,12 @@ static HRESULT vmr_create(IUnknown *outer, IUnknown **out, const CLSID *clsid) object->IVMRWindowlessControl9_iface.lpVtbl = &VMR9_WindowlessControl_Vtbl; object->IOverlay_iface.lpVtbl = &overlay_vtbl;
- video_window_init(&object->baseControlWindow, &IVideoWindow_VTable, + video_window_init(&object->window, &IVideoWindow_VTable, &object->renderer.filter, &object->renderer.sink.pin, &window_ops);
- if (FAILED(hr = video_window_create_window(&object->baseControlWindow))) + if (FAILED(hr = video_window_create_window(&object->window))) { - video_window_cleanup(&object->baseControlWindow); + video_window_cleanup(&object->window); strmbase_renderer_cleanup(&object->renderer); FreeLibrary(object->hD3d9); free(object); @@ -2621,7 +2621,7 @@ static HRESULT WINAPI VMR9_ImagePresenter_PresentImage(IVMRImagePresenter9 *ifac BOOL render = FALSE;
TRACE("(%p/%p/%p)->(...) stub\n", iface, This, This->pVMR9); - GetWindowRect(This->pVMR9->baseControlWindow.hwnd, &output); + GetWindowRect(This->pVMR9->window.hwnd, &output); TRACE("Output rectangle: %s\n", wine_dbgstr_rect(&output));
/* This might happen if we don't have active focus (eg on a different virtual desktop) */ @@ -2646,7 +2646,7 @@ static HRESULT WINAPI VMR9_ImagePresenter_PresentImage(IVMRImagePresenter9 *ifac hr = IDirect3DDevice9_EndScene(This->d3d9_dev); if (render && SUCCEEDED(hr)) { - hr = IDirect3DDevice9_Present(This->d3d9_dev, NULL, NULL, This->pVMR9->baseControlWindow.hwnd, NULL); + hr = IDirect3DDevice9_Present(This->d3d9_dev, NULL, NULL, This->pVMR9->window.hwnd, NULL); if (FAILED(hr)) FIXME("Presenting image: %08x\n", hr); } @@ -2770,12 +2770,12 @@ static BOOL CreateRenderingWindow(struct default_presenter *This, VMR9Allocation TRACE("(%p)->()\n", This);
/* Obtain a monitor and d3d9 device */ - d3d9_adapter = d3d9_adapter_from_hwnd(This->d3d9_ptr, This->pVMR9->baseControlWindow.hwnd, &This->hMon); + d3d9_adapter = d3d9_adapter_from_hwnd(This->d3d9_ptr, This->pVMR9->window.hwnd, &This->hMon);
/* Now try to create the d3d9 device */ ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; - d3dpp.hDeviceWindow = This->pVMR9->baseControlWindow.hwnd; + d3dpp.hDeviceWindow = This->pVMR9->window.hwnd; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferHeight = This->pVMR9->target_rect.bottom - This->pVMR9->target_rect.top; d3dpp.BackBufferWidth = This->pVMR9->target_rect.right - This->pVMR9->target_rect.left; @@ -2874,19 +2874,19 @@ static HRESULT VMR9_SurfaceAllocator_UpdateDeviceReset(struct default_presenter /* Now try to create the d3d9 device */ ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; - d3dpp.hDeviceWindow = This->pVMR9->baseControlWindow.hwnd; + d3dpp.hDeviceWindow = This->pVMR9->window.hwnd; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
if (This->d3d9_dev) IDirect3DDevice9_Release(This->d3d9_dev); This->d3d9_dev = NULL; hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter_from_hwnd(This->d3d9_ptr, - This->pVMR9->baseControlWindow.hwnd, &This->hMon), D3DDEVTYPE_HAL, NULL, + This->pVMR9->window.hwnd, &This->hMon), D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev); if (FAILED(hr)) { hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter_from_hwnd(This->d3d9_ptr, - This->pVMR9->baseControlWindow.hwnd, &This->hMon), D3DDEVTYPE_HAL, NULL, + This->pVMR9->window.hwnd, &This->hMon), D3DDEVTYPE_HAL, NULL, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev); if (FAILED(hr)) {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/quartz_private.h | 3 +-- dlls/quartz/video.c | 43 ++++++++++++++++++++---------------- dlls/quartz/videorenderer.c | 23 ------------------- dlls/quartz/vmr9.c | 23 ------------------- 4 files changed, 25 insertions(+), 67 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 9c39b642c48..2aca6000742 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -31,6 +31,7 @@ #include "wingdi.h" #include "winuser.h" #include "dshow.h" +#include "dvdmedia.h" #include "wine/debug.h" #include "wine/heap.h" #include "wine/strmbase.h" @@ -174,7 +175,6 @@ typedef struct tagBaseControlVideo typedef HRESULT (WINAPI *BaseControlVideo_GetSourceRect)(BaseControlVideo* This, RECT *pSourceRect); typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage); typedef HRESULT (WINAPI *BaseControlVideo_GetTargetRect)(BaseControlVideo* This, RECT *pTargetRect); -typedef VIDEOINFOHEADER* (WINAPI *BaseControlVideo_GetVideoFormat)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultSourceRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultTargetRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This); @@ -187,7 +187,6 @@ typedef struct BaseControlVideoFuncTable BaseControlVideo_GetSourceRect pfnGetSourceRect; BaseControlVideo_GetStaticImage pfnGetStaticImage; BaseControlVideo_GetTargetRect pfnGetTargetRect; - BaseControlVideo_GetVideoFormat pfnGetVideoFormat; BaseControlVideo_IsDefaultSourceRect pfnIsDefaultSourceRect; BaseControlVideo_IsDefaultTargetRect pfnIsDefaultTargetRect; BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect; diff --git a/dlls/quartz/video.c b/dlls/quartz/video.c index 11baee261d5..213e3ce92db 100644 --- a/dlls/quartz/video.c +++ b/dlls/quartz/video.c @@ -120,9 +120,24 @@ static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID i return hr; }
+static const VIDEOINFOHEADER *get_video_format(BaseControlVideo *video) +{ + /* Members of VIDEOINFOHEADER up to bmiHeader are identical to those of + * VIDEOINFOHEADER2. */ + return (const VIDEOINFOHEADER *)video->pPin->mt.pbFormat; +} + +static const BITMAPINFOHEADER *get_bitmap_header(BaseControlVideo *video) +{ + const AM_MEDIA_TYPE *mt = &video->pPin->mt; + if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; + else + return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; +} + static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame) { - VIDEOINFOHEADER *vih; BaseControlVideo *This = impl_from_IBasicVideo(iface);
if (!pAvgTimePerFrame) @@ -132,14 +147,12 @@ static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIM
TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame);
- vih = This->pFuncsTable->pfnGetVideoFormat(This); - *pAvgTimePerFrame = vih->AvgTimePerFrame; + *pAvgTimePerFrame = get_video_format(This)->AvgTimePerFrame; return S_OK; }
static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate) { - VIDEOINFOHEADER *vih; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate); @@ -149,14 +162,12 @@ static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate if (!This->pPin->peer) return VFW_E_NOT_CONNECTED;
- vih = This->pFuncsTable->pfnGetVideoFormat(This); - *pBitRate = vih->dwBitRate; + *pBitRate = get_video_format(This)->dwBitRate; return S_OK; }
static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate) { - VIDEOINFOHEADER *vih; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate); @@ -166,37 +177,32 @@ static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBi if (!This->pPin->peer) return VFW_E_NOT_CONNECTED;
- vih = This->pFuncsTable->pfnGetVideoFormat(This); - *pBitErrorRate = vih->dwBitErrorRate; + *pBitErrorRate = get_video_format(This)->dwBitErrorRate; return S_OK; }
static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth) { - VIDEOINFOHEADER *vih; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth); if (!pVideoWidth) return E_POINTER;
- vih = This->pFuncsTable->pfnGetVideoFormat(This); - *pVideoWidth = vih->bmiHeader.biWidth; + *pVideoWidth = get_bitmap_header(This)->biWidth;
return S_OK; }
static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight) { - VIDEOINFOHEADER *vih; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight); if (!pVideoHeight) return E_POINTER;
- vih = This->pFuncsTable->pfnGetVideoFormat(This); - *pVideoHeight = abs(vih->bmiHeader.biHeight); + *pVideoHeight = abs(get_bitmap_header(This)->biHeight);
return S_OK; } @@ -550,16 +556,15 @@ static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *ifa
static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight) { - VIDEOINFOHEADER *vih; BaseControlVideo *This = impl_from_IBasicVideo(iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(This);
TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight); if (!pWidth || !pHeight) return E_POINTER;
- vih = This->pFuncsTable->pfnGetVideoFormat(This); - *pHeight = vih->bmiHeader.biHeight; - *pWidth = vih->bmiHeader.biWidth; + *pHeight = bitmap_header->biHeight; + *pWidth = bitmap_header->biWidth;
return S_OK; } diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 6e31e196951..b7a82e4faa3 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -352,28 +352,6 @@ static HRESULT WINAPI VideoRenderer_GetTargetRect(BaseControlVideo* iface, RECT return S_OK; }
-static VIDEOINFOHEADER* WINAPI VideoRenderer_GetVideoFormat(BaseControlVideo* iface) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - AM_MEDIA_TYPE *pmt; - - TRACE("(%p/%p)\n", This, iface); - - pmt = &This->renderer.sink.pin.mt; - if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) { - return (VIDEOINFOHEADER*)pmt->pbFormat; - } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) { - static VIDEOINFOHEADER vih; - VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat; - memcpy(&vih,vih2,sizeof(VIDEOINFOHEADER)); - memcpy(&vih.bmiHeader, &vih2->bmiHeader, sizeof(BITMAPINFOHEADER)); - return &vih; - } else { - ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt->formattype)); - return NULL; - } -} - static HRESULT WINAPI VideoRenderer_IsDefaultSourceRect(BaseControlVideo* iface) { struct video_renderer *This = impl_from_BaseControlVideo(iface); @@ -430,7 +408,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { VideoRenderer_GetSourceRect, VideoRenderer_GetStaticImage, VideoRenderer_GetTargetRect, - VideoRenderer_GetVideoFormat, VideoRenderer_IsDefaultSourceRect, VideoRenderer_IsDefaultTargetRect, VideoRenderer_SetDefaultSourceRect, diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 8fdcb3809be..abca2a03d17 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -772,28 +772,6 @@ static HRESULT WINAPI VMR9_GetTargetRect(BaseControlVideo* This, RECT *pTargetRe return S_OK; }
-static VIDEOINFOHEADER* WINAPI VMR9_GetVideoFormat(BaseControlVideo* This) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - AM_MEDIA_TYPE *pmt; - - TRACE("(%p/%p)\n", pVMR9, This); - - pmt = &pVMR9->renderer.sink.pin.mt; - if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo)) { - return (VIDEOINFOHEADER*)pmt->pbFormat; - } else if (IsEqualIID(&pmt->formattype, &FORMAT_VideoInfo2)) { - static VIDEOINFOHEADER vih; - VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat; - memcpy(&vih,vih2,sizeof(VIDEOINFOHEADER)); - memcpy(&vih.bmiHeader, &vih2->bmiHeader, sizeof(BITMAPINFOHEADER)); - return &vih; - } else { - ERR("Unknown format type %s\n", qzdebugstr_guid(&pmt->formattype)); - return NULL; - } -} - static HRESULT WINAPI VMR9_IsDefaultSourceRect(BaseControlVideo* This) { struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); @@ -850,7 +828,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { VMR9_GetSourceRect, VMR9_GetStaticImage, VMR9_GetTargetRect, - VMR9_GetVideoFormat, VMR9_IsDefaultSourceRect, VMR9_IsDefaultTargetRect, VMR9_SetDefaultSourceRect,
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/quartz_private.h | 4 ---- dlls/quartz/video.c | 8 ++++---- dlls/quartz/videorenderer.c | 18 ------------------ dlls/quartz/vmr9.c | 18 ------------------ 4 files changed, 4 insertions(+), 44 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 2aca6000742..7f2372ce33b 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -175,8 +175,6 @@ typedef struct tagBaseControlVideo typedef HRESULT (WINAPI *BaseControlVideo_GetSourceRect)(BaseControlVideo* This, RECT *pSourceRect); typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage); typedef HRESULT (WINAPI *BaseControlVideo_GetTargetRect)(BaseControlVideo* This, RECT *pTargetRect); -typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultSourceRect)(BaseControlVideo* This); -typedef HRESULT (WINAPI *BaseControlVideo_IsDefaultTargetRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultTargetRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_SetSourceRect)(BaseControlVideo* This, RECT *pSourceRect); @@ -187,8 +185,6 @@ typedef struct BaseControlVideoFuncTable BaseControlVideo_GetSourceRect pfnGetSourceRect; BaseControlVideo_GetStaticImage pfnGetStaticImage; BaseControlVideo_GetTargetRect pfnGetTargetRect; - BaseControlVideo_IsDefaultSourceRect pfnIsDefaultSourceRect; - BaseControlVideo_IsDefaultTargetRect pfnIsDefaultTargetRect; BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect; BaseControlVideo_SetDefaultTargetRect pfnSetDefaultTargetRect; BaseControlVideo_SetSourceRect pfnSetSourceRect; diff --git a/dlls/quartz/video.c b/dlls/quartz/video.c index 213e3ce92db..2d002d8de43 100644 --- a/dlls/quartz/video.c +++ b/dlls/quartz/video.c @@ -592,16 +592,16 @@ static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *pBuf
static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface) { - BaseControlVideo *This = impl_from_IBasicVideo(iface); + FIXME("iface %p, stub!\n", iface);
- return This->pFuncsTable->pfnIsDefaultSourceRect(This); + return S_OK; }
static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface) { - BaseControlVideo *This = impl_from_IBasicVideo(iface); + FIXME("iface %p, stub!\n", iface);
- return This->pFuncsTable->pfnIsDefaultTargetRect(This); + return S_OK; }
static const IBasicVideoVtbl basic_video_vtbl = diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index b7a82e4faa3..39d1586c772 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -352,22 +352,6 @@ static HRESULT WINAPI VideoRenderer_GetTargetRect(BaseControlVideo* iface, RECT return S_OK; }
-static HRESULT WINAPI VideoRenderer_IsDefaultSourceRect(BaseControlVideo* iface) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - FIXME("(%p/%p)->(): stub !!!\n", This, iface); - - return S_OK; -} - -static HRESULT WINAPI VideoRenderer_IsDefaultTargetRect(BaseControlVideo* iface) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - FIXME("(%p/%p)->(): stub !!!\n", This, iface); - - return S_OK; -} - static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(BaseControlVideo* iface) { struct video_renderer *This = impl_from_BaseControlVideo(iface); @@ -408,8 +392,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { VideoRenderer_GetSourceRect, VideoRenderer_GetStaticImage, VideoRenderer_GetTargetRect, - VideoRenderer_IsDefaultSourceRect, - VideoRenderer_IsDefaultTargetRect, VideoRenderer_SetDefaultSourceRect, VideoRenderer_SetDefaultTargetRect, VideoRenderer_SetSourceRect, diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index abca2a03d17..c0d6799eec1 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -772,22 +772,6 @@ static HRESULT WINAPI VMR9_GetTargetRect(BaseControlVideo* This, RECT *pTargetRe return S_OK; }
-static HRESULT WINAPI VMR9_IsDefaultSourceRect(BaseControlVideo* This) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - FIXME("(%p/%p)->(): stub !!!\n", pVMR9, This); - - return S_OK; -} - -static HRESULT WINAPI VMR9_IsDefaultTargetRect(BaseControlVideo* This) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - FIXME("(%p/%p)->(): stub !!!\n", pVMR9, This); - - return S_OK; -} - static HRESULT WINAPI VMR9_SetDefaultSourceRect(BaseControlVideo* This) { struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); @@ -828,8 +812,6 @@ static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { VMR9_GetSourceRect, VMR9_GetStaticImage, VMR9_GetTargetRect, - VMR9_IsDefaultSourceRect, - VMR9_IsDefaultTargetRect, VMR9_SetDefaultSourceRect, VMR9_SetDefaultTargetRect, VMR9_SetSourceRect,
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/quartz_private.h | 10 +- dlls/quartz/video.c | 216 ++++++++++++----------------------- dlls/quartz/videorenderer.c | 68 +++-------- dlls/quartz/vmr9.c | 93 +++++---------- 4 files changed, 111 insertions(+), 276 deletions(-)
diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 7f2372ce33b..2bbebd48b3a 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -166,29 +166,23 @@ typedef struct tagBaseControlVideo { IBasicVideo IBasicVideo_iface;
+ RECT src, dst; + struct strmbase_filter *pFilter; struct strmbase_pin *pPin;
const struct BaseControlVideoFuncTable *pFuncsTable; } BaseControlVideo;
-typedef HRESULT (WINAPI *BaseControlVideo_GetSourceRect)(BaseControlVideo* This, RECT *pSourceRect); typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage); -typedef HRESULT (WINAPI *BaseControlVideo_GetTargetRect)(BaseControlVideo* This, RECT *pTargetRect); typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This); typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultTargetRect)(BaseControlVideo* This); -typedef HRESULT (WINAPI *BaseControlVideo_SetSourceRect)(BaseControlVideo* This, RECT *pSourceRect); -typedef HRESULT (WINAPI *BaseControlVideo_SetTargetRect)(BaseControlVideo* This, RECT *pTargetRect);
typedef struct BaseControlVideoFuncTable { - BaseControlVideo_GetSourceRect pfnGetSourceRect; BaseControlVideo_GetStaticImage pfnGetStaticImage; - BaseControlVideo_GetTargetRect pfnGetTargetRect; BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect; BaseControlVideo_SetDefaultTargetRect pfnSetDefaultTargetRect; - BaseControlVideo_SetSourceRect pfnSetSourceRect; - BaseControlVideo_SetTargetRect pfnSetTargetRect; } BaseControlVideoFuncTable;
void basic_video_init(BaseControlVideo *video, struct strmbase_filter *filter, diff --git a/dlls/quartz/video.c b/dlls/quartz/video.c index 2d002d8de43..ace83664898 100644 --- a/dlls/quartz/video.c +++ b/dlls/quartz/video.c @@ -207,271 +207,197 @@ static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVid return S_OK; }
-static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG SourceLeft) +static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG left) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, SourceLeft); - hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - if (SUCCEEDED(hr)) - { - SourceRect.right = (SourceRect.right - SourceRect.left) + SourceLeft; - SourceRect.left = SourceLeft; - hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect); + TRACE("iface %p, left %d.\n", iface, left);
- return hr; + if (left < 0 || This->src.right + left - This->src.left > get_bitmap_header(This)->biWidth) + return E_INVALIDARG; + + OffsetRect(&This->src, left - This->src.left, 0); + return S_OK; }
static HRESULT WINAPI basic_video_get_SourceLeft(IBasicVideo *iface, LONG *pSourceLeft) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft); if (!pSourceLeft) return E_POINTER; - This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - *pSourceLeft = SourceRect.left; + *pSourceLeft = This->src.left;
return S_OK; }
-static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG SourceWidth) +static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG width) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, SourceWidth); - hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - if (SUCCEEDED(hr)) - { - SourceRect.right = SourceRect.left + SourceWidth; - hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect); + TRACE("iface %p, width %d.\n", iface, width);
- return hr; + if (width <= 0 || This->src.left + width > get_bitmap_header(This)->biWidth) + return E_INVALIDARG; + + This->src.right = This->src.left + width; + return S_OK; }
static HRESULT WINAPI basic_video_get_SourceWidth(IBasicVideo *iface, LONG *pSourceWidth) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth); if (!pSourceWidth) return E_POINTER; - This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - *pSourceWidth = SourceRect.right - SourceRect.left; + *pSourceWidth = This->src.right - This->src.left;
return S_OK; }
-static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG SourceTop) +static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG top) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, SourceTop); - hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - if (SUCCEEDED(hr)) - { - SourceRect.bottom = (SourceRect.bottom - SourceRect.top) + SourceTop; - SourceRect.top = SourceTop; - hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect); + TRACE("iface %p, top %d.\n", iface, top);
- return hr; + if (top < 0 || This->src.bottom + top - This->src.top > get_bitmap_header(This)->biHeight) + return E_INVALIDARG; + + OffsetRect(&This->src, 0, top - This->src.top); + return S_OK; }
static HRESULT WINAPI basic_video_get_SourceTop(IBasicVideo *iface, LONG *pSourceTop) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop); if (!pSourceTop) return E_POINTER; - This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - *pSourceTop = SourceRect.top; + *pSourceTop = This->src.top;
return S_OK; }
-static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG SourceHeight) +static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG height) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, SourceHeight); - hr = This->pFuncsTable->pfnGetSourceRect(This, &SourceRect); - if (SUCCEEDED(hr)) - { - SourceRect.bottom = SourceRect.top + SourceHeight; - hr = BaseControlVideoImpl_CheckSourceRect(This, &SourceRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetSourceRect(This, &SourceRect); + TRACE("iface %p, height %d.\n", iface, height);
- return hr; + if (height <= 0 || This->src.top + height > get_bitmap_header(This)->biHeight) + return E_INVALIDARG; + + This->src.bottom = This->src.top + height; + return S_OK; }
static HRESULT WINAPI basic_video_get_SourceHeight(IBasicVideo *iface, LONG *pSourceHeight) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight); if (!pSourceHeight) return E_POINTER; - This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
- *pSourceHeight = SourceRect.bottom - SourceRect.top; + *pSourceHeight = This->src.bottom - This->src.top;
return S_OK; }
-static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG DestinationLeft) +static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG left) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, DestinationLeft); - hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - if (SUCCEEDED(hr)) - { - DestRect.right = (DestRect.right - DestRect.left) + DestinationLeft; - DestRect.left = DestinationLeft; - hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect); + TRACE("iface %p, left %d.\n", iface, left);
- return hr; + OffsetRect(&This->dst, left - This->dst.left, 0); + return S_OK; }
static HRESULT WINAPI basic_video_get_DestinationLeft(IBasicVideo *iface, LONG *pDestinationLeft) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft); if (!pDestinationLeft) return E_POINTER; - This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - *pDestinationLeft = DestRect.left; + *pDestinationLeft = This->dst.left;
return S_OK; }
-static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG DestinationWidth) +static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG width) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, DestinationWidth); - hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - if (SUCCEEDED(hr)) - { - DestRect.right = DestRect.left + DestinationWidth; - hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect); + TRACE("iface %p, width %d.\n", iface, width);
- return hr; + if (width <= 0) + return E_INVALIDARG; + + This->dst.right = This->dst.left + width; + return S_OK; }
static HRESULT WINAPI basic_video_get_DestinationWidth(IBasicVideo *iface, LONG *pDestinationWidth) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth); if (!pDestinationWidth) return E_POINTER; - This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - *pDestinationWidth = DestRect.right - DestRect.left; + *pDestinationWidth = This->dst.right - This->dst.left;
return S_OK; }
-static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG DestinationTop) +static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG top) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, DestinationTop); - hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - if (SUCCEEDED(hr)) - { - DestRect.bottom = (DestRect.bottom - DestRect.top) + DestinationTop; - DestRect.top = DestinationTop; - hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect); + TRACE("iface %p, top %d.\n", iface, top);
- return hr; + OffsetRect(&This->dst, 0, top - This->dst.top); + return S_OK; }
static HRESULT WINAPI basic_video_get_DestinationTop(IBasicVideo *iface, LONG *pDestinationTop) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop); if (!pDestinationTop) return E_POINTER; - This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - *pDestinationTop = DestRect.top; + *pDestinationTop = This->dst.top;
return S_OK; }
-static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG DestinationHeight) +static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG height) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface); - HRESULT hr;
- TRACE("(%p/%p)->(%d)\n", This, iface, DestinationHeight); - hr = This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - if (SUCCEEDED(hr)) - { - DestRect.bottom = DestRect.top + DestinationHeight; - hr = BaseControlVideoImpl_CheckTargetRect(This, &DestRect); - } - if (SUCCEEDED(hr)) - hr = This->pFuncsTable->pfnSetTargetRect(This, &DestRect); + TRACE("iface %p, height %d.\n", iface, height);
- return hr; + if (height <= 0) + return E_INVALIDARG; + + This->dst.bottom = This->dst.top + height; + return S_OK; }
static HRESULT WINAPI basic_video_get_DestinationHeight(IBasicVideo *iface, LONG *pDestinationHeight) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight); if (!pDestinationHeight) return E_POINTER; - This->pFuncsTable->pfnGetTargetRect(This, &DestRect); - *pDestinationHeight = DestRect.bottom - DestRect.top; + *pDestinationHeight = This->dst.bottom - This->dst.top;
return S_OK; } @@ -486,23 +412,22 @@ static HRESULT WINAPI basic_video_SetSourcePosition(IBasicVideo *iface, LONG Lef SetRect(&SourceRect, Left, Top, Left + Width, Top + Height); if (FAILED(BaseControlVideoImpl_CheckSourceRect(This, &SourceRect))) return E_INVALIDARG; - return This->pFuncsTable->pfnSetSourceRect(This, &SourceRect); + This->src = SourceRect; + return S_OK; }
static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight) { - RECT SourceRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight); if (!pLeft || !pTop || !pWidth || !pHeight) return E_POINTER; - This->pFuncsTable->pfnGetSourceRect(This, &SourceRect);
- *pLeft = SourceRect.left; - *pTop = SourceRect.top; - *pWidth = SourceRect.right - SourceRect.left; - *pHeight = SourceRect.bottom - SourceRect.top; + *pLeft = This->src.left; + *pTop = This->src.top; + *pWidth = This->src.right - This->src.left; + *pHeight = This->src.bottom - This->src.top;
return S_OK; } @@ -525,23 +450,22 @@ static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, LON SetRect(&DestRect, Left, Top, Left + Width, Top + Height); if (FAILED(BaseControlVideoImpl_CheckTargetRect(This, &DestRect))) return E_INVALIDARG; - return This->pFuncsTable->pfnSetTargetRect(This, &DestRect); + This->dst = DestRect; + return S_OK; }
static HRESULT WINAPI basic_video_GetDestinationPosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight) { - RECT DestRect; BaseControlVideo *This = impl_from_IBasicVideo(iface);
TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight); if (!pLeft || !pTop || !pWidth || !pHeight) return E_POINTER; - This->pFuncsTable->pfnGetTargetRect(This, &DestRect);
- *pLeft = DestRect.left; - *pTop = DestRect.top; - *pWidth = DestRect.right - DestRect.left; - *pHeight = DestRect.bottom - DestRect.top; + *pLeft = This->dst.left; + *pTop = This->dst.top; + *pWidth = This->dst.right - This->dst.left; + *pHeight = This->dst.bottom - This->dst.top;
return S_OK; } diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 39d1586c772..9a79ad4581c 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -44,8 +44,6 @@ struct video_renderer
IOverlay IOverlay_iface;
- RECT SourceRect; - RECT DestRect; LONG VideoWidth; LONG VideoHeight; LONG FullScreenMode; @@ -102,6 +100,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); + RECT src = filter->baseControlVideo.src, dst = filter->baseControlVideo.dst; LPBYTE pbSrcStream = NULL; HRESULT hr; HDC dc; @@ -116,13 +115,9 @@ static HRESULT WINAPI VideoRenderer_DoRenderSample(struct strmbase_renderer *ifa }
dc = GetDC(filter->window.hwnd); - StretchDIBits(dc, filter->DestRect.left, filter->DestRect.top, - filter->DestRect.right - filter->DestRect.left, - filter->DestRect.bottom - filter->DestRect.top, - filter->SourceRect.left, filter->SourceRect.top, - filter->SourceRect.right - filter->SourceRect.left, - filter->SourceRect.bottom - filter->SourceRect.top, - pbSrcStream, (BITMAPINFO *)get_bitmap_header(&filter->renderer.sink.pin.mt), DIB_RGB_COLORS, SRCCOPY); + StretchDIBits(dc, dst.left, dst.top, dst.right - dst.left, dst.bottom - dst.top, + src.left, src.top, src.right - src.left, src.bottom - src.top, pbSrcStream, + (BITMAPINFO *)get_bitmap_header(&filter->renderer.sink.pin.mt), DIB_RGB_COLORS, SRCCOPY); ReleaseDC(filter->window.hwnd, dc);
if (filter->renderer.filter.state == State_Paused) @@ -236,7 +231,7 @@ static HRESULT video_renderer_connect(struct strmbase_renderer *iface, const AM_ filter->VideoWidth = bitmap_header->biWidth; filter->VideoHeight = abs(bitmap_header->biHeight); SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight); - filter->SourceRect = filter->DestRect = rect; + filter->baseControlVideo.src = filter->baseControlVideo.dst = rect;
AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE, GetWindowLongW(window, GWL_EXSTYLE)); @@ -258,15 +253,10 @@ static RECT video_renderer_get_default_rect(struct video_window *iface)
static BOOL video_renderer_resize(struct video_window *iface, LONG Width, LONG Height) { - struct video_renderer *This = impl_from_video_window(iface); + struct video_renderer *filter = impl_from_video_window(iface);
TRACE("WM_SIZE %d %d\n", Width, Height); - GetClientRect(iface->hwnd, &This->DestRect); - TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n", - This->DestRect.left, - This->DestRect.top, - This->DestRect.right - This->DestRect.left, - This->DestRect.bottom - This->DestRect.top); + GetClientRect(iface->hwnd, &filter->baseControlVideo.dst);
return TRUE; } @@ -291,13 +281,6 @@ static const struct video_window_ops window_ops = .resize = video_renderer_resize, };
-static HRESULT WINAPI VideoRenderer_GetSourceRect(BaseControlVideo* iface, RECT *pSourceRect) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - CopyRect(pSourceRect,&This->SourceRect); - return S_OK; -} - static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image) { struct video_renderer *filter = impl_from_BaseControlVideo(iface); @@ -345,18 +328,11 @@ static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG return S_OK; }
-static HRESULT WINAPI VideoRenderer_GetTargetRect(BaseControlVideo* iface, RECT *pTargetRect) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - CopyRect(pTargetRect,&This->DestRect); - return S_OK; -} - static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(BaseControlVideo* iface) { struct video_renderer *This = impl_from_BaseControlVideo(iface);
- SetRect(&This->SourceRect, 0, 0, This->VideoWidth, This->VideoHeight); + SetRect(&This->baseControlVideo.src, 0, 0, This->VideoWidth, This->VideoHeight);
return S_OK; } @@ -369,33 +345,15 @@ static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(BaseControlVideo* iface if (!GetClientRect(This->window.hwnd, &rect)) return E_FAIL;
- SetRect(&This->DestRect, 0, 0, rect.right, rect.bottom); + SetRect(&This->baseControlVideo.dst, 0, 0, rect.right, rect.bottom);
return S_OK; }
-static HRESULT WINAPI VideoRenderer_SetSourceRect(BaseControlVideo* iface, RECT *pSourceRect) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - CopyRect(&This->SourceRect,pSourceRect); - return S_OK; -} - -static HRESULT WINAPI VideoRenderer_SetTargetRect(BaseControlVideo* iface, RECT *pTargetRect) -{ - struct video_renderer *This = impl_from_BaseControlVideo(iface); - CopyRect(&This->DestRect,pTargetRect); - return S_OK; -} - static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { - VideoRenderer_GetSourceRect, VideoRenderer_GetStaticImage, - VideoRenderer_GetTargetRect, VideoRenderer_SetDefaultSourceRect, VideoRenderer_SetDefaultTargetRect, - VideoRenderer_SetSourceRect, - VideoRenderer_SetTargetRect };
static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface, @@ -428,16 +386,16 @@ static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG f SetWindowLongW(window, GWL_STYLE, WS_POPUP); SetWindowPos(window, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW); - GetWindowRect(window, &filter->DestRect); + GetWindowRect(window, &filter->baseControlVideo.dst); } else { ShowWindow(window, SW_HIDE); SetParent(window, filter->window.hwndOwner); SetWindowLongW(window, GWL_STYLE, filter->saved_style); - GetClientRect(window, &filter->DestRect); - SetWindowPos(window, 0, filter->DestRect.left, filter->DestRect.top, - filter->DestRect.right, filter->DestRect.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); + GetClientRect(window, &filter->baseControlVideo.dst); + SetWindowPos(window, 0, filter->baseControlVideo.dst.left, filter->baseControlVideo.dst.top, + filter->baseControlVideo.dst.right, filter->baseControlVideo.dst.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); } filter->FullScreenMode = fullscreen;
diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index c0d6799eec1..4e535629cce 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -104,8 +104,6 @@ struct quartz_vmr /* for Windowless Mode */ HWND hWndClippingWindow;
- RECT source_rect; - RECT target_rect; LONG VideoWidth; LONG VideoHeight;
@@ -229,9 +227,6 @@ static DWORD VMR9_SendSampleData(struct quartz_vmr *This, VMR9PresentationInfo * width = bmiHeader->biWidth; height = bmiHeader->biHeight;
- TRACE("Src Rect: %s\n", wine_dbgstr_rect(&This->source_rect)); - TRACE("Dst Rect: %s\n", wine_dbgstr_rect(&This->target_rect)); - hr = IDirect3DSurface9_LockRect(info->lpSurf, &lock, NULL, D3DLOCK_DISCARD); if (FAILED(hr)) { @@ -420,8 +415,8 @@ static HRESULT allocate_surfaces(struct quartz_vmr *filter, const AM_MEDIA_TYPE if (filter->mode == VMR9Mode_Windowless && !filter->hWndClippingWindow) return S_OK;
- info.dwWidth = filter->source_rect.right; - info.dwHeight = filter->source_rect.bottom; + info.dwWidth = filter->baseControlVideo.src.right; + info.dwHeight = filter->baseControlVideo.src.bottom; info.Pool = D3DPOOL_DEFAULT; info.MinBuffers = 1; info.szAspectRatio.cx = info.dwWidth; @@ -517,7 +512,7 @@ static HRESULT vmr_connect(struct strmbase_renderer *iface, const AM_MEDIA_TYPE filter->VideoWidth = bitmap_header->biWidth; filter->VideoHeight = bitmap_header->biHeight; SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight); - filter->source_rect = filter->target_rect = rect; + filter->baseControlVideo.src = filter->baseControlVideo.dst = rect;
AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE, GetWindowLongW(window, GWL_EXSTYLE)); @@ -679,12 +674,7 @@ static BOOL vmr_resize(struct video_window *This, LONG Width, LONG Height) struct quartz_vmr *pVMR9 = impl_from_video_window(This);
TRACE("WM_SIZE %d %d\n", Width, Height); - GetClientRect(This->hwnd, &pVMR9->target_rect); - TRACE("WM_SIZING: DestRect=(%d,%d),(%d,%d)\n", - pVMR9->target_rect.left, - pVMR9->target_rect.top, - pVMR9->target_rect.right - pVMR9->target_rect.left, - pVMR9->target_rect.bottom - pVMR9->target_rect.top); + GetClientRect(This->hwnd, &pVMR9->baseControlVideo.dst);
return TRUE; } @@ -695,13 +685,6 @@ static const struct video_window_ops window_ops = .resize = vmr_resize, };
-static HRESULT WINAPI VMR9_GetSourceRect(BaseControlVideo* This, RECT *pSourceRect) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - CopyRect(pSourceRect,&pVMR9->source_rect); - return S_OK; -} - static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image) { struct quartz_vmr *filter = impl_from_BaseControlVideo(iface); @@ -765,18 +748,11 @@ out: return hr; }
-static HRESULT WINAPI VMR9_GetTargetRect(BaseControlVideo* This, RECT *pTargetRect) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - CopyRect(pTargetRect,&pVMR9->target_rect); - return S_OK; -} - static HRESULT WINAPI VMR9_SetDefaultSourceRect(BaseControlVideo* This) { struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This);
- SetRect(&pVMR9->source_rect, 0, 0, pVMR9->VideoWidth, pVMR9->VideoHeight); + SetRect(&pVMR9->baseControlVideo.src, 0, 0, pVMR9->VideoWidth, pVMR9->VideoHeight);
return S_OK; } @@ -789,33 +765,15 @@ static HRESULT WINAPI VMR9_SetDefaultTargetRect(BaseControlVideo* This) if (!GetClientRect(pVMR9->window.hwnd, &rect)) return E_FAIL;
- SetRect(&pVMR9->target_rect, 0, 0, rect.right, rect.bottom); - - return S_OK; -} + SetRect(&pVMR9->baseControlVideo.dst, 0, 0, rect.right, rect.bottom);
-static HRESULT WINAPI VMR9_SetSourceRect(BaseControlVideo* This, RECT *pSourceRect) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - CopyRect(&pVMR9->source_rect,pSourceRect); - return S_OK; -} - -static HRESULT WINAPI VMR9_SetTargetRect(BaseControlVideo* This, RECT *pTargetRect) -{ - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); - CopyRect(&pVMR9->target_rect,pTargetRect); return S_OK; }
static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { - VMR9_GetSourceRect, VMR9_GetStaticImage, - VMR9_GetTargetRect, VMR9_SetDefaultSourceRect, VMR9_SetDefaultTargetRect, - VMR9_SetSourceRect, - VMR9_SetTargetRect };
static const IVideoWindowVtbl IVideoWindow_VTable = @@ -1552,10 +1510,10 @@ static HRESULT WINAPI VMR7WindowlessControl_SetVideoPosition(IVMRWindowlessContr EnterCriticalSection(&This->renderer.filter.csFilter);
if (source) - This->source_rect = *source; + This->baseControlVideo.src = *source; if (dest) { - This->target_rect = *dest; + This->baseControlVideo.dst = *dest; FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest)); SetWindowPos(This->window.hwnd, NULL, dest->left, dest->top, dest->right - dest->left, dest->bottom-dest->top, @@ -1573,10 +1531,10 @@ static HRESULT WINAPI VMR7WindowlessControl_GetVideoPosition(IVMRWindowlessContr struct quartz_vmr *This = impl_from_IVMRWindowlessControl(iface);
if (source) - *source = This->source_rect; + *source = This->baseControlVideo.src;
if (dest) - *dest = This->target_rect; + *dest = This->baseControlVideo.dst;
FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest); return S_OK; @@ -1753,10 +1711,10 @@ static HRESULT WINAPI VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessContr EnterCriticalSection(&This->renderer.filter.csFilter);
if (source) - This->source_rect = *source; + This->baseControlVideo.src = *source; if (dest) { - This->target_rect = *dest; + This->baseControlVideo.dst = *dest; FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest)); SetWindowPos(This->window.hwnd, NULL, dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top, @@ -1773,10 +1731,10 @@ static HRESULT WINAPI VMR9WindowlessControl_GetVideoPosition(IVMRWindowlessContr struct quartz_vmr *This = impl_from_IVMRWindowlessControl9(iface);
if (source) - *source = This->source_rect; + *source = This->baseControlVideo.src;
if (dest) - *dest = This->target_rect; + *dest = This->baseControlVideo.dst;
FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest); return S_OK; @@ -2561,10 +2519,11 @@ static HRESULT VMR9_ImagePresenter_PresentOffscreenSurface(struct default_presen }
/* Move rect to origin and flip it */ - SetRect(&target_rect, 0, This->pVMR9->target_rect.bottom - This->pVMR9->target_rect.top, - This->pVMR9->target_rect.right - This->pVMR9->target_rect.left, 0); + SetRect(&target_rect, 0, This->pVMR9->baseControlVideo.dst.bottom - This->pVMR9->baseControlVideo.dst.top, + This->pVMR9->baseControlVideo.dst.right - This->pVMR9->baseControlVideo.dst.left, 0);
- hr = IDirect3DDevice9_StretchRect(This->d3d9_dev, surface, &This->pVMR9->source_rect, target, &target_rect, D3DTEXF_LINEAR); + hr = IDirect3DDevice9_StretchRect(This->d3d9_dev, surface, + &This->pVMR9->baseControlVideo.src, target, &target_rect, D3DTEXF_LINEAR); if (FAILED(hr)) ERR("IDirect3DDevice9_StretchRect -- %08x\n", hr); IDirect3DSurface9_Release(target); @@ -2736,8 +2695,8 @@ static BOOL CreateRenderingWindow(struct default_presenter *This, VMR9Allocation d3dpp.Windowed = TRUE; d3dpp.hDeviceWindow = This->pVMR9->window.hwnd; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.BackBufferHeight = This->pVMR9->target_rect.bottom - This->pVMR9->target_rect.top; - d3dpp.BackBufferWidth = This->pVMR9->target_rect.right - This->pVMR9->target_rect.left; + d3dpp.BackBufferHeight = This->pVMR9->baseControlVideo.dst.bottom - This->pVMR9->baseControlVideo.dst.top; + d3dpp.BackBufferWidth = This->pVMR9->baseControlVideo.dst.right - This->pVMR9->baseControlVideo.dst.left;
hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter, D3DDEVTYPE_HAL, NULL, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev); if (FAILED(hr)) @@ -2872,24 +2831,24 @@ static HRESULT VMR9_SurfaceAllocator_UpdateDeviceReset(struct default_presenter { if (i % 2) { - t_vert[i].x = (float)This->pVMR9->target_rect.right - (float)This->pVMR9->target_rect.left - 0.5f; - t_vert[i].u = (float)This->pVMR9->source_rect.right / (float)width; + t_vert[i].x = (float)This->pVMR9->baseControlVideo.dst.right - (float)This->pVMR9->baseControlVideo.dst.left - 0.5f; + t_vert[i].u = (float)This->pVMR9->baseControlVideo.src.right / (float)width; } else { t_vert[i].x = -0.5f; - t_vert[i].u = (float)This->pVMR9->source_rect.left / (float)width; + t_vert[i].u = (float)This->pVMR9->baseControlVideo.src.left / (float)width; }
if (i % 4 < 2) { t_vert[i].y = -0.5f; - t_vert[i].v = (float)This->pVMR9->source_rect.bottom / (float)height; + t_vert[i].v = (float)This->pVMR9->baseControlVideo.src.bottom / (float)height; } else { - t_vert[i].y = (float)This->pVMR9->target_rect.bottom - (float)This->pVMR9->target_rect.top - 0.5f; - t_vert[i].v = (float)This->pVMR9->source_rect.top / (float)height; + t_vert[i].y = (float)This->pVMR9->baseControlVideo.dst.bottom - (float)This->pVMR9->baseControlVideo.dst.top - 0.5f; + t_vert[i].v = (float)This->pVMR9->baseControlVideo.src.top / (float)height; } t_vert[i].z = 0.0f; t_vert[i].rhw = 1.0f;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/quartz/Makefile.in | 1 - dlls/quartz/quartz_private.h | 33 +- dlls/quartz/video.c | 581 ----------------------------------- dlls/quartz/videorenderer.c | 59 ++-- dlls/quartz/vmr9.c | 94 +++--- dlls/quartz/window.c | 545 ++++++++++++++++++++++++++++++++ 6 files changed, 615 insertions(+), 698 deletions(-) delete mode 100644 dlls/quartz/video.c
diff --git a/dlls/quartz/Makefile.in b/dlls/quartz/Makefile.in index ec29ef53c6b..14ba932a312 100644 --- a/dlls/quartz/Makefile.in +++ b/dlls/quartz/Makefile.in @@ -18,7 +18,6 @@ C_SRCS = \ passthrough.c \ regsvr.c \ systemclock.c \ - video.c \ videorenderer.c \ vmr9.c \ window.c diff --git a/dlls/quartz/quartz_private.h b/dlls/quartz/quartz_private.h index 2bbebd48b3a..7e49367a932 100644 --- a/dlls/quartz/quartz_private.h +++ b/dlls/quartz/quartz_private.h @@ -91,6 +91,9 @@ BOOL get_media_type(const WCHAR *filename, GUID *majortype, GUID *subtype, GUID struct video_window { IVideoWindow IVideoWindow_iface; + IBasicVideo IBasicVideo_iface; + + RECT src, dst;
HWND hwnd; BOOL AutoShow; @@ -107,6 +110,10 @@ struct video_window_ops RECT (*get_default_rect)(struct video_window *window); /* Optional, WinProc Related */ BOOL (*resize)(struct video_window *window, LONG height, LONG width); + + HRESULT (*get_current_image)(struct video_window *window, LONG *size, LONG *image); + HRESULT (WINAPI *pfnSetDefaultSourceRect)(struct video_window *window); + HRESULT (WINAPI *pfnSetDefaultTargetRect)(struct video_window *window); };
void video_window_cleanup(struct video_window *window) DECLSPEC_HIDDEN; @@ -162,30 +169,4 @@ HRESULT WINAPI BaseControlWindowImpl_GetRestorePosition(IVideoWindow *iface, LON HRESULT WINAPI BaseControlWindowImpl_HideCursor(IVideoWindow *iface, LONG HideCursor) DECLSPEC_HIDDEN; HRESULT WINAPI BaseControlWindowImpl_IsCursorHidden(IVideoWindow *iface, LONG *CursorHidden) DECLSPEC_HIDDEN;
-typedef struct tagBaseControlVideo -{ - IBasicVideo IBasicVideo_iface; - - RECT src, dst; - - struct strmbase_filter *pFilter; - struct strmbase_pin *pPin; - - const struct BaseControlVideoFuncTable *pFuncsTable; -} BaseControlVideo; - -typedef HRESULT (WINAPI *BaseControlVideo_GetStaticImage)(BaseControlVideo* This, LONG *pBufferSize, LONG *pDIBImage); -typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultSourceRect)(BaseControlVideo* This); -typedef HRESULT (WINAPI *BaseControlVideo_SetDefaultTargetRect)(BaseControlVideo* This); - -typedef struct BaseControlVideoFuncTable -{ - BaseControlVideo_GetStaticImage pfnGetStaticImage; - BaseControlVideo_SetDefaultSourceRect pfnSetDefaultSourceRect; - BaseControlVideo_SetDefaultTargetRect pfnSetDefaultTargetRect; -} BaseControlVideoFuncTable; - -void basic_video_init(BaseControlVideo *video, struct strmbase_filter *filter, - struct strmbase_pin *pin, const BaseControlVideoFuncTable *func_table) DECLSPEC_HIDDEN; - #endif /* __QUARTZ_PRIVATE_INCLUDED__ */ diff --git a/dlls/quartz/video.c b/dlls/quartz/video.c deleted file mode 100644 index ace83664898..00000000000 --- a/dlls/quartz/video.c +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Common implementation of IBasicVideo - * - * Copyright 2012 Aric Stewart, CodeWeavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "quartz_private.h" - -WINE_DEFAULT_DEBUG_CHANNEL(quartz); - -static inline BaseControlVideo *impl_from_IBasicVideo(IBasicVideo *iface) -{ - return CONTAINING_RECORD(iface, BaseControlVideo, IBasicVideo_iface); -} - -static HRESULT BaseControlVideoImpl_CheckSourceRect(BaseControlVideo *This, RECT *pSourceRect) -{ - LONG VideoWidth, VideoHeight; - HRESULT hr; - - if (IsRectEmpty(pSourceRect)) - return E_INVALIDARG; - - hr = IBasicVideo_GetVideoSize(&This->IBasicVideo_iface, &VideoWidth, &VideoHeight); - if (FAILED(hr)) - return hr; - - if (pSourceRect->top < 0 || pSourceRect->left < 0 || - pSourceRect->bottom > VideoHeight || pSourceRect->right > VideoWidth) - return E_INVALIDARG; - - return S_OK; -} - -static HRESULT BaseControlVideoImpl_CheckTargetRect(BaseControlVideo *This, RECT *pTargetRect) -{ - if (IsRectEmpty(pTargetRect)) - return E_INVALIDARG; - - return S_OK; -} - -static HRESULT WINAPI basic_video_QueryInterface(IBasicVideo *iface, REFIID iid, void **out) -{ - BaseControlVideo *video = impl_from_IBasicVideo(iface); - return IUnknown_QueryInterface(video->pFilter->outer_unk, iid, out); -} - -static ULONG WINAPI basic_video_AddRef(IBasicVideo *iface) -{ - BaseControlVideo *video = impl_from_IBasicVideo(iface); - return IUnknown_AddRef(video->pFilter->outer_unk); -} - -static ULONG WINAPI basic_video_Release(IBasicVideo *iface) -{ - BaseControlVideo *video = impl_from_IBasicVideo(iface); - return IUnknown_Release(video->pFilter->outer_unk); -} - -static HRESULT WINAPI basic_video_GetTypeInfoCount(IBasicVideo *iface, UINT *count) -{ - TRACE("iface %p, count %p.\n", iface, count); - *count = 1; - return S_OK; -} - -static HRESULT WINAPI basic_video_GetTypeInfo(IBasicVideo *iface, UINT index, - LCID lcid, ITypeInfo **typeinfo) -{ - TRACE("iface %p, index %u, lcid %#x, typeinfo %p.\n", iface, index, lcid, typeinfo); - return strmbase_get_typeinfo(IBasicVideo_tid, typeinfo); -} - -static HRESULT WINAPI basic_video_GetIDsOfNames(IBasicVideo *iface, REFIID iid, - LPOLESTR *names, UINT count, LCID lcid, DISPID *ids) -{ - ITypeInfo *typeinfo; - HRESULT hr; - - TRACE("iface %p, iid %s, names %p, count %u, lcid %#x, ids %p.\n", - iface, debugstr_guid(iid), names, count, lcid, ids); - - if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo))) - { - hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, ids); - ITypeInfo_Release(typeinfo); - } - return hr; -} - -static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID iid, LCID lcid, - WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *error_arg) -{ - ITypeInfo *typeinfo; - HRESULT hr; - - TRACE("iface %p, id %d, iid %s, lcid %#x, flags %#x, params %p, result %p, excepinfo %p, error_arg %p.\n", - iface, id, debugstr_guid(iid), lcid, flags, params, result, excepinfo, error_arg); - - if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo))) - { - hr = ITypeInfo_Invoke(typeinfo, iface, id, flags, params, result, excepinfo, error_arg); - ITypeInfo_Release(typeinfo); - } - return hr; -} - -static const VIDEOINFOHEADER *get_video_format(BaseControlVideo *video) -{ - /* Members of VIDEOINFOHEADER up to bmiHeader are identical to those of - * VIDEOINFOHEADER2. */ - return (const VIDEOINFOHEADER *)video->pPin->mt.pbFormat; -} - -static const BITMAPINFOHEADER *get_bitmap_header(BaseControlVideo *video) -{ - const AM_MEDIA_TYPE *mt = &video->pPin->mt; - if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) - return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; - else - return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; -} - -static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *pAvgTimePerFrame) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - if (!pAvgTimePerFrame) - return E_POINTER; - if (!This->pPin->peer) - return VFW_E_NOT_CONNECTED; - - TRACE("(%p/%p)->(%p)\n", This, iface, pAvgTimePerFrame); - - *pAvgTimePerFrame = get_video_format(This)->AvgTimePerFrame; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *pBitRate) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pBitRate); - - if (!pBitRate) - return E_POINTER; - if (!This->pPin->peer) - return VFW_E_NOT_CONNECTED; - - *pBitRate = get_video_format(This)->dwBitRate; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *pBitErrorRate) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pBitErrorRate); - - if (!pBitErrorRate) - return E_POINTER; - if (!This->pPin->peer) - return VFW_E_NOT_CONNECTED; - - *pBitErrorRate = get_video_format(This)->dwBitErrorRate; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *pVideoWidth) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pVideoWidth); - if (!pVideoWidth) - return E_POINTER; - - *pVideoWidth = get_bitmap_header(This)->biWidth; - - return S_OK; -} - -static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *pVideoHeight) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pVideoHeight); - if (!pVideoHeight) - return E_POINTER; - - *pVideoHeight = abs(get_bitmap_header(This)->biHeight); - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG left) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, left %d.\n", iface, left); - - if (left < 0 || This->src.right + left - This->src.left > get_bitmap_header(This)->biWidth) - return E_INVALIDARG; - - OffsetRect(&This->src, left - This->src.left, 0); - return S_OK; -} - -static HRESULT WINAPI basic_video_get_SourceLeft(IBasicVideo *iface, LONG *pSourceLeft) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pSourceLeft); - if (!pSourceLeft) - return E_POINTER; - *pSourceLeft = This->src.left; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG width) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, width %d.\n", iface, width); - - if (width <= 0 || This->src.left + width > get_bitmap_header(This)->biWidth) - return E_INVALIDARG; - - This->src.right = This->src.left + width; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_SourceWidth(IBasicVideo *iface, LONG *pSourceWidth) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pSourceWidth); - if (!pSourceWidth) - return E_POINTER; - *pSourceWidth = This->src.right - This->src.left; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG top) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, top %d.\n", iface, top); - - if (top < 0 || This->src.bottom + top - This->src.top > get_bitmap_header(This)->biHeight) - return E_INVALIDARG; - - OffsetRect(&This->src, 0, top - This->src.top); - return S_OK; -} - -static HRESULT WINAPI basic_video_get_SourceTop(IBasicVideo *iface, LONG *pSourceTop) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pSourceTop); - if (!pSourceTop) - return E_POINTER; - *pSourceTop = This->src.top; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG height) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, height %d.\n", iface, height); - - if (height <= 0 || This->src.top + height > get_bitmap_header(This)->biHeight) - return E_INVALIDARG; - - This->src.bottom = This->src.top + height; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_SourceHeight(IBasicVideo *iface, LONG *pSourceHeight) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pSourceHeight); - if (!pSourceHeight) - return E_POINTER; - - *pSourceHeight = This->src.bottom - This->src.top; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG left) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, left %d.\n", iface, left); - - OffsetRect(&This->dst, left - This->dst.left, 0); - return S_OK; -} - -static HRESULT WINAPI basic_video_get_DestinationLeft(IBasicVideo *iface, LONG *pDestinationLeft) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationLeft); - if (!pDestinationLeft) - return E_POINTER; - *pDestinationLeft = This->dst.left; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG width) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, width %d.\n", iface, width); - - if (width <= 0) - return E_INVALIDARG; - - This->dst.right = This->dst.left + width; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_DestinationWidth(IBasicVideo *iface, LONG *pDestinationWidth) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationWidth); - if (!pDestinationWidth) - return E_POINTER; - *pDestinationWidth = This->dst.right - This->dst.left; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG top) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, top %d.\n", iface, top); - - OffsetRect(&This->dst, 0, top - This->dst.top); - return S_OK; -} - -static HRESULT WINAPI basic_video_get_DestinationTop(IBasicVideo *iface, LONG *pDestinationTop) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationTop); - if (!pDestinationTop) - return E_POINTER; - *pDestinationTop = This->dst.top; - - return S_OK; -} - -static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG height) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("iface %p, height %d.\n", iface, height); - - if (height <= 0) - return E_INVALIDARG; - - This->dst.bottom = This->dst.top + height; - return S_OK; -} - -static HRESULT WINAPI basic_video_get_DestinationHeight(IBasicVideo *iface, LONG *pDestinationHeight) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p)\n", This, iface, pDestinationHeight); - if (!pDestinationHeight) - return E_POINTER; - *pDestinationHeight = This->dst.bottom - This->dst.top; - - return S_OK; -} - -static HRESULT WINAPI basic_video_SetSourcePosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height) -{ - RECT SourceRect; - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height); - - SetRect(&SourceRect, Left, Top, Left + Width, Top + Height); - if (FAILED(BaseControlVideoImpl_CheckSourceRect(This, &SourceRect))) - return E_INVALIDARG; - This->src = SourceRect; - return S_OK; -} - -static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight); - if (!pLeft || !pTop || !pWidth || !pHeight) - return E_POINTER; - - *pLeft = This->src.left; - *pTop = This->src.top; - *pWidth = This->src.right - This->src.left; - *pHeight = This->src.bottom - This->src.top; - - return S_OK; -} - -static HRESULT WINAPI basic_video_SetDefaultSourcePosition(IBasicVideo *iface) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->()\n", This, iface); - return This->pFuncsTable->pfnSetDefaultSourceRect(This); -} - -static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, LONG Left, LONG Top, LONG Width, LONG Height) -{ - RECT DestRect; - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height); - - SetRect(&DestRect, Left, Top, Left + Width, Top + Height); - if (FAILED(BaseControlVideoImpl_CheckTargetRect(This, &DestRect))) - return E_INVALIDARG; - This->dst = DestRect; - return S_OK; -} - -static HRESULT WINAPI basic_video_GetDestinationPosition(IBasicVideo *iface, LONG *pLeft, LONG *pTop, LONG *pWidth, LONG *pHeight) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%p, %p, %p, %p)\n", This, iface, pLeft, pTop, pWidth, pHeight); - if (!pLeft || !pTop || !pWidth || !pHeight) - return E_POINTER; - - *pLeft = This->dst.left; - *pTop = This->dst.top; - *pWidth = This->dst.right - This->dst.left; - *pHeight = This->dst.bottom - This->dst.top; - - return S_OK; -} - -static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *iface) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->()\n", This, iface); - return This->pFuncsTable->pfnSetDefaultTargetRect(This); -} - -static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *pWidth, LONG *pHeight) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(This); - - TRACE("(%p/%p)->(%p, %p)\n", This, iface, pWidth, pHeight); - if (!pWidth || !pHeight) - return E_POINTER; - - *pHeight = bitmap_header->biHeight; - *pWidth = bitmap_header->biWidth; - - return S_OK; -} - -static HRESULT WINAPI basic_video_GetVideoPaletteEntries(IBasicVideo *iface, LONG StartIndex, LONG Entries, LONG *pRetrieved, LONG *pPalette) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - - TRACE("(%p/%p)->(%d, %d, %p, %p)\n", This, iface, StartIndex, Entries, pRetrieved, pPalette); - if (!pRetrieved || !pPalette) - return E_POINTER; - - *pRetrieved = 0; - return VFW_E_NO_PALETTE_AVAILABLE; -} - -static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *pBufferSize, LONG *pDIBImage) -{ - BaseControlVideo *This = impl_from_IBasicVideo(iface); - if (!pBufferSize || !pDIBImage) - return E_POINTER; - - return This->pFuncsTable->pfnGetStaticImage(This, pBufferSize, pDIBImage); -} - -static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface) -{ - FIXME("iface %p, stub!\n", iface); - - return S_OK; -} - -static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface) -{ - FIXME("iface %p, stub!\n", iface); - - return S_OK; -} - -static const IBasicVideoVtbl basic_video_vtbl = -{ - basic_video_QueryInterface, - basic_video_AddRef, - basic_video_Release, - basic_video_GetTypeInfoCount, - basic_video_GetTypeInfo, - basic_video_GetIDsOfNames, - basic_video_Invoke, - basic_video_get_AvgTimePerFrame, - basic_video_get_BitRate, - basic_video_get_BitErrorRate, - basic_video_get_VideoWidth, - basic_video_get_VideoHeight, - basic_video_put_SourceLeft, - basic_video_get_SourceLeft, - basic_video_put_SourceWidth, - basic_video_get_SourceWidth, - basic_video_put_SourceTop, - basic_video_get_SourceTop, - basic_video_put_SourceHeight, - basic_video_get_SourceHeight, - basic_video_put_DestinationLeft, - basic_video_get_DestinationLeft, - basic_video_put_DestinationWidth, - basic_video_get_DestinationWidth, - basic_video_put_DestinationTop, - basic_video_get_DestinationTop, - basic_video_put_DestinationHeight, - basic_video_get_DestinationHeight, - basic_video_SetSourcePosition, - basic_video_GetSourcePosition, - basic_video_SetDefaultSourcePosition, - basic_video_SetDestinationPosition, - basic_video_GetDestinationPosition, - basic_video_SetDefaultDestinationPosition, - basic_video_GetVideoSize, - basic_video_GetVideoPaletteEntries, - basic_video_GetCurrentImage, - basic_video_IsUsingDefaultSource, - basic_video_IsUsingDefaultDestination -}; - -void basic_video_init(BaseControlVideo *video, struct strmbase_filter *filter, - struct strmbase_pin *pin, const BaseControlVideoFuncTable *func_table) -{ - video->IBasicVideo_iface.lpVtbl = &basic_video_vtbl; - video->pFilter = filter; - video->pPin = pin; - video->pFuncsTable = func_table; -} diff --git a/dlls/quartz/videorenderer.c b/dlls/quartz/videorenderer.c index 9a79ad4581c..ea5142e3213 100644 --- a/dlls/quartz/videorenderer.c +++ b/dlls/quartz/videorenderer.c @@ -40,7 +40,6 @@ struct video_renderer { struct strmbase_renderer renderer; struct video_window window; - BaseControlVideo baseControlVideo;
IOverlay IOverlay_iface;
@@ -69,11 +68,6 @@ static inline struct video_renderer *impl_from_IVideoWindow(IVideoWindow *iface) return CONTAINING_RECORD(iface, struct video_renderer, window.IVideoWindow_iface); }
-static inline struct video_renderer *impl_from_BaseControlVideo(BaseControlVideo *iface) -{ - 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)) @@ -100,7 +94,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); - RECT src = filter->baseControlVideo.src, dst = filter->baseControlVideo.dst; + RECT src = filter->window.src, dst = filter->window.dst; LPBYTE pbSrcStream = NULL; HRESULT hr; HDC dc; @@ -171,7 +165,7 @@ static HRESULT video_renderer_query_interface(struct strmbase_renderer *iface, R struct video_renderer *filter = impl_from_strmbase_renderer(iface);
if (IsEqualGUID(iid, &IID_IBasicVideo)) - *out = &filter->baseControlVideo.IBasicVideo_iface; + *out = &filter->window.IBasicVideo_iface; else if (IsEqualGUID(iid, &IID_IVideoWindow)) *out = &filter->window.IVideoWindow_iface; else @@ -231,7 +225,7 @@ static HRESULT video_renderer_connect(struct strmbase_renderer *iface, const AM_ filter->VideoWidth = bitmap_header->biWidth; filter->VideoHeight = abs(bitmap_header->biHeight); SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight); - filter->baseControlVideo.src = filter->baseControlVideo.dst = rect; + filter->window.src = filter->window.dst = rect;
AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE, GetWindowLongW(window, GWL_EXSTYLE)); @@ -256,7 +250,7 @@ static BOOL video_renderer_resize(struct video_window *iface, LONG Width, LONG H struct video_renderer *filter = impl_from_video_window(iface);
TRACE("WM_SIZE %d %d\n", Width, Height); - GetClientRect(iface->hwnd, &filter->baseControlVideo.dst); + GetClientRect(iface->hwnd, &filter->window.dst);
return TRUE; } @@ -275,21 +269,13 @@ static const struct strmbase_renderer_ops renderer_ops = .renderer_connect = video_renderer_connect, };
-static const struct video_window_ops window_ops = -{ - .get_default_rect = video_renderer_get_default_rect, - .resize = video_renderer_resize, -}; - -static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image) +static HRESULT video_renderer_get_current_image(struct video_window *iface, LONG *size, LONG *image) { - struct video_renderer *filter = impl_from_BaseControlVideo(iface); + struct video_renderer *filter = impl_from_video_window(iface); const BITMAPINFOHEADER *bih; size_t image_size; BYTE *sample_data;
- TRACE("filter %p, size %p, image %p.\n", filter, size, image); - EnterCriticalSection(&filter->renderer.csRenderLock);
bih = get_bitmap_header(&filter->renderer.sink.pin.mt); @@ -328,32 +314,35 @@ static HRESULT WINAPI VideoRenderer_GetStaticImage(BaseControlVideo *iface, LONG return S_OK; }
-static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(BaseControlVideo* iface) +static HRESULT WINAPI VideoRenderer_SetDefaultSourceRect(struct video_window *iface) { - struct video_renderer *This = impl_from_BaseControlVideo(iface); + struct video_renderer *This = impl_from_video_window(iface);
- SetRect(&This->baseControlVideo.src, 0, 0, This->VideoWidth, This->VideoHeight); + SetRect(&This->window.src, 0, 0, This->VideoWidth, This->VideoHeight);
return S_OK; }
-static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(BaseControlVideo* iface) +static HRESULT WINAPI VideoRenderer_SetDefaultTargetRect(struct video_window *iface) { - struct video_renderer *This = impl_from_BaseControlVideo(iface); + struct video_renderer *This = impl_from_video_window(iface); RECT rect;
if (!GetClientRect(This->window.hwnd, &rect)) return E_FAIL;
- SetRect(&This->baseControlVideo.dst, 0, 0, rect.right, rect.bottom); + SetRect(&This->window.dst, 0, 0, rect.right, rect.bottom);
return S_OK; }
-static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { - VideoRenderer_GetStaticImage, - VideoRenderer_SetDefaultSourceRect, - VideoRenderer_SetDefaultTargetRect, +static const struct video_window_ops window_ops = +{ + .get_default_rect = video_renderer_get_default_rect, + .resize = video_renderer_resize, + .get_current_image = video_renderer_get_current_image, + .pfnSetDefaultSourceRect = VideoRenderer_SetDefaultSourceRect, + .pfnSetDefaultTargetRect = VideoRenderer_SetDefaultTargetRect, };
static HRESULT WINAPI VideoWindow_get_FullScreenMode(IVideoWindow *iface, @@ -386,16 +375,16 @@ static HRESULT WINAPI VideoWindow_put_FullScreenMode(IVideoWindow *iface, LONG f SetWindowLongW(window, GWL_STYLE, WS_POPUP); SetWindowPos(window, HWND_TOP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW); - GetWindowRect(window, &filter->baseControlVideo.dst); + GetWindowRect(window, &filter->window.dst); } else { ShowWindow(window, SW_HIDE); SetParent(window, filter->window.hwndOwner); SetWindowLongW(window, GWL_STYLE, filter->saved_style); - GetClientRect(window, &filter->baseControlVideo.dst); - SetWindowPos(window, 0, filter->baseControlVideo.dst.left, filter->baseControlVideo.dst.top, - filter->baseControlVideo.dst.right, filter->baseControlVideo.dst.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); + GetClientRect(window, &filter->window.dst); + SetWindowPos(window, 0, filter->window.dst.left, filter->window.dst.top, + filter->window.dst.right, filter->window.dst.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); } filter->FullScreenMode = fullscreen;
@@ -569,8 +558,6 @@ HRESULT video_renderer_create(IUnknown *outer, IUnknown **out)
video_window_init(&object->window, &IVideoWindow_VTable, &object->renderer.filter, &object->renderer.sink.pin, &window_ops); - basic_video_init(&object->baseControlVideo, &object->renderer.filter, - &object->renderer.sink.pin, &renderer_BaseControlVideoFuncTable);
if (FAILED(hr = video_window_create_window(&object->window))) { diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 4e535629cce..4fb8ddc32f4 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -57,7 +57,6 @@ struct quartz_vmr { struct strmbase_renderer renderer; struct video_window window; - BaseControlVideo baseControlVideo;
IAMCertifiedOutputProtection IAMCertifiedOutputProtection_iface; IAMFilterMiscFlags IAMFilterMiscFlags_iface; @@ -120,11 +119,6 @@ static inline struct quartz_vmr *impl_from_video_window(struct video_window *ifa return CONTAINING_RECORD(iface, struct quartz_vmr, window); }
-static inline struct quartz_vmr *impl_from_BaseControlVideo(BaseControlVideo *cvid) -{ - return CONTAINING_RECORD(cvid, struct quartz_vmr, baseControlVideo); -} - static inline struct quartz_vmr *impl_from_IAMCertifiedOutputProtection(IAMCertifiedOutputProtection *iface) { return CONTAINING_RECORD(iface, struct quartz_vmr, IAMCertifiedOutputProtection_iface); @@ -415,8 +409,8 @@ static HRESULT allocate_surfaces(struct quartz_vmr *filter, const AM_MEDIA_TYPE if (filter->mode == VMR9Mode_Windowless && !filter->hWndClippingWindow) return S_OK;
- info.dwWidth = filter->baseControlVideo.src.right; - info.dwHeight = filter->baseControlVideo.src.bottom; + info.dwWidth = filter->window.src.right; + info.dwHeight = filter->window.src.bottom; info.Pool = D3DPOOL_DEFAULT; info.MinBuffers = 1; info.szAspectRatio.cx = info.dwWidth; @@ -512,7 +506,7 @@ static HRESULT vmr_connect(struct strmbase_renderer *iface, const AM_MEDIA_TYPE filter->VideoWidth = bitmap_header->biWidth; filter->VideoHeight = bitmap_header->biHeight; SetRect(&rect, 0, 0, filter->VideoWidth, filter->VideoHeight); - filter->baseControlVideo.src = filter->baseControlVideo.dst = rect; + filter->window.src = filter->window.dst = rect;
AdjustWindowRectEx(&rect, GetWindowLongW(window, GWL_STYLE), FALSE, GetWindowLongW(window, GWL_EXSTYLE)); @@ -598,7 +592,7 @@ static HRESULT vmr_query_interface(struct strmbase_renderer *iface, REFIID iid, if (IsEqualGUID(iid, &IID_IVideoWindow)) *out = &filter->window.IVideoWindow_iface; else if (IsEqualGUID(iid, &IID_IBasicVideo)) - *out = &filter->baseControlVideo.IBasicVideo_iface; + *out = &filter->window.IBasicVideo_iface; else if (IsEqualGUID(iid, &IID_IAMCertifiedOutputProtection)) *out = &filter->IAMCertifiedOutputProtection_iface; else if (IsEqualGUID(iid, &IID_IAMFilterMiscFlags)) @@ -674,20 +668,14 @@ static BOOL vmr_resize(struct video_window *This, LONG Width, LONG Height) struct quartz_vmr *pVMR9 = impl_from_video_window(This);
TRACE("WM_SIZE %d %d\n", Width, Height); - GetClientRect(This->hwnd, &pVMR9->baseControlVideo.dst); + GetClientRect(This->hwnd, &pVMR9->window.dst);
return TRUE; }
-static const struct video_window_ops window_ops = +static HRESULT vmr_get_current_image(struct video_window *iface, LONG *size, LONG *image) { - .get_default_rect = vmr_get_default_rect, - .resize = vmr_resize, -}; - -static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, LONG *image) -{ - struct quartz_vmr *filter = impl_from_BaseControlVideo(iface); + struct quartz_vmr *filter = impl_from_video_window(iface); IDirect3DSurface9 *rt = NULL, *surface = NULL; D3DLOCKED_RECT locked_rect; IDirect3DDevice9 *device; @@ -697,8 +685,6 @@ static HRESULT WINAPI VMR9_GetStaticImage(BaseControlVideo *iface, LONG *size, L char *dst; HRESULT hr;
- TRACE("filter %p, size %d, image %p.\n", filter, *size, image); - EnterCriticalSection(&filter->renderer.csRenderLock); device = filter->allocator_d3d9_dev;
@@ -748,32 +734,35 @@ out: return hr; }
-static HRESULT WINAPI VMR9_SetDefaultSourceRect(BaseControlVideo* This) +static HRESULT WINAPI VMR9_SetDefaultSourceRect(struct video_window *iface) { - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); + struct quartz_vmr *filter = impl_from_video_window(iface);
- SetRect(&pVMR9->baseControlVideo.src, 0, 0, pVMR9->VideoWidth, pVMR9->VideoHeight); + SetRect(&filter->window.src, 0, 0, filter->VideoWidth, filter->VideoHeight);
return S_OK; }
-static HRESULT WINAPI VMR9_SetDefaultTargetRect(BaseControlVideo* This) +static HRESULT WINAPI VMR9_SetDefaultTargetRect(struct video_window *iface) { RECT rect; - struct quartz_vmr* pVMR9 = impl_from_BaseControlVideo(This); + struct quartz_vmr *filter = impl_from_video_window(iface);
- if (!GetClientRect(pVMR9->window.hwnd, &rect)) + if (!GetClientRect(filter->window.hwnd, &rect)) return E_FAIL;
- SetRect(&pVMR9->baseControlVideo.dst, 0, 0, rect.right, rect.bottom); + SetRect(&filter->window.dst, 0, 0, rect.right, rect.bottom);
return S_OK; }
-static const BaseControlVideoFuncTable renderer_BaseControlVideoFuncTable = { - VMR9_GetStaticImage, - VMR9_SetDefaultSourceRect, - VMR9_SetDefaultTargetRect, +static const struct video_window_ops window_ops = +{ + .get_default_rect = vmr_get_default_rect, + .resize = vmr_resize, + .get_current_image = vmr_get_current_image, + .pfnSetDefaultSourceRect = VMR9_SetDefaultSourceRect, + .pfnSetDefaultTargetRect = VMR9_SetDefaultTargetRect, };
static const IVideoWindowVtbl IVideoWindow_VTable = @@ -1510,10 +1499,10 @@ static HRESULT WINAPI VMR7WindowlessControl_SetVideoPosition(IVMRWindowlessContr EnterCriticalSection(&This->renderer.filter.csFilter);
if (source) - This->baseControlVideo.src = *source; + This->window.src = *source; if (dest) { - This->baseControlVideo.dst = *dest; + This->window.dst = *dest; FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest)); SetWindowPos(This->window.hwnd, NULL, dest->left, dest->top, dest->right - dest->left, dest->bottom-dest->top, @@ -1531,10 +1520,10 @@ static HRESULT WINAPI VMR7WindowlessControl_GetVideoPosition(IVMRWindowlessContr struct quartz_vmr *This = impl_from_IVMRWindowlessControl(iface);
if (source) - *source = This->baseControlVideo.src; + *source = This->window.src;
if (dest) - *dest = This->baseControlVideo.dst; + *dest = This->window.dst;
FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest); return S_OK; @@ -1711,10 +1700,10 @@ static HRESULT WINAPI VMR9WindowlessControl_SetVideoPosition(IVMRWindowlessContr EnterCriticalSection(&This->renderer.filter.csFilter);
if (source) - This->baseControlVideo.src = *source; + This->window.src = *source; if (dest) { - This->baseControlVideo.dst = *dest; + This->window.dst = *dest; FIXME("Output rectangle: %s.\n", wine_dbgstr_rect(dest)); SetWindowPos(This->window.hwnd, NULL, dest->left, dest->top, dest->right - dest->left, dest->bottom - dest->top, @@ -1731,10 +1720,10 @@ static HRESULT WINAPI VMR9WindowlessControl_GetVideoPosition(IVMRWindowlessContr struct quartz_vmr *This = impl_from_IVMRWindowlessControl9(iface);
if (source) - *source = This->baseControlVideo.src; + *source = This->window.src;
if (dest) - *dest = This->baseControlVideo.dst; + *dest = This->window.dst;
FIXME("(%p/%p)->(%p/%p) stub\n", iface, This, source, dest); return S_OK; @@ -2352,9 +2341,6 @@ static HRESULT vmr_create(IUnknown *outer, IUnknown **out, const CLSID *clsid) return hr; }
- basic_video_init(&object->baseControlVideo, &object->renderer.filter, - &object->renderer.sink.pin, &renderer_BaseControlVideoFuncTable); - object->run_event = CreateEventW(NULL, TRUE, FALSE, NULL);
TRACE("Created VMR %p.\n", object); @@ -2519,11 +2505,11 @@ static HRESULT VMR9_ImagePresenter_PresentOffscreenSurface(struct default_presen }
/* Move rect to origin and flip it */ - SetRect(&target_rect, 0, This->pVMR9->baseControlVideo.dst.bottom - This->pVMR9->baseControlVideo.dst.top, - This->pVMR9->baseControlVideo.dst.right - This->pVMR9->baseControlVideo.dst.left, 0); + SetRect(&target_rect, 0, This->pVMR9->window.dst.bottom - This->pVMR9->window.dst.top, + This->pVMR9->window.dst.right - This->pVMR9->window.dst.left, 0);
hr = IDirect3DDevice9_StretchRect(This->d3d9_dev, surface, - &This->pVMR9->baseControlVideo.src, target, &target_rect, D3DTEXF_LINEAR); + &This->pVMR9->window.src, target, &target_rect, D3DTEXF_LINEAR); if (FAILED(hr)) ERR("IDirect3DDevice9_StretchRect -- %08x\n", hr); IDirect3DSurface9_Release(target); @@ -2695,8 +2681,8 @@ static BOOL CreateRenderingWindow(struct default_presenter *This, VMR9Allocation d3dpp.Windowed = TRUE; d3dpp.hDeviceWindow = This->pVMR9->window.hwnd; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.BackBufferHeight = This->pVMR9->baseControlVideo.dst.bottom - This->pVMR9->baseControlVideo.dst.top; - d3dpp.BackBufferWidth = This->pVMR9->baseControlVideo.dst.right - This->pVMR9->baseControlVideo.dst.left; + d3dpp.BackBufferHeight = This->pVMR9->window.dst.bottom - This->pVMR9->window.dst.top; + d3dpp.BackBufferWidth = This->pVMR9->window.dst.right - This->pVMR9->window.dst.left;
hr = IDirect3D9_CreateDevice(This->d3d9_ptr, d3d9_adapter, D3DDEVTYPE_HAL, NULL, D3DCREATE_MIXED_VERTEXPROCESSING, &d3dpp, &This->d3d9_dev); if (FAILED(hr)) @@ -2831,24 +2817,24 @@ static HRESULT VMR9_SurfaceAllocator_UpdateDeviceReset(struct default_presenter { if (i % 2) { - t_vert[i].x = (float)This->pVMR9->baseControlVideo.dst.right - (float)This->pVMR9->baseControlVideo.dst.left - 0.5f; - t_vert[i].u = (float)This->pVMR9->baseControlVideo.src.right / (float)width; + t_vert[i].x = (float)This->pVMR9->window.dst.right - (float)This->pVMR9->window.dst.left - 0.5f; + t_vert[i].u = (float)This->pVMR9->window.src.right / (float)width; } else { t_vert[i].x = -0.5f; - t_vert[i].u = (float)This->pVMR9->baseControlVideo.src.left / (float)width; + t_vert[i].u = (float)This->pVMR9->window.src.left / (float)width; }
if (i % 4 < 2) { t_vert[i].y = -0.5f; - t_vert[i].v = (float)This->pVMR9->baseControlVideo.src.bottom / (float)height; + t_vert[i].v = (float)This->pVMR9->window.src.bottom / (float)height; } else { - t_vert[i].y = (float)This->pVMR9->baseControlVideo.dst.bottom - (float)This->pVMR9->baseControlVideo.dst.top - 0.5f; - t_vert[i].v = (float)This->pVMR9->baseControlVideo.src.top / (float)height; + t_vert[i].y = (float)This->pVMR9->window.dst.bottom - (float)This->pVMR9->window.dst.top - 0.5f; + t_vert[i].v = (float)This->pVMR9->window.src.top / (float)height; } t_vert[i].z = 0.0f; t_vert[i].rhw = 1.0f; diff --git a/dlls/quartz/window.c b/dlls/quartz/window.c index b8fbd2694ca..ebd3ffe3024 100644 --- a/dlls/quartz/window.c +++ b/dlls/quartz/window.c @@ -656,6 +656,550 @@ HRESULT WINAPI BaseControlWindowImpl_IsCursorHidden(IVideoWindow *iface, LONG *C return S_OK; }
+static inline struct video_window *impl_from_IBasicVideo(IBasicVideo *iface) +{ + return CONTAINING_RECORD(iface, struct video_window, IBasicVideo_iface); +} + +static HRESULT WINAPI basic_video_QueryInterface(IBasicVideo *iface, REFIID iid, void **out) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + return IUnknown_QueryInterface(window->pFilter->outer_unk, iid, out); +} + +static ULONG WINAPI basic_video_AddRef(IBasicVideo *iface) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + return IUnknown_AddRef(window->pFilter->outer_unk); +} + +static ULONG WINAPI basic_video_Release(IBasicVideo *iface) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + return IUnknown_Release(window->pFilter->outer_unk); +} + +static HRESULT WINAPI basic_video_GetTypeInfoCount(IBasicVideo *iface, UINT *count) +{ + TRACE("iface %p, count %p.\n", iface, count); + *count = 1; + return S_OK; +} + +static HRESULT WINAPI basic_video_GetTypeInfo(IBasicVideo *iface, UINT index, + LCID lcid, ITypeInfo **typeinfo) +{ + TRACE("iface %p, index %u, lcid %#x, typeinfo %p.\n", iface, index, lcid, typeinfo); + return strmbase_get_typeinfo(IBasicVideo_tid, typeinfo); +} + +static HRESULT WINAPI basic_video_GetIDsOfNames(IBasicVideo *iface, REFIID iid, + LPOLESTR *names, UINT count, LCID lcid, DISPID *ids) +{ + ITypeInfo *typeinfo; + HRESULT hr; + + TRACE("iface %p, iid %s, names %p, count %u, lcid %#x, ids %p.\n", + iface, debugstr_guid(iid), names, count, lcid, ids); + + if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo))) + { + hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, ids); + ITypeInfo_Release(typeinfo); + } + return hr; +} + +static HRESULT WINAPI basic_video_Invoke(IBasicVideo *iface, DISPID id, REFIID iid, LCID lcid, + WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *error_arg) +{ + ITypeInfo *typeinfo; + HRESULT hr; + + TRACE("iface %p, id %d, iid %s, lcid %#x, flags %#x, params %p, result %p, excepinfo %p, error_arg %p.\n", + iface, id, debugstr_guid(iid), lcid, flags, params, result, excepinfo, error_arg); + + if (SUCCEEDED(hr = strmbase_get_typeinfo(IBasicVideo_tid, &typeinfo))) + { + hr = ITypeInfo_Invoke(typeinfo, iface, id, flags, params, result, excepinfo, error_arg); + ITypeInfo_Release(typeinfo); + } + return hr; +} + +static const VIDEOINFOHEADER *get_video_format(struct video_window *window) +{ + /* Members of VIDEOINFOHEADER up to bmiHeader are identical to those of + * VIDEOINFOHEADER2. */ + return (const VIDEOINFOHEADER *)window->pPin->mt.pbFormat; +} + +static const BITMAPINFOHEADER *get_bitmap_header(struct video_window *window) +{ + const AM_MEDIA_TYPE *mt = &window->pPin->mt; + if (IsEqualGUID(&mt->formattype, &FORMAT_VideoInfo)) + return &((VIDEOINFOHEADER *)mt->pbFormat)->bmiHeader; + else + return &((VIDEOINFOHEADER2 *)mt->pbFormat)->bmiHeader; +} + +static HRESULT WINAPI basic_video_get_AvgTimePerFrame(IBasicVideo *iface, REFTIME *reftime) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + if (!reftime) + return E_POINTER; + if (!window->pPin->peer) + return VFW_E_NOT_CONNECTED; + + TRACE("window %p, reftime %p.\n", window, reftime); + + *reftime = get_video_format(window)->AvgTimePerFrame; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_BitRate(IBasicVideo *iface, LONG *rate) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, rate %p.\n", window, rate); + + if (!rate) + return E_POINTER; + if (!window->pPin->peer) + return VFW_E_NOT_CONNECTED; + + *rate = get_video_format(window)->dwBitRate; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_BitErrorRate(IBasicVideo *iface, LONG *rate) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, rate %p.\n", window, rate); + + if (!rate) + return E_POINTER; + if (!window->pPin->peer) + return VFW_E_NOT_CONNECTED; + + *rate = get_video_format(window)->dwBitErrorRate; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_VideoWidth(IBasicVideo *iface, LONG *width) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, width %p.\n", window, width); + + if (!width) + return E_POINTER; + + *width = get_bitmap_header(window)->biWidth; + + return S_OK; +} + +static HRESULT WINAPI basic_video_get_VideoHeight(IBasicVideo *iface, LONG *height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, height %p.\n", window, height); + + if (!height) + return E_POINTER; + + *height = abs(get_bitmap_header(window)->biHeight); + + return S_OK; +} + +static HRESULT WINAPI basic_video_put_SourceLeft(IBasicVideo *iface, LONG left) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %d.\n", window, left); + + if (left < 0 || window->src.right + left - window->src.left > get_bitmap_header(window)->biWidth) + return E_INVALIDARG; + + OffsetRect(&window->src, left - window->src.left, 0); + return S_OK; +} + +static HRESULT WINAPI basic_video_get_SourceLeft(IBasicVideo *iface, LONG *left) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %p.\n", window, left); + + if (!left) + return E_POINTER; + + *left = window->src.left; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_SourceWidth(IBasicVideo *iface, LONG width) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, width %d.\n", window, width); + + if (width <= 0 || window->src.left + width > get_bitmap_header(window)->biWidth) + return E_INVALIDARG; + + window->src.right = window->src.left + width; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_SourceWidth(IBasicVideo *iface, LONG *width) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, width %p.\n", window, width); + + if (!width) + return E_POINTER; + + *width = window->src.right - window->src.left; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_SourceTop(IBasicVideo *iface, LONG top) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, top %d.\n", window, top); + + if (top < 0 || window->src.bottom + top - window->src.top > get_bitmap_header(window)->biHeight) + return E_INVALIDARG; + + OffsetRect(&window->src, 0, top - window->src.top); + return S_OK; +} + +static HRESULT WINAPI basic_video_get_SourceTop(IBasicVideo *iface, LONG *top) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, top %p.\n", window, top); + + if (!top) + return E_POINTER; + + *top = window->src.top; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_SourceHeight(IBasicVideo *iface, LONG height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, height %d.\n", window, height); + + if (height <= 0 || window->src.top + height > get_bitmap_header(window)->biHeight) + return E_INVALIDARG; + + window->src.bottom = window->src.top + height; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_SourceHeight(IBasicVideo *iface, LONG *height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, height %p\n", window, height); + + if (!height) + return E_POINTER; + + *height = window->src.bottom - window->src.top; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_DestinationLeft(IBasicVideo *iface, LONG left) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %d.\n", window, left); + + OffsetRect(&window->dst, left - window->dst.left, 0); + return S_OK; +} + +static HRESULT WINAPI basic_video_get_DestinationLeft(IBasicVideo *iface, LONG *left) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %p.\n", window, left); + + if (!left) + return E_POINTER; + + *left = window->dst.left; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_DestinationWidth(IBasicVideo *iface, LONG width) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, width %d.\n", window, width); + + if (width <= 0) + return E_INVALIDARG; + + window->dst.right = window->dst.left + width; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_DestinationWidth(IBasicVideo *iface, LONG *width) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, width %p.\n", window, width); + + if (!width) + return E_POINTER; + + *width = window->dst.right - window->dst.left; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_DestinationTop(IBasicVideo *iface, LONG top) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, top %d.\n", window, top); + + OffsetRect(&window->dst, 0, top - window->dst.top); + return S_OK; +} + +static HRESULT WINAPI basic_video_get_DestinationTop(IBasicVideo *iface, LONG *top) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, top %p.\n", window, top); + + if (!top) + return E_POINTER; + + *top = window->dst.top; + return S_OK; +} + +static HRESULT WINAPI basic_video_put_DestinationHeight(IBasicVideo *iface, LONG height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, height %d.\n", window, height); + + if (height <= 0) + return E_INVALIDARG; + + window->dst.bottom = window->dst.top + height; + return S_OK; +} + +static HRESULT WINAPI basic_video_get_DestinationHeight(IBasicVideo *iface, LONG *height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, height %p.\n", window, height); + + if (!height) + return E_POINTER; + + *height = window->dst.bottom - window->dst.top; + return S_OK; +} + +static HRESULT WINAPI basic_video_SetSourcePosition(IBasicVideo *iface, + LONG left, LONG top, LONG width, LONG height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(window); + + TRACE("window %p, left %d, top %d, width %d, height %d.\n", window, left, top, width, height); + + if (left < 0 || left + width > bitmap_header->biWidth || width <= 0) + return E_INVALIDARG; + if (top < 0 || top + height > bitmap_header->biHeight || height <= 0) + return E_INVALIDARG; + + SetRect(&window->src, left, top, left + width, top + height); + return S_OK; +} + +static HRESULT WINAPI basic_video_GetSourcePosition(IBasicVideo *iface, + LONG *left, LONG *top, LONG *width, LONG *height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %p, top %p, width %p, height %p.\n", window, left, top, width, height); + + if (!left || !top || !width || !height) + return E_POINTER; + + *left = window->src.left; + *top = window->src.top; + *width = window->src.right - window->src.left; + *height = window->src.bottom - window->src.top; + return S_OK; +} + +static HRESULT WINAPI basic_video_SetDefaultSourcePosition(IBasicVideo *iface) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p.\n", window); + + return window->ops->pfnSetDefaultSourceRect(window); +} + +static HRESULT WINAPI basic_video_SetDestinationPosition(IBasicVideo *iface, + LONG left, LONG top, LONG width, LONG height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %d, top %d, width %d, height %d.\n", window, left, top, width, height); + + if (width <= 0 || height <= 0) + return E_INVALIDARG; + + SetRect(&window->dst, left, top, left + width, top + height); + return S_OK; +} + +static HRESULT WINAPI basic_video_GetDestinationPosition(IBasicVideo *iface, + LONG *left, LONG *top, LONG *width, LONG *height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, left %p, top %p, width %p, height %p.\n", window, left, top, width, height); + + if (!left || !top || !width || !height) + return E_POINTER; + + *left = window->dst.left; + *top = window->dst.top; + *width = window->dst.right - window->dst.left; + *height = window->dst.bottom - window->dst.top; + return S_OK; +} + +static HRESULT WINAPI basic_video_SetDefaultDestinationPosition(IBasicVideo *iface) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p.\n", window); + + return window->ops->pfnSetDefaultTargetRect(window); +} + +static HRESULT WINAPI basic_video_GetVideoSize(IBasicVideo *iface, LONG *width, LONG *height) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + const BITMAPINFOHEADER *bitmap_header = get_bitmap_header(window); + + TRACE("window %p, width %p, height %p.\n", window, width, height); + + if (!width || !height) + return E_POINTER; + + *width = bitmap_header->biWidth; + *height = bitmap_header->biHeight; + return S_OK; +} + +static HRESULT WINAPI basic_video_GetVideoPaletteEntries(IBasicVideo *iface, + LONG start, LONG count, LONG *ret_count, LONG *palette) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + FIXME("window %p, start %d, count %d, ret_count %p, palette %p, stub!\n", + window, start, count, ret_count, palette); + + if (!ret_count || !palette) + return E_POINTER; + + *ret_count = 0; + return VFW_E_NO_PALETTE_AVAILABLE; +} + +static HRESULT WINAPI basic_video_GetCurrentImage(IBasicVideo *iface, LONG *size, LONG *image) +{ + struct video_window *window = impl_from_IBasicVideo(iface); + + TRACE("window %p, size %p, image %p.\n", window, size, image); + + if (!size || !image) + return E_POINTER; + + return window->ops->get_current_image(window, size, image); +} + +static HRESULT WINAPI basic_video_IsUsingDefaultSource(IBasicVideo *iface) +{ + FIXME("iface %p, stub!\n", iface); + + return S_OK; +} + +static HRESULT WINAPI basic_video_IsUsingDefaultDestination(IBasicVideo *iface) +{ + FIXME("iface %p, stub!\n", iface); + + return S_OK; +} + +static const IBasicVideoVtbl basic_video_vtbl = +{ + basic_video_QueryInterface, + basic_video_AddRef, + basic_video_Release, + basic_video_GetTypeInfoCount, + basic_video_GetTypeInfo, + basic_video_GetIDsOfNames, + basic_video_Invoke, + basic_video_get_AvgTimePerFrame, + basic_video_get_BitRate, + basic_video_get_BitErrorRate, + basic_video_get_VideoWidth, + basic_video_get_VideoHeight, + basic_video_put_SourceLeft, + basic_video_get_SourceLeft, + basic_video_put_SourceWidth, + basic_video_get_SourceWidth, + basic_video_put_SourceTop, + basic_video_get_SourceTop, + basic_video_put_SourceHeight, + basic_video_get_SourceHeight, + basic_video_put_DestinationLeft, + basic_video_get_DestinationLeft, + basic_video_put_DestinationWidth, + basic_video_get_DestinationWidth, + basic_video_put_DestinationTop, + basic_video_get_DestinationTop, + basic_video_put_DestinationHeight, + basic_video_get_DestinationHeight, + basic_video_SetSourcePosition, + basic_video_GetSourcePosition, + basic_video_SetDefaultSourcePosition, + basic_video_SetDestinationPosition, + basic_video_GetDestinationPosition, + basic_video_SetDefaultDestinationPosition, + basic_video_GetVideoSize, + basic_video_GetVideoPaletteEntries, + basic_video_GetCurrentImage, + basic_video_IsUsingDefaultSource, + basic_video_IsUsingDefaultDestination +}; + void video_window_unregister_class(void) { if (!UnregisterClassW(class_name, NULL) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST) @@ -668,6 +1212,7 @@ void video_window_init(struct video_window *window, const IVideoWindowVtbl *vtbl memset(window, 0, sizeof(*window)); window->ops = ops; window->IVideoWindow_iface.lpVtbl = vtbl; + window->IBasicVideo_iface.lpVtbl = &basic_video_vtbl; window->AutoShow = OATRUE; window->pFilter = owner; window->pPin = pin;