summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2020-12-10 11:11:04 +0800
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-12-30 11:23:01 +0000
commit5015a66c561d203e339b4c3a1c24dec5b1f9a6ef (patch)
treea73a7c022090a28a83bbf73669955a3a77025100 /sys
parent3158ff43693caaac12a58be009c38fff38c40401 (diff)
downloadgstreamer-plugins-bad-5015a66c561d203e339b4c3a1c24dec5b1f9a6ef.tar.gz
msdk: check GstMsdkContext instead of mfxSession instance
When creating a GstMsdkContext instance, it also creates a mfxSession instance, so we may check GstMsdkContext instead of mfxSession instance to make sure MSDK is available. In addition, according to MSDK doc [1], MFXVideoCORE_SetHandle function should be executed before any actual usage of library including queries, otherwise the behavior is unexpected, so we should call MFXVideoCORE_QueryPlatform after MFXVideoCORE_SetHandle on Linux [1] https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#working-with-va-api-applications Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1921>
Diffstat (limited to 'sys')
-rw-r--r--sys/msdk/gstmsdkcontext.c9
-rw-r--r--sys/msdk/msdk.c16
2 files changed, 13 insertions, 12 deletions
diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c
index c31f73a54..d9210780a 100644
--- a/sys/msdk/gstmsdkcontext.c
+++ b/sys/msdk/gstmsdkcontext.c
@@ -178,6 +178,7 @@ static gboolean
gst_msdk_context_open (GstMsdkContext * context, gboolean hardware,
GstMsdkContextJobType job_type)
{
+ mfxU16 codename;
GstMsdkContextPrivate *priv = context->priv;
priv->job_type = job_type;
@@ -196,6 +197,13 @@ gst_msdk_context_open (GstMsdkContext * context, gboolean hardware,
}
#endif
+ codename = msdk_get_platform_codename (priv->session);
+
+ if (codename != MFX_PLATFORM_UNKNOWN)
+ GST_INFO ("Detected MFX platform with device code %d", codename);
+ else
+ GST_WARNING ("Unknown MFX platform");
+
return TRUE;
failed:
@@ -359,7 +367,6 @@ _requested_frame_size_is_equal_or_lower (mfxFrameAllocRequest * _req,
(!(_req->Type & MFX_MEMTYPE_EXPORT_FRAME) &&
_req->Info.Width <= cached_resp->request.Info.Width &&
_req->Info.Height <= cached_resp->request.Info.Height))
-
return TRUE;
return FALSE;
diff --git a/sys/msdk/msdk.c b/sys/msdk/msdk.c
index 6e610301b..f37a5d72d 100644
--- a/sys/msdk/msdk.c
+++ b/sys/msdk/msdk.c
@@ -191,7 +191,6 @@ msdk_open_session (mfxIMPL impl)
};
mfxIMPL implementation;
mfxStatus status;
- mfxU16 codename;
static const gchar *implementation_names[] = {
"AUTO", "SOFTWARE", "HARDWARE", "AUTO_ANY", "HARDWARE_ANY", "HARDWARE2",
@@ -218,13 +217,6 @@ msdk_open_session (mfxIMPL impl)
goto failed;
}
- codename = msdk_get_platform_codename (session);
-
- if (codename != MFX_PLATFORM_UNKNOWN)
- GST_INFO ("Detected MFX platform with device code %d", codename);
- else
- GST_WARNING ("Unknown MFX platform");
-
GST_INFO ("MFX implementation: 0x%04x (%s)", implementation,
implementation_names[MFX_IMPL_BASETYPE (implementation)]);
GST_INFO ("MFX version: %d.%d", version.Major, version.Minor);
@@ -239,12 +231,14 @@ failed:
gboolean
msdk_is_available (void)
{
- mfxSession session = msdk_open_session (MFX_IMPL_HARDWARE_ANY);
- if (!session) {
+ /* Make sure we can create GstMsdkContext instance (the job type is not used actually) */
+ GstMsdkContext *msdk_context = gst_msdk_context_new (1, GST_MSDK_JOB_DECODER);
+
+ if (!msdk_context) {
return FALSE;
}
- msdk_close_session (session);
+ gst_object_unref (msdk_context);
return TRUE;
}