diff --git a/configure.ac b/configure.ac
index 5d5994f..eb7e896 100644
--- a/configure.ac
+++ b/configure.ac
@@ -401,6 +401,10 @@ dnl check for mmap()
 AC_FUNC_MMAP
 AM_CONDITIONAL(HAVE_MMAP, test "x$ac_cv_func_mmap_fixed_mapped" = "xyes")
 
+dnl check for posix_memalign(), getpagesize()
+AC_CHECK_FUNCS([posix_memalign])
+AC_CHECK_FUNCS([getpagesize])
+
 dnl Check for POSIX timers
 AC_CHECK_FUNCS(clock_gettime, [], [
   AC_CHECK_LIB(rt, clock_gettime, [
@@ -557,6 +561,24 @@ dnl bit of a misnomer, but keep the conditional named like this so we don't
 dnl have to change too much elsewhere
 AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
 
+dnl configure the desired buffer alignment
+AC_ARG_WITH([buffer-alignment],
+  AS_HELP_STRING([--with-buffer-alignment],[8,N,malloc,pagesize (default is 32)]),
+  [
+    if test "x$withval" = "xyes"
+    then
+      AC_DEFINE(BUFFER_ALIGNMENT, 32, [Buffer alignment to use])
+    else
+      case "${withval}" in
+        malloc) AC_DEFINE(BUFFER_ALIGNMENT_MALLOC, 1, [Buffer alignment by malloc default]) ;;
+        pagesize)  AC_DEFINE(BUFFER_ALIGNMENT_PAGESIZE, 1, [Buffer alignment by pagesize]) ;;
+        *)   AC_DEFINE_UNQUOTED(BUFFER_ALIGNMENT, ${withval}, [Buffer alignment to use]) ;;
+      esac
+    fi
+  ], [
+    AC_DEFINE(BUFFER_ALIGNMENT_MALLOC, 1, [Buffer alignment by malloc default]) 
+  ]
+)
 
 dnl *** set variables based on configure arguments
 
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index b56b16c..e574c2d 100644
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
@@ -115,6 +115,13 @@
  */
 #include "gst_private.h"
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
 #include "gstbuffer.h"
 #include "gstinfo.h"
 #include "gstutils.h"
@@ -127,6 +134,25 @@ static GType gst_subbuffer_get_type (void);
 static GType _gst_subbuffer_type = 0;
 static GType _gst_buffer_type = 0;
 
+/* buffer alignment in bytes
+ * an alignment of 8 would be the same as malloc() guarantees
+ */
+#ifdef HAVE_POSIX_MEMALIGN
+#ifdef BUFFER_ALIGNMENT_MALLOC
+static size_t _gst_buffer_data_alignment = 8;
+#else
+#ifdef BUFFER_ALIGNMENT_PAGESIZE
+static size_t _gst_buffer_data_alignment = 0;
+#else
+#ifdef BUFFER_ALIGNMENT
+static size_t _gst_buffer_data_alignment = BUFFER_ALIGNMENT;
+#else
+#error "No buffer alignment configured"
+#endif
+#endif
+#endif
+#endif
+
 void
 _gst_buffer_initialize (void)
 {
@@ -135,6 +161,12 @@ _gst_buffer_initialize (void)
    * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
   g_type_class_ref (gst_buffer_get_type ());
   g_type_class_ref (gst_subbuffer_get_type ());
+
+#ifdef HAVE_GETPAGESIZE
+#ifdef BUFFER_ALIGNMENT_PAGESIZE
+  _gst_buffer_data_alignment = getpagesize ();
+#endif
+#endif
 }
 
 #define _do_init \
@@ -238,7 +270,29 @@ _gst_buffer_copy (GstBuffer * buffer)
   copy = gst_buffer_new ();
 
   /* we simply copy everything from our parent */
+#ifdef HAVE_POSIX_MEMALIGN
+  {
+    void *memptr = NULL;
+    
+    if (G_LIKELY (buffer->size)) {
+      gint errval;
+  
+      errval = posix_memalign (&memptr, _gst_buffer_data_alignment, buffer->size);
+      if (G_UNLIKELY (errval != 0)) {
+        /* terminate on error like g_memdup() would */
+        g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes",
+                 G_STRLOC, buffer->size);
+      }
+      else {
+         memcpy (memptr, buffer->data, buffer->size);
+      }
+    }
+    copy->data = (guint8 *) memptr;
+  }
+#else
   copy->data = g_memdup (buffer->data, buffer->size);
+#endif
+
   /* make sure it gets freed (even if the parent is subclassed, we return a
      normal buffer) */
   copy->malloc_data = copy->data;
@@ -258,7 +312,13 @@ gst_buffer_init (GstBuffer * buffer)
   GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
   GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE;
   GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
+#ifdef HAVE_POSIX_MEMALIGN
+  /* we will use posix_memalign */
+  GST_BUFFER_FREE_FUNC (buffer) = free;
+#else
+  /* we will use g_malloc */
   GST_BUFFER_FREE_FUNC (buffer) = g_free;
+#endif
 }
 
 /**
@@ -305,7 +365,25 @@ gst_buffer_new_and_alloc (guint size)
 
   newbuf = gst_buffer_new ();
 
+#ifdef HAVE_POSIX_MEMALIGN
+  {
+    void *memptr = NULL;
+
+    if (G_LIKELY (size)) {
+      gint errval;
+
+      errval = posix_memalign (&memptr, _gst_buffer_data_alignment, size);
+      if (G_UNLIKELY (errval != 0)) {
+        /* terminate on error like g_memdup() would */
+        g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes",
+                 G_STRLOC, size);
+      }
+    }
+    newbuf->malloc_data = (guint8 *) memptr;
+  }
+#else
   newbuf->malloc_data = g_malloc (size);
+#endif
   GST_BUFFER_DATA (newbuf) = newbuf->malloc_data;
   GST_BUFFER_SIZE (newbuf) = size;
 
@@ -335,13 +413,27 @@ gst_buffer_try_new_and_alloc (guint size)
 {
   GstBuffer *newbuf;
   guint8 *malloc_data;
+#ifdef HAVE_POSIX_MEMALIGN
+  void *memptr = NULL;
+
+  if (G_LIKELY (size)) {
+    gint errval;
 
+    errval = posix_memalign (&memptr, _gst_buffer_data_alignment, size);
+    if (G_UNLIKELY (errval != 0)) {
+      GST_CAT_WARNING (GST_CAT_BUFFER, "failed to allocate %d bytes", size);
+      return NULL;
+    }
+  }
+  malloc_data = (guint8 *) memptr;
+#else
   malloc_data = g_try_malloc (size);
 
   if (G_UNLIKELY (malloc_data == NULL && size != 0)) {
     GST_CAT_WARNING (GST_CAT_BUFFER, "failed to allocate %d bytes", size);
     return NULL;
   }
+#endif
 
   /* FIXME: there's no g_type_try_create_instance() in GObject yet, so this
    * will still abort if a new GstBuffer structure can't be allocated */
