Author: post
Date: 2009-07-05 14:25:50 +0200 (Sun, 05 Jul 2009)
New Revision: 73
Modified:
RawSpeed/DngDecoder.cpp
RawSpeed/FileReader.cpp
RawSpeed/RawImage.cpp
RawSpeed/rawstudio-plugin-api.cpp
Log:
- Fixed rather big oops in crop - guess we have been using dcraw for some time
;)
- Implemented mmap read for testing.
- Made load timing optional by define.
- Fixed DNG crop resulting in invalid CFA filter.
Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp 2009-06-08 17:54:54 UTC (rev 72)
+++ RawSpeed/DngDecoder.cpp 2009-07-05 12:25:50 UTC (rev 73)
@@ -254,10 +254,6 @@
iPoint2D top_left(corners[1], corners[0]);
new_size = iPoint2D(corners[3]-corners[1], corners[2]-corners[0]);
mRaw->subFrame(top_left,new_size);
- if (top_left.x & 1)
- mRaw->cfa.shiftLeft();
- if (top_left.y & 1)
- mRaw->cfa.shiftDown();
}
#endif
// Linearization
Modified: RawSpeed/FileReader.cpp
===================================================================
--- RawSpeed/FileReader.cpp 2009-06-08 17:54:54 UTC (rev 72)
+++ RawSpeed/FileReader.cpp 2009-07-05 12:25:50 UTC (rev 73)
@@ -1,28 +1,29 @@
#include "StdAfx.h"
#include "FileReader.h"
-#ifdef __unix__
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#endif // __unix__
-/*
- 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
+#ifdef __unix__
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#endif // __unix__
+/*
+ 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
@@ -33,23 +34,31 @@
{
}
-FileMap* FileReader::readFile() {
+FileMap* FileReader::readFile() {
#ifdef __unix__
- struct stat st;
- int bytes_read = 0;
- int fd;
- char *dest;
-
- stat(mFilename, &st);
- FileMap *fileData = new FileMap(st.st_size);
-
- fd = open(mFilename, O_RDONLY);
-
- while(bytes_read < st.st_size) {
- dest = (char *) fileData->getDataWrt(bytes_read);
- bytes_read += read(fd, dest, st.st_size-bytes_read);
+ struct stat st;
+ int bytes_read = 0;
+ int fd;
+ char *dest;
+
+ stat(mFilename, &st);
+ fd = open(mFilename, O_RDONLY);
+#if 0
+ // Not used, as it is slower than sync read
+
+ guchar* pa = (guchar*)mmap(0, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE,
fd, 0);
+ FileMap *fileData = new FileMap(pa, st.st_size);
+
+#else
+ FileMap *fileData = new FileMap(st.st_size);
+
+ while(bytes_read < st.st_size) {
+ dest = (char *) fileData->getDataWrt(bytes_read);
+ bytes_read += read(fd, dest, st.st_size-bytes_read);
}
-#else // __unix__
+#endif
+
+#else // __unix__
HANDLE file_h; // File handle
file_h = CreateFile(mFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (file_h == INVALID_HANDLE_VALUE) {
@@ -67,8 +76,8 @@
delete fileData;
throw new FileIOException("Could not read file.");
}
- CloseHandle(file_h);
-
+ CloseHandle(file_h);
+
#endif // __unix__
return fileData;
}
Modified: RawSpeed/RawImage.cpp
===================================================================
--- RawSpeed/RawImage.cpp 2009-06-08 17:54:54 UTC (rev 72)
+++ RawSpeed/RawImage.cpp 2009-07-05 12:25:50 UTC (rev 73)
@@ -76,15 +76,17 @@
guchar* RawImageData::getData( guint x, guint y )
{
+ if ((int)x>=dim.x)
+ ThrowRDE("RawImageData::getData - X Position outside image requested.");
+ if ((int)y>=dim.y) {
+ ThrowRDE("RawImageData::getData - Y Position outside image requested.");
+ }
+
x+= mOffset.x;
y+= mOffset.y;
if (!data)
ThrowRDE("RawImageData::getData - Data not yet allocated.");
- if ((int)x>=dim.x)
- ThrowRDE("RawImageData::getData - X Position outside image requested.");
- if ((int)y>=dim.y)
- ThrowRDE("RawImageData::getData - Y Position outside image requested.");
return &data[y*pitch+x*bpp];
}
Modified: RawSpeed/rawstudio-plugin-api.cpp
===================================================================
--- RawSpeed/rawstudio-plugin-api.cpp 2009-06-08 17:54:54 UTC (rev 72)
+++ RawSpeed/rawstudio-plugin-api.cpp 2009-07-05 12:25:50 UTC (rev 73)
@@ -28,6 +28,8 @@
#include "CameraMetaData.h"
#include "rawstudio-plugin-api.h"
+//#define TIME_LOAD 1
+
extern "C" {
RS_IMAGE16 *
@@ -47,7 +49,17 @@
try
{
+#ifdef TIME_LOAD
+ GTimer *gt = g_timer_new();
+#endif
+
m = f.readFile();
+
+#ifdef TIME_LOAD
+ printf("Open %s: %.03fs\n", filename, g_timer_elapsed(gt,
NULL));
+ g_timer_destroy(gt);
+#endif
+
TiffParser t(m);
t.parseData();
d = t.getDecompressor();
@@ -57,11 +69,17 @@
gint col, row;
gint cpp;
- GTimer *gt = g_timer_new();
+#ifdef TIME_LOAD
+ gt = g_timer_new();
+#endif
+
d->decodeRaw();
d->decodeMetaData(c);
- printf("%s: %.03f\n", filename, g_timer_elapsed(gt,
NULL));
+
+#ifdef TIME_LOAD
+ printf("Decode %s: %.03fs\n", filename,
g_timer_elapsed(gt, NULL));
g_timer_destroy(gt);
+#endif
for (guint i = 0; i < d->errors.size(); i++)
printf("Error Encountered:%s\n", d->errors[i]);
@@ -82,11 +100,13 @@
if (r->isCFA)
image->filters = r->cfa.getDcrawFilter();
+
if (r->isCFA)
{
// printf("DCRAW
filter:%x\n",r->cfa.getDcrawFilter());
// printf("%s", r->cfa.asString().c_str());
}
+
if (cpp == 1)
{
BitBlt((guchar *)(GET_PIXEL(image,0,0)),image->pitch*2,
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit