nvdec,nvenc: Port to dynamic library loading
... and put them into new nvcodec plugin.
* nvcodec plugin
Now each nvenc and nvdec element is moved to be a part of nvcodec plugin
for better interoperability.
Additionally, cuda runtime API header dependencies
(i.e., cuda_runtime_api.h and cuda_gl_interop.h) are removed.
Note that cuda runtime APIs have prefix "cuda". Since 1.16 release with
Windows support, only "cuda.h" and "cudaGL.h" dependent symbols have
been used except for some defined types. However, those types could be
replaced with other types which were defined by "cuda.h".
* dynamic library loading
CUDA library will be opened with g_module_open() instead of build-time linking.
On Windows, nvcuda.dll is installed to system path by CUDA Toolkit
installer, and on *nix, user should ensure that libcuda.so.1 can be
loadable (i.e., via LD_LIBRARY_PATH or default dlopen path)
Therefore, NVIDIA_VIDEO_CODEC_SDK_PATH env build time dependency for Windows
is removed.
2019-05-17 13:27:50 +00:00
|
|
|
nvcodec_sources = [
|
|
|
|
'plugin.c',
|
|
|
|
'gstnvenc.c',
|
|
|
|
'gstnvbaseenc.c',
|
|
|
|
'gstnvh264enc.c',
|
|
|
|
'gstnvh265enc.c',
|
|
|
|
'gstcudaloader.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
nvdec_sources = [
|
|
|
|
'gstnvdec.c',
|
|
|
|
'gstcuvidloader.c',
|
|
|
|
]
|
|
|
|
|
|
|
|
use_nvcodec_gl = false
|
|
|
|
extra_c_args = []
|
|
|
|
|
|
|
|
cuda_dep = dependency('', required : false)
|
|
|
|
cuda_header_dep = dependency('', required : false)
|
|
|
|
cuda_incdir = ''
|
|
|
|
|
|
|
|
nvcodec_option = get_option('nvcodec')
|
|
|
|
if nvcodec_option.disabled()
|
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
|
|
|
cuda_versions = [
|
|
|
|
'10.1',
|
|
|
|
'10.0',
|
|
|
|
'9.2',
|
|
|
|
'9.1',
|
|
|
|
'9.0',
|
|
|
|
'8.0',
|
|
|
|
'7.5',
|
|
|
|
'7.0',
|
|
|
|
'6.5',
|
|
|
|
]
|
|
|
|
cuda_ver = ''
|
|
|
|
|
2019-06-07 11:27:21 +00:00
|
|
|
cuda_dep = dependency('cuda', required:false)
|
|
|
|
if cuda_dep.found()
|
|
|
|
cuda_ver = cuda_dep.version()
|
|
|
|
endif
|
|
|
|
|
nvdec,nvenc: Port to dynamic library loading
... and put them into new nvcodec plugin.
* nvcodec plugin
Now each nvenc and nvdec element is moved to be a part of nvcodec plugin
for better interoperability.
Additionally, cuda runtime API header dependencies
(i.e., cuda_runtime_api.h and cuda_gl_interop.h) are removed.
Note that cuda runtime APIs have prefix "cuda". Since 1.16 release with
Windows support, only "cuda.h" and "cudaGL.h" dependent symbols have
been used except for some defined types. However, those types could be
replaced with other types which were defined by "cuda.h".
* dynamic library loading
CUDA library will be opened with g_module_open() instead of build-time linking.
On Windows, nvcuda.dll is installed to system path by CUDA Toolkit
installer, and on *nix, user should ensure that libcuda.so.1 can be
loadable (i.e., via LD_LIBRARY_PATH or default dlopen path)
Therefore, NVIDIA_VIDEO_CODEC_SDK_PATH env build time dependency for Windows
is removed.
2019-05-17 13:27:50 +00:00
|
|
|
# FIXME: use break syntax when we use meson >= '0.49'
|
|
|
|
foreach v : cuda_versions
|
|
|
|
if cuda_ver == ''
|
|
|
|
cuda_dep = dependency('cuda-' + v, required: false)
|
|
|
|
if cuda_dep.found()
|
|
|
|
cuda_ver = v
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
if cuda_dep.found()
|
|
|
|
if cc.has_header('cuda.h', dependencies: cuda_dep)
|
|
|
|
cuda_header_dep = cuda_dep.partial_dependency(compile_args : true, includes : true)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if not cuda_header_dep.found()
|
|
|
|
cuda_root = run_command(python3, '-c', 'import os; print(os.environ.get("CUDA_PATH"))').stdout().strip()
|
|
|
|
if cuda_root != '' and cuda_root != 'None'
|
|
|
|
cuda_incdir = join_paths (cuda_root, 'include')
|
|
|
|
|
|
|
|
if cc.has_header('cuda.h', args: '-I' + cuda_incdir)
|
|
|
|
cuda_header_dep = declare_dependency(include_directories: include_directories(cuda_incdir))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if not cuda_header_dep.found()
|
|
|
|
if nvcodec_option.enabled()
|
|
|
|
error('The nvcodec plugin was enabled explicitly, but required CUDA dependency was not found.')
|
|
|
|
endif
|
|
|
|
subdir_done()
|
|
|
|
endif
|
|
|
|
|
|
|
|
if gstgl_dep.found()
|
|
|
|
if cuda_dep.found()
|
|
|
|
if cc.has_header('cudaGL.h', dependencies: cuda_dep)
|
|
|
|
use_nvcodec_gl = true
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
if cc.has_header('cudaGL.h', args: '-I' + cuda_incdir)
|
|
|
|
use_nvcodec_gl = true
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if use_nvcodec_gl
|
|
|
|
# FIXME: make nvdec usable without OpenGL dependency
|
|
|
|
nvcodec_sources += nvdec_sources
|
|
|
|
extra_c_args += ['-DHAVE_NVCODEC_GST_GL=1']
|
|
|
|
endif
|
|
|
|
|
|
|
|
gstnvcodec = library('gstnvcodec',
|
|
|
|
nvcodec_sources,
|
|
|
|
c_args : gst_plugins_bad_args + extra_c_args,
|
|
|
|
include_directories : [configinc],
|
|
|
|
dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstgl_dep, cuda_header_dep, gmodule_dep],
|
|
|
|
install : true,
|
|
|
|
install_dir : plugins_install_dir,
|
|
|
|
)
|
|
|
|
pkgconfig.generate(gstnvcodec, install_dir : plugins_pkgconfig_install_dir)
|
|
|
|
plugins += [gstnvcodec]
|
|
|
|
|