[vlc-commits] dxva2: use the external d3d9_handle_t and d3d9_device_t creation API
Steve Lhomme
git at videolan.org
Thu Nov 15 14:20:03 CET 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Nov 15 11:55:27 2018 +0100| [7fdce3197b8c77cfe17c5a4274e7bf229bd33b32] | committer: Steve Lhomme
dxva2: use the external d3d9_handle_t and d3d9_device_t creation API
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7fdce3197b8c77cfe17c5a4274e7bf229bd33b32
---
modules/codec/avcodec/dxva2.c | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 6116fa3e21..9569990841 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -270,7 +270,26 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
return VLC_ENOMEM;
/* Load dll*/
- if (D3D9_Create(va, &sys->hd3d) != VLC_SUCCESS) {
+ if (p_sys!=NULL && p_sys->surface!=NULL)
+ {
+ IDirect3DDevice9 *device;
+ if ( FAILED(IDirect3DSurface9_GetDevice( p_sys->surface, &device )) )
+ {
+ free( sys );
+ goto error;
+ }
+ if ( D3D9_CreateExternal(va, &sys->hd3d, device) != VLC_SUCCESS ||
+ FAILED(D3D9_CreateDeviceExternal( device, &sys->hd3d, 0, &fmt->video, &sys->d3d_dev)) )
+ {
+ IDirect3DDevice9_Release(device);
+ free( sys );
+ goto error;
+ }
+ D3DSURFACE_DESC src;
+ if (SUCCEEDED(IDirect3DSurface9_GetDesc(p_sys->surface, &src)))
+ sys->render = src.Format;
+ }
+ else if (D3D9_Create(va, &sys->hd3d) != VLC_SUCCESS) {
msg_Warn(va, "cannot load d3d9.dll");
free( sys );
goto error;
@@ -302,15 +321,6 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
va->sys = sys;
- if (p_sys!=NULL)
- {
- D3DSURFACE_DESC src;
- if (SUCCEEDED(IDirect3DSurface9_GetDesc(p_sys->surface, &src)))
- sys->render = src.Format;
- IDirect3DSurface9_GetDevice(p_sys->surface, &sys->d3d_dev.dev );
- sys->d3d_dev.owner = false;
- }
-
err = directx_va_Open(va, &sys->dx_sys);
if (err!=VLC_SUCCESS)
goto error;
More information about the vlc-commits
mailing list