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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/909>
This commit is contained in:
Haihao Xiang 2019-12-06 12:02:50 +08:00 committed by GStreamer Marge Bot
parent 957034d71a
commit b6eca79557
2 changed files with 24 additions and 0 deletions

View file

@ -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 */

View file

@ -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__ */