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', option('sctp-internal-usrsctp', type: 'feature', value : 'enabled',
description: 'Whether to use the bundled usrsctp library or the system one') 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 # Common feature options
option('examples', type : 'feature', value : 'auto', yield : true) option('examples', type : 'feature', value : 'auto', yield : true)
option('tests', type : 'feature', value : 'auto', yield : true) option('tests', type : 'feature', value : 'auto', yield : true)

View file

@ -32,17 +32,24 @@ endif
have_msdk = false have_msdk = false
msdk_dep = [] msdk_dep = []
use_msdk = false
use_onevpl = false
msdk_option = get_option('msdk') msdk_option = get_option('msdk')
if msdk_option.disabled() if msdk_option.disabled()
subdir_done() subdir_done()
endif endif
mfx_dep = dependency('libmfx', required: false) mfx_api = get_option('mfx_api')
if mfx_dep.found()
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_incdir = mfx_dep.get_pkgconfig_variable('includedir')
mfx_inc = [] mfx_inc = []
else use_msdk = true
else
# Old versions of MediaSDK don't provide a pkg-config file # 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() 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_lib = cxx.find_library('mfx', dirs: mfx_libdir, required: msdk_option)
mfx_inc = include_directories(mfx_incdir) mfx_inc = include_directories(mfx_incdir)
mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib) mfx_dep = declare_dependency(include_directories: mfx_inc, dependencies: mfx_lib)
elif msdk_option.enabled() use_msdk = true
error('msdk plugin enabled but Intel Media SDK not found: consider setting PKG_CONFIG_PATH, INTELMEDIASDKROOT or MFX_HOME') 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 else
subdir_done() subdir_done()
endif endif
endif endif
# Old versions of MediaSDK don't have the 'mfx' directory prefix # Check oneVPL firstly
if cxx.has_header('mfx/mfxdefs.h', args: '-I' + mfx_incdir) 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_incdir = join_paths([mfx_incdir, 'mfx'])
mfx_inc = include_directories(mfx_incdir) mfx_inc = include_directories(mfx_incdir)
endif 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' ] msdk_sources += [ 'gstmsdkvp9dec.c' ]
cdata.set10('USE_MSDK_VP9_DEC', 1) cdata.set10('USE_MSDK_VP9_DEC', 1)
endif endif