Author: post
Date: 2009-07-05 17:28:03 +0200 (Sun, 05 Jul 2009)
New Revision: 74

Modified:
   RawSpeed/ArwDecoder.cpp
   RawSpeed/ArwDecoder.h
   RawSpeed/Camera.cpp
   RawSpeed/Camera.h
   RawSpeed/CameraMetaData.cpp
   RawSpeed/CameraMetaData.h
   RawSpeed/Cr2Decoder.cpp
   RawSpeed/Cr2Decoder.h
   RawSpeed/DngDecoder.cpp
   RawSpeed/DngDecoder.h
   RawSpeed/NefDecoder.cpp
   RawSpeed/NefDecoder.h
   RawSpeed/OrfDecoder.cpp
   RawSpeed/OrfDecoder.h
   RawSpeed/PefDecoder.cpp
   RawSpeed/PefDecoder.h
   RawSpeed/RawDecoder.cpp
   RawSpeed/RawDecoder.h
   RawSpeed/Rw2Decoder.cpp
   RawSpeed/Rw2Decoder.h
   RawSpeed/StdAfx.h
   RawSpeed/compile-rawstudio.sh
   RawSpeed/rawstudio-plugin-api.cpp
   cameras.xml
Log:
- Added "supported" tag to camera XML, to make it possible to disable defective 
cameras easily.
- Added "mode" tag to camera XML, to enable settings for different modes (sRAW, 
compressed, uncompressed, etc)
- Updated camera support.
- Fixed division by zero on some DNGs (must be investigated further).
- Updated various line endings (big thanks to my editors for "fixing" that).

Modified: RawSpeed/ArwDecoder.cpp
===================================================================
--- RawSpeed/ArwDecoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/ArwDecoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -37,14 +37,6 @@
 {
   vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 
-  // TODO: Add support for these models.
-  if (!data[0]->getEntry(MODEL)->getString().compare("DSLR-A900")) {
-    ThrowRDE("ARW Decoder: Model not supported");
-  }
-  if (!data[0]->getEntry(MODEL)->getString().compare("DSLR-A700")) {
-    ThrowRDE("ARW Decoder: Model not supported");
-  }
-
   data = mRootIFD->getIFDsWithTag(STRIPOFFSETS);
 
   if (data.empty())
@@ -170,6 +162,15 @@
   ThrowRDE("Unsupported bit depth");
 }
 
+void ArwDecoder::checkSupport(CameraMetaData *meta) {
+  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("ARW 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 ArwDecoder::decodeMetaData(CameraMetaData *meta)
 {
   //Default
@@ -182,5 +183,5 @@
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
 
-  setMetaData(meta, make, model);
+  setMetaData(meta, make, model, "");
 }
\ No newline at end of file

Modified: RawSpeed/ArwDecoder.h
===================================================================
--- RawSpeed/ArwDecoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/ArwDecoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,27 +15,28 @@
 
     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
-*/
-#pragma once
-#include "RawDecoder.h"
-#include "LJpegPlain.h"
-#include "TiffIFD.h"
-#include "BitPumpPlain.h"
-
-class ArwDecoder :
-  public RawDecoder
-{
-public:
-  ArwDecoder(TiffIFD *rootIFD, FileMap* file);
-  virtual ~ArwDecoder(void);
-  virtual RawImage decodeRaw();
-  virtual void decodeMetaData(CameraMetaData *meta);
-protected:
-  void DecodeARW(ByteStream &input, guint w, guint h);
-  void DecodeARW2(ByteStream &input, guint w, guint h, guint bpp);
-  TiffIFD *mRootIFD;
-  guint curve[0x4001];
-};
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+#include "RawDecoder.h"
+#include "LJpegPlain.h"
+#include "TiffIFD.h"
+#include "BitPumpPlain.h"
+
+class ArwDecoder :
+  public RawDecoder
+{
+public:
+  ArwDecoder(TiffIFD *rootIFD, FileMap* file);
+  virtual ~ArwDecoder(void);
+  virtual RawImage decodeRaw();
+  virtual void checkSupport(CameraMetaData *meta);
+  virtual void decodeMetaData(CameraMetaData *meta);
+protected:
+  void DecodeARW(ByteStream &input, guint w, guint h);
+  void DecodeARW2(ByteStream &input, guint w, guint h, guint bpp);
+  TiffIFD *mRootIFD;
+  guint curve[0x4001];
+};

Modified: RawSpeed/Camera.cpp
===================================================================
--- RawSpeed/Camera.cpp 2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/Camera.cpp 2009-07-05 15:28:03 UTC (rev 74)
@@ -1,5 +1,6 @@
 #include "StdAfx.h"
 #include "Camera.h"
+#include <iostream>
 
 Camera::Camera(xmlDocPtr doc, xmlNodePtr cur) {
   xmlChar *key;
@@ -15,6 +16,23 @@
   model = string((const char*)key);
   xmlFree(key);
 
+  supported = true;
+  key = xmlGetProp(cur,(const xmlChar *)"supported");
+  if (key) {
+    string s = string((const char*)key);
+    if (s.compare("no") == 0)
+      supported = false;
+    xmlFree(key);
+  }
+
+  key = xmlGetProp(cur,(const xmlChar *)"mode");
+  if (key) {
+    mode = string((const char*)key);
+    xmlFree(key);
+  } else {
+    mode = string("");
+  }
+
   cur = cur->xmlChildrenNode;
   while (cur != NULL) {
     parseCameraChild(doc, cur);

Modified: RawSpeed/Camera.h
===================================================================
--- RawSpeed/Camera.h   2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/Camera.h   2009-07-05 15:28:03 UTC (rev 74)
@@ -12,9 +12,11 @@
   virtual ~Camera(void);
   string make;
   string model;
+  string mode;
   ColorFilterArray cfa;
   guint black;
   guint white;
+  gboolean supported;
   iPoint2D cropSize;
   iPoint2D cropPos;
   vector<BlackArea> blackAreas;

Modified: RawSpeed/CameraMetaData.cpp
===================================================================
--- RawSpeed/CameraMetaData.cpp 2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/CameraMetaData.cpp 2009-07-05 15:28:03 UTC (rev 74)
@@ -1,6 +1,5 @@
 #include "StdAfx.h"
 #include "CameraMetaData.h"
-#include <iostream>
 
 CameraMetaData::CameraMetaData(char *docname)
 {
@@ -30,7 +29,7 @@
   while (cur != NULL) {
     if ((!xmlStrcmp(cur->name, (const xmlChar *)"Camera"))){
       Camera *camera = new Camera(doc, cur);
-      string id = string(camera->make).append(camera->model);
+      string id = 
string(camera->make).append(camera->model).append(camera->mode);
       if (cameras.end() !=cameras.find(id))
         printf("CameraMetaData: Duplicate entry found for camera: %s %s, 
Skipping!\n",camera->make.c_str(), camera->model.c_str());
       else 
@@ -84,9 +83,9 @@
   cout << "</Camera>" <<endl;
 }
 
-Camera* CameraMetaData::getCamera( string make, string model )
+Camera* CameraMetaData::getCamera( string make, string model, string mode )
 {
-  string id = string(make).append(model);
+  string id = string(make).append(model).append(mode);
   if (cameras.end() ==cameras.find(id))
     return NULL;
   return cameras[id];

Modified: RawSpeed/CameraMetaData.h
===================================================================
--- RawSpeed/CameraMetaData.h   2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/CameraMetaData.h   2009-07-05 15:28:03 UTC (rev 74)
@@ -13,7 +13,7 @@
   xmlParserCtxtPtr ctxt; /* the parser context */
   map<string,Camera*> cameras;
   void dumpXML();
-  Camera* getCamera(string make, string model);
+  Camera* getCamera(string make, string model, string mode);
 protected:
   void dumpCameraXML(Camera* cam);
 };

Modified: RawSpeed/Cr2Decoder.cpp
===================================================================
--- RawSpeed/Cr2Decoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/Cr2Decoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -110,6 +110,15 @@
   return mRaw;
 }
 
+void Cr2Decoder::checkSupport(CameraMetaData *meta) {
+  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("CR2 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 Cr2Decoder::decodeMetaData(CameraMetaData *meta) {
   mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
   vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
@@ -120,6 +129,5 @@
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
 
-  setMetaData(meta, make, model);
-
+  setMetaData(meta, make, model,"");
 }
\ No newline at end of file

Modified: RawSpeed/Cr2Decoder.h
===================================================================
--- RawSpeed/Cr2Decoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/Cr2Decoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,33 +15,34 @@
 
     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
-*/
-#pragma once
-#include "RawDecoder.h"
-#include "LJpegPlain.h"
-#include "TiffIFD.h"
-
-class Cr2Decoder :
-  public RawDecoder
-{
-public:
-  Cr2Decoder(TiffIFD *rootIFD, FileMap* file);
-  virtual RawImage decodeRaw();
-  virtual void decodeMetaData(CameraMetaData *meta);
-  virtual ~Cr2Decoder(void);
-protected:
-  TiffIFD *mRootIFD;
-};
-
-class Cr2Slice {
-public:
-  Cr2Slice() { w = h = offset = count = 0;};
-  ~Cr2Slice() {};
-  guint w;
-  guint h;
-  guint offset;
-  guint count;
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+#include "RawDecoder.h"
+#include "LJpegPlain.h"
+#include "TiffIFD.h"
+
+class Cr2Decoder :
+  public RawDecoder
+{
+public:
+  Cr2Decoder(TiffIFD *rootIFD, FileMap* file);
+  virtual RawImage decodeRaw();
+  virtual void checkSupport(CameraMetaData *meta);
+  virtual void decodeMetaData(CameraMetaData *meta);
+  virtual ~Cr2Decoder(void);
+protected:
+  TiffIFD *mRootIFD;
+};
+
+class Cr2Slice {
+public:
+  Cr2Slice() { w = h = offset = count = 0;};
+  ~Cr2Slice() {};
+  guint w;
+  guint h;
+  guint offset;
+  guint count;
 };
\ No newline at end of file

Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/DngDecoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -33,7 +33,7 @@
 
   if (v[0] != 1)
     ThrowRDE("Not a supported DNG image format: 
v%u.%u.%u.%u",(int)v[0],(int)v[1],(int)v[2],(int)v[3]);
-  if (v[1] > 2)
+  if (v[1] > 3)
     ThrowRDE("Not a supported DNG image format: 
v%u.%u.%u.%u",(int)v[0],(int)v[1],(int)v[2],(int)v[3]);
 
   if ((v[0] <= 1) && (v[1] < 1) ) // Prior to v1.1.xxx  fix LJPEG encoding bug
@@ -132,6 +132,7 @@
               c2 = CFA_BLUE; break;
             default:
               c2 = CFA_UNKNOWN;
+              ThrowRDE("DNG Decoder: Unsupported CFA Color.");
           }
           mRaw->cfa.setColorAt(iPoint2D(x,y),c2);
         }
@@ -289,7 +290,10 @@
         black = MIN(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]);
     } else {
       const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray();
-      black = blackarray[0] / blackarray[1];
+      if (blackarray[1])
+        black = blackarray[0] / blackarray[1];
+      else 
+        black = 0;
     }
   } else {
     black = 0;
@@ -306,6 +310,15 @@
 #endif
 }
 
+void DngDecoder::checkSupport(CameraMetaData *meta) {
+  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("DNG Support check: Model name found");
+  string make = data[0]->getEntry(MAKE)->getString();
+  string model = data[0]->getEntry(MODEL)->getString();
+  this->checkCameraSupported(meta, make, model, "dng");
+}
+
 void DngDecoder::printMetaData()
 {  
   vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
@@ -344,7 +357,10 @@
         black = MIN(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]);
     } else {
       const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray();
-      black = blackarray[0] / blackarray[1];
+      if ( blackarray[1] )
+        black = blackarray[0] / blackarray[1];
+      else 
+        black = 0;
     }
   } else {
     black = 0;

Modified: RawSpeed/DngDecoder.h
===================================================================
--- RawSpeed/DngDecoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/DngDecoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,37 +15,38 @@
 
     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
-*/
-#pragma once
-#include "LJpegPlain.h"
-#include "TiffIFD.h"
-#include "DngDecoderSlices.h"
-
-
-
-class DngDecoder : 
-  public RawDecoder
-{
-public:
-  DngDecoder(TiffIFD *rootIFD, FileMap* file);
-  virtual ~DngDecoder(void);
-  virtual RawImage decodeRaw();
-  virtual void decodeMetaData(CameraMetaData *meta);
-protected:
-  TiffIFD *mRootIFD;
-  gboolean mFixLjpeg;
-  void printMetaData();
-};
-
-class DngStrip {
-public:
-  DngStrip() { h = offset = count = offsetY = 0;};
-  ~DngStrip() {};
-  guint h;
-  guint offset; // Offset in bytes
-  guint count;
-  guint offsetY;
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+#include "LJpegPlain.h"
+#include "TiffIFD.h"
+#include "DngDecoderSlices.h"
+
+
+
+class DngDecoder : 
+  public RawDecoder
+{
+public:
+  DngDecoder(TiffIFD *rootIFD, FileMap* file);
+  virtual ~DngDecoder(void);
+  virtual RawImage decodeRaw();
+  virtual void decodeMetaData(CameraMetaData *meta);
+  virtual void checkSupport(CameraMetaData *meta);
+protected:
+  TiffIFD *mRootIFD;
+  gboolean mFixLjpeg;
+  void printMetaData();
 };
+
+class DngStrip {
+public:
+  DngStrip() { h = offset = count = offsetY = 0;};
+  ~DngStrip() {};
+  guint h;
+  guint offset; // Offset in bytes
+  guint count;
+  guint offsetY;
+};

Modified: RawSpeed/NefDecoder.cpp
===================================================================
--- RawSpeed/NefDecoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/NefDecoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -211,6 +211,15 @@
   }*/
 }
 
+void NefDecoder::checkSupport(CameraMetaData *meta) {
+  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("NEF 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 NefDecoder::decodeMetaData(CameraMetaData *meta)
 {
   mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
@@ -218,12 +227,12 @@
   vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 
   if (data.empty())
-    ThrowRDE("ARW Meta Decoder: Model name found");
+    ThrowRDE("NEF Meta Decoder: Model name found");
 
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
 
-  setMetaData(meta, make, model);
+  setMetaData(meta, make, model,"");
 
 /*  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 

Modified: RawSpeed/NefDecoder.h
===================================================================
--- RawSpeed/NefDecoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/NefDecoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,38 +15,39 @@
 
     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
-*/
-#pragma once
-#include "RawDecoder.h"
-#include "LJpegPlain.h"
-#include "TiffIFD.h"
-#include "BitPumpPlain.h"
-#include "TiffParser.h"
-#include "NikonDecompressor.h"
-
-class NefDecoder :
-  public RawDecoder
-{
-public:
-  NefDecoder(TiffIFD *rootIFD, FileMap* file);
-  virtual ~NefDecoder(void);
-  virtual RawImage decodeRaw();
-  virtual void decodeMetaData(CameraMetaData *meta);
-  TiffIFD *mRootIFD;
-private:
-  gboolean D100IsCompressed(guint offset);
-  void DecodeUncompressed();
-  void DecodeD100Uncompressed();
-};
-
-class NefSlice {
-public:
-  NefSlice() { h = offset = count = 0;};
-  ~NefSlice() {};
-  guint h;
-  guint offset;
-  guint count;
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+#include "RawDecoder.h"
+#include "LJpegPlain.h"
+#include "TiffIFD.h"
+#include "BitPumpPlain.h"
+#include "TiffParser.h"
+#include "NikonDecompressor.h"
+
+class NefDecoder :
+  public RawDecoder
+{
+public:
+  NefDecoder(TiffIFD *rootIFD, FileMap* file);
+  virtual ~NefDecoder(void);
+  virtual RawImage decodeRaw();
+  virtual void decodeMetaData(CameraMetaData *meta);
+  virtual void checkSupport(CameraMetaData *meta);
+  TiffIFD *mRootIFD;
+private:
+  gboolean D100IsCompressed(guint offset);
+  void DecodeUncompressed();
+  void DecodeD100Uncompressed();
+};
+
+class NefSlice {
+public:
+  NefSlice() { h = offset = count = 0;};
+  ~NefSlice() {};
+  guint h;
+  guint offset;
+  guint count;
 };
\ No newline at end of file

Modified: RawSpeed/OrfDecoder.cpp
===================================================================
--- RawSpeed/OrfDecoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/OrfDecoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -1,26 +1,26 @@
 #include "StdAfx.h"
 #include "OrfDecoder.h"
-#include "TiffParserOlympus.h"
+#include "TiffParserOlympus.h"
 #ifdef __unix__
-#include <stdlib.h>
+#include <stdlib.h>
 #endif
-/* 
-    RawSpeed - RAW file decoder.
-
-    Copyright (C) 2009 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
+/* 
+    RawSpeed - RAW file decoder.
+
+    Copyright (C) 2009 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
@@ -91,65 +91,74 @@
   return mRaw;
 }
 
-void OrfDecoder::decodeCompressed(ByteStream& s,guint w, guint h)
-{
-  int nbits, sign, low, high, i, wo, n, nw;
-  int acarry[2][3], *carry, pred, diff;
-
+void OrfDecoder::decodeCompressed(ByteStream& s,guint w, guint h)
+{
+  int nbits, sign, low, high, i, wo, n, nw;
+  int acarry[2][3], *carry, pred, diff;
+
   guchar* data = mRaw->getData();
-  gint pitch = mRaw->pitch;
-
-  s.skipBytes(7);
-  BitPumpMSB bits(&s);
-
-  for (guint y=0; y < h; y++) {
-    memset (acarry, 0, sizeof acarry);
+  gint pitch = mRaw->pitch;
+
+  s.skipBytes(7);
+  BitPumpMSB bits(&s);
+
+  for (guint y=0; y < h; y++) {
+    memset (acarry, 0, sizeof acarry);
     gushort* dest = (gushort*)&data[y*pitch];
-    for (guint x=0; x < w; x++) {
-      bits.fill();
-      carry = acarry[x & 1];
-      i = 2 * (carry[2] < 3);
-      for (nbits=2+i; (gushort) carry[0] >> (nbits+i); nbits++);
-      sign = bits.getBitNoFill() * -1;
-      low  = bits.getBitsNoFill(2);
-      for (high = 0; high < 12; high++)
-        if (bits.getBitNoFill()) break;
-      if (high == 12)
-        high = bits.getBits(16-nbits) >> 1;
-      carry[0] = (high << nbits) | bits.getBits(nbits);
-      diff = (carry[0] ^ sign) + carry[1];
-      carry[1] = (diff*3 + carry[1]) >> 5;
-      carry[2] = carry[0] > 16 ? 0 : carry[2]+1;
-      if (y < 2 && x < 2) pred = 0;
-      else if (y < 2) pred = dest[x-2];
-      else if (x < 2) pred = dest[-pitch+((gint)x)];  // Pitch is in bytes, 
and dest is in short, so we skip two lines
-      else {
-        wo  = dest[x-2];
-        n  = dest[-pitch+((gint)x)];
-        nw = dest[-pitch+((gint)x)-2];
-        if ((wo < nw && nw < n) || (n < nw && nw < wo)) {
-          if (abs(wo-nw) > 32 || abs(n-nw) > 32)
-            pred = wo + n - nw;
-          else pred = (wo + n) >> 1;
-        } else pred = abs(wo-nw) > abs(n-nw) ? wo : n;
-      }
-       dest[x] = pred + ((diff << 2) | low);
-       _ASSERTE(0 == dest[x]>>12) ;
-    }
-  }
-}
+    for (guint x=0; x < w; x++) {
+      bits.fill();
+      carry = acarry[x & 1];
+      i = 2 * (carry[2] < 3);
+      for (nbits=2+i; (gushort) carry[0] >> (nbits+i); nbits++);
+      sign = bits.getBitNoFill() * -1;
+      low  = bits.getBitsNoFill(2);
+      for (high = 0; high < 12; high++)
+        if (bits.getBitNoFill()) break;
+      if (high == 12)
+        high = bits.getBits(16-nbits) >> 1;
+      carry[0] = (high << nbits) | bits.getBits(nbits);
+      diff = (carry[0] ^ sign) + carry[1];
+      carry[1] = (diff*3 + carry[1]) >> 5;
+      carry[2] = carry[0] > 16 ? 0 : carry[2]+1;
+      if (y < 2 && x < 2) pred = 0;
+      else if (y < 2) pred = dest[x-2];
+      else if (x < 2) pred = dest[-pitch+((gint)x)];  // Pitch is in bytes, 
and dest is in short, so we skip two lines
+      else {
+        wo  = dest[x-2];
+        n  = dest[-pitch+((gint)x)];
+        nw = dest[-pitch+((gint)x)-2];
+        if ((wo < nw && nw < n) || (n < nw && nw < wo)) {
+          if (abs(wo-nw) > 32 || abs(n-nw) > 32)
+            pred = wo + n - nw;
+          else pred = (wo + n) >> 1;
+        } else pred = abs(wo-nw) > abs(n-nw) ? wo : n;
+      }
+       dest[x] = pred + ((diff << 2) | low);
+       _ASSERTE(0 == dest[x]>>12) ;
+    }
+  }
+}
 
+void OrfDecoder::checkSupport(CameraMetaData *meta) {
+  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("ORF 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 OrfDecoder::decodeMetaData(CameraMetaData *meta)
 {
   mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
   vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 
   if (data.empty())
-    ThrowRDE("ARW Meta Decoder: Model name found");
+    ThrowRDE("ORF Meta Decoder: Model name found");
 
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
 
-  setMetaData(meta, make, model);
+  setMetaData(meta, make, model,"");
 
-}
+}

Modified: RawSpeed/OrfDecoder.h
===================================================================
--- RawSpeed/OrfDecoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/OrfDecoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,27 +15,28 @@
 
     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
-*/
-#pragma once
-#include "RawDecoder.h"
-#include "LJpegPlain.h"
-#include "TiffIFD.h"
-#include "BitPumpPlain.h"
-
-
-class OrfDecoder :
-  public RawDecoder
-{
-public:
-  OrfDecoder(TiffIFD *rootIFD, FileMap* file);
-  virtual ~OrfDecoder(void);
-  virtual RawImage decodeRaw();
-  virtual void decodeMetaData(CameraMetaData *meta);
-private:
-  void decodeCompressed(ByteStream& s,guint w, guint h);
-  TiffIFD *mRootIFD;
-
-};
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+#include "RawDecoder.h"
+#include "LJpegPlain.h"
+#include "TiffIFD.h"
+#include "BitPumpPlain.h"
+
+
+class OrfDecoder :
+  public RawDecoder
+{
+public:
+  OrfDecoder(TiffIFD *rootIFD, FileMap* file);
+  virtual ~OrfDecoder(void);
+  virtual RawImage decodeRaw();
+  virtual void decodeMetaData(CameraMetaData *meta);
+  virtual void checkSupport(CameraMetaData *meta);
+private:
+  void decodeCompressed(ByteStream& s,guint w, guint h);
+  TiffIFD *mRootIFD;
+
+};

Modified: RawSpeed/PefDecoder.cpp
===================================================================
--- RawSpeed/PefDecoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/PefDecoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -69,6 +69,16 @@
   return mRaw;
 }
 
+void PefDecoder::checkSupport(CameraMetaData *meta) {
+  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("PEF 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 PefDecoder::decodeMetaData(CameraMetaData *meta)
 {
   mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
@@ -80,7 +90,7 @@
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
 
-  setMetaData(meta, make, model);
+  setMetaData(meta, make, model,"");
 
 /*  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
 

Modified: RawSpeed/PefDecoder.h
===================================================================
--- RawSpeed/PefDecoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/PefDecoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,23 +15,23 @@
 
     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
-*/
-#pragma once
-#include "RawDecoder.h"
-#include "TiffIFD.h"
-#include "PentaxDecompressor.h"
-
-class PefDecoder :
-  public RawDecoder
-{
-public:
-  PefDecoder(TiffIFD *rootIFD, FileMap* file);
-  virtual ~PefDecoder(void);
-  virtual RawImage decodeRaw();
-  virtual void decodeMetaData(CameraMetaData *meta);
- TiffIFD *mRootIFD;
-
-};
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+#pragma once
+#include "RawDecoder.h"
+#include "TiffIFD.h"
+#include "PentaxDecompressor.h"
+
+class PefDecoder :
+  public RawDecoder
+{
+public:
+  PefDecoder(TiffIFD *rootIFD, FileMap* file);
+  virtual ~PefDecoder(void);
+  virtual RawImage decodeRaw();
+  virtual void decodeMetaData(CameraMetaData *meta);
+  virtual void checkSupport(CameraMetaData *meta);
+  TiffIFD *mRootIFD;
+};

Modified: RawSpeed/RawDecoder.cpp
===================================================================
--- RawSpeed/RawDecoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/RawDecoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -1,22 +1,22 @@
 #include "StdAfx.h"
 #include "RawDecoder.h"
-/* 
-    RawSpeed - RAW file decoder.
-
-    Copyright (C) 2009 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
+/* 
+    RawSpeed - RAW file decoder.
+
+    Copyright (C) 2009 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
@@ -105,14 +105,26 @@
       dest[x+1] = (g2>>2) | (g3<<4);
     }
   }
-}
+}
 
+  void RawDecoder::checkCameraSupported(CameraMetaData *meta, string make, 
string model, string mode) {
+  TrimSpaces(make);
+  TrimSpaces(model);
+  Camera* cam = meta->getCamera(make, model, mode);
+  if (!cam && mode.length() == 0) {
+    printf("Unable to find camera in database: %s %s\n", make.c_str(), 
model.c_str());
+    return;    // Assume true.
+  }
 
-void RawDecoder::setMetaData( CameraMetaData *meta, string make, string model )
+  if (!cam->supported)
+    ThrowRDE("Camera not supported (explicit). Sorry.");
+}
+
+void RawDecoder::setMetaData( CameraMetaData *meta, string make, string model, 
string mode )
 {
   TrimSpaces(make);
   TrimSpaces(model);
-  Camera *cam = meta->getCamera(make, model);
+  Camera *cam = meta->getCamera(make, model, mode);
   if (!cam) {
     printf("Unable to find camera in database: %s %s\n", make.c_str(), 
model.c_str());
     return;

Modified: RawSpeed/RawDecoder.h
===================================================================
--- RawSpeed/RawDecoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/RawDecoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -13,13 +13,15 @@
   RawDecoder(FileMap* file);
   virtual ~RawDecoder(void);
   virtual RawImage decodeRaw() = 0;
+  virtual void checkSupport(CameraMetaData *meta) = 0;
   virtual void decodeMetaData(CameraMetaData *meta) = 0;
   FileMap *mFile; 
   void readUncompressedRaw(ByteStream &input, iPoint2D& size, iPoint2D& 
offset, int inputPitch, int bitPerPixel, gboolean MSBOrder);
   RawImage mRaw; 
   vector<const char*> errors;
 protected:
-  virtual void setMetaData(CameraMetaData *meta, string make, string model);
+  void checkCameraSupported(CameraMetaData *meta, string make, string model, 
string mode);
+  virtual void setMetaData(CameraMetaData *meta, string make, string model, 
string mode);
   void Decode12BitRaw(ByteStream &input, guint w, guint h);
   void TrimSpaces( string& str);
 };

Modified: RawSpeed/Rw2Decoder.cpp
===================================================================
--- RawSpeed/Rw2Decoder.cpp     2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/Rw2Decoder.cpp     2009-07-05 15:28:03 UTC (rev 74)
@@ -34,6 +34,17 @@
   return NULL;
 }
 
+void Rw2Decoder::checkSupport(CameraMetaData *meta) {
+  ThrowRDE("RW2 Decoder: Not supported");
+/*  vector<TiffIFD*> data = mRootIFD->getIFDsWithTag(MODEL);
+  if (data.empty())
+    ThrowRDE("PEF 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 Rw2Decoder::decodeMetaData( CameraMetaData *meta )
 {
 

Modified: RawSpeed/Rw2Decoder.h
===================================================================
--- RawSpeed/Rw2Decoder.h       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/Rw2Decoder.h       2009-07-05 15:28:03 UTC (rev 74)
@@ -15,23 +15,24 @@
 
 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
-*/
-#pragma once
-#include "RawDecoder.h"
-#include "TiffIFD.h"
-#include "BitPumpPlain.h"
-#include "TiffParser.h"
-
-class Rw2Decoder :
-  public RawDecoder
-{
-public:
-  Rw2Decoder(TiffIFD *rootIFD, FileMap* file);
-  virtual ~Rw2Decoder(void);
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+
+http://www.klauspost.com
+*/
+#pragma once
+#include "RawDecoder.h"
+#include "TiffIFD.h"
+#include "BitPumpPlain.h"
+#include "TiffParser.h"
+
+class Rw2Decoder :
+  public RawDecoder
+{
+public:
+  Rw2Decoder(TiffIFD *rootIFD, FileMap* file);
+  virtual ~Rw2Decoder(void);
   RawImage decodeRaw();
   virtual void decodeMetaData(CameraMetaData *meta);
-  TiffIFD *mRootIFD;
-};
+  virtual void checkSupport(CameraMetaData *meta);
+  TiffIFD *mRootIFD;
+};

Modified: RawSpeed/StdAfx.h
===================================================================
--- RawSpeed/StdAfx.h   2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/StdAfx.h   2009-07-05 15:28:03 UTC (rev 74)
@@ -15,35 +15,36 @@
 
     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
-*/
-
-
-#pragma once
-
-
-#define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from 
Windows headers
-#include <stdio.h>
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  
USA
+
+    http://www.klauspost.com
+*/
+
+
+#pragma once
+
+
+#define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from 
Windows headers
+#include <stdio.h>
 #ifndef __unix__
-#include <tchar.h>
-#include <io.h>
-#include <Windows.h>
+#include <tchar.h>
+#include <io.h>
+#include <Windows.h>
 #include <crtdbg.h>
-#endif // __unix__
-#include <malloc.h>
-#include <math.h>
-// STL
-#include <string>
-#include <vector>
-#include <map>
-#include <list>
-using namespace std;
-
-//My own
-#include "TiffTag.h"
-#include "Common.h"
-#include "Point.h"
-
-
+#endif // __unix__
+#include <malloc.h>
+#include <math.h>
+// STL
+#include <iostream>
+#include <string>
+#include <vector>
+#include <map>
+#include <list>
+using namespace std;
+
+//My own
+#include "TiffTag.h"
+#include "Common.h"
+#include "Point.h"
+
+

Modified: RawSpeed/compile-rawstudio.sh
===================================================================
--- RawSpeed/compile-rawstudio.sh       2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/compile-rawstudio.sh       2009-07-05 15:28:03 UTC (rev 74)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-make -f rawstudio-plugin.makefile all && sudo make -f 
rawstudio-plugin.makefile install
\ No newline at end of file
+make -j4 -f rawstudio-plugin.makefile all && sudo make -f 
rawstudio-plugin.makefile install
\ No newline at end of file

Modified: RawSpeed/rawstudio-plugin-api.cpp
===================================================================
--- RawSpeed/rawstudio-plugin-api.cpp   2009-07-05 12:25:50 UTC (rev 73)
+++ RawSpeed/rawstudio-plugin-api.cpp   2009-07-05 15:28:03 UTC (rev 74)
@@ -28,7 +28,7 @@
 #include "CameraMetaData.h"
 #include "rawstudio-plugin-api.h"
 
-//#define TIME_LOAD 1
+#define TIME_LOAD 1
 
 extern "C" {
 
@@ -72,7 +72,7 @@
 #ifdef TIME_LOAD
                        gt = g_timer_new();
 #endif
-
+      d->checkSupport(c);
                        d->decodeRaw();
                        d->decodeMetaData(c);
 

Modified: cameras.xml
===================================================================
--- cameras.xml 2009-07-05 12:25:50 UTC (rev 73)
+++ cameras.xml 2009-07-05 15:28:03 UTC (rev 74)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE Cameras SYSTEM 
"http://rawspeed.klauspost.com/dtd/cameras/1.0/cameras.dtd";>
+<!DOCTYPE Cameras SYSTEM 
"http://rawspeed.klauspost.com/dtd/cameras/1.1/cameras.dtd";>
 <Cameras>
   <Camera make="Canon" model="Canon EOS 20D">
     <CFA width="2" height="2">
@@ -201,6 +201,16 @@
     <Crop x="0" y="0" width="3032" height="2024"/>
     <Sensor black="0" white="4095"/>
   </Camera>
+  <Camera make="NIKON CORPORATION" model="NIKON D1">
+    <CFA width="2" height="2">
+      <Color x="0" y="0">BLUE</Color>
+      <Color x="1" y="0">GREEN</Color>
+      <Color x="0" y="1">GREEN</Color>
+      <Color x="1" y="1">RED</Color>
+    </CFA>
+    <Crop x="0" y="0" width="2000" height="1312"/>
+    <Sensor black="0" white="4095"/>
+  </Camera>
   <Camera make="NIKON CORPORATION" model="NIKON D1H">
     <CFA width="2" height="2">
       <Color x="0" y="0">BLUE</Color>
@@ -211,7 +221,7 @@
     <Crop x="0" y="0" width="2012" height="1324"/>
     <Sensor black="0" white="4095"/>
   </Camera>
-  <Camera make="NIKON CORPORATION" model="NIKON D1X">
+  <Camera make="NIKON CORPORATION" model="NIKON D1X" supported="no">
     <CFA width="2" height="2">
       <Color x="0" y="0">BLUE</Color>
       <Color x="1" y="0">GREEN</Color>
@@ -223,10 +233,10 @@
   </Camera>
   <Camera make="NIKON CORPORATION" model="NIKON D200">
     <CFA width="2" height="2">
-      <Color x="0" y="0">RED</Color>
-      <Color x="1" y="0">GREEN</Color>
-      <Color x="0" y="1">GREEN</Color>
-      <Color x="1" y="1">BLUE</Color>
+      <Color x="0" y="0">GREEN</Color>
+      <Color x="1" y="0">RED</Color>
+      <Color x="0" y="1">BLUE</Color>
+      <Color x="1" y="1">GREEN</Color>
     </CFA>
     <Crop x="0" y="0" width="3900" height="2616"/>
     <Sensor black="0" white="3880"/>
@@ -251,7 +261,7 @@
     <Crop x="0" y="0" width="4312" height="2868"/>
     <Sensor black="0" white="3880"/>
   </Camera>
-  <Camera make="NIKON CORPORATION" model="NIKON D3">
+  <Camera make="NIKON CORPORATION" model="NIKON D3" supported="no">
     <CFA width="2" height="2">
       <Color x="0" y="0">RED</Color>
       <Color x="1" y="0">GREEN</Color>
@@ -259,7 +269,7 @@
       <Color x="1" y="1">BLUE</Color>
     </CFA>
     <Crop x="0" y="0" width="4284" height="2844"/>
-    <Sensor black="0" white="15892"/>
+    <Sensor black="0" white="65535"/>
   </Camera>
   <Camera make="NIKON CORPORATION" model="NIKON D300">
     <CFA width="2" height="2">
@@ -361,7 +371,7 @@
     <Crop x="0" y="0" width="2608" height="1950"/>
     <Sensor black="0" white="4095"/>
   </Camera>
-  <Camera make="NIKON" model="E5700">
+  <Camera make="NIKON" model="E5700" supported="no">    
     <CFA width="2" height="2">
       <Color x="0" y="0">GREEN</Color>
       <Color x="1" y="0">UNKNOWN</Color>
@@ -611,7 +621,7 @@
     <Crop x="0" y="0" width="4599" height="3064"/>
     <Sensor black="0" white="4095"/>
   </Camera>
-  <Camera make="SONY" model="DSLR-A700">
+  <Camera make="SONY" model="DSLR-A700" supported="no">
     <CFA width="2" height="2">
       <Color x="1" y="1">BLUE</Color>
       <Color x="1" y="0">GREEN</Color>
@@ -621,7 +631,7 @@
     <Crop x="0" y="0" width="4288" height="2856"/>
     <Sensor black="512" white="4095"/>
   </Camera>
-  <Camera make="SONY" model="DSLR-A900">
+  <Camera make="SONY" model="DSLR-A900" supported="no">
     <CFA width="2" height="2">
       <Color x="0" y="0">RED</Color>
       <Color x="1" y="0">GREEN</Color>


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

Reply via email to