5 'gstmsdkcontextutil.c',
7 'gstmsdkdecproputil.c',
17 'gstmsdksystemmemory.c',
19 'gstmsdkvideomemory.c',
31 onevpl_extra_args = []
33 msdk_option = get_option('msdk')
34 if msdk_option.disabled()
38 if host_machine.system() == 'windows'
39 msdk_sources += ['msdk_d3d.c', 'gstmsdkallocator_d3d.c' ]
41 if not gstva_dep.found()
42 if msdk_option.enabled()
43 error('The msdk plugin was enabled explicity, but required va dependencies were not found.')
47 msdk_sources += ['msdk_libva.c', 'gstmsdkallocator_libva.c']
50 mfx_api = get_option('mfx_api')
52 if mfx_api != 'oneVPL'
53 mfx_dep = dependency('libmfx', version: ['>= 1.0', '<= 1.99'], required: false)
56 mfx_incdir = mfx_dep.get_variable('includedir')
60 # Old versions of MediaSDK don't provide a pkg-config file
61 mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))', check: false).stdout().strip()
64 mfx_libdir = [mfx_root + '/lib/lin_x64', mfx_root + '/lib/x64', mfx_root + '/lib64', mfx_root + '/lib']
65 if host_machine.system() == 'windows'
66 if host_machine.cpu_family() == 'x86'
67 mfx_libdir = [mfx_root + '/lib/win32']
69 mfx_libdir = [mfx_root + '/lib/x64']
72 mfx_incdir = join_paths([mfx_root, 'include'])
73 mfx_lib = cxx.find_library('mfx', dirs: mfx_libdir, required: msdk_option)
74 mfx_inc = include_directories(mfx_incdir)
75 mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib)
81 if not use_msdk and mfx_api != 'MSDK'
82 mfx_dep = dependency('vpl', version: '>= 2.2', required: false)
85 mfx_incdir = mfx_dep.get_variable('includedir')
91 if not use_msdk and not use_onevpl
92 if msdk_option.enabled()
93 error('msdk plugin enabled but the Intel Media SDK or the oneVPL SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME')
99 # Check oneVPL firstly
101 onevpl_extra_args += ['-DONEVPL_EXPERIMENTAL']
102 mfx_incdir = join_paths([mfx_incdir, 'vpl'])
103 mfx_inc = include_directories(mfx_incdir)
104 elif cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir)
105 mfx_incdir = join_paths([mfx_incdir, 'mfx'])
106 mfx_inc = include_directories(mfx_incdir)
109 if use_onevpl or cxx.has_header('mfxvp9.h', args: '-I' + mfx_incdir)
110 msdk_sources += [ 'gstmsdkvp9dec.c' ]
111 cdata.set('USE_MSDK_VP9_DEC', 1)
114 # Usually MFX_VERSION 1026+ is required to support raw VP9 stream, however Fedora 30 has MFX_VERSION==1026
115 # but without support for raw VP9 stream, so mfxExtVP9Param is checked as well.
116 # See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/988#note_408093
117 mfx_ver126_check_code = '''
119 #include <mfxstructures.h>
120 #if MFX_VERSION < 1026
121 #error "The current version of mfx doesn't support raw vp9 stream"
126 have_mfx_ver126 = cc.compiles(mfx_ver126_check_code,
127 include_directories : [configinc, mfx_inc])
130 msdk_sources += [ 'gstmsdkvp9enc.c' ]
131 cdata.set('USE_MSDK_VP9_ENC', 1)
134 mfx_ver134_check_code = '''
136 #if MFX_VERSION < 1034
137 #error "The current version of mfx doesn't support AV1 decoding"
141 have_mfx_ver134 = cc.compiles(mfx_ver134_check_code,
142 include_directories : [configinc, mfx_inc])
145 msdk_sources += [ 'gstmsdkav1dec.c' ]
146 cdata.set('USE_MSDK_AV1_DEC', 1)
149 mfx_ver205_check_code = '''
151 #if MFX_VERSION < 2005
152 #error "The current verison of mfx doesn't support AV1 encoding"
156 have_mfx_ver205 = cc.compiles(mfx_ver205_check_code,
157 include_directories: [configinc, mfx_inc])
159 if use_onevpl and have_mfx_ver205
160 msdk_sources += [ 'gstmsdkav1enc.c' ]
161 cdata.set10('USE_MSDK_AV1_ENC', 1)
164 if host_machine.system() == 'windows'
165 if cc.get_id() != 'msvc' and msdk_option.enabled()
166 error('msdk plugin can only be built with MSVC')
168 legacy_stdio_dep = cc.find_library('legacy_stdio_definitions', required: get_option('msdk'))
169 d3d11_dep = cc.find_library('d3d11', required: get_option('msdk'))
170 msdk_deps = declare_dependency(dependencies: [d3d11_dep, legacy_stdio_dep])
171 msdk_deps_found = d3d11_dep.found() and legacy_stdio_dep.found() and cc.get_id() == 'msvc'
173 libdl_dep = cc.find_library('dl', required: get_option('msdk'))
174 libgudev_dep = dependency('gudev-1.0', required: get_option('msdk'))
175 libdrm_dep = dependency('libdrm', required: get_option('msdk'))
176 msdk_deps = declare_dependency(dependencies: [gstva_dep, libdl_dep, libgudev_dep, libdrm_dep])
177 msdk_deps_found = gstva_dep.found() and libdl_dep.found() and libgudev_dep.found() and libdrm_dep.found()
181 if host_machine.system() != 'windows'
182 driverdir = libva_dep.get_variable('driverdir', default_value: '')
184 driverdir = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
186 cdata.set_quoted('VA_DRIVERS_PATH', '@0@'.format(driverdir))
189 gstmsdktag = library('gstmsdk',
191 c_args : gst_plugins_bad_args + ['-DGST_USE_UNSTABLE_API'] + onevpl_extra_args,
192 include_directories : [configinc, mfx_inc],
193 dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstallocators_dep, gstcodecparsers_dep, mfx_dep, msdk_deps],
195 install_dir : plugins_install_dir,
197 plugins += [gstmsdktag]