Author: post
Date: 2011-03-24 21:40:27 +0100 (Thu, 24 Mar 2011)
New Revision: 354

Modified:
   RawSpeed/DngDecoder.cpp
   RawSpeed/RawDecoder.cpp
Log:
Add Rawspeed support for float point DNGs.

Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp     2011-03-24 19:16:35 UTC (rev 353)
+++ RawSpeed/DngDecoder.cpp     2011-03-24 20:40:27 UTC (rev 354)
@@ -72,7 +72,19 @@
   }
 
   TiffIFD* raw = data[0];
-  mRaw = RawImage::create();
+  uint32 sample_format = 1;
+  uint32 bps = raw->getEntry(BITSPERSAMPLE)->getInt();
+
+  if (raw->hasEntry(SAMPLEFORMAT))
+    sample_format = raw->getEntry(SAMPLEFORMAT)->getInt();
+
+  if (sample_format == 1)
+    mRaw = RawImage::create(TYPE_USHORT16);
+  else if (sample_format == 3)
+    mRaw = RawImage::create(TYPE_FLOAT32);
+  else
+    ThrowRDE("DNG Decoder: Only 16 bit unsigned or float point data 
supported.");
+
   mRaw->isCFA = (raw->getEntry(PHOTOMETRICINTERPRETATION)->getShort() == 
32803);
 
   if (mRaw->isCFA)
@@ -80,6 +92,12 @@
   else
     _RPT0(0, "This is NOT a CFA image\n");
 
+  if (sample_format == 1 && bps > 16)
+    ThrowRDE("DNG Decoder: Integer precision larger than 16 bits currently not 
supported.");
+
+  if (sample_format == 3 && bps != 32)
+    ThrowRDE("DNG Decoder: Float point must be 32 bits per sample.");
+
   try {
     mRaw->dim.x = raw->getEntry(IMAGEWIDTH)->getInt();
     mRaw->dim.y = raw->getEntry(IMAGELENGTH)->getInt();
@@ -157,13 +175,6 @@
         uint32 yPerSlice = raw->getEntry(ROWSPERSTRIP)->getInt();
         uint32 width = raw->getEntry(IMAGEWIDTH)->getInt();
         uint32 height = raw->getEntry(IMAGELENGTH)->getInt();
-        uint32 bps = raw->getEntry(BITSPERSAMPLE)->getShort();
- 
-        if (raw->hasEntry(SAMPLEFORMAT)) {
-          uint32 sample_format = raw->getEntry(SAMPLEFORMAT)->getInt();
-          if (sample_format != 1)
-            ThrowRDE("DNG Decoder: Only 16 bit unsigned data supported.");
-        }
           
         if (TEcounts->count != TEoffsets->count) {
           ThrowRDE("DNG Decoder: Byte count number does not match strip size: 
count:%u, strips:%u ", TEcounts->count, TEoffsets->count);
@@ -221,6 +232,9 @@
         }
         mRaw->createData();
 
+        if (sample_format != 1)
+           ThrowRDE("DNG Decoder: Only 16 bit unsigned data supported for 
compressed data.");
+
         DngDecoderSlices slices(mFile, mRaw);
         if (raw->hasEntry(TILEOFFSETS)) {
           uint32 tilew = raw->getEntry(TILEWIDTH)->getInt();

Modified: RawSpeed/RawDecoder.cpp
===================================================================
--- RawSpeed/RawDecoder.cpp     2011-03-24 19:16:35 UTC (rev 353)
+++ RawSpeed/RawDecoder.cpp     2011-03-24 20:40:27 UTC (rev 354)
@@ -107,7 +107,7 @@
     else
       ThrowIOE("readUncompressedRaw: Not enough data to decode a single line. 
Image file truncated.");
   }
-  if (bitPerPixel > 16)
+  if (bitPerPixel > 16 && mRaw->getDataType() == TYPE_USHORT16)
     ThrowRDE("readUncompressedRaw: Unsupported bit depth");
 
   uint32 skipBits = inputPitch - w * bitPerPixel / 8;  // Skip per line
@@ -119,6 +119,15 @@
   uint32 y = offset.y;
   h = MIN(h + (uint32)offset.y, (uint32)mRaw->dim.y);
 
+  if (mRaw->getDataType() == TYPE_FLOAT32)
+  {
+    if (bitPerPixel != 32)
+      ThrowRDE("readUncompressedRaw: Only 32 bit float point supported");
+    BitBlt(&data[offset.x*sizeof(float)*cpp+y*outPitch], outPitch,
+        input.getData(), inputPitch, w*mRaw->getBpp(), h - y);
+    return;
+  }
+
   if (MSBOrder) {
     BitPumpMSB bits(&input);
     w *= cpp;


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to