---
configure | 8 ++++++--
libavformat/avisynth.c | 14 +++++---------
libavutil/dyn_lib_open.h | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 11 deletions(-)
create mode 100644 libavutil/dyn_lib_open.h
diff --git a/configure b/configure
index ce52f50..a7671b7 100755
--- a/configure
+++ b/configure
@@ -1673,6 +1673,7 @@ CONFIG_EXTRA="
cabac
dirac_parse
dvprofile
+ dyn_lib_open
faandct
faanidct
fdctdsp
@@ -4565,9 +4566,12 @@ for func in $MATH_FUNCS; do
eval check_mathfunc $func \${${func}_args:-1}
done
+# This needs to be evaluated here instead of via the generic mechanism
+# (setting dyn_lib_open_deps_any) since we want it set here
+enabled_any dlopen LoadLibrary && enable dyn_lib_open || disable dyn_lib_open
+
# these are off by default, so fail if requested and not available
-enabled avisynth && { check_lib2 "avisynth/avisynth_c.h windows.h"
LoadLibrary ||
- check_lib2 "avxsynth/avxsynth_c.h dlfcn.h"
dlopen -ldl ||
+enabled avisynth && { { check_header "avisynth/avisynth_c.h" &&
enabled dyn_lib_open; } ||
die "ERROR: LoadLibrary/dlopen not found, or
avisynth header not found"; }
enabled cuda && check_lib cuda.h cuInit -lcuda
enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h
header not found"; }
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c
index fe71a42..d6d28e9 100644
--- a/libavformat/avisynth.c
+++ b/libavformat/avisynth.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/dyn_lib_open.h"
#include "libavutil/internal.h"
#include "libavcodec/internal.h"
#include "avformat.h"
@@ -36,14 +37,9 @@
#define AVISYNTH_LIB "avisynth"
#define USING_AVISYNTH
#else
- #include <dlfcn.h>
#include <avxsynth/avxsynth_c.h>
#define AVISYNTH_NAME "libavxsynth"
#define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF
-
- #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_LOCAL)
- #define GetProcAddress dlsym
- #define FreeLibrary dlclose
#endif
typedef struct AviSynthLibrary {
@@ -113,13 +109,13 @@ static av_cold void avisynth_atexit_handler(void);
static av_cold int avisynth_load_library(void)
{
- avs_library.library = LoadLibrary(AVISYNTH_LIB);
+ avs_library.library = load_library(AVISYNTH_LIB);
if (!avs_library.library)
return AVERROR_UNKNOWN;
#define LOAD_AVS_FUNC(name, continue_on_fail) \
avs_library.name = \
- (void *)GetProcAddress(avs_library.library, #name); \
+ (void *)get_function(avs_library.library, #name); \
if (!continue_on_fail && !avs_library.name) \
goto fail;
@@ -154,7 +150,7 @@ static av_cold int avisynth_load_library(void)
return 0;
fail:
- FreeLibrary(avs_library.library);
+ free_library(avs_library.library);
return AVERROR_UNKNOWN;
}
@@ -222,7 +218,7 @@ static av_cold void avisynth_atexit_handler(void)
avisynth_context_destroy(avs);
avs = next;
}
- FreeLibrary(avs_library.library);
+ free_library(avs_library.library);
avs_atexit_called = 1;
}
diff --git a/libavutil/dyn_lib_open.h b/libavutil/dyn_lib_open.h
new file mode 100644
index 0000000..d69d169
--- /dev/null
+++ b/libavutil/dyn_lib_open.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_DYN_LIB_OPEN_H
+#define AVUTIL_DYN_LIB_OPEN_H
+
+#include "config.h"
+
+#if HAVE_LOADLIBRARY
+#include <windows.h>
+
+#define load_library LoadLibrary
+#define get_function GetProcAddress
+#define free_library FreeLibrary
+
+#elif HAVE_DLOPEN
+#include <dlfcn.h>
+
+#define load_library(x) dlopen(x, RTLD_NOW | RTLD_LOCAL)
+#define get_function dlsym
+#define free_library dlclose
+#endif
+
+#endif /* AVUTIL_DYN_LIB_OPEN_H */
--
2.7.4 (Apple Git-66)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel