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

quartz/vmr9: Use calloc().

parent 33f11bce
...@@ -597,7 +597,7 @@ static void vmr_destroy(struct strmbase_renderer *iface) ...@@ -597,7 +597,7 @@ static void vmr_destroy(struct strmbase_renderer *iface)
FreeLibrary(filter->hD3d9); FreeLibrary(filter->hD3d9);
BaseControlWindow_Destroy(&filter->baseControlWindow); BaseControlWindow_Destroy(&filter->baseControlWindow);
strmbase_renderer_cleanup(&filter->renderer); strmbase_renderer_cleanup(&filter->renderer);
CoTaskMemFree(filter); free(filter);
InterlockedDecrement(&object_locks); InterlockedDecrement(&object_locks);
} }
...@@ -2291,69 +2291,57 @@ static const IOverlayVtbl overlay_vtbl = ...@@ -2291,69 +2291,57 @@ static const IOverlayVtbl overlay_vtbl =
static HRESULT vmr_create(IUnknown *outer, IUnknown **out, const CLSID *clsid) static HRESULT vmr_create(IUnknown *outer, IUnknown **out, const CLSID *clsid)
{ {
struct quartz_vmr *object;
HRESULT hr; HRESULT hr;
struct quartz_vmr* pVMR;
*out = NULL; if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
pVMR = CoTaskMemAlloc(sizeof(struct quartz_vmr));
pVMR->hD3d9 = LoadLibraryA("d3d9.dll"); object->hD3d9 = LoadLibraryA("d3d9.dll");
if (!pVMR->hD3d9 ) if (!object->hD3d9)
{ {
WARN("Could not load d3d9.dll\n"); WARN("Could not load d3d9.dll\n");
CoTaskMemFree(pVMR); free(object);
return VFW_E_DDRAW_CAPS_NOT_SUITABLE; return VFW_E_DDRAW_CAPS_NOT_SUITABLE;
} }
pVMR->IAMCertifiedOutputProtection_iface.lpVtbl = &IAMCertifiedOutputProtection_Vtbl; strmbase_renderer_init(&object->renderer, outer, clsid, L"VMR Input0", &renderer_ops);
pVMR->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_Vtbl; object->IAMCertifiedOutputProtection_iface.lpVtbl = &IAMCertifiedOutputProtection_Vtbl;
object->IAMFilterMiscFlags_iface.lpVtbl = &IAMFilterMiscFlags_Vtbl;
pVMR->mode = 0; object->IVMRFilterConfig_iface.lpVtbl = &VMR7_FilterConfig_Vtbl;
pVMR->allocator_d3d9_dev = NULL; object->IVMRFilterConfig9_iface.lpVtbl = &VMR9_FilterConfig_Vtbl;
pVMR->allocator_mon= NULL; object->IVMRMonitorConfig_iface.lpVtbl = &VMR7_MonitorConfig_Vtbl;
pVMR->num_surfaces = pVMR->cur_surface = 0; object->IVMRMonitorConfig9_iface.lpVtbl = &VMR9_MonitorConfig_Vtbl;
pVMR->allocator = NULL; object->IVMRSurfaceAllocatorNotify_iface.lpVtbl = &VMR7_SurfaceAllocatorNotify_Vtbl;
pVMR->presenter = NULL; object->IVMRSurfaceAllocatorNotify9_iface.lpVtbl = &VMR9_SurfaceAllocatorNotify_Vtbl;
pVMR->hWndClippingWindow = NULL; object->IVMRWindowlessControl_iface.lpVtbl = &VMR7_WindowlessControl_Vtbl;
pVMR->IVMRFilterConfig_iface.lpVtbl = &VMR7_FilterConfig_Vtbl; object->IVMRWindowlessControl9_iface.lpVtbl = &VMR9_WindowlessControl_Vtbl;
pVMR->IVMRFilterConfig9_iface.lpVtbl = &VMR9_FilterConfig_Vtbl; object->IOverlay_iface.lpVtbl = &overlay_vtbl;
pVMR->IVMRMonitorConfig_iface.lpVtbl = &VMR7_MonitorConfig_Vtbl;
pVMR->IVMRMonitorConfig9_iface.lpVtbl = &VMR9_MonitorConfig_Vtbl; hr = video_window_init(&object->baseControlWindow, &IVideoWindow_VTable,
pVMR->IVMRSurfaceAllocatorNotify_iface.lpVtbl = &VMR7_SurfaceAllocatorNotify_Vtbl; &object->renderer.filter, &object->renderer.sink.pin, &renderer_BaseWindowFuncTable);
pVMR->IVMRSurfaceAllocatorNotify9_iface.lpVtbl = &VMR9_SurfaceAllocatorNotify_Vtbl;
pVMR->IVMRWindowlessControl_iface.lpVtbl = &VMR7_WindowlessControl_Vtbl;
pVMR->IVMRWindowlessControl9_iface.lpVtbl = &VMR9_WindowlessControl_Vtbl;
pVMR->IOverlay_iface.lpVtbl = &overlay_vtbl;
strmbase_renderer_init(&pVMR->renderer, outer, clsid, L"VMR Input0", &renderer_ops);
hr = video_window_init(&pVMR->baseControlWindow, &IVideoWindow_VTable,
&pVMR->renderer.filter, &pVMR->renderer.sink.pin, &renderer_BaseWindowFuncTable);
if (FAILED(hr)) if (FAILED(hr))
goto fail; goto fail;
if (FAILED(hr = BaseWindowImpl_PrepareWindow(&pVMR->baseControlWindow.baseWindow))) if (FAILED(hr = BaseWindowImpl_PrepareWindow(&object->baseControlWindow.baseWindow)))
goto fail; goto fail;
hr = basic_video_init(&pVMR->baseControlVideo, &pVMR->renderer.filter, hr = basic_video_init(&object->baseControlVideo, &object->renderer.filter,
&pVMR->renderer.sink.pin, &renderer_BaseControlVideoFuncTable); &object->renderer.sink.pin, &renderer_BaseControlVideoFuncTable);
if (FAILED(hr)) if (FAILED(hr))
goto fail; goto fail;
pVMR->run_event = CreateEventW(NULL, TRUE, FALSE, NULL); object->run_event = CreateEventW(NULL, TRUE, FALSE, NULL);
*out = &pVMR->renderer.filter.IUnknown_inner; TRACE("Created VMR %p.\n", object);
ZeroMemory(&pVMR->source_rect, sizeof(RECT)); *out = &object->renderer.filter.IUnknown_inner;
ZeroMemory(&pVMR->target_rect, sizeof(RECT));
TRACE("Created at %p\n", pVMR);
return hr; return hr;
fail: fail:
BaseWindowImpl_DoneWithWindow(&pVMR->baseControlWindow.baseWindow); BaseWindowImpl_DoneWithWindow(&object->baseControlWindow.baseWindow);
strmbase_renderer_cleanup(&pVMR->renderer); strmbase_renderer_cleanup(&object->renderer);
FreeLibrary(pVMR->hD3d9); FreeLibrary(object->hD3d9);
CoTaskMemFree(pVMR); free(object);
return hr; return hr;
} }
...@@ -2423,7 +2411,7 @@ static ULONG WINAPI VMR9_ImagePresenter_Release(IVMRImagePresenter9 *iface) ...@@ -2423,7 +2411,7 @@ static ULONG WINAPI VMR9_ImagePresenter_Release(IVMRImagePresenter9 *iface)
IDirect3DSurface9_Release(surface); IDirect3DSurface9_Release(surface);
} }
CoTaskMemFree(This->d3d9_surfaces); free(This->d3d9_surfaces);
This->d3d9_surfaces = NULL; This->d3d9_surfaces = NULL;
This->num_surfaces = 0; This->num_surfaces = 0;
if (This->d3d9_vertex) if (This->d3d9_vertex)
...@@ -2431,7 +2419,7 @@ static ULONG WINAPI VMR9_ImagePresenter_Release(IVMRImagePresenter9 *iface) ...@@ -2431,7 +2419,7 @@ static ULONG WINAPI VMR9_ImagePresenter_Release(IVMRImagePresenter9 *iface)
IDirect3DVertexBuffer9_Release(This->d3d9_vertex); IDirect3DVertexBuffer9_Release(This->d3d9_vertex);
This->d3d9_vertex = NULL; This->d3d9_vertex = NULL;
} }
CoTaskMemFree(This); free(This);
return 0; return 0;
} }
return refCount; return refCount;
...@@ -2699,8 +2687,8 @@ static BOOL CreateRenderingWindow(VMR9DefaultAllocatorPresenterImpl *This, VMR9A ...@@ -2699,8 +2687,8 @@ static BOOL CreateRenderingWindow(VMR9DefaultAllocatorPresenterImpl *This, VMR9A
} }
IVMRSurfaceAllocatorNotify9_SetD3DDevice(This->SurfaceAllocatorNotify, This->d3d9_dev, This->hMon); IVMRSurfaceAllocatorNotify9_SetD3DDevice(This->SurfaceAllocatorNotify, This->d3d9_dev, This->hMon);
This->d3d9_surfaces = CoTaskMemAlloc(*numbuffers * sizeof(IDirect3DSurface9 *)); if (!(This->d3d9_surfaces = calloc(*numbuffers, sizeof(IDirect3DSurface9 *))))
ZeroMemory(This->d3d9_surfaces, *numbuffers * sizeof(IDirect3DSurface9 *)); return FALSE;
hr = VMR9_SurfaceAllocator_SetAllocationSettings(This, info); hr = VMR9_SurfaceAllocator_SetAllocationSettings(This, info);
if (FAILED(hr)) if (FAILED(hr))
...@@ -2915,19 +2903,18 @@ static IDirect3D9 *init_d3d9(HMODULE d3d9_handle) ...@@ -2915,19 +2903,18 @@ static IDirect3D9 *init_d3d9(HMODULE d3d9_handle)
static HRESULT VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr *parent, LPVOID * ppv) static HRESULT VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr *parent, LPVOID * ppv)
{ {
VMR9DefaultAllocatorPresenterImpl *object;
HRESULT hr = S_OK; HRESULT hr = S_OK;
int i; int i;
VMR9DefaultAllocatorPresenterImpl* This;
This = CoTaskMemAlloc(sizeof(VMR9DefaultAllocatorPresenterImpl)); if (!(object = calloc(1, sizeof(*object))))
if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->d3d9_ptr = init_d3d9(parent->hD3d9); object->d3d9_ptr = init_d3d9(parent->hD3d9);
if (!This->d3d9_ptr) if (!object->d3d9_ptr)
{ {
WARN("Could not initialize d3d9.dll\n"); WARN("Could not initialize d3d9.dll\n");
CoTaskMemFree(This); free(object);
return VFW_E_DDRAW_CAPS_NOT_SUITABLE; return VFW_E_DDRAW_CAPS_NOT_SUITABLE;
} }
...@@ -2936,7 +2923,7 @@ static HRESULT VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr *paren ...@@ -2936,7 +2923,7 @@ static HRESULT VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr *paren
{ {
D3DDISPLAYMODE mode; D3DDISPLAYMODE mode;
hr = IDirect3D9_EnumAdapterModes(This->d3d9_ptr, i++, D3DFMT_X8R8G8B8, 0, &mode); hr = IDirect3D9_EnumAdapterModes(object->d3d9_ptr, i++, D3DFMT_X8R8G8B8, 0, &mode);
if (hr == D3DERR_INVALIDCALL) break; /* out of adapters */ if (hr == D3DERR_INVALIDCALL) break; /* out of adapters */
} while (FAILED(hr)); } while (FAILED(hr));
if (FAILED(hr)) if (FAILED(hr))
...@@ -2944,24 +2931,18 @@ static HRESULT VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr *paren ...@@ -2944,24 +2931,18 @@ static HRESULT VMR9DefaultAllocatorPresenterImpl_create(struct quartz_vmr *paren
if (hr == D3DERR_NOTAVAILABLE) if (hr == D3DERR_NOTAVAILABLE)
{ {
ERR("Format not supported\n"); ERR("Format not supported\n");
IDirect3D9_Release(This->d3d9_ptr); IDirect3D9_Release(object->d3d9_ptr);
CoTaskMemFree(This); free(object);
return VFW_E_DDRAW_CAPS_NOT_SUITABLE; return VFW_E_DDRAW_CAPS_NOT_SUITABLE;
} }
This->IVMRImagePresenter9_iface.lpVtbl = &VMR9_ImagePresenter; object->IVMRImagePresenter9_iface.lpVtbl = &VMR9_ImagePresenter;
This->IVMRSurfaceAllocatorEx9_iface.lpVtbl = &VMR9_SurfaceAllocator; object->IVMRSurfaceAllocatorEx9_iface.lpVtbl = &VMR9_SurfaceAllocator;
This->refCount = 1; object->refCount = 1;
This->pVMR9 = parent; object->pVMR9 = parent;
This->d3d9_surfaces = NULL;
This->d3d9_dev = NULL;
This->hMon = 0;
This->d3d9_vertex = NULL;
This->num_surfaces = 0;
This->SurfaceAllocatorNotify = NULL;
This->reset = FALSE;
*ppv = &This->IVMRImagePresenter9_iface; TRACE("Created default presenter %p.\n", object);
*ppv = &object->IVMRImagePresenter9_iface;
return S_OK; return S_OK;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment