[FFmpeg-devel] [PATCH 2/2] avcodec/nvenc: Add support for cygwin
Timo Rothenpieler
timo at rothenpieler.org
Mon Dec 7 15:14:09 CET 2015
---
libavcodec/nvenc.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 9e448f9..b541e14 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -36,16 +36,18 @@
#include "internal.h"
#include "thread.h"
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__CYGWIN__)
#define CUDAAPI __stdcall
#else
#define CUDAAPI
#endif
#if defined(_WIN32)
+#define DL_OPEN_FUNC(l) LoadLibrary(TEXT(l))
#define LOAD_FUNC(l, s) GetProcAddress(l, s)
#define DL_CLOSE_FUNC(l) FreeLibrary(l)
#else
+#define DL_OPEN_FUNC(l) dlopen(l, RTLD_LAZY)
#define LOAD_FUNC(l, s) dlsym(l, s)
#define DL_CLOSE_FUNC(l) dlclose(l)
#endif
@@ -347,10 +349,10 @@ static av_cold int nvenc_dyload_cuda(AVCodecContext *avctx)
if (dl_fn->cuda_lib)
return 1;
-#if defined(_WIN32)
- dl_fn->cuda_lib = LoadLibrary(TEXT("nvcuda.dll"));
+#if defined(_WIN32) || defined(__CYGWIN__)
+ dl_fn->cuda_lib = DL_OPEN_FUNC("nvcuda.dll");
#else
- dl_fn->cuda_lib = dlopen("libcuda.so", RTLD_LAZY);
+ dl_fn->cuda_lib = DL_OPEN_FUNC("libcuda.so");
#endif
if (!dl_fn->cuda_lib) {
@@ -472,14 +474,14 @@ static av_cold int nvenc_dyload_nvenc(AVCodecContext *avctx)
if (dl_fn->nvenc_lib)
return 1;
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__CYGWIN__)
if (sizeof(void*) == 8) {
- dl_fn->nvenc_lib = LoadLibrary(TEXT("nvEncodeAPI64.dll"));
+ dl_fn->nvenc_lib = DL_OPEN_FUNC("nvEncodeAPI64.dll");
} else {
- dl_fn->nvenc_lib = LoadLibrary(TEXT("nvEncodeAPI.dll"));
+ dl_fn->nvenc_lib = DL_OPEN_FUNC("nvEncodeAPI.dll");
}
#else
- dl_fn->nvenc_lib = dlopen("libnvidia-encode.so.1", RTLD_LAZY);
+ dl_fn->nvenc_lib = DL_OPEN_FUNC("libnvidia-encode.so.1");
#endif
if (!dl_fn->nvenc_lib) {
--
2.6.3
More information about the ffmpeg-devel
mailing list