From b6eca795572d395a9f8bb83cc382c845020d120e Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Fri, 6 Dec 2019 12:02:50 +0800 Subject: [PATCH] msdkdec: allow sub class to add extra parameters for additional configuration MSDK allows user add extended buffers to a bitstream for additional configuration. This commit is to support this feature in this plugin Part-of: --- sys/msdk/gstmsdkdec.c | 16 ++++++++++++++++ sys/msdk/gstmsdkdec.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c index 595a6e9523..da91f267f0 100644 --- a/sys/msdk/gstmsdkdec.c +++ b/sys/msdk/gstmsdkdec.c @@ -83,6 +83,15 @@ static gboolean gst_msdkdec_drain (GstVideoDecoder * decoder); static gboolean gst_msdkdec_flush (GstVideoDecoder * decoder); static gboolean gst_msdkdec_negotiate (GstMsdkDec * thiz, gboolean hard_reset); +void +gst_msdkdec_add_bs_extra_param (GstMsdkDec * thiz, mfxExtBuffer * param) +{ + if (thiz->num_bs_extra_params < MAX_BS_EXTRA_PARAMS) { + thiz->bs_extra_params[thiz->num_bs_extra_params] = param; + thiz->num_bs_extra_params++; + } +} + static GstVideoCodecFrame * gst_msdkdec_get_oldest_frame (GstVideoDecoder * decoder) { @@ -288,6 +297,7 @@ gst_msdkdec_close_decoder (GstMsdkDec * thiz, gboolean reset_param) if (reset_param) memset (&thiz->param, 0, sizeof (thiz->param)); + thiz->num_bs_extra_params = 0; thiz->initialized = FALSE; gst_adapter_clear (thiz->adapter); } @@ -1034,6 +1044,12 @@ gst_msdkdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame) memset (&bitstream, 0, sizeof (bitstream)); + /* Add extended buffers */ + if (thiz->num_bs_extra_params) { + bitstream.NumExtParam = thiz->num_bs_extra_params; + bitstream.ExtParam = thiz->bs_extra_params; + } + if (gst_video_decoder_get_packetized (decoder)) { /* Packetized stream: we prefer to have a parser as a connected upstream * element to the decoder */ diff --git a/sys/msdk/gstmsdkdec.h b/sys/msdk/gstmsdkdec.h index efc5b5a37c..7bde77dca8 100644 --- a/sys/msdk/gstmsdkdec.h +++ b/sys/msdk/gstmsdkdec.h @@ -54,6 +54,8 @@ G_BEGIN_DECLS #define GST_IS_MSDKDEC_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MSDKDEC)) +#define MAX_BS_EXTRA_PARAMS 8 + typedef struct _GstMsdkDec GstMsdkDec; typedef struct _GstMsdkDecClass GstMsdkDecClass; typedef struct _MsdkDecTask MsdkDecTask; @@ -98,6 +100,9 @@ struct _GstMsdkDec /* element properties */ gboolean hardware; guint async_depth; + + mfxExtBuffer *bs_extra_params[MAX_BS_EXTRA_PARAMS]; + guint num_bs_extra_params; }; struct _GstMsdkDecClass @@ -117,6 +122,9 @@ struct _GstMsdkDecClass GType gst_msdkdec_get_type (void); +void +gst_msdkdec_add_bs_extra_param (GstMsdkDec * thiz, mfxExtBuffer * param); + G_END_DECLS #endif /* __GST_MSDKDEC_H__ */