buffer: always copy all buffer flags when asked
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 25 Aug 2011 14:20:21 +0000 (16:20 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 25 Aug 2011 14:20:21 +0000 (16:20 +0200)
Don't try to be smart and copy only a subset of buffer flag

gst/gstbuffer.c
libs/gst/base/gstbasetransform.c

index c7160c8..eda17c1 100644 (file)
@@ -270,14 +270,8 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
       bufsize);
 
   if (flags & GST_BUFFER_COPY_FLAGS) {
-    guint mask;
-
-    /* copy relevant flags */
-    mask = GST_BUFFER_FLAG_LIVE | GST_BUFFER_FLAG_IN_CAPS |
-        GST_BUFFER_FLAG_DELTA_UNIT | GST_BUFFER_FLAG_DISCONT |
-        GST_BUFFER_FLAG_GAP | GST_BUFFER_FLAG_MEDIA1 |
-        GST_BUFFER_FLAG_MEDIA2 | GST_BUFFER_FLAG_MEDIA3;
-    GST_MINI_OBJECT_FLAGS (dest) |= GST_MINI_OBJECT_FLAGS (src) & mask;
+    /* copy flags */
+    GST_MINI_OBJECT_FLAGS (dest) = GST_MINI_OBJECT_FLAGS (src);
   }
 
   if (flags & GST_BUFFER_COPY_TIMESTAMPS) {
index 2f6ee96..e33801e 100644 (file)
@@ -1457,48 +1457,24 @@ static gboolean
 default_copy_metadata (GstBaseTransform * trans,
     GstBuffer * inbuf, GstBuffer * outbuf)
 {
-  GstBaseTransformPrivate *priv;
-  gboolean copymeta;
-  guint mask;
-
-  priv = trans->priv;
+  GstBaseTransformPrivate *priv = trans->priv;
 
   /* now copy the metadata */
-  mask = GST_BUFFER_FLAG_LIVE | GST_BUFFER_FLAG_IN_CAPS |
-      GST_BUFFER_FLAG_DELTA_UNIT | GST_BUFFER_FLAG_DISCONT |
-      GST_BUFFER_FLAG_GAP | GST_BUFFER_FLAG_MEDIA1 |
-      GST_BUFFER_FLAG_MEDIA2 | GST_BUFFER_FLAG_MEDIA3;
-
-  /* see if the flags and timestamps match */
-  copymeta =
-      (GST_MINI_OBJECT_FLAGS (outbuf) & mask) !=
-      (GST_MINI_OBJECT_FLAGS (inbuf) & mask);
-  copymeta |=
-      GST_BUFFER_TIMESTAMP (outbuf) != GST_BUFFER_TIMESTAMP (inbuf) ||
-      GST_BUFFER_DURATION (outbuf) != GST_BUFFER_DURATION (inbuf) ||
-      GST_BUFFER_OFFSET (outbuf) != GST_BUFFER_OFFSET (inbuf) ||
-      GST_BUFFER_OFFSET_END (outbuf) != GST_BUFFER_OFFSET_END (inbuf);
-  /* we need to modify the metadata when the element is not gap aware,
-   * passthrough is not used and the gap flag is set */
-  copymeta |= !priv->gap_aware && !trans->passthrough
-      && (GST_MINI_OBJECT_FLAGS (outbuf) & GST_BUFFER_FLAG_GAP);
-
-  if (copymeta) {
-    GST_DEBUG_OBJECT (trans, "copying metadata");
-
-    /* this should not happen, buffers allocated from a pool or with
-     * new_allocate should always be writable. */
-    if (!gst_buffer_is_writable (outbuf))
-      goto not_writable;
-
-    /* when we get here, the metadata should be writable */
-    gst_buffer_copy_into (outbuf, inbuf,
-        GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
-
-    /* clear the GAP flag when the subclass does not understand it */
-    if (!priv->gap_aware)
-      GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_GAP);
-  }
+  GST_DEBUG_OBJECT (trans, "copying metadata");
+
+  /* this should not happen, buffers allocated from a pool or with
+   * new_allocate should always be writable. */
+  if (!gst_buffer_is_writable (outbuf))
+    goto not_writable;
+
+  /* when we get here, the metadata should be writable */
+  gst_buffer_copy_into (outbuf, inbuf,
+      GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
+
+  /* clear the GAP flag when the subclass does not understand it */
+  if (!priv->gap_aware)
+    GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_GAP);
+
   return TRUE;
 
   /* ERRORS */