From 8e4d7c364283528ac1348501360760a389138546 Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Fri, 29 Mar 2019 13:22:55 +0800 Subject: msdkdec: add postinit_decoder The workaround for https://github.com/Intel-Media-SDK/MediaSDK/issues/1139 is required for vp8 only, so move this workaround to the corresponding postinit_decoder function The pipeline below works with this change gst-launch-1.0 filesrc location=SA10104.vc1 ! \ 'video/x-wmv,profile=(string)advanced',width=720,height=480,framerate=14/1 ! \ msdkvc1dec ! fakesink --- sys/msdk/gstmsdkdec.c | 15 +++++++++------ sys/msdk/gstmsdkdec.h | 2 ++ sys/msdk/gstmsdkvp8dec.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c index 74137c0a5..19b6b570a 100644 --- a/sys/msdk/gstmsdkdec.c +++ b/sys/msdk/gstmsdkdec.c @@ -338,12 +338,7 @@ gst_msdkdec_init_decoder (GstMsdkDec * thiz) msdk_status_to_string (status)); } - /* Force the structure to MFX_PICSTRUCT_PROGRESSIVE if it is unknow to - * work-around MSDK issue: - * https://github.com/Intel-Media-SDK/MediaSDK/issues/1139 - */ - if (thiz->param.mfx.FrameInfo.PicStruct == MFX_PICSTRUCT_UNKNOWN) - thiz->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; + klass->postinit_decoder (thiz); status = MFXVideoDECODE_QueryIOSurf (session, &thiz->param, &request); if (status < MFX_ERR_NONE) { @@ -1472,6 +1467,13 @@ gst_msdkdec_preinit_decoder (GstMsdkDec * decoder) return TRUE; } +static gboolean +gst_msdkdec_postinit_decoder (GstMsdkDec * decoder) +{ + /* Do nothing */ + return TRUE; +} + static void gst_msdkdec_class_init (GstMsdkDecClass * klass) { @@ -1501,6 +1503,7 @@ gst_msdkdec_class_init (GstMsdkDecClass * klass) decoder_class->drain = GST_DEBUG_FUNCPTR (gst_msdkdec_drain); klass->preinit_decoder = GST_DEBUG_FUNCPTR (gst_msdkdec_preinit_decoder); + klass->postinit_decoder = GST_DEBUG_FUNCPTR (gst_msdkdec_postinit_decoder); g_object_class_install_property (gobject_class, GST_MSDKDEC_PROP_HARDWARE, g_param_spec_boolean ("hardware", "Hardware", "Enable hardware decoders", diff --git a/sys/msdk/gstmsdkdec.h b/sys/msdk/gstmsdkdec.h index 660c634e4..9ab21e2e1 100644 --- a/sys/msdk/gstmsdkdec.h +++ b/sys/msdk/gstmsdkdec.h @@ -110,6 +110,8 @@ struct _GstMsdkDecClass /* reset mfx parameters per codec */ gboolean (*preinit_decoder) (GstMsdkDec * decoder); + /* adjust mfx parameters per codec */ + gboolean (*postinit_decoder) (GstMsdkDec * decoder); }; struct _MsdkDecTask diff --git a/sys/msdk/gstmsdkvp8dec.c b/sys/msdk/gstmsdkvp8dec.c index ae68f94c8..ba229cefd 100644 --- a/sys/msdk/gstmsdkvp8dec.c +++ b/sys/msdk/gstmsdkvp8dec.c @@ -147,6 +147,19 @@ gst_msdkvp8dec_preinit_decoder (GstMsdkDec * decoder) return TRUE; } +static gboolean +gst_msdkvp8dec_postinit_decoder (GstMsdkDec * decoder) +{ + /* Force the structure to MFX_PICSTRUCT_PROGRESSIVE if it is unknow to + * work-around MSDK issue: + * https://github.com/Intel-Media-SDK/MediaSDK/issues/1139 + */ + if (decoder->param.mfx.FrameInfo.PicStruct == MFX_PICSTRUCT_UNKNOWN) + decoder->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; + + return TRUE; +} + static void gst_msdkvp8dec_class_init (GstMsdkVP8DecClass * klass) { @@ -164,6 +177,8 @@ gst_msdkvp8dec_class_init (GstMsdkVP8DecClass * klass) decoder_class->configure = GST_DEBUG_FUNCPTR (gst_msdkvp8dec_configure); decoder_class->preinit_decoder = GST_DEBUG_FUNCPTR (gst_msdkvp8dec_preinit_decoder); + decoder_class->postinit_decoder = + GST_DEBUG_FUNCPTR (gst_msdkvp8dec_postinit_decoder); gst_element_class_set_static_metadata (element_class, "Intel MSDK VP8 decoder", -- cgit v1.2.1