[Rawstudio-commit] r3164 - in trunk: . plugins plugins/load-rawspeed

Klaus Post klauspost at gmail.com
Sat Feb 6 16:35:59 CET 2010


Author: post
Date: 2010-02-06 16:35:58 +0100 (Sat, 06 Feb 2010)
New Revision: 3164

Added:
   trunk/plugins/load-rawspeed/Makefile.am
   trunk/plugins/load-rawspeed/rawstudio-plugin-api.cpp
   trunk/plugins/load-rawspeed/rawstudio-plugin-api.h
   trunk/plugins/load-rawspeed/rawstudio-plugin.c
Modified:
   trunk/configure.in
   trunk/plugins/Makefile.am
Log:
Add RawSpeed plugin and makefiles

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2010-02-06 14:49:44 UTC (rev 3163)
+++ trunk/configure.in	2010-02-06 15:35:58 UTC (rev 3164)
@@ -124,6 +124,7 @@
 plugins/lensfun/Makefile
 plugins/load-dcraw/Makefile
 plugins/load-gdk/Makefile
+plugins/load-rawspeed/Makefile
 plugins/meta-ciff/Makefile
 plugins/meta-mrw/Makefile
 plugins/meta-raf/Makefile

Modified: trunk/plugins/Makefile.am
===================================================================
--- trunk/plugins/Makefile.am	2010-02-06 14:49:44 UTC (rev 3163)
+++ trunk/plugins/Makefile.am	2010-02-06 15:35:58 UTC (rev 3164)
@@ -15,6 +15,7 @@
 	lensfun \
 	load-dcraw \
 	load-gdk \
+	load-rawspeed \
 	meta-ciff \
 	meta-mrw \
 	meta-raf \

Added: trunk/plugins/load-rawspeed/Makefile.am
===================================================================
--- trunk/plugins/load-rawspeed/Makefile.am	                        (rev 0)
+++ trunk/plugins/load-rawspeed/Makefile.am	2010-02-06 15:35:58 UTC (rev 3164)
@@ -0,0 +1,66 @@
+plugindir = $(libdir)/rawstudio/plugins
+
+AM_CFLAGS =\
+	-Wall\
+	-O3
+
+AM_CXXFLAGS = $(AM_CFLAGS)
+
+INCLUDES = \
+	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+	@PACKAGE_CFLAGS@ \
+	-I$(top_srcdir)/librawstudio/ \
+	-I$(top_srcdir)/ \
+	-I$(top_srcdir)/plugins/load-rawspeed/rawspeed/
+ 
+lib_LTLIBRARIES = load_rawspeed.la
+
+libdir = $(datadir)/rawstudio/plugins/
+
+load_rawspeed_la_LIBADD = @PACKAGE_LIBS@
+load_rawspeed_la_LDFLAGS = -module -avoid-version
+load_rawspeed_la_SOURCES =  rawstudio-plugin-api.cpp \
+	rawstudio-plugin.c \
+	rawspeed/ArwDecoder.cpp \
+	rawspeed/BitPumpJPEG.cpp \
+	rawspeed/BitPumpMSB.cpp \
+	rawspeed/BitPumpPlain.cpp \
+	rawspeed/BlackArea.cpp \
+	rawspeed/ByteStream.cpp \
+	rawspeed/Camera.cpp \
+	rawspeed/CameraMetaData.cpp \
+	rawspeed/CameraMetadataException.cpp \
+	rawspeed/ColorFilterArray.cpp \
+	rawspeed/Common.cpp \
+	rawspeed/Cr2Decoder.cpp \
+	rawspeed/DngDecoder.cpp \
+	rawspeed/DngDecoderSlices.cpp \
+	rawspeed/FileIOException.cpp \
+	rawspeed/FileMap.cpp \
+	rawspeed/FileReader.cpp \
+	rawspeed/IOException.cpp \
+	rawspeed/LJpegDecompressor.cpp \
+	rawspeed/LJpegPlain.cpp \
+	rawspeed/NefDecoder.cpp \
+	rawspeed/NikonDecompressor.cpp \
+	rawspeed/OrfDecoder.cpp \
+	rawspeed/PefDecoder.cpp \
+	rawspeed/PentaxDecompressor.cpp \
+	rawspeed/RawDecoder.cpp \
+	rawspeed/RawDecoderException.cpp \
+	rawspeed/RawImage.cpp \
+	rawspeed/Rw2Decoder.cpp \
+	rawspeed/StdAfx.cpp \
+	rawspeed/TiffEntryBE.cpp \
+	rawspeed/TiffEntry.cpp \
+	rawspeed/TiffIFDBE.cpp \
+	rawspeed/TiffIFD.cpp \
+	rawspeed/TiffParser.cpp \
+	rawspeed/TiffParserException.cpp \
+	rawspeed/TiffParserHeaderless.cpp \
+	rawspeed/TiffParserOlympus.cpp
+
+rawspeeddir = $(datadir)/rawspeed
+rawspeed_DATA = data/cameras.xml
+EXTRA_DIST = $(rawspeed_DATA)
\ No newline at end of file

Added: trunk/plugins/load-rawspeed/rawstudio-plugin-api.cpp
===================================================================
--- trunk/plugins/load-rawspeed/rawstudio-plugin-api.cpp	                        (rev 0)
+++ trunk/plugins/load-rawspeed/rawstudio-plugin-api.cpp	2010-02-06 15:35:58 UTC (rev 3164)
@@ -0,0 +1,156 @@
+#include <rawstudio.h>
+#include "StdAfx.h"
+#include "FileReader.h"
+#include "TiffParser.h"
+#include "RawDecoder.h"
+#include "CameraMetaData.h"
+#include "rawstudio-plugin-api.h"
+/* 
+    RawSpeed - RAW file decoder.
+
+    Copyright (C) 2009 Klaus Post
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+    http://www.klauspost.com
+*/
+
+#define TIME_LOAD 1
+
+using namespace RawSpeed;
+
+extern "C" {
+
+RS_IMAGE16 *
+load_rawspeed(const gchar *filename)
+{
+	static CameraMetaData *c = NULL;
+	if (!c)
+	{
+		gchar *path = g_build_filename(PACKAGE_DATA_DIR, "rawspeed/cameras.xml", NULL);
+    try {
+		c = new CameraMetaData(path);
+    } catch (CameraMetadataException e) {
+		printf("RawSpeed: Could not open camera metadata information.\n%s\nRawSpeed will not be used!\n", e.what());
+		return NULL;
+	}
+		g_free(path);
+	}
+
+	RS_IMAGE16 *image = NULL;
+	FileReader f((char *) filename);
+	RawDecoder *d = 0;
+	FileMap* m = 0;
+
+	try
+	{
+#ifdef TIME_LOAD
+		GTimer *gt = g_timer_new();
+#endif
+
+		try
+		{
+			rs_io_lock();
+			m = f.readFile();
+			rs_io_unlock();
+		} catch (FileIOException e) {
+			printf("RawSpeed: IO Error occured:%s\n", e.what());
+			g_timer_destroy(gt);
+			return image;
+		}
+
+#ifdef TIME_LOAD
+		printf("RawSpeed Open %s: %.03fs\n", filename, g_timer_elapsed(gt, NULL));
+		g_timer_destroy(gt);
+#endif
+
+		TiffParser t(m);
+		t.parseData();
+		d = t.getDecoder();
+
+		try
+		{
+			gint col, row;
+			gint cpp;
+
+#ifdef TIME_LOAD
+			gt = g_timer_new();
+#endif
+      d->checkSupport(c);
+			d->decodeRaw();
+			d->decodeMetaData(c);
+
+			for (guint i = 0; i < d->errors.size(); i++)
+				printf("RawSpeed: Error Encountered:%s\n", d->errors[i]);
+
+			RawImage r = d->mRaw;
+      r->scaleBlackWhite();
+
+#ifdef TIME_LOAD
+	  printf("RawSpeed Decode %s: %.03fs\n", filename, g_timer_elapsed(gt, NULL));
+      g_timer_destroy(gt);
+#endif
+
+			cpp = r->getCpp();
+			if (cpp == 1) 
+				image = rs_image16_new(r->dim.x, r->dim.y, cpp, cpp);
+			else if (cpp == 3) 
+				image = rs_image16_new(r->dim.x, r->dim.y, 3, 4);
+			else {
+				printf("RawSpeed: Unsupported component per pixel count\n");
+				return NULL;
+			}
+
+			if (r->isCFA)
+				image->filters = r->cfa.getDcrawFilter();
+
+
+      if (cpp == 1) 
+      {
+        BitBlt((guchar *)(GET_PIXEL(image,0,0)),image->pitch*2,
+          r->getData(0,0), r->pitch, r->bpp*r->dim.x, r->dim.y);
+      } else 
+      {
+        for(row=0;row<image->h;row++)
+        {
+          gushort *inpixel = (gushort*)&r->getData()[row*r->pitch];
+          gushort *outpixel = GET_PIXEL(image, 0, row);
+          for(col=0;col<image->w;col++)
+          {
+            *outpixel++ =  *inpixel++;
+            *outpixel++ =  *inpixel++;
+            *outpixel++ =  *inpixel++;
+            outpixel++;
+          }
+        }
+      }
+		}
+		catch (RawDecoderException e)
+		{
+			printf("RawSpeed: RawDecoderException: %s\n", e.what());
+		}
+	}
+	catch (TiffParserException e)
+	{
+		printf("RawSpeed: TiffParserException: %s\n", e.what());
+	}
+
+	if (d) delete d;
+	if (m) delete m;
+
+	return image;
+}
+
+} /* extern "C" */

Added: trunk/plugins/load-rawspeed/rawstudio-plugin-api.h
===================================================================
--- trunk/plugins/load-rawspeed/rawstudio-plugin-api.h	                        (rev 0)
+++ trunk/plugins/load-rawspeed/rawstudio-plugin-api.h	2010-02-06 15:35:58 UTC (rev 3164)
@@ -0,0 +1,30 @@
+#include <rawstudio.h>
+/* 
+    RawSpeed - RAW file decoder.
+
+    Copyright (C) 2009 Klaus Post
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+    http://www.klauspost.com
+*/
+
+G_BEGIN_DECLS
+
+RS_IMAGE16 *
+load_rawspeed(const gchar *filename);
+
+G_END_DECLS
+

Added: trunk/plugins/load-rawspeed/rawstudio-plugin.c
===================================================================
--- trunk/plugins/load-rawspeed/rawstudio-plugin.c	                        (rev 0)
+++ trunk/plugins/load-rawspeed/rawstudio-plugin.c	2010-02-06 15:35:58 UTC (rev 3164)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2006-2009 Anders Brander <anders at brander.dk> and
+ * Anders Kvist <akv at lnxbx.dk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include <rawstudio.h>
+#include "rawstudio-plugin-api.h"
+
+G_MODULE_EXPORT void
+rs_plugin_load(RSPlugin *plugin)
+{
+	rs_filetype_register_loader(".arw", "Sony", load_rawspeed, 5);
+	rs_filetype_register_loader(".cr2", "Canon CR2", load_rawspeed, 5);
+	rs_filetype_register_loader(".dng", "Adobe Digital Negative", load_rawspeed, 5);
+	rs_filetype_register_loader(".nef", "Nikon NEF", load_rawspeed, 5);
+	rs_filetype_register_loader(".orf", "Olympus", load_rawspeed, 5);
+	rs_filetype_register_loader(".pef", "Pentax raw", load_rawspeed, 5);
+	rs_filetype_register_loader(".rw2", "Panasonic raw", load_rawspeed, 5);
+}




More information about the Rawstudio-commit mailing list