From d5a16bccac7fdc30daef3e31fbb499131f21b4b7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 4 Dec 2013 09:00:43 +0100 Subject: [PATCH] videoparsers: refactor remove_fields in getcaps --- gst/videoparsers/gstdiracparse.c | 21 ++++++++++++++------- gst/videoparsers/gsth263parse.c | 21 ++++++++++++++------- gst/videoparsers/gsth264parse.c | 25 ++++++++++++++++--------- gst/videoparsers/gsth265parse.c | 25 ++++++++++++++++--------- gst/videoparsers/gstmpeg4videoparse.c | 22 ++++++++++++++-------- gst/videoparsers/gstmpegvideoparse.c | 21 ++++++++++++++------- gst/videoparsers/gstvc1parse.c | 25 +++++++++++++++---------- 7 files changed, 103 insertions(+), 57 deletions(-) diff --git a/gst/videoparsers/gstdiracparse.c b/gst/videoparsers/gstdiracparse.c index 1e250891ca..373d0d509d 100644 --- a/gst/videoparsers/gstdiracparse.c +++ b/gst/videoparsers/gstdiracparse.c @@ -387,6 +387,19 @@ gst_dirac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) return GST_FLOW_OK; } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + + gst_structure_remove_field (s, "parsed"); + } +} + static GstCaps * gst_dirac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) { @@ -397,15 +410,9 @@ gst_dirac_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { - guint i, n; - /* Remove the parsed field */ peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peercaps, i); - gst_structure_remove_field (s, "parsed"); - } + remove_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); diff --git a/gst/videoparsers/gsth263parse.c b/gst/videoparsers/gsth263parse.c index 8d7b5e67fa..46ab4fee94 100644 --- a/gst/videoparsers/gsth263parse.c +++ b/gst/videoparsers/gsth263parse.c @@ -361,6 +361,19 @@ more: return res; } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + + gst_structure_remove_field (s, "parsed"); + } +} + static GstCaps * gst_h263_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) { @@ -371,15 +384,9 @@ gst_h263_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { - guint i, n; - /* Remove parsed field */ peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peercaps, i); - gst_structure_remove_field (s, "parsed"); - } + remove_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 8eb301b232..6e8b5dc23e 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -1894,6 +1894,21 @@ refuse_caps: } } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (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"); + gst_structure_remove_field (s, "parsed"); + } +} + static GstCaps * gst_h264_parse_get_caps (GstBaseParse * parse, GstCaps * filter) { @@ -1903,16 +1918,8 @@ gst_h264_parse_get_caps (GstBaseParse * parse, GstCaps * filter) templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { - guint i, n; - peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peercaps, i); - gst_structure_remove_field (s, "alignment"); - gst_structure_remove_field (s, "stream-format"); - gst_structure_remove_field (s, "parsed"); - } + remove_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); diff --git a/gst/videoparsers/gsth265parse.c b/gst/videoparsers/gsth265parse.c index 429af2966c..bf03b5b064 100644 --- a/gst/videoparsers/gsth265parse.c +++ b/gst/videoparsers/gsth265parse.c @@ -1832,6 +1832,21 @@ refuse_caps: } } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (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"); + gst_structure_remove_field (s, "parsed"); + } +} + static GstCaps * gst_h265_parse_get_caps (GstBaseParse * parse, GstCaps * filter) { @@ -1841,16 +1856,8 @@ gst_h265_parse_get_caps (GstBaseParse * parse, GstCaps * filter) templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { - guint i, n; - peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peercaps, i); - gst_structure_remove_field (s, "alignment"); - gst_structure_remove_field (s, "stream-format"); - gst_structure_remove_field (s, "parsed"); - } + remove_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); diff --git a/gst/videoparsers/gstmpeg4videoparse.c b/gst/videoparsers/gstmpeg4videoparse.c index 333db5da8b..6cc75d0514 100644 --- a/gst/videoparsers/gstmpeg4videoparse.c +++ b/gst/videoparsers/gstmpeg4videoparse.c @@ -830,6 +830,19 @@ gst_mpeg4vparse_set_caps (GstBaseParse * parse, GstCaps * caps) return TRUE; } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + + gst_structure_remove_field (s, "parsed"); + } +} + static GstCaps * gst_mpeg4vparse_get_caps (GstBaseParse * parse, GstCaps * filter) @@ -841,16 +854,9 @@ gst_mpeg4vparse_get_caps (GstBaseParse * parse, GstCaps * filter) peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { - guint i, n; - /* Remove the parsed field */ peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peercaps, i); - - gst_structure_remove_field (s, "parsed"); - } + remove_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 1feb3c52b4..a68b809b84 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -1023,6 +1023,19 @@ gst_mpegv_parse_set_caps (GstBaseParse * parse, GstCaps * caps) return TRUE; } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + + gst_structure_remove_field (s, "parsed"); + } +} + static GstCaps * gst_mpegv_parse_get_caps (GstBaseParse * parse, GstCaps * filter) { @@ -1032,15 +1045,9 @@ gst_mpegv_parse_get_caps (GstBaseParse * parse, GstCaps * filter) templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter); if (peercaps) { - guint i, n; - /* Remove the parsed field */ peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - GstStructure *s = gst_caps_get_structure (peercaps, i); - gst_structure_remove_field (s, "parsed"); - } + remove_fields (peercaps); res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps); diff --git a/gst/videoparsers/gstvc1parse.c b/gst/videoparsers/gstvc1parse.c index 9bb37aba3b..5643d3da6a 100644 --- a/gst/videoparsers/gstvc1parse.c +++ b/gst/videoparsers/gstvc1parse.c @@ -363,6 +363,20 @@ gst_vc1_parse_renegotiate (GstVC1Parse * vc1parse) return TRUE; } +static void +remove_fields (GstCaps * caps) +{ + guint i, n; + + n = gst_caps_get_size (caps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (caps, i); + + gst_structure_remove_field (s, "stream-format"); + gst_structure_remove_field (s, "header-format"); + } +} + static GstCaps * gst_vc1_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) { @@ -373,20 +387,11 @@ gst_vc1_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)); peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), NULL); if (peercaps) { - guint i, n; - GstStructure *s; - /* Remove the stream-format and header-format fields * and add the generic ones again by intersecting * with our template */ peercaps = gst_caps_make_writable (peercaps); - n = gst_caps_get_size (peercaps); - for (i = 0; i < n; i++) { - s = gst_caps_get_structure (peercaps, i); - - gst_structure_remove_field (s, "stream-format"); - gst_structure_remove_field (s, "header-format"); - } + remove_fields (peercaps); ret = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (peercaps);