6 'gstmsdkcontextutil.c',
8 'gstmsdkdecproputil.c',
18 'gstmsdksystemmemory.c',
20 'gstmsdkvideomemory.c',
32 onevpl_extra_args = []
35 '-DGST_USE_UNSTABLE_API',
38 msdk_option = get_option('msdk')
39 if msdk_option.disabled()
43 if host_machine.system() == 'windows'
44 msdk_sources += ['msdk_d3d.c', 'gstmsdkallocator_d3d.c' ]
45 if gstd3d11_dep.found()
46 extra_args += ['-DCOBJMACROS']
48 if msdk_option.enabled()
49 error('The msdk plugin was enabled explicity, but required d3d11 dependencies were not found.')
55 if not gstva_dep.found()
56 if msdk_option.enabled()
57 error('The msdk plugin was enabled explicity, but required va dependencies were not found.')
61 msdk_sources += ['msdk_libva.c', 'gstmsdkallocator_libva.c']
64 mfx_api = get_option('mfx_api')
66 if mfx_api != 'oneVPL'
67 mfx_dep = dependency('libmfx', version: ['>= 1.0', '<= 1.99'], required: false)
70 mfx_incdir = mfx_dep.get_variable('includedir')
74 # Old versions of MediaSDK don't provide a pkg-config file
75 mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))', check: false).stdout().strip()
78 mfx_libdir = [mfx_root + '/lib/lin_x64', mfx_root + '/lib/x64', mfx_root + '/lib64', mfx_root + '/lib']
79 if host_machine.system() == 'windows'
80 if host_machine.cpu_family() == 'x86'
81 mfx_libdir = [mfx_root + '/lib/win32']
83 mfx_libdir = [mfx_root + '/lib/x64']
86 mfx_incdir = join_paths([mfx_root, 'include'])
87 mfx_lib = cxx.find_library('mfx', dirs: mfx_libdir, required: msdk_option)
88 mfx_inc = include_directories(mfx_incdir)
89 mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib)
95 if not use_msdk and mfx_api != 'MSDK'
96 mfx_dep = dependency('vpl', version: '>= 2.2', required: false)
99 mfx_incdir = mfx_dep.get_variable('includedir')
105 if not use_msdk and not use_onevpl
106 if msdk_option.enabled()
107 error('msdk plugin enabled but the Intel Media SDK or the oneVPL SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME')
113 # Check oneVPL firstly
115 onevpl_extra_args += ['-DONEVPL_EXPERIMENTAL']
116 mfx_incdir = join_paths([mfx_incdir, 'vpl'])
117 mfx_inc = include_directories(mfx_incdir)
118 elif cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir)
119 mfx_incdir = join_paths([mfx_incdir, 'mfx'])
120 mfx_inc = include_directories(mfx_incdir)
123 if use_onevpl or cxx.has_header('mfxvp9.h', args: '-I' + mfx_incdir)
124 msdk_sources += [ 'gstmsdkvp9dec.c' ]
125 cdata.set('USE_MSDK_VP9_DEC', 1)
128 # Usually MFX_VERSION 1026+ is required to support raw VP9 stream, however Fedora 30 has MFX_VERSION==1026
129 # but without support for raw VP9 stream, so mfxExtVP9Param is checked as well.
130 # See https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/988#note_408093
131 mfx_ver126_check_code = '''
133 #include <mfxstructures.h>
134 #if MFX_VERSION < 1026
135 #error "The current version of mfx doesn't support raw vp9 stream"
140 have_mfx_ver126 = cc.compiles(mfx_ver126_check_code,
141 include_directories : [configinc, mfx_inc])
144 msdk_sources += [ 'gstmsdkvp9enc.c' ]
145 cdata.set('USE_MSDK_VP9_ENC', 1)
148 mfx_ver134_check_code = '''
150 #if MFX_VERSION < 1034
151 #error "The current version of mfx doesn't support AV1 decoding"
155 have_mfx_ver134 = cc.compiles(mfx_ver134_check_code,
156 include_directories : [configinc, mfx_inc])
159 msdk_sources += [ 'gstmsdkav1dec.c' ]
160 cdata.set('USE_MSDK_AV1_DEC', 1)
163 mfx_ver205_check_code = '''
165 #if MFX_VERSION < 2005
166 #error "The current verison of mfx doesn't support AV1 encoding"
170 have_mfx_ver205 = cc.compiles(mfx_ver205_check_code,
171 include_directories: [configinc, mfx_inc])
173 if use_onevpl and have_mfx_ver205
174 msdk_sources += [ 'gstmsdkav1enc.c' ]
175 cdata.set10('USE_MSDK_AV1_ENC', 1)
178 if host_machine.system() == 'windows'
179 if cc.get_id() != 'msvc' and msdk_option.enabled()
180 error('msdk plugin can only be built with MSVC')
182 legacy_stdio_dep = cc.find_library('legacy_stdio_definitions', required: get_option('msdk'))
183 msdk_deps = declare_dependency(dependencies: [gstd3d11_dep, legacy_stdio_dep])
184 msdk_deps_found = gstd3d11_dep.found() and legacy_stdio_dep.found() and cc.get_id() == 'msvc'
186 libdl_dep = cc.find_library('dl', required: get_option('msdk'))
187 libgudev_dep = dependency('gudev-1.0', required: get_option('msdk'))
188 libdrm_dep = dependency('libdrm', required: get_option('msdk'))
189 msdk_deps = declare_dependency(dependencies: [gstva_dep, libdl_dep, libgudev_dep, libdrm_dep])
190 msdk_deps_found = gstva_dep.found() and libdl_dep.found() and libgudev_dep.found() and libdrm_dep.found()
194 if host_machine.system() != 'windows'
195 driverdir = libva_dep.get_variable('driverdir', default_value: '')
197 driverdir = join_paths(get_option('prefix'), get_option('libdir'), 'dri')
199 cdata.set_quoted('VA_DRIVERS_PATH', '@0@'.format(driverdir))
202 gstmsdktag = library('gstmsdk',
204 c_args : gst_plugins_bad_args + extra_args + onevpl_extra_args,
205 include_directories : [configinc, mfx_inc],
206 dependencies : [gstbase_dep, gstvideo_dep, gstpbutils_dep, gstallocators_dep, gstcodecparsers_dep, mfx_dep, msdk_deps],
208 install_dir : plugins_install_dir,
210 plugins += [gstmsdktag]