[Rawstudio-commit] rawspeed r52 - RawSpeed
Klaus Post
klauspost at gmail.com
Sun Feb 1 14:21:19 CET 2009
Author: post
Date: 2009-02-01 14:21:19 +0100 (Sun, 01 Feb 2009)
New Revision: 52
Modified:
RawSpeed/ArwDecoder.cpp
RawSpeed/ColorFilterArray.cpp
RawSpeed/ColorFilterArray.h
RawSpeed/DngDecoder.cpp
RawSpeed/NefDecoder.cpp
RawSpeed/Point.h
Log:
- Added DNG CFA Layout read.
- Fixed Uncompressed DNG, with bits < 16
Modified: RawSpeed/ArwDecoder.cpp
===================================================================
--- RawSpeed/ArwDecoder.cpp 2009-02-01 12:51:52 UTC (rev 51)
+++ RawSpeed/ArwDecoder.cpp 2009-02-01 13:21:19 UTC (rev 52)
@@ -161,5 +161,13 @@
void ArwDecoder::decodeMetaData()
{
mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
+ vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+ if (data.empty())
+ ThrowRDE("CR2 Decoder: Model name found");
+
+ string model = data[0]->getEntry(MODEL)->getString();
+ if (!model.compare("DSLR-A700"))
+ mRaw->cfa.setCFA(CFA_GREEN2, CFA_BLUE, CFA_RED, CFA_GREEN);
+
}
\ No newline at end of file
Modified: RawSpeed/ColorFilterArray.cpp
===================================================================
--- RawSpeed/ColorFilterArray.cpp 2009-02-01 12:51:52 UTC (rev 51)
+++ RawSpeed/ColorFilterArray.cpp 2009-02-01 13:21:19 UTC (rev 52)
@@ -78,4 +78,12 @@
default:
return string("UNKNOWN");
}
+}
+
+void ColorFilterArray::setColorAt( iPoint2D pos, CFAColor c ) {
+ if (pos.x > 1 || pos.x < 0)
+ ThrowRDE("ColorFilterArray::SetColor: position out of CFA pattern");
+ if (pos.y > 1 || pos.y < 0)
+ ThrowRDE("ColorFilterArray::SetColor: position out of CFA pattern");
+ cfa[pos.x+pos.y*2] = c;
}
\ No newline at end of file
Modified: RawSpeed/ColorFilterArray.h
===================================================================
--- RawSpeed/ColorFilterArray.h 2009-02-01 12:51:52 UTC (rev 51)
+++ RawSpeed/ColorFilterArray.h 2009-02-01 13:21:19 UTC (rev 52)
@@ -29,6 +29,7 @@
ColorFilterArray(CFAColor up_left, CFAColor up_right, CFAColor down_left, CFAColor down_right);
virtual ~ColorFilterArray(void);
void setCFA(CFAColor up_left, CFAColor up_right, CFAColor down_left, CFAColor down_right);
+ void setColorAt(iPoint2D pos, CFAColor c);
void setCFA(guchar dcrawCode);
__inline CFAColor getColorAt(guint x, guint y) {return cfa[(x&1)+((y&1)<<1)];}
guint toDcrawColor(CFAColor c);
Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp 2009-02-01 12:51:52 UTC (rev 51)
+++ RawSpeed/DngDecoder.cpp 2009-02-01 13:21:19 UTC (rev 52)
@@ -81,7 +81,7 @@
try {
mRaw->dim.x = raw->getEntry(IMAGEWIDTH)->getInt();
mRaw->dim.y = raw->getEntry(IMAGELENGTH)->getInt();
- mRaw->bpp = raw->getEntry(BITSPERSAMPLE)->getShort()/8;
+ mRaw->bpp = 2;
} catch (TiffParserException) {
ThrowRDE("DNG Decoder: Could not read basic image information.");
}
@@ -89,23 +89,42 @@
try {
int compression = raw->getEntry(COMPRESSION)->getShort();
-/* if (mRaw->isCFA) {
+ if (mRaw->isCFA) {
+ if (raw->getEntry(CFALAYOUT)->getShort() != 1)
+ ThrowRDE("DNG Decoder: Unsupported CFA Layout.");
+
const unsigned short* pDim = raw->getEntry(CFAREPEATPATTERNDIM)->getShortArray(); // Get the size
const unsigned char* cPat = raw->getEntry(CFAPATTERN)->getData(); // Does NOT contain dimensions as some documents state
- const unsigned char* cPlaneOrder = raw->getEntry(CFAPLANECOLOR)->getData(); // Map from the order in the image, to the position in the CFA
+// const unsigned char* cPlaneOrder = raw->getEntry(CFAPLANECOLOR)->getData(); // Map from the order in the image, to the position in the CFA
- int patternSize = pDim[0]*pDim[1];
- if (patternSize != raw->getEntry(CFAPATTERN)->count)
+ iPoint2D cfaSize(pDim[1],pDim[0]);
+ if (pDim[0] != 2)
+ ThrowRDE("DNG Decoder: Unsupported CFA configuration.");
+ if (pDim[1] != 2)
+ ThrowRDE("DNG Decoder: Unsupported CFA configuration.");
+
+ if (cfaSize.area() != raw->getEntry(CFAPATTERN)->count)
ThrowRDE("DNG Decoder: CFA pattern dimension and pattern count does not match: %d.");
- iPoint2D cfaSize(pDim[1],pDim[0]);
- mRaw->cfa = ColorFilterArray(cfaSize);
+
for (int y = 0; y < cfaSize.y; y++) {
for (int x = 0; x < cfaSize.x; x++) {
- mRaw->cfa.setColorAt(iPoint2D(x,y),(CFAColor)cPat[x+y*cfaSize.x]);
+ guint 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;
+ }
+ mRaw->cfa.setColorAt(iPoint2D(x,y),c2);
}
}
}
-*/
+
// Now load the image
if (compression == 1) { // Uncompressed.
@@ -151,7 +170,7 @@
ByteStream in(mFile->getData(slice.offset),slice.count);
iPoint2D size(width,slice.h);
iPoint2D pos(0,slice.offsetY);
- readUncompressedRaw(in,size,pos,width*mRaw->bpp,bps,false);
+ readUncompressedRaw(in,size,pos,width*bps/8,bps,true);
}
} catch (TiffParserException) {
@@ -221,4 +240,5 @@
{
mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
-}
\ No newline at end of file
+}
+
Modified: RawSpeed/NefDecoder.cpp
===================================================================
--- RawSpeed/NefDecoder.cpp 2009-02-01 12:51:52 UTC (rev 51)
+++ RawSpeed/NefDecoder.cpp 2009-02-01 13:21:19 UTC (rev 52)
@@ -221,9 +221,7 @@
string model(data[0]->getEntry(MODEL)->getString());
- if (!model.compare("NIKON D100 ") ||
- !model.compare("NIKON D200") ||
- !model.compare("NIKON D2H") ||
+ if (!model.compare("NIKON D2H") ||
!model.compare("NIKON D40X") ||
!model.compare("NIKON D60") ||
!model.compare("NIKON D90") )
@@ -231,6 +229,12 @@
mRaw->cfa.setCFA(CFA_GREEN2, CFA_BLUE, CFA_RED, CFA_GREEN);
}
+ if (!model.compare("NIKON D100 ") ||
+ !model.compare("NIKON D200") )
+ {
+ mRaw->cfa.setCFA(CFA_GREEN2, CFA_RED, CFA_BLUE, CFA_GREEN);
+ }
+
if (!model.compare("NIKON D1 ") ||
!model.compare("NIKON D1H") ||
!model.compare("NIKON D40") ||
Modified: RawSpeed/Point.h
===================================================================
--- RawSpeed/Point.h 2009-02-01 12:51:52 UTC (rev 51)
+++ RawSpeed/Point.h 2009-02-01 13:21:19 UTC (rev 52)
@@ -26,9 +26,9 @@
class iPoint2D {
public:
iPoint2D() {x = y = 0; }
- iPoint2D( int a, int b) {
- x=a; y=b;}
- ~iPoint2D() {};
+ iPoint2D( int a, int b) {x=a; y=b;}
+ ~iPoint2D();
+ guint area() {return abs(x*y);}
int x,y;
};
More information about the Rawstudio-commit
mailing list