deinterlace: implement accept-caps

Implement accept-caps handler to avoid doing a full caps query
downstream to handle it.

This commit implements accept-caps as a simplification of the _getcaps
function, so it exposes the same limitations that getcaps would.
For example, not accepting renegotiation to caps with capsfeatures when
it was last configured to a caps that it has to deinterlace.
This commit is contained in:
Thiago Santos 2015-10-19 17:50:28 -03:00
parent cf830a55b1
commit 82d62b9edd

View file

@ -2123,6 +2123,32 @@ gst_fraction_double (gint * n_out, gint * d_out, gboolean half)
return TRUE; return TRUE;
} }
static gboolean
gst_deinterlace_acceptcaps (GstDeinterlace * self, GstPad * pad, GstCaps * caps)
{
gboolean ret;
GstCaps *ourcaps;
GstVideoInterlaceMode interlacing_mode;
interlacing_mode = GST_VIDEO_INFO_INTERLACE_MODE (&self->vinfo);
if (self->mode == GST_DEINTERLACE_MODE_INTERLACED ||
(self->mode == GST_DEINTERLACE_MODE_AUTO &&
interlacing_mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE)) {
ourcaps = gst_caps_from_string (DEINTERLACE_CAPS);
} else {
ourcaps = gst_pad_get_pad_template_caps (pad);
}
ret = gst_caps_can_intersect (caps, ourcaps);
gst_caps_unref (ourcaps);
GST_DEBUG_OBJECT (pad, "accept-caps result:%d for caps %" GST_PTR_FORMAT,
ret, caps);
return ret;
}
static GstCaps * static GstCaps *
gst_deinterlace_getcaps (GstDeinterlace * self, GstPad * pad, GstCaps * filter) gst_deinterlace_getcaps (GstDeinterlace * self, GstPad * pad, GstCaps * filter)
{ {
@ -2675,6 +2701,17 @@ gst_deinterlace_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
res = TRUE; res = TRUE;
break; break;
} }
case GST_QUERY_ACCEPT_CAPS:
{
GstCaps *caps;
gboolean ret;
gst_query_parse_accept_caps (query, &caps);
ret = gst_deinterlace_acceptcaps (self, pad, caps);
gst_query_set_accept_caps_result (query, ret);
res = TRUE;
break;
}
case GST_QUERY_ALLOCATION: case GST_QUERY_ALLOCATION:
if (self->passthrough) if (self->passthrough)
res = gst_pad_peer_query (self->srcpad, query); res = gst_pad_peer_query (self->srcpad, query);