va: postproc: update passthrough and reconfigure pads

Added helper function _update_passthrough() which will define and set
the pass-through mode of the filter, and it'll either reconfigure both
pads or it will just mark the src pad for renegotiation or nothing at
all.

There are cases where both pads have to be reconfigured (direction
changed, for example), other when just src pad has to (filters
updated) or none (changing to ready state).

The requirement of renegotiation depends on the need to enable/disable
its VA buffer pools.

This patch sets pass-through mode by default, so the buffer pools
aren't allocated if no filtering/direction operations are defined,
which is the correct behavior.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2074>
This commit is contained in:
Víctor Manuel Jáquez Leal 2021-03-11 18:53:09 +01:00
parent 451c875d40
commit 0b2848fc32

View file

@ -197,6 +197,26 @@ gst_va_vpp_dispose (GObject * object)
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
_update_passthrough (GstVaVpp * self, gboolean reconf)
{
GstBaseTransform *trans = GST_BASE_TRANSFORM (self);
gboolean old, new;
old = gst_base_transform_is_passthrough (trans);
GST_OBJECT_LOCK (self);
new = (self->op_flags == 0);
GST_OBJECT_UNLOCK (self);
if (old != new) {
GST_INFO_OBJECT (self, "%s passthrough", new ? "enabling" : "disabling");
if (reconf)
gst_base_transform_reconfigure_src (trans);
gst_base_transform_set_passthrough (trans, new);
}
}
static void
_update_properties_unlocked (GstVaVpp * self)
{
@ -290,6 +310,10 @@ gst_va_vpp_set_property (GObject * object, guint prop_id,
_update_properties_unlocked (self);
GST_OBJECT_UNLOCK (object);
/* no reconfig here because it's done in
* _update_properties_unlocked() */
_update_passthrough (self, FALSE);
}
static void
@ -360,6 +384,7 @@ gst_va_vpp_change_state (GstElement * element, GstStateChange transition)
if (!gst_va_filter_open (self->filter))
goto open_failed;
_update_properties_unlocked (self);
_update_passthrough (self, FALSE);
break;
default:
break;
@ -776,6 +801,9 @@ gst_va_vpp_set_caps (GstBaseTransform * trans, GstCaps * incaps,
self->negotiated =
gst_va_filter_set_formats (self->filter, &self->in_info, &self->out_info);
if (self->negotiated)
_update_passthrough (self, FALSE);
return self->negotiated;
/* ERRORS */
@ -947,7 +975,7 @@ gst_va_vpp_before_transform (GstBaseTransform * trans, GstBuffer * inbuf)
self->op_flags &= ~VPP_CONVERT_FILTERS;
GST_OBJECT_UNLOCK (self);
gst_base_transform_set_passthrough (trans, self->op_flags == 0);
_update_passthrough (self, TRUE);
}
static inline gsize
@ -2182,6 +2210,11 @@ gst_va_vpp_sink_event (GstBaseTransform * trans, GstEvent * event)
_update_properties_unlocked (self);
GST_OBJECT_UNLOCK (self);
/* no reconfig here because it's done in
* _update_properties_unlocked */
_update_passthrough (self, FALSE);
break;
default:
break;