mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
msdk: Create msdk context without job_type
The job_type is not necessary when creating a normal msdk context. Make the APIs for creating context more flexible. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4177>
This commit is contained in:
parent
dafb801a18
commit
6242fca526
6 changed files with 36 additions and 26 deletions
|
@ -115,6 +115,7 @@ static gboolean
|
|||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
gboolean ret;
|
||||
GstMsdkContext *context;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_msdk_debug, "msdk", 0, "msdk");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_msdkdec_debug, "msdkdec", 0, "msdkdec");
|
||||
|
@ -145,7 +146,8 @@ plugin_init (GstPlugin * plugin)
|
|||
|
||||
plugin_add_dependencies (plugin);
|
||||
|
||||
if (!msdk_is_available ())
|
||||
context = gst_msdk_context_new (TRUE);
|
||||
if (!context)
|
||||
return TRUE; /* return TRUE to avoid getting blacklisted */
|
||||
|
||||
ret = gst_element_register (plugin, "msdkh264dec", GST_RANK_NONE,
|
||||
|
@ -196,6 +198,8 @@ plugin_init (GstPlugin * plugin)
|
|||
ret = gst_element_register (plugin, "msdkvpp", GST_RANK_NONE,
|
||||
GST_TYPE_MSDKVPP);
|
||||
|
||||
gst_object_unref (context);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,15 +304,13 @@ gst_msdk_context_use_d3d11 (GstMsdkContext * context)
|
|||
#endif
|
||||
|
||||
static gboolean
|
||||
gst_msdk_context_open (GstMsdkContext * context, gboolean hardware,
|
||||
GstMsdkContextJobType job_type)
|
||||
gst_msdk_context_open (GstMsdkContext * context, gboolean hardware)
|
||||
{
|
||||
mfxU16 codename;
|
||||
GstMsdkContextPrivate *priv = context->priv;
|
||||
MsdkSession msdk_session;
|
||||
mfxIMPL impl;
|
||||
|
||||
priv->job_type = job_type;
|
||||
priv->hardware = hardware;
|
||||
|
||||
impl = hardware ? MFX_IMPL_HARDWARE_ANY : MFX_IMPL_SOFTWARE;
|
||||
|
@ -410,19 +408,30 @@ gst_msdk_context_class_init (GstMsdkContextClass * klass)
|
|||
}
|
||||
|
||||
GstMsdkContext *
|
||||
gst_msdk_context_new (gboolean hardware, GstMsdkContextJobType job_type)
|
||||
gst_msdk_context_new (gboolean hardware)
|
||||
{
|
||||
GstMsdkContext *obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL);
|
||||
|
||||
if (obj && !gst_msdk_context_open (obj, hardware, job_type)) {
|
||||
if (obj)
|
||||
gst_object_unref (obj);
|
||||
if (obj && !gst_msdk_context_open (obj, hardware)) {
|
||||
gst_object_unref (obj);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
GstMsdkContext *
|
||||
gst_msdk_context_new_with_job_type (gboolean hardware,
|
||||
GstMsdkContextJobType job_type)
|
||||
{
|
||||
GstMsdkContext *obj = gst_msdk_context_new (hardware);
|
||||
|
||||
if (obj)
|
||||
obj->priv->job_type = job_type;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
GstMsdkContext *
|
||||
gst_msdk_context_new_with_parent (GstMsdkContext * parent)
|
||||
{
|
||||
|
@ -783,6 +792,13 @@ gst_msdk_context_get_job_type (GstMsdkContext * context)
|
|||
return context->priv->job_type;
|
||||
}
|
||||
|
||||
void
|
||||
gst_msdk_context_set_job_type (GstMsdkContext * context,
|
||||
GstMsdkContextJobType job_type)
|
||||
{
|
||||
context->priv->job_type = job_type;
|
||||
}
|
||||
|
||||
void
|
||||
gst_msdk_context_add_job_type (GstMsdkContext * context,
|
||||
GstMsdkContextJobType job_type)
|
||||
|
|
|
@ -87,7 +87,9 @@ struct _GstMsdkContextClass
|
|||
|
||||
GType gst_msdk_context_get_type (void);
|
||||
|
||||
GstMsdkContext * gst_msdk_context_new (gboolean hardware, GstMsdkContextJobType job_type);
|
||||
GstMsdkContext * gst_msdk_context_new (gboolean hardware);
|
||||
GstMsdkContext * gst_msdk_context_new_with_job_type (gboolean hardware,
|
||||
GstMsdkContextJobType job_type);
|
||||
GstMsdkContext * gst_msdk_context_new_with_parent (GstMsdkContext * parent);
|
||||
#ifndef _WIN32
|
||||
GstMsdkContext * gst_msdk_context_new_with_va_display (GstObject * display_obj,
|
||||
|
@ -141,6 +143,10 @@ gst_msdk_context_get_alloc_pool (GstMsdkContext * context);
|
|||
GstMsdkContextJobType
|
||||
gst_msdk_context_get_job_type (GstMsdkContext * context);
|
||||
|
||||
void
|
||||
gst_msdk_context_set_job_type (GstMsdkContext * context,
|
||||
GstMsdkContextJobType job_type);
|
||||
|
||||
void
|
||||
gst_msdk_context_add_job_type (GstMsdkContext * context, GstMsdkContextJobType job_type);
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ gst_msdk_ensure_new_context (GstElement * element, gboolean hardware,
|
|||
to enable user to choose GPU device in multi-GPU environment. This variable
|
||||
is only valid when there's no context returned by upstream or downstream.
|
||||
Otherwise it will use the device that created by upstream or downstream. */
|
||||
msdk_context = gst_msdk_context_new (hardware, job);
|
||||
msdk_context = gst_msdk_context_new_with_job_type (hardware, job);
|
||||
if (!msdk_context) {
|
||||
GST_ERROR_OBJECT (element, "Context creation failed");
|
||||
return FALSE;
|
||||
|
|
|
@ -388,20 +388,6 @@ failed:
|
|||
return msdk_session;
|
||||
}
|
||||
|
||||
gboolean
|
||||
msdk_is_available (void)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
gst_object_unref (msdk_context);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gst_msdk_set_video_alignment (GstVideoInfo * info, guint alloc_w, guint alloc_h,
|
||||
GstVideoAlignment * alignment)
|
||||
|
|
|
@ -114,8 +114,6 @@ MsdkSession msdk_open_session (mfxIMPL impl);
|
|||
void msdk_close_mfx_session (mfxSession session);
|
||||
void msdk_close_session (MsdkSession * session);
|
||||
|
||||
gboolean msdk_is_available (void);
|
||||
|
||||
mfxFrameSurface1 *msdk_get_free_surface (mfxFrameSurface1 * surfaces,
|
||||
guint size);
|
||||
void msdk_frame_to_surface (GstVideoFrame * frame, mfxFrameSurface1 * surface);
|
||||
|
|
Loading…
Reference in a new issue