[vlc-devel] [PATCH 18/20] hw:d3d9: make use of D3D9_FilterHoldInstance()
Steve Lhomme
robux4 at videolabs.io
Wed Nov 22 18:18:37 CET 2017
---
modules/hw/d3d9/d3d9_filters.c | 27 ++++++---------------------
modules/hw/d3d9/dxa9.c | 20 +++++++-------------
modules/hw/d3d9/dxva2_deinterlace.c | 28 ++++++----------------------
3 files changed, 19 insertions(+), 56 deletions(-)
diff --git a/modules/hw/d3d9/d3d9_filters.c b/modules/hw/d3d9/d3d9_filters.c
index d0212718eb..0fd40fb02a 100644
--- a/modules/hw/d3d9/d3d9_filters.c
+++ b/modules/hw/d3d9/d3d9_filters.c
@@ -225,7 +225,6 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
HINSTANCE hdecoder_dll = NULL;
HINSTANCE d3d9_dll = NULL;
HRESULT hr;
- picture_t *dst = NULL;
GUID *processorGUIDs = NULL;
GUID *processorGUID = NULL;
IDirectXVideoProcessorService *processor = NULL;
@@ -248,13 +247,11 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
if (!hdecoder_dll)
goto error;
- dst = filter_NewPicture(filter);
- if (dst == NULL)
- goto error;
-
- if (!dst->p_sys)
+ D3DSURFACE_DESC dstDesc;
+ D3D9_FilterHoldInstance(filter, &sys->d3d_dev, &dstDesc);
+ if (!sys->d3d_dev.dev)
{
- msg_Dbg(filter, "D3D9 opaque without a texture");
+ msg_Dbg(filter, "Filter without a context");
goto error;
}
@@ -266,15 +263,6 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
if (CreateVideoService == NULL)
goto error;
- hr = IDirect3DSurface9_GetDevice( dst->p_sys->surface, &sys->d3d_dev.dev );
- if (FAILED(hr))
- goto error;
-
- D3DSURFACE_DESC dstDesc;
- hr = IDirect3DSurface9_GetDesc( dst->p_sys->surface, &dstDesc );
- if (unlikely(FAILED(hr)))
- goto error;
-
hr = CreateVideoService( sys->d3d_dev.dev, &IID_IDirectXVideoProcessorService,
(void**)&processor);
if (FAILED(hr))
@@ -397,7 +385,6 @@ static int D3D9OpenAdjust(vlc_object_t *obj)
goto error;
CoTaskMemFree(processorGUIDs);
- picture_Release(dst);
IDirectXVideoProcessorService_Release(processor);
sys->hdecoder_dll = hdecoder_dll;
@@ -414,13 +401,11 @@ error:
if (processor)
IDirectXVideoProcessorService_Release(processor);
if (sys)
- D3D9_ReleaseDevice( &sys->d3d_dev );
+ D3D9_FilterReleaseInstance( &sys->d3d_dev );
if (hdecoder_dll)
FreeLibrary(hdecoder_dll);
if (d3d9_dll)
FreeLibrary(d3d9_dll);
- if (dst)
- picture_Release(dst);
free(sys);
return VLC_EGENERIC;
@@ -433,7 +418,7 @@ static void D3D9CloseAdjust(vlc_object_t *obj)
IDirect3DSurface9_Release( sys->hw_surface );
IDirectXVideoProcessor_Release( sys->processor );
- D3D9_ReleaseDevice( &sys->d3d_dev );
+ D3D9_FilterReleaseInstance( &sys->d3d_dev );
FreeLibrary( sys->hdecoder_dll );
FreeLibrary( sys->d3d9_dll );
diff --git a/modules/hw/d3d9/dxa9.c b/modules/hw/d3d9/dxa9.c
index 6815db2a93..fed821c8ff 100644
--- a/modules/hw/d3d9/dxa9.c
+++ b/modules/hw/d3d9/dxa9.c
@@ -369,17 +369,13 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
goto done;
}
- picture_t *peek = filter_NewPicture(p_filter);
- if (peek == NULL)
- return VLC_EGENERIC;
- if (!peek->p_sys)
+ D3DSURFACE_DESC texDesc;
+ D3D9_FilterHoldInstance(p_filter, &p_sys->d3d_dev, &texDesc);
+ if (!p_sys->d3d_dev.dev)
{
- msg_Dbg(p_filter, "D3D9 opaque without a texture");
- return VLC_EGENERIC;
+ msg_Dbg(p_filter, "Filter without a context");
+ goto done;
}
-
- D3DSURFACE_DESC texDesc;
- IDirect3DSurface9_GetDesc( peek->p_sys->surface, &texDesc);
if (texDesc.Format == 0)
goto done;
@@ -406,7 +402,6 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
}
picture_Setup(p_dst, &p_dst->format);
- IDirect3DSurface9_GetDevice(peek->p_sys->surface, &p_sys->d3d_dev.dev);
HRESULT hr = IDirect3DDevice9_CreateOffscreenPlainSurface(p_sys->d3d_dev.dev,
p_dst->format.i_width,
p_dst->format.i_height,
@@ -440,14 +435,13 @@ int D3D9OpenCPUConverter( vlc_object_t *obj )
done:
video_format_Clean(&fmt_staging);
- picture_Release(peek);
if (err != VLC_SUCCESS)
{
if (p_cpu_filter)
DeleteFilter( p_cpu_filter );
if (texture)
IDirect3DSurface9_Release(texture);
- D3D9_ReleaseDevice(&p_sys->d3d_dev);
+ D3D9_FilterReleaseInstance(&p_sys->d3d_dev);
if (hd3d_dll)
FreeLibrary(hd3d_dll);
free(p_sys);
@@ -470,7 +464,7 @@ void D3D9CloseCPUConverter( vlc_object_t *obj )
filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
DeleteFilter(p_sys->filter);
picture_Release(p_sys->staging);
- D3D9_ReleaseDevice(&p_sys->d3d_dev);
+ D3D9_FilterReleaseInstance(&p_sys->d3d_dev);
FreeLibrary(p_sys->hd3d_dll);
free( p_sys );
p_filter->p_sys = NULL;
diff --git a/modules/hw/d3d9/dxva2_deinterlace.c b/modules/hw/d3d9/dxva2_deinterlace.c
index 27f6fdb0d8..994ee997ea 100644
--- a/modules/hw/d3d9/dxva2_deinterlace.c
+++ b/modules/hw/d3d9/dxva2_deinterlace.c
@@ -274,7 +274,6 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
HINSTANCE hdecoder_dll = NULL;
HINSTANCE d3d9_dll = NULL;
HRESULT hr;
- picture_t *dst = NULL;
GUID *processorGUIDs = NULL;
GUID *processorGUID = NULL;
IDirectXVideoProcessorService *processor = NULL;
@@ -297,13 +296,11 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
if (unlikely(sys == NULL))
goto error;
- dst = filter_NewPicture(filter);
- if (dst == NULL)
- goto error;
-
- if (!dst->p_sys)
+ D3DSURFACE_DESC dstDesc;
+ D3D9_FilterHoldInstance( filter, &sys->d3d_dev, &dstDesc );
+ if (!sys->d3d_dev.dev)
{
- msg_Dbg(filter, "D3D9 opaque without a texture");
+ msg_Dbg(filter, "Filter without a context");
goto error;
}
@@ -314,16 +311,6 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
(void *)GetProcAddress(hdecoder_dll, "DXVA2CreateVideoService");
if (CreateVideoService == NULL)
goto error;
-
- hr = IDirect3DSurface9_GetDevice( dst->p_sys->surface, &sys->d3d_dev.dev );
- if (FAILED(hr))
- goto error;
-
- D3DSURFACE_DESC dstDesc;
- hr = IDirect3DSurface9_GetDesc( dst->p_sys->surface, &dstDesc );
- if (unlikely(FAILED(hr)))
- goto error;
-
hr = CreateVideoService( sys->d3d_dev.dev, &IID_IDirectXVideoProcessorService,
(void**)&processor);
if (FAILED(hr))
@@ -464,7 +451,6 @@ int D3D9OpenDeinterlace(vlc_object_t *obj)
CoTaskMemFree(processorGUIDs);
IDirectXVideoProcessorService_Release(processor);
- picture_Release(dst);
sys->buffer_new = filter->owner.video.buffer_new;
filter->owner.video.buffer_new = NewOutputPicture;
@@ -480,13 +466,11 @@ error:
IDirectXVideoProcessor_Release( sys->processor );
if (processor)
IDirectXVideoProcessorService_Release(processor);
- D3D9_ReleaseDevice( &sys->d3d_dev );
+ D3D9_FilterReleaseInstance( &sys->d3d_dev );
if (hdecoder_dll)
FreeLibrary(hdecoder_dll);
if (d3d9_dll)
FreeLibrary(d3d9_dll);
- if (dst)
- picture_Release(dst);
free(sys);
return VLC_EGENERIC;
@@ -499,7 +483,7 @@ void D3D9CloseDeinterlace(vlc_object_t *obj)
IDirect3DSurface9_Release( sys->hw_surface );
IDirectXVideoProcessor_Release( sys->processor );
- D3D9_ReleaseDevice( &sys->d3d_dev );
+ D3D9_FilterReleaseInstance( &sys->d3d_dev );
FreeLibrary( sys->hdecoder_dll );
FreeLibrary( sys->d3d9_dll );
--
2.14.2
More information about the vlc-devel
mailing list