1msdk_sources = [ 2 'gstmsdk.c', 3 'gstmsdkbufferpool.c', 4 'gstmsdkcontext.c', 5 'gstmsdkcontextutil.c', 6 'gstmsdkdec.c', 7 'gstmsdkdecproputil.c', 8 'gstmsdkenc.c', 9 'gstmsdkh264dec.c', 10 'gstmsdkh264enc.c', 11 'gstmsdkh265dec.c', 12 'gstmsdkh265enc.c', 13 'gstmsdkmjpegdec.c', 14 'gstmsdkmjpegenc.c', 15 'gstmsdkmpeg2dec.c', 16 'gstmsdkmpeg2enc.c', 17 'gstmsdksystemmemory.c', 18 'gstmsdkvc1dec.c', 19 'gstmsdkvideomemory.c', 20 'gstmsdkvp8dec.c', 21 'gstmsdkvpp.c', 22 'gstmsdkvpputil.c', 23 'msdk-enums.c', 24 'msdk.c', 25] 26 27if host_machine.system() == 'windows' 28 msdk_sources += ['msdk_d3d.c', 'gstmsdkallocator_d3d.c' ] 29else 30 msdk_sources += ['msdk_libva.c', 'gstmsdkallocator_libva.c'] 31endif 32 33have_msdk = false 34msdk_dep = [] 35use_msdk = false 36use_onevpl = false 37 38msdk_option = get_option('msdk') 39if msdk_option.disabled() 40 subdir_done() 41endif 42 43mfx_api = get_option('mfx_api') 44 45if mfx_api != 'oneVPL' 46 mfx_dep = dependency('libmfx', version: ['>= 1.0', '<= 1.99'], required: false) 47 48 if mfx_dep.found() 49 mfx_incdir = mfx_dep.get_variable('includedir') 50 mfx_inc = [] 51 use_msdk = true 52 else 53 # Old versions of MediaSDK don't provide a pkg-config file 54 mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))', check: false).stdout().strip() 55 56 if mfx_root != '' 57 mfx_libdir = [mfx_root + '/lib/lin_x64', mfx_root + '/lib/x64', mfx_root + '/lib64', mfx_root + '/lib'] 58 if host_machine.system() == 'windows' 59 if host_machine.cpu_family() == 'x86' 60 mfx_libdir = [mfx_root + '/lib/win32'] 61 else 62 mfx_libdir = [mfx_root + '/lib/x64'] 63 endif 64 endif 65 mfx_incdir = join_paths([mfx_root, 'include']) 66 mfx_lib = cxx.find_library('mfx', dirs: mfx_libdir, required: msdk_option) 67 mfx_inc = include_directories(mfx_incdir) 68 mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib) 69 use_msdk = true 70 endif 71 endif 72endif 73 74if not use_msdk and mfx_api != 'MSDK' 75 mfx_dep = dependency('vpl', version: '>= 2.2', required: false) 76 77 if mfx_dep.found() 78 mfx_incdir = mfx_dep.get_variable('includedir') 79 mfx_inc = [] 80 use_onevpl = true 81 endif 82endif 83 84if not use_msdk and not use_onevpl 85 if msdk_option.enabled() 86 error('msdk plugin enabled but the Intel Media SDK or the oneVPL SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME') 87 else 88 subdir_done() 89 endif 90endif 91 92# Check oneVPL firstly 93if use_onevpl 94 mfx_incdir = join_paths([mfx_incdir, 'vpl']) 95 mfx_inc = include_directories(mfx_incdir) 96elif cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir) 97 mfx_incdir = join_paths([mfx_incdir, 'mfx']) 98 mfx_inc = include_directories(mfx_incdir) 99endif 100 101if use_onevpl or cxx.has_header('mfxvp9.h', args: '-I' + mfx_incdir) 102 msdk_sources += [ 'gstmsdkvp9dec.c' ] 103 cdata.set('USE_MSDK_VP9_DEC', 1) 104endif 105 106# Usually MFX_VERSION 1026+ is required to support raw VP9 stream, however Fedora 30 has MFX_VERSION==1026 107# but without support for raw VP9 stream, so mfxExtVP9Param is checked as well. 108# See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/988#note_408093 109mfx_ver126_check_code = ''' 110#include <mfxdefs.h> 111#include <mfxstructures.h> 112#if MFX_VERSION < 1026 113#error "The current version of mfx doesn't support raw vp9 stream" 114#endif 115mfxExtVP9Param ext; 116''' 117 118have_mfx_ver126 = cc.compiles(mfx_ver126_check_code, 119 include_directories : [configinc, mfx_inc]) 120 121if have_mfx_ver126 122 msdk_sources += [ 'gstmsdkvp9enc.c' ] 123 cdata.set('USE_MSDK_VP9_ENC', 1) 124endif 125 126mfx_ver134_check_code = ''' 127#include <mfxdefs.h> 128#if MFX_VERSION < 1034 129#error "The current version of mfx doesn't support AV1 decoding" 130#endif 131''' 132 133have_mfx_ver134 = cc.compiles(mfx_ver134_check_code, 134 include_directories : [configinc, mfx_inc]) 135 136if have_mfx_ver134 137 msdk_sources += [ 'gstmsdkav1dec.c' ] 138 cdata.set('USE_MSDK_AV1_DEC', 1) 139endif 140 141if host_machine.system() == 'windows' 142 if cc.get_id() != 'msvc' and msdk_option.enabled() 143 error('msdk plugin can only be built with MSVC') 144 endif 145 legacy_stdio_dep = cc.find_library('legacy_stdio_definitions', required: get_option('msdk')) 146 d3d11_dep = cc.find_library('d3d11', required: get_option('msdk')) 147 msdk_deps = declare_dependency(dependencies: [d3d11_dep, legacy_stdio_dep]) 148 msdk_deps_found = d3d11_dep.found() and legacy_stdio_dep.found() and cc.get_id() == 'msvc' 149else 150 libva_dep = dependency('libva', required: get_option('msdk')) 151 libva_drm_dep = dependency('libva-drm', required: get_option('msdk')) 152 libdl_dep = cc.find_library('dl', required: get_option('msdk')) 153 libgudev_dep = dependency('gudev-1.0', required: get_option('msdk')) 154 libdrm_dep = dependency('libdrm', required: get_option('msdk')) 155 msdk_deps = declare_dependency(dependencies: [libva_dep, libva_drm_dep, libdl_dep, libgudev_dep, libdrm_dep]) 156 msdk_deps_found = libva_dep.found() and libva_drm_dep.found() and libdl_dep.found() and libgudev_dep.found() and libdrm_dep.found() 157endif 158 159if msdk_deps_found 160 if host_machine.system() != 'windows' 161 driverdir = libva_dep.get_variable('driverdir', default_value: '') 162 if driverdir == '' 163 driverdir = join_paths(get_option('prefix'), get_option('libdir'), 'dri') 164 endif 165 cdata.set_quoted('VA_DRIVERS_PATH', '@0@'.format(driverdir)) 166 endif 167 168 gstmsdktag = library('gstmsdk', 169 msdk_sources, 170 c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'], 171 include_directories : [configinc, mfx_inc], 172 dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstallocators_dep, gstcodecparsers_dep, mfx_dep, msdk_deps], 173 install : true, 174 install_dir : plugins_install_dir, 175 ) 176 pkgconfig.generate(gstmsdktag, install_dir : plugins_pkgconfig_install_dir) 177 plugins += [gstmsdktag] 178 have_msdk = true 179endif 180