Author: post
Date: 2009-09-02 17:59:33 +0200 (Wed, 02 Sep 2009)
New Revision: 141

Modified:
   RawSpeed/CameraMetaData.cpp
   RawSpeed/RawImage.h
   RawSpeed/Rw2Decoder.cpp
   RawSpeed/Rw2Decoder.h
   cameras.xml
Log:
- Added support for different aspect ratios on Panasonic cameras.
- Added support for Panasonic GH1.

Modified: RawSpeed/CameraMetaData.cpp
===================================================================
--- RawSpeed/CameraMetaData.cpp 2009-09-02 14:57:26 UTC (rev 140)
+++ RawSpeed/CameraMetaData.cpp 2009-09-02 15:59:33 UTC (rev 141)
@@ -58,6 +58,12 @@
     }
     cur = cur->next;
   }
+  if (doc)
+    xmlFreeDoc(doc);
+  doc = 0;
+  if (ctxt)
+    xmlFreeParserCtxt(ctxt);
+  ctxt = 0;
 }
 
 CameraMetaData::~CameraMetaData(void) {

Modified: RawSpeed/RawImage.h
===================================================================
--- RawSpeed/RawImage.h 2009-09-02 14:57:26 UTC (rev 140)
+++ RawSpeed/RawImage.h 2009-09-02 15:59:33 UTC (rev 141)
@@ -48,6 +48,7 @@
   int whitePoint;
   vector<BlackArea> blackAreas;
   iPoint2D subsampling;
+  gboolean isAllocated() {return !!data;}
 protected:
   RawImageData(void);
   RawImageData(iPoint2D dim, guint bpp, guint cpp=1);

Modified: RawSpeed/Rw2Decoder.cpp
===================================================================
--- RawSpeed/Rw2Decoder.cpp     2009-09-02 14:57:26 UTC (rev 140)
+++ RawSpeed/Rw2Decoder.cpp     2009-09-02 15:59:33 UTC (rev 141)
@@ -93,7 +93,6 @@
       } else if ((nonz[i & 1] = pana_bits(8)) || i > 11)
         pred[i & 1] = nonz[i & 1] << 4 | pana_bits(4);
       dest[x] = pred[x&1];
-      _ASSERTE(dest[x] < 4098);
     }
   }
 }
@@ -143,11 +142,41 @@
 
   string make = data[0]->getEntry(MAKE)->getString();
   string model = data[0]->getEntry(MODEL)->getString();
-  string mode = "";
+  string mode = getMode(model);
 
-  if (!model.compare("DMC-LX3") && (mRaw->dim.x > 4000))
-    mode ="wide";
+  printf("Mode: %s\n",mode.c_str());
 
   setMetaData(meta, make, model, mode);
+}
 
-}
\ No newline at end of file
+bool Rw2Decoder::almostEqualRelative(float A, float B, float maxRelativeError)
+{
+  if (A == B)
+    return true;
+
+  float relativeError = fabs((A - B) / B);
+  if (relativeError <= maxRelativeError)
+    return true;
+  return false;
+}
+
+std::string Rw2Decoder::getMode( const string model )
+{
+  float ratio = 3.0f / 2.0f;  // Default
+  if (mRaw->isAllocated()) {
+    ratio = (float)mRaw->dim.x / (float)mRaw->dim.y;
+  }
+
+  if (!model.compare("DMC-LX3") || !model.compare("DMC-G1") || 
!model.compare("DMC-GH1") || !model.compare("DMC-GF1")) {
+    if (almostEqualRelative(ratio,16.0f/9.0f,0.02f))
+      return "16:9";
+    if (almostEqualRelative(ratio,3.0f/2.0f,0.02f))
+      return "3:2";
+    if (almostEqualRelative(ratio,4.0f/3.0f,0.02f))
+      return "4:3";
+    if (almostEqualRelative(ratio,1.0f,0.02f))
+      return "1:1";
+  }
+
+  return "";
+}

Modified: RawSpeed/Rw2Decoder.h
===================================================================
--- RawSpeed/Rw2Decoder.h       2009-09-02 14:57:26 UTC (rev 140)
+++ RawSpeed/Rw2Decoder.h       2009-09-02 15:59:33 UTC (rev 141)
@@ -37,7 +37,9 @@
   TiffIFD *mRootIFD;
 private:
   guint pana_bits (int nbits);
+  string getMode(const string model);
   void DecodeRw2();
+  bool almostEqualRelative(float A, float B, float maxRelativeError);
   guint load_flags;
   ByteStream* input;
   guchar buf[0x4000];

Modified: cameras.xml
===================================================================
--- cameras.xml 2009-09-02 14:57:26 UTC (rev 140)
+++ cameras.xml 2009-09-02 15:59:33 UTC (rev 141)
@@ -699,14 +699,30 @@
     <Crop x="0" y="0" width="3668" height="2754"/>
     <Sensor black="15" white="3986"/>
   </Camera>
-  <Camera make="Panasonic" model = "DMC-G1">
+  <Camera make="Panasonic" model = "DMC-G1" mode="4:3">
     <CFA width="2" height="2">
       <Color x="0" y="0">GREEN</Color><Color x="1" y="0">BLUE</Color>
       <Color x="0" y="1">RED</Color><Color x="1" y="1">GREEN</Color>
     </CFA>
-    <Crop x="0" y="0" width="4034" height="3016"/>
+    <Crop x="0" y="0" width="4034" height="3016" />
     <Sensor black="15" white="3986"/>
   </Camera>
+  <Camera make="Panasonic" model = "DMC-GH1" mode="4:3">
+    <CFA width="2" height="2">
+      <Color x="0" y="0">GREEN</Color><Color x="1" y="0">BLUE</Color>
+      <Color x="0" y="1">RED</Color><Color x="1" y="1">GREEN</Color>
+    </CFA>
+    <Crop x="0" y="0" width="-28" height="0"/>
+    <Sensor black="0" white="5111"/>
+  </Camera>
+  <Camera make="Panasonic" model = "DMC-GH1" mode="16:9">
+    <CFA width="2" height="2">
+      <Color x="0" y="0">GREEN</Color><Color x="1" y="0">BLUE</Color>
+      <Color x="0" y="1">RED</Color><Color x="1" y="1">GREEN</Color>
+    </CFA>
+    <Crop x="0" y="0" width="-28" height="0"/>
+    <Sensor black="0" white="5111"/>
+  </Camera>
   <Camera make="Panasonic" model = "DMC-FZ38">
     <CFA width="2" height="2">
       <Color x="0" y="0">BLUE</Color><Color x="1" y="0">GREEN</Color>
@@ -715,7 +731,7 @@
     <Crop x="0" y="0" width="4030" height="3018"/>
     <Sensor black="130" white="4086"/>
   </Camera>
-  <Camera make="Panasonic" model = "DMC-LX3" mode="wide">
+  <Camera make="Panasonic" model = "DMC-LX3" mode="16:9">
     <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>
@@ -723,7 +739,7 @@
     <Crop x="0" y="0" width="3990" height="2250"/>
     <Sensor black="0" white="4095"/>
   </Camera>
-  <Camera make="Panasonic" model = "DMC-LX3">
+  <Camera make="Panasonic" model = "DMC-LX3" mode="4:3">
     <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>


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

Reply via email to