Author: post
Date: 2011-03-19 20:46:54 +0100 (Sat, 19 Mar 2011)
New Revision: 349

Modified:
   RawSpeed/DngDecoder.cpp
   RawSpeed/RawDecoder.cpp
   RawSpeed/RawDecoder.h
Log:
Add a setting to RawSpeed, you can set this if you do not want Rawspeed to 
attempt to decode images, where it does not have reliable information about 
CFA, cropping, black and white point. Not affecting DNG's.

Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp     2011-03-19 19:38:48 UTC (rev 348)
+++ RawSpeed/DngDecoder.cpp     2011-03-19 19:46:54 UTC (rev 349)
@@ -158,7 +158,13 @@
         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);
         }
@@ -369,6 +375,9 @@
   vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
   if (data.empty())
     ThrowRDE("DNG Support check: Model name found");
+
+  // We set this, since DNG's are not explicitly added. 
+  failOnUnknown = FALSE;
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
   this->checkCameraSupported(meta, make, model, "dng");

Modified: RawSpeed/RawDecoder.cpp
===================================================================
--- RawSpeed/RawDecoder.cpp     2011-03-19 19:38:48 UTC (rev 348)
+++ RawSpeed/RawDecoder.cpp     2011-03-19 19:46:54 UTC (rev 349)
@@ -26,6 +26,7 @@
 
        RawDecoder::RawDecoder(FileMap* file) : mRaw(RawImage::create()), 
mFile(file) {
   decoderVersion = 0;
+  failOnUnknown = FALSE;
 }
 
 RawDecoder::~RawDecoder(void) {
@@ -186,6 +187,9 @@
     if (mode.length() == 0)
       printf("Unable to find camera in database: %s %s %s\n", make.c_str(), 
model.c_str(), mode.c_str());
 
+     if (failOnUnknown)
+       ThrowRDE("Camera not supported, and not allowed to guess. Sorry.");
+
     // Assume the camera can be decoded, but return false, so decoders can see 
that we are unsure.
     return false;    
   }

Modified: RawSpeed/RawDecoder.h
===================================================================
--- RawSpeed/RawDecoder.h       2011-03-19 19:38:48 UTC (rev 348)
+++ RawSpeed/RawDecoder.h       2011-03-19 19:46:54 UTC (rev 349)
@@ -84,6 +84,13 @@
   /* Remember this is automatically refcounted, so a reference is retained 
until this class is destroyed */
   RawImage mRaw; 
 
+  /* You can set this if you do not want Rawspeed to attempt to decode images, 
*/
+  /* where it does not have reliable information about CFA, cropping, black 
and white point */
+  /* It is pretty safe to leave this disabled (default behaviour), but if you 
do not want to */
+  /* support unknown cameras, you can enable this */
+  /* DNGs are always attempted to be decoded, so this variable has no effect 
on DNGs */
+  bool failOnUnknown;
+
   /* Vector containing silent errors that occurred doing decoding, that may 
have lead to */
   /* an incomplete image. */
   vector<const char*> errors;
@@ -135,13 +142,13 @@
    map<string,string> hints;
 };
 
-class RawSlice {
-public:
-  RawSlice() { h = offset = count = 0;};
-  ~RawSlice() {};
-  uint32 h;
-  uint32 offset;
-  uint32 count;
+class RawSlice {
+public:
+  RawSlice() { h = offset = count = 0;};
+  ~RawSlice() {};
+  uint32 h;
+  uint32 offset;
+  uint32 count;
 };
 
 } // namespace RawSpeed


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

Reply via email to