dxva2: only keep a reference to the DXVA2 DLL in the DXVA2 pictures
authorSteve Lhomme <robux4@ycbcr.xyz>
Wed, 11 Dec 2019 10:17:21 +0000 (11:17 +0100)
committerSteve Lhomme <robux4@ycbcr.xyz>
Fri, 13 Dec 2019 09:12:51 +0000 (10:12 +0100)
The others don't allocate surfaces from that DLL.

modules/codec/avcodec/dxva2.c
modules/video_chroma/d3d9_fmt.h

index 3ef809c..16f8f57 100644 (file)
@@ -41,6 +41,7 @@ struct dxva2_pic_context
 {
     struct d3d9_pic_context ctx;
     struct vlc_va_surface_t *va_surface;
+    HINSTANCE               dxva2_dll;
 };
 
 #define DXVA2_PICCONTEXT_FROM_PICCTX(pic_ctx)  \
@@ -162,10 +163,12 @@ static void dxva2_pic_context_destroy(picture_context_t *ctx)
 {
     struct dxva2_pic_context *pic_ctx = DXVA2_PICCONTEXT_FROM_PICCTX(ctx);
     struct vlc_va_surface_t *va_surface = pic_ctx->va_surface;
+    HINSTANCE dxva2_dll = pic_ctx->dxva2_dll;
     static_assert(offsetof(struct dxva2_pic_context, ctx.s) == 0,
         "Cast assumption failure");
     d3d9_pic_context_destroy(ctx);
     va_surface_Release(va_surface);
+    FreeLibrary(dxva2_dll);
 }
 
 static picture_context_t *dxva2_pic_context_copy(picture_context_t *ctx)
@@ -202,6 +205,7 @@ static picture_context_t* NewSurfacePicContext(vlc_va_t *va, vlc_va_surface_t *v
     if (unlikely(pic_ctx==NULL))
         return NULL;
     pic_ctx->va_surface = va_surface;
+    pic_ctx->dxva2_dll = LoadLibrary(TEXT("DXVA2.DLL"));
     return &pic_ctx->ctx.s;
 }
 
index 50dc0e8..9647c9b 100644 (file)
@@ -35,7 +35,6 @@
 typedef struct
 {
     IDirect3DSurface9    *surface;
-    HINSTANCE            dxva2_dll;
 } picture_sys_d3d9_t;
 
 struct d3d9_pic_context
@@ -127,13 +126,11 @@ static inline d3d9_video_context_t *GetD3D9ContextPrivate(vlc_video_context *vct
 static inline void AcquireD3D9PictureSys(picture_sys_d3d9_t *p_sys)
 {
     IDirect3DSurface9_AddRef(p_sys->surface);
-    p_sys->dxva2_dll = LoadLibrary(TEXT("DXVA2.DLL"));
 }
 
 static inline void ReleaseD3D9PictureSys(picture_sys_d3d9_t *p_sys)
 {
     IDirect3DSurface9_Release(p_sys->surface);
-    FreeLibrary(p_sys->dxva2_dll);
 }
 
 HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, int,