diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c index 0974248a30..a0d8baa71f 100644 --- a/sys/msdk/gstmsdkdec.c +++ b/sys/msdk/gstmsdkdec.c @@ -40,6 +40,7 @@ #include "gstmsdkvideomemory.h" #include "gstmsdksystemmemory.h" #include "gstmsdkcontextutil.h" +#include "msdk-enums.h" GST_DEBUG_CATEGORY_EXTERN (gst_msdkdec_debug); #define GST_CAT_DEFAULT gst_msdkdec_debug @@ -61,10 +62,12 @@ enum PROP_0, PROP_HARDWARE, PROP_ASYNC_DEPTH, + PROP_OUTPUT_ORDER, }; #define PROP_HARDWARE_DEFAULT TRUE #define PROP_ASYNC_DEPTH_DEFAULT 1 +#define PROP_OUTPUT_ORDER_DEFAULT GST_MSDKDEC_OUTPUT_ORDER_DISPLAY #define gst_msdkdec_parent_class parent_class G_DEFINE_TYPE (GstMsdkDec, gst_msdkdec, GST_TYPE_VIDEO_DECODER); @@ -272,6 +275,10 @@ gst_msdkdec_init_decoder (GstMsdkDec * thiz) thiz->param.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420; thiz->param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; + /* This is a deprecated attribute in msdk-2017 version, but some + * customers still using this for low-latency streaming of non-b-frame + * encoded streams */ + thiz->param.mfx.DecodedOrder = thiz->output_order; /* allow subclass configure further */ if (klass->configure) { if (!klass->configure (thiz)) @@ -1060,6 +1067,9 @@ gst_msdkdec_set_property (GObject * object, guint prop_id, const GValue * value, case PROP_ASYNC_DEPTH: thiz->async_depth = g_value_get_uint (value); break; + case PROP_OUTPUT_ORDER: + thiz->output_order = g_value_get_enum (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1089,6 +1099,9 @@ gst_msdkdec_get_property (GObject * object, guint prop_id, GValue * value, case PROP_ASYNC_DEPTH: g_value_set_uint (value, thiz->async_depth); break; + case PROP_OUTPUT_ORDER: + g_value_set_enum (value, thiz->output_order); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1144,6 +1157,13 @@ gst_msdkdec_class_init (GstMsdkDecClass * klass) 1, 20, PROP_ASYNC_DEPTH_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_OUTPUT_ORDER, + g_param_spec_enum ("output-order", "DecodedFramesOutputOrder", + "Decoded frames output order", + gst_msdkdec_output_order_get_type (), + PROP_OUTPUT_ORDER_DEFAULT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + gst_element_class_add_static_pad_template (element_class, &src_factory); } @@ -1156,6 +1176,7 @@ gst_msdkdec_init (GstMsdkDec * thiz) thiz->tasks = g_array_new (FALSE, TRUE, sizeof (MsdkDecTask)); thiz->hardware = PROP_HARDWARE_DEFAULT; thiz->async_depth = PROP_ASYNC_DEPTH_DEFAULT; + thiz->output_order = PROP_OUTPUT_ORDER_DEFAULT; thiz->is_packetized = TRUE; thiz->adapter = gst_adapter_new (); } diff --git a/sys/msdk/gstmsdkdec.h b/sys/msdk/gstmsdkdec.h index 2df8e73804..f6f0825ed2 100644 --- a/sys/msdk/gstmsdkdec.h +++ b/sys/msdk/gstmsdkdec.h @@ -86,6 +86,7 @@ struct _GstMsdkDec /* element properties */ gboolean hardware; guint async_depth; + guint output_order; }; struct _GstMsdkDecClass diff --git a/sys/msdk/msdk-enums.c b/sys/msdk/msdk-enums.c index 03ce6375b9..4ea47404d9 100644 --- a/sys/msdk/msdk-enums.c +++ b/sys/msdk/msdk-enums.c @@ -33,6 +33,26 @@ #include "msdk-enums.h" +/*========= MSDK Decoder Enums =========================*/ +GType +gst_msdkdec_output_order_get_type (void) +{ + static GType type = 0; + + static const GEnumValue values[] = { + {GST_MSDKDEC_OUTPUT_ORDER_DISPLAY, "Output frames in Display order", + "display"}, + {GST_MSDKDEC_OUTPUT_ORDER_DECODE, "Output frames in Decoded order", + "decoded"}, + {0, NULL, NULL} + }; + + if (!type) { + type = g_enum_register_static ("GstMsdkDecOutputOrder", values); + } + return type; +} + /*========= MSDK Encoder Enums =========================*/ GType gst_msdkenc_rate_control_get_type (void) diff --git a/sys/msdk/msdk-enums.h b/sys/msdk/msdk-enums.h index 444a3877ec..171938cbde 100644 --- a/sys/msdk/msdk-enums.h +++ b/sys/msdk/msdk-enums.h @@ -40,6 +40,16 @@ G_BEGIN_DECLS #define _MFX_TRELLIS_NONE 0 +/*========= MSDK Decoder Enums =========================*/ +typedef enum +{ + GST_MSDKDEC_OUTPUT_ORDER_DISPLAY = 0, + GST_MSDKDEC_OUTPUT_ORDER_DECODE, +} GstMskdDecOutputOrder; + +GType +gst_msdkdec_output_order_get_type (void); + /*========= MSDK Encoder Enums =========================*/ GType gst_msdkenc_rate_control_get_type (void);