diff --git a/configure.ac b/configure.ac
index 9d4eaee..796a8d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ m4_define([png_required_version], [0.0.0])
 m4_define([librsvg_required_version], [2.14.0])
 m4_define([openexr_required_version], [0.0.0])
 m4_define([sdl_required_version], [0.0.0])
-m4_define([openraw_required_version], [0.0.5])
+m4_define([libraw_required_version], [0.13])
 m4_define([jasper_required_version], [1.900.1])
 m4_define([graphviz_required_version], [0.0.0])
 
@@ -784,19 +784,19 @@ AC_SUBST(SDL_LIBS)
 
 
 ######################
-# Check for libopenraw
+# Check for libraw
 ######################
 
-AC_ARG_WITH(libopenraw, [  --without-libopenraw    build without openraw support])
+AC_ARG_WITH(libraw, [  --without-libraw    build without LibRaw support])
 
-have_libopenraw="no"
-if test "x$with_libopenraw" != "xno"; then
-  PKG_CHECK_MODULES(OPENRAW, libopenraw-1.0 >= openraw_required_version,
-    have_libopenraw="yes",
-    have_libopenraw="no  (openraw library not found)")
+have_libraw="no"
+if test "x$with_libraw" != "xno"; then
+  PKG_CHECK_MODULES(LIBRAW, libraw_r >= libraw_required_version,
+    have_libraw="yes",
+    have_libraw="no  (LibRaw library not found)")
 fi
 
-AM_CONDITIONAL(HAVE_OPENRAW, test "$have_libopenraw" = "yes")
+AM_CONDITIONAL(HAVE_LIBRAW, test "$have_libraw" = "yes")
 
 AC_SUBST(OPENRAW_CFLAGS) 
 AC_SUBST(OPENRAW_LIBS) 
@@ -1137,7 +1137,7 @@ Optional dependencies:
   OpenEXR:         $have_openexr
   rsvg:            $have_librsvg
   SDL:             $have_sdl
-  openraw:         $have_libopenraw
+  libraw:          $have_libraw
   Jasper:          $have_jasper
   graphviz:        $have_graphviz
   avformat:        $have_libavformat
diff --git a/operations/external/Makefile.am b/operations/external/Makefile.am
index 90419bf..670214f 100644
--- a/operations/external/Makefile.am
+++ b/operations/external/Makefile.am
@@ -74,11 +74,11 @@ display_la_LIBADD = $(op_libs) $(SDL_LIBS)
 display_la_CFLAGS = $(AM_CFLAGS) $(SDL_CFLAGS)
 endif
 
-if HAVE_OPENRAW
-ops += openraw.la
-openraw_la_SOURCES = openraw.c
-openraw_la_LIBADD = $(op_libs) $(OPENRAW_LIBS)
-openraw_la_CFLAGS = $(AM_CFLAGS) $(OPENRAW_CFLAGS)
+if HAVE_LIBRAW
+ops += libraw.la
+libraw_la_SOURCES = libraw.c
+libraw_la_LIBADD = $(op_libs) $(LIBRAW_LIBS)
+libraw_la_CFLAGS = $(AM_CFLAGS) $(LIBRAW_CFLAGS)
 endif
 
 if HAVE_V4L
diff --git a/operations/external/libraw.c b/operations/external/libraw.c
index 4ad1964..d2f7e29 100644
--- a/operations/external/libraw.c
+++ b/operations/external/libraw.c
@@ -15,6 +15,7 @@
  *
  * Copyright 2006 Øyvind Kolås <pippin@gimp.org>
  * Copyright 2008 Hubert Figuière <hub@figuiere.net>
+ * Copyright 2011 Chong Kai Xiong <w_velocity@yahoo.com>
  */
 
 #include "config.h"
@@ -39,23 +40,12 @@ typedef struct
   GeglOperationSourceClass parent_class;
 } GeglChantClass;
 
-#define GEGL_CHANT_C_FILE       "openraw.c"
+#define GEGL_CHANT_C_FILE       "libraw.c"
 #include "gegl-chant.h"
 GEGL_DEFINE_DYNAMIC_OPERATION(GEGL_TYPE_OPERATION_SOURCE)
 
 #include <stdio.h>
-#include <libopenraw/libopenraw.h>
-
-
-/* We can't release the pixel data itself, so we ignore the first argument
- * and release the libopenraw structure instead.
- */
-static void
-destroy_rawdata (void * pixels, void * rawdata)
-{
-  or_rawdata_release (rawdata);
-}
-
+#include <libraw.h>
 
 static void
 free_buffer (GeglOperation * operation)
@@ -77,7 +67,6 @@ free_buffer (GeglOperation * operation)
   }
 }
 
-
 /* Loads the RAW pixel data from the specified path in chant parameters into
  * a GeglBuffer for caching. Maintains copy of the path that has been cached
  * so we can check for modifications and recache.
@@ -88,8 +77,7 @@ load_buffer (GeglOperation *operation)
   GeglChantO *o    = GEGL_CHANT_PROPERTIES (operation);
   GeglChant  *self = GEGL_CHANT(operation);
 
-  ORRawDataRef rawdata;
-  ORRawFileRef rawfile;
+  libraw_data_t *rawdata;
 
   /* If the path has changed since last time, destroy our cache */
   if (!self->cached_path || strcmp (self->cached_path, o->path))
@@ -103,48 +91,70 @@ load_buffer (GeglOperation *operation)
     }
   g_assert (self->cached_path == NULL);
 
-  /* Gather the file and data resources needed for our cache */
-  rawfile = or_rawfile_new(o->path, OR_RAWFILE_TYPE_UNKNOWN);
-  if (!rawfile)
+  rawdata = libraw_init (0);
+
+  if (!rawdata)
     {
       return NULL;
     }
 
-  rawdata = or_rawdata_new();
-  if(or_rawfile_get_rawdata(rawfile, rawdata, OR_OPTIONS_NONE) != OR_ERROR_NONE)
+  /* Gather the file and data resources needed for our cache */
+
+  if (libraw_open_file(rawdata, o->path))
+    {
+      goto clean_data;
+    }
+
+  /* TODO: Handle 3-color Foveon and 4-color Sinar 4-shot */
+  if (rawdata->idata.is_foveon)
     {
-      goto clean_file;
+      goto clean_data;
     }
 
-  if(or_rawdata_format (rawdata) != OR_DATA_TYPE_CFA)
+  if (libraw_unpack (rawdata))
     {
-      goto clean_file;
+      goto clean_data;
     }
 
-  /* Build a gegl_buffer, backed with the libopenraw supplied data. */
+  /* Build a gegl_buffer, backed with the LibRaw supplied data. */
     {
       GeglRectangle extent = { 0, 0, 0, 0 };
       guint32 width, height;
-      void * data = or_rawdata_data(rawdata);
+      gint row, col, component;
+      guint16 *buffer;
+      gint offset;
+
+      width  = rawdata->sizes.iwidth;
+      height = rawdata->sizes.iheight;
 
-      or_rawdata_dimensions(rawdata, &width, &height);
       g_assert (height > 0 && width > 0);
       extent.width  = width;
       extent.height = height;
 
+      buffer = g_new (guint16, width * height);
+      offset = 0;
+
+      for (row = 0; row < height; row++)
+        for (col = 0; col < width; col++)
+          {
+            component = rawdata->idata.filters >> (((row << 1 & 14) + (col & 1)) << 1) & 3;
+            buffer[offset] = rawdata->image[offset][component];
+            offset++;
+          }
+
       g_assert (o->chant_data == NULL);
-      o->chant_data = gegl_buffer_linear_new_from_data(data,
-                                                       babl_format ("Y u16"),
-                                                       &extent,
-                                                       GEGL_AUTO_ROWSTRIDE,
-                                                       G_CALLBACK (destroy_rawdata),
-                                                       rawdata);
+      o->chant_data = gegl_buffer_linear_new_from_data (buffer,
+                                                        babl_format ("Y u16"),
+                                                        &extent,
+                                                        GEGL_AUTO_ROWSTRIDE,
+                                                        G_CALLBACK (g_free),
+                                                        NULL);
     }
 
   self->cached_path = g_strdup (o->path);
 
-clean_file:
-  or_rawfile_release(rawfile);
+clean_data:
+  libraw_close(rawdata);
 
   return o->chant_data;
 }
@@ -160,7 +170,7 @@ prepare (GeglOperation *operation)
 static GeglRectangle
 get_bounding_box (GeglOperation *operation)
 {
-  GeglChantO   *o = GEGL_CHANT_PROPERTIES (operation);
+  GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
   if (!load_buffer (operation))
     {
       GeglRectangle nullrect = { 0, 0, 0, 0 };
@@ -198,7 +208,7 @@ process (GeglOperation          *operation,
    * we continue to service metadata calls after giving the object to the
    * context.
    */
-  g_assert(o->chant_data);
+  g_assert (o->chant_data);
   gegl_operation_context_take_object (context, "output", G_OBJECT (o->chant_data));
   g_object_ref (G_OBJECT (o->chant_data));
 
@@ -236,7 +246,7 @@ gegl_chant_class_init (GeglChantClass *klass)
   operation_class->get_bounding_box = get_bounding_box;
   operation_class->get_cached_region = get_cached_region;
 
-  operation_class->name        = "gegl:openraw-load";
+  operation_class->name        = "gegl:libraw-load";
   operation_class->categories  = "hidden";
   operation_class->description = "Camera RAW image loader";
   operation_class->prepare     = prepare;
@@ -244,13 +254,13 @@ gegl_chant_class_init (GeglChantClass *klass)
   if (done)
     return;
 
-  /* query libopenraw instead. need a new API */
-  gegl_extension_handler_register (".cr2", "gegl:openraw-load");
-  gegl_extension_handler_register (".crw", "gegl:openraw-load");
-  gegl_extension_handler_register (".erf", "gegl:openraw-load");
-  gegl_extension_handler_register (".mrw", "gegl:openraw-load");
-  gegl_extension_handler_register (".nef", "gegl:openraw-load");
-  gegl_extension_handler_register (".dng", "gegl:openraw-load");
+  /* query LibRaw instead. need a new API */
+  gegl_extension_handler_register (".cr2", "gegl:libraw-load");
+  gegl_extension_handler_register (".crw", "gegl:libraw-load");
+  gegl_extension_handler_register (".erf", "gegl:libraw-load");
+  gegl_extension_handler_register (".mrw", "gegl:libraw-load");
+  gegl_extension_handler_register (".nef", "gegl:libraw-load");
+  gegl_extension_handler_register (".dng", "gegl:libraw-load");
 
   done = TRUE;
 }
