[Rawstudio-commit] rawspeed r58 - RawSpeed

Klaus Post klauspost at gmail.com
Sun Feb 8 13:31:19 CET 2009


Author: post
Date: 2009-02-08 13:31:19 +0100 (Sun, 08 Feb 2009)
New Revision: 58

Modified:
   RawSpeed/ColorFilterArray.cpp
   RawSpeed/DngDecoder.cpp
   RawSpeed/RawImage.cpp
   RawSpeed/RawImage.h
   RawSpeed/RawSpeed.cpp
Log:
- Added DNG Linearizaton.
- Don't override DNG CFA definition.
- Added RawImage helper to get data with offset.

Modified: RawSpeed/ColorFilterArray.cpp
===================================================================
--- RawSpeed/ColorFilterArray.cpp	2009-02-08 11:48:04 UTC (rev 57)
+++ RawSpeed/ColorFilterArray.cpp	2009-02-08 12:31:19 UTC (rev 58)
@@ -86,4 +86,5 @@
   if (pos.y > 1 || pos.y < 0)
     ThrowRDE("ColorFilterArray::SetColor: position out of CFA pattern");
   cfa[pos.x+pos.y*2] = c;
+  _RPT2(0, "cfa[%u] = %u\n",pos.x+pos.y*2, c);
 }
\ No newline at end of file

Modified: RawSpeed/DngDecoder.cpp
===================================================================
--- RawSpeed/DngDecoder.cpp	2009-02-08 11:48:04 UTC (rev 57)
+++ RawSpeed/DngDecoder.cpp	2009-02-08 12:31:19 UTC (rev 58)
@@ -233,12 +233,32 @@
   } catch (TiffParserException) {
     ThrowRDE("DNG Decoder: Image could not be read.");
   }
+
+  // Linearization
+
+  if (raw->hasEntry(LINEARIZATIONTABLE)) {
+    const gushort* intable = raw->getEntry(LINEARIZATIONTABLE)->getShortArray();
+    guint len =  raw->getEntry(LINEARIZATIONTABLE)->count;
+    gushort table[65536];
+    for (guint i = 0; i < 65536 ; i++ ) {
+      if (i<len)
+        table[i] = intable[i];
+      else
+        table[i] = intable[len-1];
+    }
+    for (guint y = 0; y < mRaw->dim.y; y++) {
+      guint cw = mRaw->dim.x*mRaw->getCpp();
+      gushort* pixels = (gushort*)mRaw->getData(0,y);
+      for (guint x = 0; x < cw; x++) {
+        *pixels++  = table[*pixels];
+      }
+    }
+  }
   return mRaw;
 }
 
 void DngDecoder::decodeMetaData()
 {
-  mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE);
 
 }
 

Modified: RawSpeed/RawImage.cpp
===================================================================
--- RawSpeed/RawImage.cpp	2009-02-08 11:48:04 UTC (rev 57)
+++ RawSpeed/RawImage.cpp	2009-02-08 12:31:19 UTC (rev 58)
@@ -68,6 +68,17 @@
   return data;
 }
 
+guchar* RawImageData::getData( guint x, guint y )
+{
+  if (!data)
+    ThrowRDE("RawImageData::getData - Data not yet allocated.");
+  if (x>=dim.x)
+    ThrowRDE("RawImageData::getData - X Position outside image requested.");
+  if (y>=dim.y)
+    ThrowRDE("RawImageData::getData - Y Position outside image requested.");
+  return &data[y*pitch+x*bpp];
+}
+
 RawImage::RawImage( RawImageData* p ) : p_(p)
 {
   pthread_mutex_lock(&p_->mymutex);

Modified: RawSpeed/RawImage.h
===================================================================
--- RawSpeed/RawImage.h	2009-02-08 11:48:04 UTC (rev 57)
+++ RawSpeed/RawImage.h	2009-02-08 12:31:19 UTC (rev 58)
@@ -36,6 +36,7 @@
   guint pitch;
   void createData();
   guchar* getData();
+  guchar* getData(guint x, guint y);    // Not super fast, but safe. Don't use per pixel.
   gboolean isCFA;
   ColorFilterArray cfa;
 private:

Modified: RawSpeed/RawSpeed.cpp
===================================================================
--- RawSpeed/RawSpeed.cpp	2009-02-08 11:48:04 UTC (rev 57)
+++ RawSpeed/RawSpeed.cpp	2009-02-08 12:31:19 UTC (rev 58)
@@ -23,7 +23,7 @@
 #include "FileReader.h"
 #include "TiffParser.h"
 #include "RawDecoder.h"
-//#define _USE_GFL_
+#define _USE_GFL_
 #ifdef _USE_GFL_
 #include "libgfl.h"
 #pragma comment(lib, "libgfl.lib") 
@@ -56,6 +56,10 @@
       for (guint i = 0; i < d->errors.size(); i++) {
         printf("Error Encoutered:%s", d->errors[i]);
       }
+      if (r->isCFA) {
+        printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter());
+        printf(r->cfa.asString().c_str());
+      }
 
 #ifdef _USE_GFL_
       GFL_BITMAP* b;
@@ -108,9 +112,10 @@
     return 1;
   }
 #endif
-
+/*
 //  OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_LX3(300109).dng"));
   //OpenFile(FileReader(L"..\\testimg\\Panasonic_LX3.rw2"));
+  OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk2.cr2"));
   OpenFile(FileReader(L"..\\testimg\\5d.CR2"));
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk3-2.cr2"));
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_20D-demosaic.cr2"));
@@ -125,11 +130,13 @@
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1D_Mk2.cr2"));
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1000D.cr2"));
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1D_Mk3.cr2"));
-  OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk2.cr2"));
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk3.cr2"));
   OpenFile(FileReader(L"..\\testimg\\Canon_EOS_400D.cr2"));
   
     
+  
+  OpenFile(FileReader(L"..\\testimg\\Pentax_K10D-2.dng"));
+  OpenFile(FileReader(L"..\\testimg\\Pentax_K10D.pef"));
   OpenFile(FileReader(L"..\\testimg\\Pentax_K100D.pef"));
   OpenFile(FileReader(L"..\\testimg\\Pentax_K10D.pef"));
   OpenFile(FileReader(L"..\\testimg\\Pentax_K20D.pef"));
@@ -144,6 +151,8 @@
   OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900-2.arw"));
   OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900.arw"));
 
+  OpenFile(FileReader(L"..\\testimg\\Nikon_D1.nef"));
+  OpenFile(FileReader(L"..\\testimg\\Nikon_D100-backhigh.nef"));
   OpenFile(FileReader(L"..\\testimg\\Nikon_D200_compressed-1.nef"));
   OpenFile(FileReader(L"..\\testimg\\NikonCoolPix8800.nef"));
   OpenFile(FileReader(L"..\\testimg\\Nikon_D1H.nef"));
@@ -192,7 +201,7 @@
   OpenFile(FileReader(L"..\\testimg\\Olympus_E520-5.orf"));
   OpenFile(FileReader(L"..\\testimg\\Olympus_E520.orf"));
   OpenFile(FileReader(L"..\\testimg\\Olympus_SP350.orf"));
-
+*/
   OpenFile(FileReader(L"..\\testimg\\dng\\5d-raw.dng"));
   OpenFile(FileReader(L"..\\testimg\\dng\\5d.dng"));
   OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS10-linear.dng"));




More information about the Rawstudio-commit mailing list