Author: post
Date: 2009-08-09 14:18:38 +0200 (Sun, 09 Aug 2009)
New Revision: 101
Modified:
RawSpeed/Cr2Decoder.cpp
RawSpeed/DngDecoder.cpp
cameras.xml
Log:
- Use mode tags properly for sRaw and DNGs.
- Also use alternative crop tags for DNGs (Pentax mainly).
Modified: RawSpeed/Cr2Decoder.cpp
===================================================================
--- RawSpeed/Cr2Decoder.cpp 2009-08-06 17:37:50 UTC (rev 100)
+++ RawSpeed/Cr2Decoder.cpp 2009-08-09 12:18:38 UTC (rev 101)
@@ -134,14 +134,15 @@
string make = data[0]->getEntry(MAKE)->getString();
string model = data[0]->getEntry(MODEL)->getString();
+ string mode = "";
if (mRaw->subsampling.y == 2 && mRaw->subsampling.x == 2)
- model += "-sRaw1";
+ mode = "sRaw1";
if (mRaw->subsampling.y == 1 && mRaw->subsampling.x == 2)
- model += "-sRaw2";
+ mode = "sRaw2";
- setMetaData(meta, make, model,"");
+ setMetaData(meta, make, model, mode);
}
Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp 2009-08-06 17:37:50 UTC (rev 100)
+++ RawSpeed/DngDecoder.cpp 2009-08-09 12:18:38 UTC (rev 101)
@@ -268,11 +268,29 @@
iPoint2D new_size(mRaw->dim.x, mRaw->dim.y);
#ifndef PRINT_INFO
// Crop
+
if (raw->hasEntry(ACTIVEAREA)) {
const guint *corners = raw->getEntry(ACTIVEAREA)->getIntArray();
iPoint2D top_left(corners[1], corners[0]);
new_size = iPoint2D(corners[3]-corners[1], corners[2]-corners[0]);
mRaw->subFrame(top_left,new_size);
+
+ } else if (raw->hasEntry(DEFAULTCROPORIGIN)) {
+
+ iPoint2D top_left(0,0);
+
+ if (raw->getEntry(DEFAULTCROPORIGIN)->type == TIFF_LONG) {
+ const guint* tl = raw->getEntry(DEFAULTCROPORIGIN)->getIntArray();
+ const guint* sz = raw->getEntry(DEFAULTCROPSIZE)->getIntArray();
+ top_left = iPoint2D(tl[0], tl[1]);
+ new_size = iPoint2D(sz[0], sz[1]);
+ } else if (raw->getEntry(DEFAULTCROPORIGIN)->type == TIFF_SHORT) {
+ const gushort* tl = raw->getEntry(DEFAULTCROPORIGIN)->getShortArray();
+ const gushort* sz = raw->getEntry(DEFAULTCROPSIZE)->getShortArray();
+ top_left = iPoint2D(tl[0], tl[1]);
+ new_size = iPoint2D(sz[0], sz[1]);
+ }
+ mRaw->subFrame(top_left,new_size);
}
#endif
// Linearization
@@ -352,39 +370,81 @@
TrimSpaces(model);
TrimSpaces(make);
- data = mRootIFD->getIFDsWithTag(ACTIVEAREA);
+ data = mRootIFD->getIFDsWithTag(COMPRESSION);
+
if (data.empty())
- ThrowRDE("Model name found");
+ ThrowRDE("DNG Decoder: No image data found");
+
+ // Erase the ones not with JPEG compression
+ for (vector<TiffIFD*>::iterator i = data.begin(); i != data.end(); ) {
+ int compression = (*i)->getEntry(COMPRESSION)->getShort();
+ bool isSubsampled = false;
+ try {
+ isSubsampled = (*i)->getEntry(NEWSUBFILETYPE)->getInt()&1; // bit 0 is
on if image is subsampled
+ } catch (TiffParserException) {}
+ if ((compression != 7 && compression != 1) || isSubsampled) { // Erase if
subsampled, or not JPEG or uncompressed
+ i = data.erase(i);
+ } else {
+ i++;
+ }
+ }
+
+ if (data.empty())
+ ThrowRDE("RAW section not found");
+
raw = data[0];
-
ColorFilterArray cfa(mRaw->cfa);
- const guint *corners = raw->getEntry(ACTIVEAREA)->getIntArray();
- iPoint2D top_left(corners[1], corners[0]);
- iPoint2D new_size(corners[3]-corners[1], corners[2]-corners[0]);
+ // Crop
+ iPoint2D top_left(0,0);
+ iPoint2D new_size(mRaw->dim.x, mRaw->dim.y);
+
+ if (raw->hasEntry(ACTIVEAREA)) {
+ const guint *corners = raw->getEntry(ACTIVEAREA)->getIntArray();
+ top_left = iPoint2D(corners[1], corners[0]);
+ new_size = iPoint2D(corners[3]-corners[1], corners[2]-corners[0]);
+
+ } else if (raw->hasEntry(DEFAULTCROPORIGIN)) {
+
+ if (raw->getEntry(DEFAULTCROPORIGIN)->type == TIFF_LONG) {
+ const guint* tl = raw->getEntry(DEFAULTCROPORIGIN)->getIntArray();
+ const guint* sz = raw->getEntry(DEFAULTCROPSIZE)->getIntArray();
+ top_left = iPoint2D(tl[0], tl[1]);
+ new_size = iPoint2D(sz[0], sz[1]);
+ } else if (raw->getEntry(DEFAULTCROPORIGIN)->type == TIFF_SHORT) {
+ const gushort* tl = raw->getEntry(DEFAULTCROPORIGIN)->getShortArray();
+ const gushort* sz = raw->getEntry(DEFAULTCROPSIZE)->getShortArray();
+ top_left = iPoint2D(tl[0], tl[1]);
+ new_size = iPoint2D(sz[0], sz[1]);
+ }
+ }
+
if (top_left.x & 1)
cfa.shiftLeft();
if (top_left.y & 1)
cfa.shiftDown();
- const gushort *blackdim =
raw->getEntry(BLACKLEVELREPEATDIM)->getShortArray();
- int black = 65536;
- if (blackdim[0] != 0 && blackdim[1] != 0) {
- if (raw->hasEntry(BLACKLEVELDELTAV)) {
- const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray();
- int blackbase = blackarray[0] / blackarray[1];
- const gint *blackarrayv = (const
gint*)raw->getEntry(BLACKLEVELDELTAV)->getIntArray();
- for (int i = 0; i < new_size.y; i++)
- black = MIN(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]);
+ int black = -1;
+ if (raw->hasEntry(BLACKLEVELREPEATDIM)) {
+ const gushort *blackdim =
raw->getEntry(BLACKLEVELREPEATDIM)->getShortArray();
+ black = 65536;
+ if (blackdim[0] != 0 && blackdim[1] != 0) {
+ if (raw->hasEntry(BLACKLEVELDELTAV)) {
+ const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray();
+ int blackbase = blackarray[0] / blackarray[1];
+ const gint *blackarrayv = (const
gint*)raw->getEntry(BLACKLEVELDELTAV)->getIntArray();
+ for (int i = 0; i < new_size.y; i++)
+ black = MIN(black, blackbase + blackarrayv[i*2] /
blackarrayv[i*2+1]);
+ } else {
+ const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray();
+ if ( blackarray[1] )
+ black = blackarray[0] / blackarray[1];
+ else
+ black = 0;
+ }
} else {
- const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray();
- if ( blackarray[1] )
- black = blackarray[0] / blackarray[1];
- else
- black = 0;
+ black = 0;
}
- } else {
- black = 0;
}
cout << "<Camera make=\"" << make << "\" model = \"" << model << "\">" <<
endl;
Modified: cameras.xml
===================================================================
--- cameras.xml 2009-08-06 17:37:50 UTC (rev 100)
+++ cameras.xml 2009-08-09 12:18:38 UTC (rev 101)
@@ -63,7 +63,7 @@
<Crop x="64" y="52" width="4752" height="3158"/>
<Sensor black="900" white="16383"/>
</Camera>
- <Camera make="Canon" model="Canon EOS 50D-sRaw1">
+ <Camera make="Canon" model="Canon EOS 50D" mode="sRaw1">
<Crop x="0" y="0" width="3272" height="2178"/>
<Sensor black="0" white="16383"/>
</Camera>
@@ -107,11 +107,11 @@
<Crop x="158" y="51" width="5634" height="3753"/>
<Sensor black="1024" white="15600"/>
</Camera>
- <Camera make="Canon" model="Canon EOS 5D Mark II-sRaw1">
+ <Camera make="Canon" model="Canon EOS 5D Mark II" mode="sRaw1">
<Crop x="0" y="0" width="3872" height="2574"/>
<Sensor black="0" white="15600"/>
</Camera>
- <Camera make="Canon" model="Canon EOS 5D Mark II-sRaw2">
+ <Camera make="Canon" model="Canon EOS 5D Mark II" mode="sRaw2">
<Crop x="0" y="0" width="2808" height="1872"/>
<Sensor black="0" white="15600"/>
</Camera>
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit