diff -rupN gst-plugins-bad-1.1.3/sys/uvch264/gstuvch264_mjpgdemux.c gst-plugins-bad-1.1.3.new/sys/uvch264/gstuvch264_mjpgdemux.c
--- gst-plugins-bad-1.1.3/sys/uvch264/gstuvch264_mjpgdemux.c	2013-07-28 12:14:54.000000000 -0400
+++ gst-plugins-bad-1.1.3.new/sys/uvch264/gstuvch264_mjpgdemux.c	2013-08-12 14:42:33.444103761 -0400
@@ -469,8 +469,12 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
   GstPad *aux_pad = NULL;
   GstCaps **aux_caps = NULL;
   guint last_offset;
+  guint last_offset_jpeg;
+  guint last_offset_aux;
   guint i;
   GstMapInfo info;
+  guint8 *ptr;
+  guint32 size;
 
   self = GST_UVC_H264_MJPG_DEMUX (GST_PAD_PARENT (pad));
 
@@ -479,40 +483,50 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
   }
 
   last_offset = 0;
-  gst_buffer_map (buf, &info, GST_MAP_READ);
+  last_offset_aux = 0;
+  last_offset_jpeg = 0;
+
+  gst_memory_map (gst_buffer_get_memory(buf, 0), &info, GST_MAP_READ);
+  ptr = info.data;
+  size = info.size;
 
   jpeg_buf = gst_buffer_copy_region (buf, GST_BUFFER_COPY_METADATA, 0, 0);
 
-  for (i = 0; i < info.size - 1; i++) {
+  for (i = 0; i < size - 1; i++) {
     /* Check for APP4 (0xe4) marker in the jpeg */
-    if (info.data[i] == 0xff && info.data[i + 1] == 0xe4) {
+    if (ptr[i] == 0xff && ptr[i + 1] == 0xe4) {
       guint16 segment_size;
 
       /* Sanity check sizes and get segment size */
-      if (i + 4 >= info.size) {
+      if (i + 4 >= size) {
         GST_ELEMENT_ERROR (self, STREAM, DEMUX,
             ("Not enough data to read marker size"), (NULL));
         ret = GST_FLOW_ERROR;
         goto done;
       }
-      segment_size = GUINT16_FROM_BE (*((guint16 *) (info.data + i + 2)));
+      segment_size = GUINT16_FROM_BE (*((guint16 *) (ptr + i + 2)));
+
+      GST_DEBUG_OBJECT (self,
+          "Found APP4 marker (%d). JPG: %d-%d - APP4: %d - %d", segment_size,
+          last_offset, i, i, i + 2 + segment_size);
 
-      if (i + segment_size + 2 >= info.size) {
+      if (i + segment_size + 2 >= size) {
         GST_ELEMENT_ERROR (self, STREAM, DEMUX,
             ("Not enough data to read marker content"), (NULL));
         ret = GST_FLOW_ERROR;
         goto done;
       }
-      GST_DEBUG_OBJECT (self,
-          "Found APP4 marker (%d). JPG: %d-%d - APP4: %d - %d", segment_size,
-          last_offset, i, i, i + 2 + segment_size);
+      //GST_DEBUG_OBJECT (self,
+      //    "Found APP4 marker (%d). JPG: %d-%d - APP4: %d - %d", segment_size,
+      //    last_offset, i, i, i + 2 + segment_size);
 
       /* Add JPEG data between the last offset and this market */
       if (i - last_offset > 0) {
-        GstMemory *m = gst_memory_copy (info.memory, last_offset,
-            i - last_offset);
-        gst_buffer_append_memory (jpeg_buf, m);
+        gst_buffer_resize(jpeg_buf, 0, gst_buffer_get_size(jpeg_buf) + (i - last_offset));
+        gst_buffer_fill (jpeg_buf, last_offset_jpeg, &ptr[last_offset], i - last_offset);
+        last_offset_jpeg += (i - last_offset);
       }
+
       last_offset = i + 2 + segment_size;
 
       /* Reset i/segment size to the app4 data (ignore marker header/size) */
@@ -528,7 +542,7 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
           goto done;
         }
 
-        aux_header = *((AuxiliaryStreamHeader *) (info.data + i));
+        aux_header = *((AuxiliaryStreamHeader *) (ptr + i));
         /* version should be little endian but it looks more like BE */
         aux_header.version = GUINT16_FROM_BE (aux_header.version);
         aux_header.header_len = GUINT16_FROM_LE (aux_header.header_len);
@@ -543,7 +557,7 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
             GST_FOURCC_ARGS (aux_header.type),
             aux_header.width, aux_header.height,
             aux_header.frame_interval, aux_header.delay, aux_header.pts);
-        aux_size = *((guint32 *) (info.data + i + aux_header.header_len));
+        aux_size = *((guint32 *) (ptr + i + aux_header.header_len));
         GST_DEBUG_OBJECT (self, "Auxiliary stream size : %d bytes", aux_size);
 
         if (aux_size > 0) {
@@ -619,7 +633,7 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
           }
 
           /* Create new auxiliary buffer list and adjust i/segment size */
-          aux_buf = gst_buffer_new ();
+          aux_buf = gst_buffer_new_and_alloc (aux_size);
         }
 
         i += sizeof (aux_header) + sizeof (aux_size);
@@ -635,15 +649,13 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
       }
 
       if (segment_size > 0) {
-        GstMemory *m;
-        m = gst_memory_copy (info.memory, i, segment_size);
-
         GST_BUFFER_DURATION (aux_buf) =
             aux_header.frame_interval * 100 * GST_NSECOND;
 
         _pts_to_timestamp (self, aux_buf, aux_header.pts);
 
-        gst_buffer_append_memory (aux_buf, m);
+        gst_buffer_fill (aux_buf, last_offset_aux, &ptr[i], segment_size);
+        last_offset_aux += segment_size;
 
         aux_size -= segment_size;
 
@@ -663,15 +675,15 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
       }
 
       i += segment_size - 1;
-    } else if (info.data[i] == 0xff && info.data[i + 1] == 0xda) {
-      GstMemory *m;
+    } else if (ptr[i] == 0xff && ptr[i + 1] == 0xda) {
 
       /* The APP4 markers must be before the SOS marker, so this is the end */
       GST_DEBUG_OBJECT (self, "Found SOS marker.");
 
-      m = gst_memory_copy (info.memory, last_offset, info.size - last_offset);
-      gst_buffer_append_memory (jpeg_buf, m);
-      last_offset = info.size;
+      gst_buffer_resize(jpeg_buf, 0, gst_buffer_get_size(jpeg_buf) + (size - last_offset));
+      gst_buffer_fill (jpeg_buf, last_offset_jpeg, &ptr[last_offset], size - last_offset);
+      last_offset = size;
+      last_offset_jpeg += size;
       break;
     }
   }
@@ -683,7 +695,7 @@ gst_uvc_h264_mjpg_demux_chain (GstPad *
     goto done;
   }
 
-  if (last_offset != info.size) {
+  if (last_offset != size) {
     /* this means there was no SOS marker in the jpg, so we assume the JPG was
        just a container */
     GST_DEBUG_OBJECT (self, "SOS marker wasn't found. MJPG is container only");
@@ -706,7 +718,7 @@ done:
   if (jpeg_buf)
     gst_buffer_unref (jpeg_buf);
 
-  gst_buffer_unmap (buf, &info);
+  gst_memory_unmap (gst_buffer_get_memory(buf, 0), &info);
 
   /* We must always unref the input buffer since we never push it out */
   gst_buffer_unref (buf);
