[FFmpeg-cvslog] avutil/hwcontext_dxva.c: Use new safe dlopen code.

Matt Oliver git at videolan.org
Sat Nov 5 09:08:27 EET 2016


ffmpeg | branch: master | Matt Oliver <protogonoi at gmail.com> | Sat Oct 29 18:25:05 2016 +1100| [85db1f97eb506b7b0fd876f428872b89f967cc53] | committer: Matt Oliver

avutil/hwcontext_dxva.c: Use new safe dlopen code.

Signed-off-by: Matt Oliver <protogonoi at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85db1f97eb506b7b0fd876f428872b89f967cc53
---

 libavutil/hwcontext_dxva2.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index e79254b..40a4a27 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -37,6 +37,7 @@
 #include "imgutils.h"
 #include "pixdesc.h"
 #include "pixfmt.h"
+#include "compat/w32dlfcn.h"
 
 typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT);
 typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **);
@@ -318,10 +319,10 @@ static void dxva2_device_free(AVHWDeviceContext *ctx)
         IDirect3D9_Release(priv->d3d9);
 
     if (priv->d3dlib)
-        FreeLibrary(priv->d3dlib);
+        dlclose(priv->d3dlib);
 
     if (priv->dxva2lib)
-        FreeLibrary(priv->dxva2lib);
+        dlclose(priv->dxva2lib);
 
     av_freep(&ctx->user_opaque);
 }
@@ -352,24 +353,24 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, const char *device,
 
     priv->device_handle = INVALID_HANDLE_VALUE;
 
-    priv->d3dlib = LoadLibrary("d3d9.dll");
+    priv->d3dlib = dlopen("d3d9.dll", 0);
     if (!priv->d3dlib) {
         av_log(ctx, AV_LOG_ERROR, "Failed to load D3D9 library\n");
         return AVERROR_UNKNOWN;
     }
-    priv->dxva2lib = LoadLibrary("dxva2.dll");
+    priv->dxva2lib = dlopen("dxva2.dll", 0);
     if (!priv->dxva2lib) {
         av_log(ctx, AV_LOG_ERROR, "Failed to load DXVA2 library\n");
         return AVERROR_UNKNOWN;
     }
 
-    createD3D = (pDirect3DCreate9 *)GetProcAddress(priv->d3dlib, "Direct3DCreate9");
+    createD3D = (pDirect3DCreate9 *)dlsym(priv->d3dlib, "Direct3DCreate9");
     if (!createD3D) {
         av_log(ctx, AV_LOG_ERROR, "Failed to locate Direct3DCreate9\n");
         return AVERROR_UNKNOWN;
     }
-    createDeviceManager = (pCreateDeviceManager9 *)GetProcAddress(priv->dxva2lib,
-                                                                  "DXVA2CreateDirect3DDeviceManager9");
+    createDeviceManager = (pCreateDeviceManager9 *)dlsym(priv->dxva2lib,
+                                                         "DXVA2CreateDirect3DDeviceManager9");
     if (!createDeviceManager) {
         av_log(ctx, AV_LOG_ERROR, "Failed to locate DXVA2CreateDirect3DDeviceManager9\n");
         return AVERROR_UNKNOWN;



More information about the ffmpeg-cvslog mailing list