From 82d62b9edd04bb7f5a1fece9d803e02629ddefd1 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 19 Oct 2015 17:50:28 -0300 Subject: 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. --- gst/deinterlace/gstdeinterlace.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c index 0c46a4229..e4aeafa05 100644 --- a/gst/deinterlace/gstdeinterlace.c +++ b/gst/deinterlace/gstdeinterlace.c @@ -2123,6 +2123,32 @@ gst_fraction_double (gint * n_out, gint * d_out, gboolean half) 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 * 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; 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: if (self->passthrough) res = gst_pad_peer_query (self->srcpad, query); -- cgit v1.2.3