diff --git a/sys/msdk/gstmsdkh265dec.c b/sys/msdk/gstmsdkh265dec.c index 14d7ac7edb..b43448d8fa 100644 --- a/sys/msdk/gstmsdkh265dec.c +++ b/sys/msdk/gstmsdkh265dec.c @@ -33,8 +33,6 @@ # include #endif -#include - #include "gstmsdkh265dec.h" #include "gstmsdkvideomemory.h" @@ -66,7 +64,6 @@ gst_msdkh265dec_configure (GstMsdkDec * decoder) { GstMsdkH265Dec *h265dec = GST_MSDKH265DEC (decoder); mfxSession session; - mfxStatus status; const mfxPluginUID *uid; session = gst_msdk_context_get_session (decoder->context); @@ -76,15 +73,8 @@ gst_msdkh265dec_configure (GstMsdkDec * decoder) else uid = &MFX_PLUGINID_HEVCD_SW; - status = MFXVideoUSER_Load (session, uid, 1); - if (status < MFX_ERR_NONE) { - GST_ERROR_OBJECT (h265dec, "Media SDK Plugin load failed (%s)", - msdk_status_to_string (status)); + if (!gst_msdk_load_plugin (session, uid, 1, "msdkh265dec")) return FALSE; - } else if (status > MFX_ERR_NONE) { - GST_WARNING_OBJECT (h265dec, "Media SDK Plugin load warning: %s", - msdk_status_to_string (status)); - } decoder->param.mfx.CodecId = MFX_CODEC_HEVC; diff --git a/sys/msdk/gstmsdkh265enc.c b/sys/msdk/gstmsdkh265enc.c index 9e720aade9..0d15be7eb1 100644 --- a/sys/msdk/gstmsdkh265enc.c +++ b/sys/msdk/gstmsdkh265enc.c @@ -33,8 +33,6 @@ # include #endif -#include - #include #include "gstmsdkh265enc.h" @@ -91,7 +89,6 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder) { GstMsdkH265Enc *h265enc = GST_MSDKH265ENC (encoder); mfxSession session; - mfxStatus status; const mfxPluginUID *uid; session = gst_msdk_context_get_session (encoder->context); @@ -101,15 +98,8 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder) else uid = &MFX_PLUGINID_HEVCE_SW; - status = MFXVideoUSER_Load (session, uid, 1); - if (status < MFX_ERR_NONE) { - GST_ERROR_OBJECT (h265enc, "Media SDK Plugin load failed (%s)", - msdk_status_to_string (status)); + if (!gst_msdk_load_plugin (session, uid, 1, "msdkh265enc")) return FALSE; - } else if (status > MFX_ERR_NONE) { - GST_WARNING_OBJECT (h265enc, "Media SDK Plugin load warning: %s", - msdk_status_to_string (status)); - } encoder->param.mfx.CodecId = MFX_CODEC_HEVC; diff --git a/sys/msdk/gstmsdkvp8dec.c b/sys/msdk/gstmsdkvp8dec.c index ba229cefd5..7c64126844 100644 --- a/sys/msdk/gstmsdkvp8dec.c +++ b/sys/msdk/gstmsdkvp8dec.c @@ -34,11 +34,10 @@ # include #endif -#include -#include - #include "gstmsdkvp8dec.h" +#include + GST_DEBUG_CATEGORY_EXTERN (gst_msdkvp8dec_debug); #define GST_CAT_DEFAULT gst_msdkvp8dec_debug @@ -56,22 +55,14 @@ gst_msdkvp8dec_configure (GstMsdkDec * decoder) { GstMsdkVP8Dec *vp8dec = GST_MSDKVP8DEC (decoder); mfxSession session; - mfxStatus status; const mfxPluginUID *uid; session = gst_msdk_context_get_session (decoder->context); uid = &MFX_PLUGINID_VP8D_HW; - status = MFXVideoUSER_Load (session, uid, 1); - if (status < MFX_ERR_NONE) { - GST_ERROR_OBJECT (vp8dec, "Media SDK Plugin load failed (%s)", - msdk_status_to_string (status)); + if (!gst_msdk_load_plugin (session, uid, 1, "msdkvp8dec")) return FALSE; - } else if (status > MFX_ERR_NONE) { - GST_WARNING_OBJECT (vp8dec, "Media SDK Plugin load warning: %s", - msdk_status_to_string (status)); - } decoder->param.mfx.CodecId = MFX_CODEC_VP8; /* Replaced with width and height rounded up to 16 */ diff --git a/sys/msdk/gstmsdkvp9dec.c b/sys/msdk/gstmsdkvp9dec.c index cb87b52015..3abc8255b7 100644 --- a/sys/msdk/gstmsdkvp9dec.c +++ b/sys/msdk/gstmsdkvp9dec.c @@ -35,7 +35,6 @@ # include #endif -#include #include #include "gstmsdkvp9dec.h" @@ -66,22 +65,14 @@ gst_msdkvp9dec_configure (GstMsdkDec * decoder) { GstMsdkVP9Dec *vp9dec = GST_MSDKVP9DEC (decoder); mfxSession session; - mfxStatus status; const mfxPluginUID *uid; session = gst_msdk_context_get_session (decoder->context); uid = &MFX_PLUGINID_VP9D_HW; - status = MFXVideoUSER_Load (session, uid, 1); - if (status < MFX_ERR_NONE) { - GST_ERROR_OBJECT (vp9dec, "Media SDK Plugin load failed (%s)", - msdk_status_to_string (status)); + if (!gst_msdk_load_plugin (session, uid, 1, "msdkvp9dec")) return FALSE; - } else if (status > MFX_ERR_NONE) { - GST_WARNING_OBJECT (vp9dec, "Media SDK Plugin load warning: %s", - msdk_status_to_string (status)); - } decoder->param.mfx.CodecId = MFX_CODEC_VP9; /* Replaced with width and height rounded up to 16 */ diff --git a/sys/msdk/gstmsdkvp9enc.c b/sys/msdk/gstmsdkvp9enc.c index 81c48423f6..8aaa817073 100644 --- a/sys/msdk/gstmsdkvp9enc.c +++ b/sys/msdk/gstmsdkvp9enc.c @@ -33,8 +33,6 @@ # include #endif -#include - #include #include "gstmsdkvp9enc.h" @@ -115,20 +113,12 @@ gst_msdkvp9enc_configure (GstMsdkEnc * encoder) { GstMsdkVP9Enc *thiz = GST_MSDKVP9ENC (encoder); mfxSession session; - mfxStatus status; if (encoder->hardware) { session = gst_msdk_context_get_session (encoder->context); - status = MFXVideoUSER_Load (session, &MFX_PLUGINID_VP9E_HW, 1); - if (status < MFX_ERR_NONE) { - GST_ERROR_OBJECT (thiz, "Media SDK Plugin load failed (%s)", - msdk_status_to_string (status)); + if (!gst_msdk_load_plugin (session, &MFX_PLUGINID_VP9E_HW, 1, "msdkvp9enc")) return FALSE; - } else if (status > MFX_ERR_NONE) { - GST_WARNING_OBJECT (thiz, "Media SDK Plugin load warning: %s", - msdk_status_to_string (status)); - } } encoder->num_extra_frames = encoder->async_depth - 1; diff --git a/sys/msdk/msdk.c b/sys/msdk/msdk.c index 83c9a3ebc8..5dde416808 100644 --- a/sys/msdk/msdk.c +++ b/sys/msdk/msdk.c @@ -450,3 +450,25 @@ gst_msdk_get_mfx_video_orientation_from_video_direction (guint value, break; } } + +gboolean +gst_msdk_load_plugin (mfxSession session, const mfxPluginUID * uid, + mfxU32 version, const gchar * plugin) +{ + mfxStatus status; + + status = MFXVideoUSER_Load (session, uid, version); + + if (status == MFX_ERR_UNDEFINED_BEHAVIOR) { + GST_WARNING ("Media SDK Plugin for %s has been loaded", plugin); + } else if (status < MFX_ERR_NONE) { + GST_ERROR ("Media SDK Plugin for %s load failed (%s)", plugin, + msdk_status_to_string (status)); + return FALSE; + } else if (status > MFX_ERR_NONE) { + GST_WARNING ("Media SDK Plugin for %s load warning: %s", plugin, + msdk_status_to_string (status)); + } + + return TRUE; +} diff --git a/sys/msdk/msdk.h b/sys/msdk/msdk.h index 61682a594e..84838471fe 100644 --- a/sys/msdk/msdk.h +++ b/sys/msdk/msdk.h @@ -43,6 +43,7 @@ #include #include +#include G_BEGIN_DECLS @@ -99,6 +100,10 @@ void gst_msdk_get_mfx_video_orientation_from_video_direction (guint value, guint * mfx_mirror, guint * mfx_rotation); +gboolean +gst_msdk_load_plugin (mfxSession session, const mfxPluginUID * uid, + mfxU32 version, const gchar * plugin); + G_END_DECLS #endif /* __MSDK_H__ */