[0.10] gst-plugins-bad: h264parse: prefer negotiating pass-through

Tim Müller tpm at kemper.freedesktop.org
Wed Jan 4 10:07:56 PST 2012


Module: gst-plugins-bad
Branch: 0.10
Commit: 61095e0029cae55f2b53e3694d745bb9da912277
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=61095e0029cae55f2b53e3694d745bb9da912277

Author: Mark Nauwelaerts <mark.nauwelaerts at collabora.co.uk>
Date:   Tue Jan  3 22:09:04 2012 +0100

h264parse: prefer negotiating pass-through

---

 gst/videoparsers/gsth264parse.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c
index 14b10a0..9b51d35 100644
--- a/gst/videoparsers/gsth264parse.c
+++ b/gst/videoparsers/gsth264parse.c
@@ -319,7 +319,7 @@ gst_h264_parse_format_from_caps (GstCaps * caps, guint * format, guint * align)
 
 /* check downstream caps to configure format and alignment */
 static void
-gst_h264_parse_negotiate (GstH264Parse * h264parse)
+gst_h264_parse_negotiate (GstH264Parse * h264parse, GstCaps * in_caps)
 {
   GstCaps *caps;
   guint format = GST_H264_PARSE_FORMAT_NONE;
@@ -328,10 +328,19 @@ gst_h264_parse_negotiate (GstH264Parse * h264parse)
   caps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (h264parse));
   GST_DEBUG_OBJECT (h264parse, "allowed caps: %" GST_PTR_FORMAT, caps);
 
-  gst_h264_parse_format_from_caps (caps, &format, &align);
+  if (in_caps && caps) {
+    if (gst_caps_can_intersect (in_caps, caps)) {
+      GST_DEBUG_OBJECT (h264parse, "downstream accepts upstream caps");
+      gst_h264_parse_format_from_caps (in_caps, &format, &align);
+      gst_caps_unref (caps);
+      caps = NULL;
+    }
+  }
 
-  if (caps)
+  if (caps) {
+    gst_h264_parse_format_from_caps (caps, &format, &align);
     gst_caps_unref (caps);
+  }
 
   /* default */
   if (!format)
@@ -610,7 +619,7 @@ gst_h264_parse_check_valid_frame (GstBaseParse * parse,
 
   /* need to configure aggregation */
   if (G_UNLIKELY (h264parse->format == GST_H264_PARSE_FORMAT_NONE))
-    gst_h264_parse_negotiate (h264parse);
+    gst_h264_parse_negotiate (h264parse, NULL);
 
   /* avoid stale cached parsing state */
   if (!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_PARSING)) {
@@ -1579,8 +1588,20 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps)
     }
   }
 
-  /* negotiate with downstream, sets ->format and ->align */
-  gst_h264_parse_negotiate (h264parse);
+  {
+    GstCaps *in_caps;
+
+    /* prefer input type determined above */
+    in_caps = gst_caps_new_simple ("video/x-h264",
+        "parsed", G_TYPE_BOOLEAN, TRUE,
+        "stream-format", G_TYPE_STRING,
+        gst_h264_parse_get_string (h264parse, TRUE, format),
+        "alignment", G_TYPE_STRING,
+        gst_h264_parse_get_string (h264parse, FALSE, align), NULL);
+    /* negotiate with downstream, sets ->format and ->align */
+    gst_h264_parse_negotiate (h264parse, in_caps);
+    gst_caps_unref (in_caps);
+  }
 
   if (format == h264parse->format && align == h264parse->align) {
     gst_base_parse_set_passthrough (parse, TRUE);



More information about the gstreamer-commits mailing list