mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-05 18:22:23 +00:00
vaapidecodebin: capsfilter to optimize negotiation
Add a capsfilter forcing the caps "video/x-raw(memory:VASurface), format=(string)NV12" between the queue and the vaapipostproc so no renegotiation is required. https://bugzilla.gnome.org/show_bug.cgi?id=776175
This commit is contained in:
parent
a66c2d44bf
commit
a36b9b27e5
1 changed files with 30 additions and 5 deletions
|
@ -292,7 +292,9 @@ gst_vaapi_decode_bin_class_init (GstVaapiDecodeBinClass * klass)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin)
|
gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin)
|
||||||
{
|
{
|
||||||
GstPad *queue_srcpad, *bin_srcpad, *vpp_sinkpad, *vpp_srcpad;
|
GstElement *capsfilter;
|
||||||
|
GstCaps *caps;
|
||||||
|
GstPad *queue_srcpad, *bin_srcpad, *capsfilter_sinkpad, *vpp_srcpad;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
g_object_set (G_OBJECT (vaapidecbin->queue),
|
g_object_set (G_OBJECT (vaapidecbin->queue),
|
||||||
|
@ -305,6 +307,15 @@ gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin)
|
||||||
|
|
||||||
GST_INFO_OBJECT (vaapidecbin, "enabling VPP");
|
GST_INFO_OBJECT (vaapidecbin, "enabling VPP");
|
||||||
|
|
||||||
|
/* capsfilter to avoid negotiation with vaapidecode */
|
||||||
|
caps = gst_caps_from_string
|
||||||
|
("video/x-raw(memory:VASurface), format=(string)NV12");
|
||||||
|
if (!caps)
|
||||||
|
goto error_cannot_set_caps;
|
||||||
|
capsfilter = gst_element_factory_make ("capsfilter", NULL);
|
||||||
|
g_object_set (capsfilter, "caps", caps, NULL);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
/* create the postproc */
|
/* create the postproc */
|
||||||
vaapidecbin->postproc = gst_element_factory_make ("vaapipostproc", NULL);
|
vaapidecbin->postproc = gst_element_factory_make ("vaapipostproc", NULL);
|
||||||
if (!vaapidecbin->postproc)
|
if (!vaapidecbin->postproc)
|
||||||
|
@ -312,7 +323,14 @@ gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin)
|
||||||
g_object_set (G_OBJECT (vaapidecbin->postproc), "deinterlace-method",
|
g_object_set (G_OBJECT (vaapidecbin->postproc), "deinterlace-method",
|
||||||
vaapidecbin->deinterlace_method, NULL);
|
vaapidecbin->deinterlace_method, NULL);
|
||||||
|
|
||||||
gst_bin_add (GST_BIN (vaapidecbin), vaapidecbin->postproc);
|
gst_bin_add_many (GST_BIN (vaapidecbin), capsfilter, vaapidecbin->postproc,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (!gst_element_link (capsfilter, vaapidecbin->postproc))
|
||||||
|
goto error_sync_state;
|
||||||
|
|
||||||
|
if (!gst_element_sync_state_with_parent (capsfilter))
|
||||||
|
goto error_sync_state;
|
||||||
if (!gst_element_sync_state_with_parent (vaapidecbin->postproc))
|
if (!gst_element_sync_state_with_parent (vaapidecbin->postproc))
|
||||||
goto error_sync_state;
|
goto error_sync_state;
|
||||||
|
|
||||||
|
@ -324,9 +342,9 @@ gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin)
|
||||||
|
|
||||||
/* link decoder and queue */
|
/* link decoder and queue */
|
||||||
queue_srcpad = gst_element_get_static_pad (vaapidecbin->queue, "src");
|
queue_srcpad = gst_element_get_static_pad (vaapidecbin->queue, "src");
|
||||||
vpp_sinkpad = gst_element_get_static_pad (vaapidecbin->postproc, "sink");
|
capsfilter_sinkpad = gst_element_get_static_pad (capsfilter, "sink");
|
||||||
res = (gst_pad_link (queue_srcpad, vpp_sinkpad) == GST_PAD_LINK_OK);
|
res = (gst_pad_link (queue_srcpad, capsfilter_sinkpad) == GST_PAD_LINK_OK);
|
||||||
gst_object_unref (vpp_sinkpad);
|
gst_object_unref (capsfilter_sinkpad);
|
||||||
gst_object_unref (queue_srcpad);
|
gst_object_unref (queue_srcpad);
|
||||||
if (!res)
|
if (!res)
|
||||||
goto error_link_pad;
|
goto error_link_pad;
|
||||||
|
@ -342,6 +360,13 @@ gst_vaapi_decode_bin_configure (GstVaapiDecodeBin * vaapidecbin)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
error_cannot_set_caps:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (vaapidecbin, CORE, PAD,
|
||||||
|
("Failed to configure caps for VA Surfaces."), (NULL));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
error_vpp_missing:
|
error_vpp_missing:
|
||||||
{
|
{
|
||||||
post_missing_element_message (vaapidecbin, "vaapipostproc");
|
post_missing_element_message (vaapidecbin, "vaapipostproc");
|
||||||
|
|
Loading…
Reference in a new issue