msdkdec: add postinit_decoder
authorHaihao Xiang <haihao.xiang@intel.com>
Fri, 29 Mar 2019 05:22:55 +0000 (13:22 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Fri, 29 Mar 2019 05:32:06 +0000 (13:32 +0800)
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
sys/msdk/gstmsdkdec.h
sys/msdk/gstmsdkvp8dec.c

index 74137c0..19b6b57 100644 (file)
@@ -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",
index 660c634..9ab21e2 100644 (file)
@@ -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
index ae68f94..ba229ce 100644 (file)
@@ -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",