Author: post
Date: 2011-03-19 18:19:50 +0100 (Sat, 19 Mar 2011)
New Revision: 345
Added:
RawSpeed/SrwDecoder.cpp
RawSpeed/SrwDecoder.h
Modified:
RawSpeed/RawSpeed.vcproj
RawSpeed/TiffParser.cpp
RawSpeed/TiffParser.h
Log:
Add Samsung SRW Decoder. (Must be included in makefiles!)
Modified: RawSpeed/RawSpeed.vcproj
===================================================================
--- RawSpeed/RawSpeed.vcproj 2011-03-19 17:18:45 UTC (rev 344)
+++ RawSpeed/RawSpeed.vcproj 2011-03-19 17:19:50 UTC (rev 345)
@@ -360,6 +360,10 @@
RelativePath=".\Rw2Decoder.cpp"
>
</File>
+ <File
+ RelativePath=".\SrwDecoder.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="CameraMetadata"
@@ -518,6 +522,10 @@
RelativePath=".\Rw2Decoder.h"
>
</File>
+ <File
+ RelativePath=".\SrwDecoder.h"
+ >
+ </File>
</Filter>
<Filter
Name="CameraMetadata"
Added: RawSpeed/SrwDecoder.cpp
===================================================================
--- RawSpeed/SrwDecoder.cpp (rev 0)
+++ RawSpeed/SrwDecoder.cpp 2011-03-19 17:19:50 UTC (rev 345)
@@ -0,0 +1,118 @@
+#include "StdAfx.h"
+#include "SrwDecoder.h"
+#include "TiffParserOlympus.h"
+#ifdef __unix__
+#include <stdlib.h>
+#endif
+/*
+ RawSpeed - RAW file decoder.
+
+ Copyright (C) 2009-2010 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
+*/
+
+namespace RawSpeed {
+
+SrwDecoder::SrwDecoder(TiffIFD *rootIFD, FileMap* file):
+ RawDecoder(file), mRootIFD(rootIFD) {
+}
+
+SrwDecoder::~SrwDecoder(void) {
+}
+
+RawImage SrwDecoder::decodeRaw() {
+ vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
+
+ if (data.empty())
+ ThrowRDE("Srw Decoder: No image data found");
+
+ TiffIFD* raw = data[0];
+
+ int compression = raw->getEntry(COMPRESSION)->getInt();
+ if (32769 != compression && 32770 != compression )
+ ThrowRDE("Srw Decoder: Unsupported compression");
+
+ if (32769 == compression)
+ {
+ this->decodeUncompressed(raw, false);
+ return mRaw;
+ }
+
+ if (32770 == compression)
+ {
+ this->decodeUncompressed(raw, true);
+ return mRaw;
+ }
+ ThrowRDE("Srw Decoder: Unsupported compression");
+ return mRaw;
+}
+
+void SrwDecoder::checkSupport(CameraMetaData *meta) {
+ vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+ if (data.empty())
+ ThrowRDE("Srw Support check: Model name found");
+ string make = data[0]->getEntry(MAKE)->getString();
+ string model = data[0]->getEntry(MODEL)->getString();
+ this->checkCameraSupported(meta, make, model, "");
+}
+
+void SrwDecoder::decodeMetaData(CameraMetaData *meta) {
+ mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
+ vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+
+ if (data.empty())
+ ThrowRDE("SRW Meta Decoder: Model name found");
+
+ string make = data[0]->getEntry(MAKE)->getString();
+ string model = data[0]->getEntry(MODEL)->getString();
+
+ data = mRootIFD->getIFDsWithTag(CFAPATTERN);
+ if (!this->checkCameraSupported(meta, make, model, "") && !data.empty() &&
data[0]->hasEntry(CFAREPEATPATTERNDIM)) {
+ const unsigned short* pDim =
data[0]->getEntry(CFAREPEATPATTERNDIM)->getShortArray();
+ iPoint2D cfaSize(pDim[1], pDim[0]);
+ if (cfaSize.x != 2 && cfaSize.y != 2)
+ ThrowRDE("SRW Decoder: Unsupported CFA pattern size");
+
+ const uchar8* cPat = data[0]->getEntry(CFAPATTERN)->getData();
+ if (cfaSize.area() != data[0]->getEntry(CFAPATTERN)->count)
+ ThrowRDE("SRW Decoder: CFA pattern dimension and pattern count does not
match: %d.");
+
+ for (int y = 0; y < cfaSize.y; y++) {
+ for (int x = 0; x < cfaSize.x; x++) {
+ uint32 c1 = cPat[x+y*cfaSize.x];
+ CFAColor c2;
+ switch (c1) {
+ case 0:
+ c2 = CFA_RED; break;
+ case 1:
+ c2 = CFA_GREEN; break;
+ case 2:
+ c2 = CFA_BLUE; break;
+ default:
+ c2 = CFA_UNKNOWN;
+ ThrowRDE("SRW Decoder: Unsupported CFA Color.");
+ }
+ mRaw->cfa.setColorAt(iPoint2D(x, y), c2);
+ }
+ }
+ printf("Camera CFA: %s\n", mRaw->cfa.asString().c_str());
+ }
+ setMetaData(meta, make, model, "");
+}
+
+} // namespace RawSpeed
Added: RawSpeed/SrwDecoder.h
===================================================================
--- RawSpeed/SrwDecoder.h (rev 0)
+++ RawSpeed/SrwDecoder.h 2011-03-19 17:19:50 UTC (rev 345)
@@ -0,0 +1,44 @@
+#pragma once
+#include "RawDecoder.h"
+#include "LJpegPlain.h"
+#include "TiffIFD.h"
+#include "BitPumpPlain.h"
+
+/*
+ RawSpeed - RAW file decoder.
+
+ Copyright (C) 2009-2010 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
+*/
+
+namespace RawSpeed {
+
+class SrwDecoder :
+ public RawDecoder
+{
+public:
+ SrwDecoder(TiffIFD *rootIFD, FileMap* file);
+ virtual ~SrwDecoder(void);
+ virtual RawImage decodeRaw();
+ virtual void decodeMetaData(CameraMetaData *meta);
+ virtual void checkSupport(CameraMetaData *meta);
+private:
+ TiffIFD *mRootIFD;
+};
+
+} // namespace RawSpeed
Modified: RawSpeed/TiffParser.cpp
===================================================================
--- RawSpeed/TiffParser.cpp 2011-03-19 17:18:45 UTC (rev 344)
+++ RawSpeed/TiffParser.cpp 2011-03-19 17:19:50 UTC (rev 345)
@@ -107,6 +107,7 @@
if (!potentials.empty()) { // We have make entry
for (vector<TiffIFD*>::iterator i = potentials.begin(); i !=
potentials.end(); ++i) {
string make = (*i)->getEntry(MAKE)->getString();
+ TrimSpaces(make);
if (!make.compare("Canon")) {
return new Cr2Decoder(mRootIFD, mInput);
}
@@ -116,24 +117,24 @@
if (!make.compare("NIKON")) {
return new NefDecoder(mRootIFD, mInput);
}
- if (!make.compare("OLYMPUS IMAGING CORP. ")) {
+ if (!make.compare("OLYMPUS IMAGING CORP.")) {
return new OrfDecoder(mRootIFD, mInput);
}
- if (!make.compare("SONY ")) {
- return new ArwDecoder(mRootIFD, mInput);
- }
if (!make.compare("SONY")) {
return new ArwDecoder(mRootIFD, mInput);
}
if (!make.compare("PENTAX Corporation ")) {
return new PefDecoder(mRootIFD, mInput);
}
- if (!make.compare("PENTAX ")) {
+ if (!make.compare("PENTAX")) {
return new PefDecoder(mRootIFD, mInput);
}
if (!make.compare("Panasonic")) {
return new Rw2Decoder(mRootIFD, mInput);
}
+ if (!make.compare("SAMSUNG")) {
+ return new SrwDecoder(mRootIFD, mInput);
+ }
}
}
throw TiffParserException("No decoder found. Sorry.");
Modified: RawSpeed/TiffParser.h
===================================================================
--- RawSpeed/TiffParser.h 2011-03-19 17:18:45 UTC (rev 344)
+++ RawSpeed/TiffParser.h 2011-03-19 17:19:50 UTC (rev 345)
@@ -33,6 +33,7 @@
#include "NefDecoder.h"
#include "OrfDecoder.h"
#include "Rw2Decoder.h"
+#include "SrwDecoder.h"
namespace RawSpeed {
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit