summaryrefslogtreecommitdiff
path: root/sys/msdk
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2018-12-29 13:56:49 +0800
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2019-01-08 09:11:47 +0000
commit3110f3791f94eb441d38e5fc762a0d427f0dcd54 (patch)
tree53dba41e0ea1acf9266d034d6665c3dc115d9982 /sys/msdk
parenta0943aec692714736179b2ee6ebe59ac584b87bf (diff)
downloadgstreamer-plugins-bad-3110f3791f94eb441d38e5fc762a0d427f0dcd54.tar.gz
msdk: don't reset the external frame allocator
In gst-msdk, a mfx session may be shared between different gst elements, each element tries to set the frame allocator. However, per the MSDK documation[1], the behavior is undefined if reset the frame allocator while the previous allocator is in use. Fortunately all elements use the same frame allocator, so we can avoid to call MFXVideoCORE_SetFrameAllocator again. [1]: https://software.intel.com/en-us/node/628430#MFXVideoCORE3
Diffstat (limited to 'sys/msdk')
-rw-r--r--sys/msdk/gstmsdkallocator_d3d.c3
-rw-r--r--sys/msdk/gstmsdkallocator_libva.c3
-rw-r--r--sys/msdk/gstmsdkcontext.c23
-rw-r--r--sys/msdk/gstmsdkcontext.h4
4 files changed, 29 insertions, 4 deletions
diff --git a/sys/msdk/gstmsdkallocator_d3d.c b/sys/msdk/gstmsdkallocator_d3d.c
index 75b147e86..27e457288 100644
--- a/sys/msdk/gstmsdkallocator_d3d.c
+++ b/sys/msdk/gstmsdkallocator_d3d.c
@@ -75,6 +75,5 @@ gst_msdk_set_frame_allocator (GstMsdkContext * context)
.Free = gst_msdk_frame_free,
};
- MFXVideoCORE_SetFrameAllocator (gst_msdk_context_get_session (context),
- &gst_msdk_frame_allocator);
+ gst_msdk_context_set_frame_allocator (context, &gst_msdk_frame_allocator);
}
diff --git a/sys/msdk/gstmsdkallocator_libva.c b/sys/msdk/gstmsdkallocator_libva.c
index 74be0dffc..e5200a3fe 100644
--- a/sys/msdk/gstmsdkallocator_libva.c
+++ b/sys/msdk/gstmsdkallocator_libva.c
@@ -366,8 +366,7 @@ gst_msdk_set_frame_allocator (GstMsdkContext * context)
.Free = gst_msdk_frame_free,
};
- MFXVideoCORE_SetFrameAllocator (gst_msdk_context_get_session (context),
- &gst_msdk_frame_allocator);
+ gst_msdk_context_set_frame_allocator (context, &gst_msdk_frame_allocator);
}
gboolean
diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c
index ae7b305fd..f1615ad60 100644
--- a/sys/msdk/gstmsdkcontext.c
+++ b/sys/msdk/gstmsdkcontext.c
@@ -47,6 +47,7 @@ struct _GstMsdkContextPrivate
GList *cached_alloc_responses;
gboolean hardware;
gboolean is_joined;
+ gboolean has_frame_allocator;
GstMsdkContextJobType job_type;
gint shared_async_depth;
GMutex mutex;
@@ -597,3 +598,25 @@ gst_msdk_context_add_shared_async_depth (GstMsdkContext * context,
{
context->priv->shared_async_depth += async_depth;
}
+
+void
+gst_msdk_context_set_frame_allocator (GstMsdkContext * context,
+ mfxFrameAllocator * allocator)
+{
+ GstMsdkContextPrivate *priv = context->priv;
+
+ g_mutex_lock (&priv->mutex);
+
+ if (!priv->has_frame_allocator) {
+ mfxStatus status;
+
+ status = MFXVideoCORE_SetFrameAllocator (priv->session, allocator);
+
+ if (status != MFX_ERR_NONE)
+ GST_ERROR ("Failed to set frame allocator");
+ else
+ priv->has_frame_allocator = 1;
+ }
+
+ g_mutex_unlock (&priv->mutex);
+}
diff --git a/sys/msdk/gstmsdkcontext.h b/sys/msdk/gstmsdkcontext.h
index cbaf68937..6abfa86ef 100644
--- a/sys/msdk/gstmsdkcontext.h
+++ b/sys/msdk/gstmsdkcontext.h
@@ -142,6 +142,10 @@ gst_msdk_context_get_shared_async_depth (GstMsdkContext * context);
void
gst_msdk_context_add_shared_async_depth (GstMsdkContext * context, gint async_depth);
+void
+gst_msdk_context_set_frame_allocator (GstMsdkContext * context,
+ mfxFrameAllocator * allocator);
+
G_END_DECLS
#endif /* GST_MSDK_CONTEXT_H */