videoparsers: refactor remove_fields in getcaps
authorWim Taymans <wtaymans@redhat.com>
Wed, 4 Dec 2013 08:00:43 +0000 (09:00 +0100)
committerWim Taymans <wtaymans@redhat.com>
Wed, 4 Dec 2013 08:49:20 +0000 (09:49 +0100)
gst/videoparsers/gstdiracparse.c
gst/videoparsers/gsth263parse.c
gst/videoparsers/gsth264parse.c
gst/videoparsers/gsth265parse.c
gst/videoparsers/gstmpeg4videoparse.c
gst/videoparsers/gstmpegvideoparse.c
gst/videoparsers/gstvc1parse.c

index 1e25089..373d0d5 100644 (file)
@@ -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);
index 8d7b5e6..46ab4fe 100644 (file)
@@ -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);
index 8eb301b..6e8b5dc 100644 (file)
@@ -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);
index 429af29..bf03b5b 100644 (file)
@@ -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);
index 333db5d..6cc75d0 100644 (file)
@@ -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);
index 1feb3c5..a68b809 100644 (file)
@@ -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);
index 9bb37ab..5643d3d 100644 (file)
@@ -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);