msdk: allow user build this plugin against MFX version 2.2+ (oneVPL)

Intel oneVPL SDK (oneVPL) is a successor to Intel Media SDK (MSDK)[1].
User may use -Dmfx_api=MSDK or -Dmfx_api=oneVPL to specify the required
SDK when building this plugin. If the SDK is not specified, meson will
try MSDK firstly, then oneVPL if MSDK is not available

Version 2.2+ is required in this patch because pkg-config file was not
provided officially before version 2.2

[1]https://spec.oneapi.com/versions/latest/elements/oneVPL/source/appendix/VPL_intel_media_sdk.html

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1503>
This commit is contained in:
Haihao Xiang 2021-02-18 13:38:25 +08:00
parent 5e02cec1c1
commit beda9a7333
2 changed files with 53 additions and 23 deletions

View file

@ -186,6 +186,10 @@ option('hls-crypto', type : 'combo', value : 'auto', choices : ['auto', 'nettle'
option('sctp-internal-usrsctp', type: 'feature', value : 'enabled',
description: 'Whether to use the bundled usrsctp library or the system one')
# MSDK plugin options
option('mfx_api', type : 'combo', choices : ['MSDK', 'oneVPL', 'auto'], value : 'auto',
description : 'Select MFX API to build against')
# Common feature options
option('examples', type : 'feature', value : 'auto', yield : true)
option('tests', type : 'feature', value : 'auto', yield : true)

View file

@ -32,17 +32,24 @@ endif
have_msdk = false
msdk_dep = []
use_msdk = false
use_onevpl = false
msdk_option = get_option('msdk')
if msdk_option.disabled()
subdir_done()
endif
mfx_dep = dependency('libmfx', required: false)
if mfx_dep.found()
mfx_api = get_option('mfx_api')
if mfx_api != 'oneVPL'
mfx_dep = dependency('libmfx', version: ['>= 1.0', '<= 1.99'], required: false)
if mfx_dep.found()
mfx_incdir = mfx_dep.get_pkgconfig_variable('includedir')
mfx_inc = []
else
use_msdk = true
else
# Old versions of MediaSDK don't provide a pkg-config file
mfx_root = run_command(python3, '-c', 'import os; print(os.environ.get("INTELMEDIASDKROOT", os.environ.get("MFX_HOME", "")))').stdout().strip()
@ -59,20 +66,39 @@ else
mfx_lib = cxx.find_library('mfx', dirs: mfx_libdir, required: msdk_option)
mfx_inc = include_directories(mfx_incdir)
mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib)
elif msdk_option.enabled()
error('msdk plugin enabled but Intel Media SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME')
use_msdk = true
endif
endif
endif
if not use_msdk and mfx_api != 'MSDK'
mfx_dep = dependency('vpl', version: '>= 2.2', required: false)
if mfx_dep.found()
mfx_incdir = mfx_dep.get_pkgconfig_variable('includedir')
mfx_inc = []
use_onevpl = true
endif
endif
if not use_msdk and not use_onevpl
if msdk_option.enabled()
error('msdk plugin enabled but the Intel Media SDK or the oneVPL SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME')
else
subdir_done()
endif
endif
# Old versions of MediaSDK don't have the 'mfx' directory prefix
if cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir)
# Check oneVPL firstly
if use_onevpl
mfx_incdir = join_paths([mfx_incdir, 'vpl'])
mfx_inc = include_directories(mfx_incdir)
elif cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir)
mfx_incdir = join_paths([mfx_incdir, 'mfx'])
mfx_inc = include_directories(mfx_incdir)
endif
if cxx.has_header('mfxvp9.h', args: '-I' + mfx_incdir)
if use_onevpl or cxx.has_header('mfxvp9.h', args: '-I' + mfx_incdir)
msdk_sources += [ 'gstmsdkvp9dec.c' ]
cdata.set10('USE_MSDK_VP9_DEC', 1)
endif