diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2017-11-20 17:54:54 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-11-22 17:38:04 +0200 |
commit | 00874850e716f5e983cffb6599552fc943d45d01 (patch) | |
tree | a66b094d0828f43666b17b9169820e9a7f6e1de0 /gst | |
parent | d5067b42dedeffab121b9a0359966404b09a7378 (diff) |
h265parse: put downstream caps first if possible on sink caps
Try prioritizing downstream's caps over upstream's if possible so the
parser can configured in "passthrough" if possible and save it from
doing useless conversions.
Exact same change as the one I just did in h264parse.
https://bugzilla.gnome.org/show_bug.cgi?id=790628
Diffstat (limited to 'gst')
-rw-r--r-- | gst/videoparsers/gsth265parse.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c index 951b70dc5..85be01610 100644 --- a/gst/videoparsers/gsth265parse.c +++ b/gst/videoparsers/gsth265parse.c @@ -2149,7 +2149,7 @@ refuse_caps: } static void -remove_fields (GstCaps * caps) +remove_fields (GstCaps * caps, gboolean all) { guint i, n; @@ -2157,8 +2157,10 @@ remove_fields (GstCaps * caps) for (i = 0; i < n; i++) { GstStructure *s = gst_caps_get_structure (caps, i); - gst_structure_remove_field (s, "alignment"); - gst_structure_remove_field (s, "stream-format"); + if (all) { + gst_structure_remove_field (s, "alignment"); + gst_structure_remove_field (s, "stream-format"); + } gst_structure_remove_field (s, "parsed"); } } @@ -2167,28 +2169,24 @@ static GstCaps * gst_h265_parse_get_caps (GstBaseParse * parse, GstCaps * filter) { GstCaps *peercaps, *templ; - GstCaps *res; + GstCaps *res, *tmp, *pcopy; templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); if (filter) { GstCaps *fcopy = gst_caps_copy (filter); /* Remove the fields we convert */ - remove_fields (fcopy); + remove_fields (fcopy, TRUE); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), fcopy); gst_caps_unref (fcopy); } else peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), NULL); - if (peercaps) { - peercaps = gst_caps_make_writable (peercaps); - remove_fields (peercaps); + pcopy = gst_caps_copy (peercaps); + remove_fields (pcopy, TRUE); - res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); - gst_caps_unref (peercaps); - gst_caps_unref (templ); - } else { - res = templ; - } + res = gst_caps_intersect_full (pcopy, templ, GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (pcopy); + gst_caps_unref (templ); if (filter) { GstCaps *tmp = gst_caps_intersect_full (res, filter, @@ -2197,6 +2195,15 @@ gst_h265_parse_get_caps (GstBaseParse * parse, GstCaps * filter) res = tmp; } + /* Try if we can put the downstream caps first */ + remove_fields (peercaps, FALSE); + tmp = gst_caps_intersect_full (peercaps, res, GST_CAPS_INTERSECT_FIRST); + if (!gst_caps_is_empty (tmp)) + res = gst_caps_merge (tmp, res); + else + gst_caps_unref (tmp); + + gst_caps_unref (peercaps); return res; } |