From: Seungha Yang Date: Mon, 19 Nov 2018 13:40:50 +0000 (+0900) Subject: nvdec: Add meson build with Windows support X-Git-Tag: 1.19.3~507^2~3800 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6051c47bfe3d98f96012f79e63f2b7fae618379e;p=platform%2Fupstream%2Fgstreamer.git nvdec: Add meson build with Windows support --- diff --git a/meson_options.txt b/meson_options.txt index a4c9dcf..9695fcd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -113,6 +113,7 @@ option('mplex', type : 'feature', value : 'auto', description : 'mplex audio/vid option('msdk', type : 'feature', value : 'auto', description : 'Intel Media SDK video encoder/decoder plugin') option('musepack', type : 'feature', value : 'auto', description : 'libmpcdec Musepack decoder plugin') option('neon', type : 'feature', value : 'auto', description : 'NEON HTTP source plugin') +option('nvdec', type : 'feature', value : 'auto', description : 'NVIDIA GPU decoder plugin') option('openh264', type : 'feature', value : 'auto', description : 'H.264 video codec plugin') option('openjpeg', type : 'feature', value : 'auto', description : 'JPEG2000 image codec plugin') option('opensles', type : 'feature', value : 'auto', description : 'OpenSL ES audio source/sink plugin') diff --git a/sys/meson.build b/sys/meson.build index c21494d..8a1363f 100644 --- a/sys/meson.build +++ b/sys/meson.build @@ -15,7 +15,6 @@ subdir('fbdev') subdir('ipcpipeline') subdir('kms') subdir('msdk') -#subdir('nvenc') subdir('opensles') subdir('shm') subdir('uvch264') @@ -24,3 +23,90 @@ subdir('uvch264') subdir('wasapi') subdir('winks') subdir('winscreencap') + +# CUDA dependency +cuda_dep = dependency('', required : false) +cudart_dep = dependency('', required : false) +cuda_libdir = '' +cuda_incdir = '' + +if host_machine.system() == 'windows' + # On windows, CUDA_PATH env will be set by installer + cuda_root = run_command(python3, '-c', 'import os; print(os.environ.get("CUDA_PATH"))').stdout().strip() + if cuda_root != '' + arc = '' + if build_machine.cpu_family() == 'x86_64' + arc = 'x64' + else + arc = 'Win32' + endif + cuda_libdir = join_paths (cuda_root, 'lib', arc) + cuda_incdir = join_paths (cuda_root, 'include') + cuda_lib = cc.find_library('cuda', dirs: cuda_libdir, required: false) + cudart_lib = cc.find_library('cudart', dirs: cuda_libdir, required: false) + if cuda_lib.found() + cuda_header_found = cc.has_header('cuda.h', args: '-I' + cuda_incdir) + cuda_lib_found = cc.has_function('cuInit', dependencies: cuda_lib) + if cuda_header_found and cuda_lib_found + cuda_dep = declare_dependency(include_directories: include_directories(cuda_incdir), + dependencies: cuda_lib) + endif + endif + + if cudart_lib.found() + cudart_header_found = cc.has_header('cuda_runtime_api.h', args: '-I' + cuda_incdir) + cudart_lib_found = cc.has_function('cudaGetErrorString', dependencies: cudart_lib) + if cudart_header_found and cudart_lib_found + cudart_dep = declare_dependency(dependencies: cudart_lib) + endif + endif + endif +else + cuda_versions = [ + '10.0', + '9.2', + '9.1', + '9.0', + '8.0', + '7.5', + '7.0', + '6.5', + ] + cuda_ver = '' + + # FIXME: use break syntax when we use meson >= '0.49' + foreach v : cuda_versions + if cuda_ver == '' + cuda_dep = dependency('cuda-' + v, required: false) + cudart_dep = dependency('cudart-' + v, required: false) + if cuda_dep.found() and cudart_dep.found() + cuda_ver = v + endif + endif + endforeach + + if cuda_dep.found() + cuda_header_found = cc.has_header('cuda.h', dependencies: cuda_dep) + cuda_lib_found = cc.has_function('cuInit', dependencies: cuda_dep) + if not cuda_header_found or not cuda_lib_found + message ('Missing required header and/or function in cuda dependency') + cuda_dep = dependency('', required : false) + endif + endif + + if cudart_dep.found() + cudart_header_found = cc.has_header('cuda_runtime_api.h', dependencies: cudart_dep) + cudart_lib_found = cc.has_function('cudaGetErrorString', dependencies: cudart_dep) + if not cudart_header_found or not cudart_lib_found + message ('Missing required header and/or function in cudart dependency') + cudart_dep = dependency('', required : false) + endif + endif +endif + +if cuda_dep.found() and cudart_dep.found() + subdir('nvdec') + #subdir('nvenc') +elif get_option('nvdec').enabled() + error('The nvdec plugin was enabled explicitly, but required CUDA dependencies were not found.') +endif \ No newline at end of file diff --git a/sys/nvdec/meson.build b/sys/nvdec/meson.build new file mode 100644 index 0000000..6029147 --- /dev/null +++ b/sys/nvdec/meson.build @@ -0,0 +1,38 @@ +nvdec_sources = [ + 'gstnvdec.c', + 'plugin.c' +] + +nvdec_option = get_option('nvdec') +if nvdec_option.disabled() + subdir_done() +endif + +nvcuvid_dep_found = false +if host_machine.system() == 'windows' + nvcuvid_lib = cc.find_library('nvcuvid', dirs: cuda_libdir, required: nvdec_option) +else + nvcuvid_lib = cc.find_library('nvcuvid', required: nvdec_option) +endif + +if nvcuvid_lib.found() and cc.has_function('cuvidCtxLock', dependencies: nvcuvid_lib) + nvcuvid_dep = declare_dependency(dependencies: nvcuvid_lib) + nvcuvid_dep_found = true +endif + +if nvdec_option.enabled() and not nvcuvid_dep_found + error('The nvdec plugin was enabled explicitly, but required nvcuvid library was not found.') +endif + +if nvcuvid_dep_found + gstnvdec = library('gstnvdec', + nvdec_sources, + c_args : gst_plugins_bad_args, + include_directories : [configinc], + dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstgl_dep, cuda_dep, cudart_dep, nvcuvid_dep], + install : true, + install_dir : plugins_install_dir, + ) + pkgconfig.generate(gstnvdec, install_dir : plugins_pkgconfig_install_dir) +endif +