Index: gst/gstbuffer.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/gst/gstbuffer.c,v
retrieving revision 1.140
diff -u -p -r1.140 gstbuffer.c
--- gst/gstbuffer.c	9 Jan 2008 12:19:31 -0000	1.140
+++ gst/gstbuffer.c	14 Feb 2008 19:18:43 -0000
@@ -458,12 +458,6 @@ gst_buffer_make_metadata_writable (GstBu
   } else {
     ret = gst_buffer_create_sub (buf, 0, GST_BUFFER_SIZE (buf));
 
-    /* copy all the flags except IN_CAPS */
-    GST_BUFFER_FLAGS (ret) = GST_BUFFER_FLAGS (buf);
-    GST_BUFFER_FLAG_UNSET (ret, GST_BUFFER_FLAG_IN_CAPS);
-    /* data should always be set to READONLY */
-    GST_BUFFER_FLAG_SET (ret, GST_BUFFER_FLAG_READONLY);
-
     gst_buffer_unref (buf);
   }
 
@@ -593,6 +587,17 @@ gst_buffer_create_sub (GstBuffer * buffe
   GST_BUFFER_DATA (GST_BUFFER_CAST (subbuffer)) = buffer->data + offset;
   GST_BUFFER_SIZE (GST_BUFFER_CAST (subbuffer)) = size;
 
+  if ((offset == 0) && (size == GST_BUFFER_SIZE (buffer))) {
+    /* copy all the flags except IN_CAPS */
+    GST_BUFFER_FLAG_SET (subbuffer, GST_BUFFER_FLAGS (buffer));
+    GST_BUFFER_FLAG_UNSET (subbuffer, GST_BUFFER_FLAG_IN_CAPS);
+  }
+  else {
+    /* copy only PREROLL & GAP flags */
+    GST_BUFFER_FLAG_SET (subbuffer, (GST_BUFFER_FLAGS (buffer) &
+      (GST_BUFFER_FLAG_PREROLL | GST_BUFFER_FLAG_GAP)));
+  }
+
   /* we can copy the timestamp and offset if the new buffer starts at
    * offset 0 */
   if (offset == 0) {
