[f-spot/rubenv-gsoc-2009: 84/86] Update to LibRaw 0.8.2.



commit 6c6305b2c602bd536af6899ed5b87561d4fd07b0
Author: Ruben Vermeersch <ruben savanne be>
Date:   Mon Sep 7 12:39:06 2009 +0200

    Update to LibRaw 0.8.2.

 lib/libfspotraw/LibRaw/Changelog.rus               |   39 ++
 lib/libfspotraw/LibRaw/Changelog.txt               |   38 ++
 lib/libfspotraw/LibRaw/Makefile.msvc               |    2 +-
 lib/libfspotraw/LibRaw/dcraw/dcraw.c               |  393 +++++++++++--------
 lib/libfspotraw/LibRaw/internal/dcraw_common.cpp   |  408 ++++++++++++--------
 lib/libfspotraw/LibRaw/internal/dcraw_fileio.cpp   |    2 +-
 lib/libfspotraw/LibRaw/internal/defines.h          |    8 +-
 lib/libfspotraw/LibRaw/internal/foveon.cpp         |    5 +-
 .../LibRaw/internal/libraw_internal_funcs.h        |   10 +-
 lib/libfspotraw/LibRaw/libraw/libraw.h             |   10 +-
 lib/libfspotraw/LibRaw/libraw/libraw_alloc.h       |    7 +-
 lib/libfspotraw/LibRaw/libraw/libraw_const.h       |    4 +-
 lib/libfspotraw/LibRaw/libraw/libraw_datastream.h  |   31 ++-
 lib/libfspotraw/LibRaw/libraw/libraw_internal.h    |   11 +-
 lib/libfspotraw/LibRaw/libraw/libraw_types.h       |    7 +
 lib/libfspotraw/LibRaw/libraw/libraw_version.h     |    4 +-
 lib/libfspotraw/LibRaw/samples/dcraw_half.c        |    2 +-
 lib/libfspotraw/LibRaw/src/libraw_c_api.cpp        |    7 +-
 lib/libfspotraw/LibRaw/src/libraw_cxx.cpp          |   56 ++-
 lib/libfspotraw/Makefile.am                        |    2 +-
 20 files changed, 659 insertions(+), 387 deletions(-)
---
diff --git a/lib/libfspotraw/LibRaw/Changelog.rus b/lib/libfspotraw/LibRaw/Changelog.rus
index 784f91c..3d8ba4e 100644
--- a/lib/libfspotraw/LibRaw/Changelog.rus
+++ b/lib/libfspotraw/LibRaw/Changelog.rus
@@ -1,3 +1,42 @@
+2009-09-02 Alex Tutubalin <lexa lexa ru>
+           + Èñïðàâëåíà îøèáêà â êîäå ðàñïàêîâêè Hasselblad .3FR
+           * Èìïîðòèðîâàíà dcraw 8.97/1.428: èñïðàâëåíà îøèáêà îïðåäåëåíèÿ
+             øèðèíû èçîáðàæåíèÿ äëÿ Nikon D3000
+           * LibRaw 0.8.2
+
+2009-08-31 Alex Tutubalin <lexa lexa ru>
+           + Çíà÷åíèÿ Enum LibRaw_thumbnail_formats (LIBRAW_IMAGE_*) èçìåíåíû,
+             ÷òîáû ñîîòâåòñòâîâàòü çíà÷åíèÿì â enum LibRaw_image_formats
+             (LIBRAW_THUMBNAIL_*).
+             Åñëè âû èñïîëüçóåòå óïîìÿíóòûå ñèìâîëüíûå êîíñòàíòû, âàì íåîáõîäèìî
+             ïåðåêîìïèëèðîâàòü âàø êîä.
+
+2009-08-30 Alex Tutubalin <lexa lexa ru>
+           * Èìïîðòèðîâàíà dcraw 8.97/1.427:
+             + Íîâûå êàìåðû: Canon A470, Canon G11,
+                Nikon D3000, Olympus E-P1, Panasonic DMC-FZ35/FZ38
+            * Èñïðàâëåíèÿ äëÿ ñîâìåñòèìîñòè ñ Microsoft Visual C++ 6.0
+            * Âûçîâ C-API dcraw_make_mem_thumb() ýêñïîðòèðóåòñÿ â DLL
+           * LibRaw 0.8.1
+
+2009-08-24 Alex Tutubalin <lexa lexa ru>
+           * Èìïîðòèðîâàíà  dcraw 8.86/1.426
+             + Íîâûå êàìåðû: Casio EX-Z60 and EX-Z75, Kodak Z980,
+               Nikon D5000,  Olympus X200, D560Z,C350Z,E620,
+               Pentax K7, Sony A330.
+             + Íîâûå öâåòîâûå äàííûå äëÿ ìíîãèõ êàìåð
+             + Áîëåå îáùèé êîä äëÿ ðàñïàêîâêè äàííûõ P&S êàìåð Canon è Casio
+           * LibRaw 0.8.0-Release
+
+2009-08-13 Alex Tutubalin <lexa lexa ru>
+           * Ïîääåðæêà RAW-ôàéëîâ ðàçìåðîì áîëåå 2Gb
+              - Unix (âñå âàðèàíòû)
+              - Windows (äëÿ ñèñòåì ñ âåðñèåé C runtime >= 8.0)
+           * bzero áîëåå íå èñïîëüçóåòñÿ, èáî åñòü íå âåçäå.
+           * íà âñåõ 32-áèòíûõ ñèñòåìàõ òðåáóåòñÿ ïîëíàÿ ïåðåêîìèëÿöèÿ
+             ïðèëîæåíèé
+           * LibRaw 0.8.0-Beta5
+
 2009-07-21 Alex Tutubalin <lexa lexa ru>
            * Èìïîðòèðîâàíà dcraw 8.95 (1.425):
              + Íîâûé êîä äëÿ ðàñïàêîâêè  huffman tree
diff --git a/lib/libfspotraw/LibRaw/Changelog.txt b/lib/libfspotraw/LibRaw/Changelog.txt
index 7baea0a..6a13125 100644
--- a/lib/libfspotraw/LibRaw/Changelog.txt
+++ b/lib/libfspotraw/LibRaw/Changelog.txt
@@ -1,3 +1,41 @@
+2009-09-02 Alex Tutubalin <lexa lexa ru>
+           + Fixed bug in Hasselblad .3FR unpacking code
+           * Imported dcraw 8.97/1.428: Nikon D3000 image width fix
+           * LibRaw 0.8.2
+
+2009-08-31 Alex Tutubalin <lexa lexa ru>
+           + Enum LibRaw_thumbnail_formats (LIBRAW_IMAGE_*) values changed to
+             match values in  enum LibRaw_image_formats (LIBRAW_THUMBNAIL_*).
+             You need to recompile all sources using these constants.
+
+2009-08-30 Alex Tutubalin <lexa lexa ru>
+           * Imported dcraw 8.97/1.427:
+             + new cameras: Canon A470, Canon G11 (without color data),
+                Nikon D3000, Olympus E-P1, Panasonic DMC-FZ35/FZ38
+             + some changes in decoding code.
+            * Fixes for Microsoft Visual C++ 6.0 compatibility
+            * C-API dcraw_make_mem_thumb() call finally exported in API
+           * LibRaw 0.8.1
+
+2009-08-24 Alex Tutubalin <lexa lexa ru>
+           * Imported dcraw 8.96/1.426
+             + New cameras: Casio EX-Z60 and EX-Z75, Kodak Z980,
+               Nikon D5000,  Olympus X200, D560Z,C350Z,E620,
+               Pentax K7, Sony A330.
+             + New color data for many cameras
+             + Generalized unpacker code for Canon and Casio P&S cameras
+           * LibRaw 0.8.0-Release
+
+2009-08-13 Alex Tutubalin <lexa lexa ru>
+           * RAW files larger than 2Gb are supported on:
+              - Unix (all supported: FreeBSD, MacOS X, Linux)
+              - Windows (with C runtime version  >= 8.0)
+           * bzero replaced with memset to make Solaris users happy
+           * All applications on 32-bit systems should be recompiled
+             due to data structures size changes.
+           * Minor fixes in windows makefile
+           * LibRaw 0.8.0-Beta5
+
 2009-07-21 Alex Tutubalin <lexa lexa ru>
            * Imported dcraw 8.95 (1.425):
              + new huffman tree code
diff --git a/lib/libfspotraw/LibRaw/Makefile.msvc b/lib/libfspotraw/LibRaw/Makefile.msvc
index 84e37c1..357d8f0 100644
--- a/lib/libfspotraw/LibRaw/Makefile.msvc
+++ b/lib/libfspotraw/LibRaw/Makefile.msvc
@@ -89,5 +89,5 @@ object\libraw_c_api_st.obj: src\libraw_c_api.cpp
 
 clean:
 	-del $(LIBSTATIC) $(LIBDLL) lib\*.exp
-	-del $(LIB_OBJECTS) $(LIB_OBJECTS)
+	-del $(LIB_OBJECTS) $(DLL_OBJECTS)
 	-del $(DLL) $(SAMPLES)
\ No newline at end of file
diff --git a/lib/libfspotraw/LibRaw/dcraw/dcraw.c b/lib/libfspotraw/LibRaw/dcraw/dcraw.c
index 80b007a..c63a060 100644
--- a/lib/libfspotraw/LibRaw/dcraw/dcraw.c
+++ b/lib/libfspotraw/LibRaw/dcraw/dcraw.c
@@ -19,11 +19,11 @@
    *If you have not modified dcraw.c in any way, a link to my
    homepage qualifies as "full source code".
 
-   $Revision: 1.425 $
-   $Date: 2009/06/19 21:38:38 $
+   $Revision: 1.428 $
+   $Date: 2009/08/31 15:23:49 $
  */
 
-#define VERSION "8.95"
+#define VERSION "8.97"
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
@@ -546,29 +546,6 @@ int CLASS canon_s2is()
   return 0;
 }
 
-void CLASS canon_a5_load_raw()
-{
-  ushort data[2565], *dp, pixel;
-  int vbits=0, buf=0, row, col, bc=0;
-
-  order = 0x4949;
-  for (row=-top_margin; row < raw_height-top_margin; row++) {
-    read_shorts (dp=data, raw_width * 10 / 16);
-    for (col=-left_margin; col < raw_width-left_margin; col++) {
-      if ((vbits -= 10) < 0)
-	buf = (vbits += 16, (buf << 16) + *dp++);
-      pixel = buf >> vbits & 0x3ff;
-      if ((unsigned) row < height && (unsigned) col < width)
-	BAYER(row,col) = pixel;
-      else if (col > 1-left_margin && col != width)
-	black += (bc++,pixel);
-    }
-  }
-  if (bc) black /= bc;
-  maximum = 0x3ff;
-  if (raw_width > 1600) remove_zeroes();
-}
-
 /*
    getbits(-1) initializes the buffer
    getbits(n) where 0 <= n <= 25 returns an n-bit integer
@@ -1108,7 +1085,7 @@ void CLASS adobe_dng_load_raw_nc()
   free (pixel);
 }
 
-void CLASS pentax_k10_load_raw()
+void CLASS pentax_load_raw()
 {
   ushort bit[2][13], huff[4097];
   int row, col, diff, c, i;
@@ -1123,13 +1100,13 @@ void CLASS pentax_k10_load_raw()
   huff[0] = 12;
   fseek (ifp, data_offset, SEEK_SET);
   getbits(-1);
-  for (row=0; row < height; row++)
+  for (row=0; row < raw_height; row++)
     for (col=0; col < raw_width; col++) {
       diff = ljpeg_diff (huff);
       if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
       else	   hpred[col & 1] += diff;
-      if (col < width)
-	BAYER(row,col) = hpred[col & 1];
+      if ((unsigned) (row-top_margin) < height && col < width)
+	BAYER(row-top_margin,col) = hpred[col & 1];
       if (hpred[col & 1] >> 12) derror();
     }
 }
@@ -1291,23 +1268,6 @@ int CLASS minolta_z2()
   return nz > 20;
 }
 
-/* Here raw_width is in bytes, not pixels. */
-void CLASS nikon_e900_load_raw()
-{
-  int offset=0, irow, row, col;
-
-  for (irow=0; irow < height; irow++) {
-    row = irow * 2 % height;
-    if (row == 1)
-      offset = - (-offset & -4096);
-    fseek (ifp, offset, SEEK_SET);
-    offset += raw_width;
-    getbits(-1);
-    for (col=0; col < width; col++)
-      BAYER(row,col) = getbits(10);
-  }
-}
-
 /*
    The Fuji Super CCD is just a Bayer grid rotated 45 degrees.
  */
@@ -1787,38 +1747,38 @@ void CLASS imacon_full_load_raw()
       read_shorts (image[row*width+col], 3);
 }
 
-void CLASS packed_12_load_raw()
+void CLASS packed_load_raw()
 {
-  int vbits=0, rbits=0, bwide, bite, irow, row, col, val, i;
+  int vbits=0, bwide, pwide, rbits, bite, half, irow, row, col, val, i;
   UINT64 bitbuf=0;
 
-  if (raw_width * 2 >= width * 3) {	/* If raw_width is in bytes, */
-    rbits = (bwide = raw_width) * 8;
-    raw_width = raw_width * 2 / 3;	/* convert it to pixels and  */
-    rbits -= raw_width * 12;		/* save the remainder.       */
-  } else bwide = raw_width * 3 / 2;
+  if (raw_width * 8 >= width * tiff_bps)	/* Is raw_width in bytes? */
+       pwide = (bwide = raw_width) * 8 / tiff_bps;
+  else bwide = (pwide = raw_width) * tiff_bps / 8;
+  rbits = bwide * 8 - pwide * tiff_bps;
   if (load_flags & 1) bwide = bwide * 16 / 15;
   fseek (ifp, top_margin*bwide, SEEK_CUR);
   bite = 8 + (load_flags & 24);
+  half = (height+1) >> 1;
   for (irow=0; irow < height; irow++) {
     row = irow;
     if (load_flags & 2 &&
-	(row = irow * 2 % height + irow / (height/2)) == 1 &&
+	(row = irow % half * 2 + irow / half) == 1 &&
 	load_flags & 4) {
       if (vbits=0, tiff_compress)
-	fseek (ifp, data_offset - (-width*height*3/4 & -2048), SEEK_SET);
+	fseek (ifp, data_offset - (-half*bwide & -2048), SEEK_SET);
       else {
 	fseek (ifp, 0, SEEK_END);
-	fseek (ifp, ftell(ifp)/2, SEEK_SET);
+	fseek (ifp, ftell(ifp) >> 3 << 2, SEEK_SET);
       }
     }
-    for (col=0; col < raw_width; col++) {
-      for (vbits -= 12; vbits < 0; vbits += bite) {
+    for (col=0; col < pwide; col++) {
+      for (vbits -= tiff_bps; vbits < 0; vbits += bite) {
 	bitbuf <<= bite;
 	for (i=0; i < bite; i+=8)
 	  bitbuf |= (unsigned) (fgetc(ifp) << i);
       }
-      val = bitbuf << (52-vbits) >> 52;
+      val = bitbuf << (64-tiff_bps-vbits) >> (64-tiff_bps);
       i = (col ^ (bite == 24)) - left_margin;
       if ((unsigned) i < width)
 	BAYER(row,i) = val << (load_flags >> 6);
@@ -1829,8 +1789,8 @@ void CLASS packed_12_load_raw()
     }
     vbits -= rbits;
   }
-  if (load_flags & 32 && raw_width > width)
-    black /= (raw_width - width) * height;
+  if (load_flags & 32 && pwide > width)
+    black /= (pwide - width) * height;
 }
 
 void CLASS unpacked_load_raw()
@@ -1914,7 +1874,7 @@ void CLASS panasonic_load_raw()
     }
 }
 
-void CLASS olympus_e410_load_raw()
+void CLASS olympus_load_raw()
 {
   ushort huff[4096];
   int row, col, nbits, sign, low, high, i, c, w, n, nw;
@@ -1986,26 +1946,6 @@ void CLASS minolta_rd175_load_raw()
   maximum = 0xff << 1;
 }
 
-void CLASS casio_qv5700_load_raw()
-{
-  uchar  data[3232],  *dp;
-  ushort pixel[2576], *pix;
-  int row, col;
-
-  for (row=0; row < height; row++) {
-    fread (data, 1, 3232, ifp);
-    for (dp=data, pix=pixel; dp < data+3220; dp+=5, pix+=4) {
-      pix[0] = (dp[0] << 2) + (dp[1] >> 6);
-      pix[1] = (dp[1] << 4) + (dp[2] >> 4);
-      pix[2] = (dp[2] << 6) + (dp[3] >> 2);
-      pix[3] = (dp[3] << 8) + (dp[4]     );
-    }
-    for (col=0; col < width; col++)
-      BAYER(row,col) = (pixel[col] & 0x3ff);
-  }
-  maximum = 0x3fc;
-}
-
 void CLASS quicktake_100_load_raw()
 {
   uchar pixel[484][644];
@@ -4495,6 +4435,14 @@ void CLASS parse_makernote (int base, int uptag)
       wbi = (get2(),get2());
       shot_order = (get2(),get2());
     }
+    if ((tag == 4 || tag == 0x114) && !strncmp(make,"KONICA",6)) {
+      fseek (ifp, tag == 4 ? 140:160, SEEK_CUR);
+      switch (get2()) {
+	case 72:  flip = 0;  break;
+	case 76:  flip = 6;  break;
+	case 82:  flip = 5;  break;
+      }
+    }
     if (tag == 7 && type == 2 && len > 20)
       fgets (model2, 64, ifp);
     if (tag == 8 && type == 4)
@@ -4638,7 +4586,7 @@ get2_256:
     if ((tag | 0x70) == 0x2070 && type == 4)
       fseek (ifp, get4()+base, SEEK_SET);
     if (tag == 0x2010 && type != 7)
-      load_raw = &CLASS olympus_e410_load_raw;
+      load_raw = &CLASS olympus_load_raw;
     if (tag == 0x2020)
       parse_thumb_note (base, 257, 258);
     if (tag == 0x2040)
@@ -4833,6 +4781,7 @@ void CLASS parse_kodak_ifd (int base)
   unsigned entries, tag, type, len, save;
   int i, c, wbi=-2, wbtemp=6500;
   float mul[3], num;
+  static const int wbtag[]={ 0xfa25,0xfa28,0xfa27,0xfa29,-1,-1,0xfa2a };
 
   entries = get2();
   if (entries > 1024) return;
@@ -4855,6 +4804,9 @@ void CLASS parse_kodak_ifd (int base)
       }
     if (tag == 2317) linear_table (len);
     if (tag == 6020) iso_speed = getint(type);
+    if (tag == 0xfa0d) wbi = fgetc(ifp);
+    if ((unsigned) wbi < 7 && tag == wbtag[wbi])
+      FORC3 cam_mul[c] = get4();
     fseek (ifp, save, SEEK_SET);
   }
 }
@@ -5038,6 +4990,7 @@ int CLASS parse_tiff_ifd (int base)
 	if (cfa == 072) memcpy (cfa_pc,"\005\003\004\001",4);	/* GMCY */
 	goto guess_cfa_pc;
       case 33424:
+      case 65024:
 	fseek (ifp, get4()+base, SEEK_SET);
 	parse_kodak_ifd (base);
 	break;
@@ -5235,7 +5188,7 @@ guess_cfa_pc:
 	data_offset = get4();
 	fseek (ifp, 28, SEEK_CUR);
 	data_offset += get4();
-	load_raw = &CLASS packed_12_load_raw;
+	load_raw = &CLASS packed_load_raw;
 	break;
       case 65026:
 	if (type == 2) fgets (model2, 64, ifp);
@@ -5321,7 +5274,7 @@ void CLASS parse_tiff (int base)
       case 0:  case 1:
 	switch (tiff_bps) {
 	  case  8: load_raw = &CLASS eight_bit_load_raw;	break;
-	  case 12: load_raw = &CLASS packed_12_load_raw;
+	  case 12: load_raw = &CLASS packed_load_raw;
 		   if (tiff_ifd[raw].phint == 2)
 		     load_flags = 6;
 		   if (strncmp(make,"PENTAX",6)) break;
@@ -5329,7 +5282,9 @@ void CLASS parse_tiff (int base)
 	  case 16: load_raw = &CLASS unpacked_load_raw;		break;
 	}
 	if (tiff_ifd[raw].bytes*5 == raw_width*raw_height*8) {
-	  load_raw = &CLASS packed_12_load_raw;
+	  tiff_bps = 12;
+	  maximum = 0xffff;
+	  load_raw = &CLASS packed_load_raw;
 	  load_flags = 273;
 	}
 	break;
@@ -5350,11 +5305,11 @@ void CLASS parse_tiff (int base)
       case 32769:
 	load_flags++;
       case 32773:
-	load_raw = &CLASS packed_12_load_raw;			break;
+	load_raw = &CLASS packed_load_raw;			break;
       case 34713:
 	load_raw = &CLASS nikon_compressed_load_raw;		break;
       case 65535:
-	load_raw = &CLASS pentax_k10_load_raw;			break;
+	load_raw = &CLASS pentax_load_raw;			break;
       case 65000:
 	switch (tiff_ifd[raw].phint) {
 	  case 2: load_raw = &CLASS kodak_rgb_load_raw;   filters = 0;  break;
@@ -6014,7 +5969,7 @@ void CLASS parse_foveon()
 }
 
 /*
-   Thanks to Adobe for providing these excellent CAM -> XYZ matrices!
+   All matrices are from Adobe DNG Converter unless otherwise noted.
  */
 void CLASS adobe_coeff (const char *make, const char *model)
 {
@@ -6058,6 +6013,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 } },
     { "Canon EOS 450D", 0, 0x390d,
 	{ 5784,-262,-821,-7539,15064,2672,-1982,2681,7427 } },
+    { "Canon EOS 500D", 0, 0x3479,
+	{ 4763,712,-646,-6821,14399,2640,-1921,3276,6561 } },
     { "Canon EOS 1000D", 0, 0xe43,
 	{ 6771,-1139,-977,-7818,15123,2928,-1244,1437,7533 } },
     { "Canon EOS-1Ds Mark III", 0, 0x3bb0,
@@ -6076,12 +6033,16 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 } },
     { "Canon EOS", 0, 0,
 	{ 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } },
+    { "Canon PowerShot A530", 0, 0,
+	{ 0 } },	/* don't want the A5 matrix */
     { "Canon PowerShot A50", 0, 0,
 	{ -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 } },
     { "Canon PowerShot A5", 0, 0,
 	{ -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547 } },
     { "Canon PowerShot G10", 0, 0,
 	{ 11093,-3906,-1028,-5047,12492,2879,-1003,1750,5561 } },
+    { "Canon PowerShot G11", 0, 0,
+	{ 0 } },	/* don't want the G1 matrix */
     { "Canon PowerShot G1", 0, 0,
 	{ -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557 } },
     { "Canon PowerShot G2", 0, 0,
@@ -6112,6 +6073,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 8795,-2482,-797,-7804,15403,2573,-1422,1996,7082 } },
     { "Canon PowerShot S70", 0, 0,
 	{ 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } },
+    { "Canon PowerShot A470", 0, 0,	/* DJC */
+	{ 12513,-4407,-1242,-2680,10276,2405,-878,2215,4734 } },
     { "Canon PowerShot A610", 0, 0,	/* DJC */
 	{ 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 } },
     { "Canon PowerShot A620", 0, 0,	/* DJC */
@@ -6126,8 +6089,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 14573,-5482,-1546,-1266,9799,1468,-1040,1912,3810 } },
     { "Canon PowerShot S3 IS", 0, 0,	/* DJC */
 	{ 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 } },
-    { "Canon PowerShot SX1 IS", 0, 0,	/* DJC */
-	{ 10013,-2214,-1111,-3650,11589,2062,342,685,3617 } },
+    { "Canon PowerShot SX1 IS", 0, 0,
+	{ 6578,-259,-502,-5974,13030,3309,-308,1058,4970 } },
     { "Canon PowerShot SX110 IS", 0, 0,	/* DJC */
         { 14134,-5576,-1527,-1991,10719,1273,-1158,1929,3581 } },
     { "CASIO EX-S20", 0, 0,		/* DJC */
@@ -6232,6 +6195,10 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 10511,-3836,-1102,-6946,14587,2558,-1481,1792,6246 } },
     { "KODAK P880", 0, 0xfff,
 	{ 12805,-4662,-1376,-7480,15267,2360,-1626,2194,7904 } },
+    { "KODAK EasyShare Z980", 0, 0,
+	{ 11313,-3559,-1101,-3893,11891,2257,-1214,2398,4908 } },
+    { "KODAK EASYSHARE Z1015", 0, 0xef1,
+	{ 11265,-4286,-992,-4694,12343,2647,-1090,1523,5447 } },
     { "Leaf CMost", 0, 0,
 	{ 3952,2189,449,-6701,14585,2275,-4536,7349,6536 } },
     { "Leaf Valeo 6", 0, 0,
@@ -6276,14 +6243,26 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 7702,-2245,-975,-9114,17242,1875,-2679,3055,8521 } },
     { "NIKON D1", 0, 0, /* multiplied by 2.218750, 1.0, 1.148438 */
 	{ 16772,-4726,-2141,-7611,15713,1972,-2846,3494,9521 } },
+    { "NIKON D200", 0, 0xfbc,
+	{ 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 } },
     { "NIKON D2H", 0, 0,
 	{ 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 } },
     { "NIKON D2X", 0, 0,
 	{ 10231,-2769,-1255,-8301,15900,2552,-797,680,7148 } },
+    { "NIKON D3000", 0, 0,
+	{ 8736,-2458,-935,-9075,16894,2251,-1354,1242,8263 } },
+    { "NIKON D300", 0, 0,
+	{ 9030,-1992,-715,-8465,16302,2255,-2689,3217,8069 } },
+    { "NIKON D3X", 0, 0,
+	{ 7171,-1986,-648,-8085,15555,2718,-2170,2512,7457 } },
+    { "NIKON D3", 0, 0,
+	{ 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } },
     { "NIKON D40X", 0, 0,
 	{ 8819,-2543,-911,-9025,16928,2151,-1329,1213,8449 } },
     { "NIKON D40", 0, 0,
 	{ 6992,-1668,-806,-8138,15748,2543,-874,850,7897 } },
+    { "NIKON D5000", 0, 0xf00,
+	{ 7309,-1403,-519,-8474,16008,2622,-2433,2826,8064 } },
     { "NIKON D50", 0, 0,
 	{ 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } },
     { "NIKON D60", 0, 0,
@@ -6296,14 +6275,6 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 8629,-2410,-883,-9055,16940,2171,-1490,1363,8520 } },
     { "NIKON D90", 0, 0xf00,
 	{ 7309,-1403,-519,-8474,16008,2622,-2434,2826,8064 } },
-    { "NIKON D200", 0, 0xfbc,
-	{ 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 } },
-    { "NIKON D300", 0, 0,
-	{ 9030,-1992,-715,-8465,16302,2255,-2689,3217,8069 } },
-    { "NIKON D3X", 0, 0,
-	{ 7171,-1986,-648,-8085,15555,2718,-2170,2512,7457 } },
-    { "NIKON D3", 0, 0,
-	{ 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } },
     { "NIKON E950", 0, 0x3dd,		/* DJC */
 	{ -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 } },
     { "NIKON E995", 0, 0,	/* copied from E5000 */
@@ -6350,7 +6321,7 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 } },
     { "OLYMPUS E-330", 0, 0,
 	{ 8961,-2473,-1084,-7979,15990,2067,-2319,3035,8249 } },
-    { "OLYMPUS E-30", 0, 0,
+    { "OLYMPUS E-30", 0, 0xfbc,
 	{ 8144,-1861,-1111,-7763,15894,1929,-1865,2542,7607 } },
     { "OLYMPUS E-3", 0, 0xf99,
 	{ 9487,-2875,-1115,-7533,15606,2010,-1618,2100,7389 } },
@@ -6360,12 +6331,18 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 8856,-2582,-1026,-7761,15766,2082,-2009,2575,7469 } },
     { "OLYMPUS E-420", 0, 0xfd7,
 	{ 8746,-2425,-1095,-7594,15612,2073,-1780,2309,7416 } },
-    { "OLYMPUS E-500", 0, 0,
+    { "OLYMPUS E-450", 0, 0xfd2,
+	{ 8745,-2425,-1095,-7594,15613,2073,-1780,2309,7416 } },
+    { "OLYMPUS E-500", 0, 0xfff0,
 	{ 8136,-1968,-299,-5481,13742,1871,-2556,4205,6630 } },
     { "OLYMPUS E-510", 0, 0xf6a,
 	{ 8785,-2529,-1033,-7639,15624,2112,-1783,2300,7817 } },
     { "OLYMPUS E-520", 0, 0xfd2,
 	{ 8344,-2322,-1020,-7596,15635,2048,-1748,2269,7287 } },
+    { "OLYMPUS E-620", 0, 0xfb9,
+	{ 8453,-2198,-1092,-7609,15681,2008,-1725,2337,7824 } },
+    { "OLYMPUS E-P1", 0, 0xffd,
+	{ 8343,-2050,-1021,-7715,15705,2103,-1831,2380,8235 } },
     { "OLYMPUS SP350", 0, 0,
 	{ 12078,-4836,-1069,-6671,14306,2578,-786,939,7418 } },
     { "OLYMPUS SP3", 0, 0,
@@ -6402,6 +6379,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 11057,-3604,-1155,-5152,13046,2329,-282,375,8104 } },
     { "PENTAX K-m", 0, 0,
 	{ 11057,-3604,-1155,-5152,13046,2329,-282,375,8104 } },
+    { "PENTAX K-7", 0, 0,
+	{ 9142,-2947,-678,-8648,16967,1663,-2224,2898,8615 } },
     { "Panasonic DMC-FZ8", 0, 0xf7f0,
 	{ 8986,-2755,-802,-6341,13575,3077,-1476,2144,6379 } },
     { "Panasonic DMC-FZ18", 0, 0,
@@ -6410,6 +6389,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 10109,-3488,-993,-5412,12812,2916,-1305,2140,5543 } },
     { "Panasonic DMC-FZ30", 0, 0xf94c,
 	{ 10976,-4029,-1141,-7918,15491,2600,-1670,2071,8246 } },
+    { "Panasonic DMC-FZ35", 147, 0xfff,
+	{ 9938,-2780,-890,-4604,12393,2480,-1117,2304,4620 } },
     { "Panasonic DMC-FZ50", 0, 0xfff0,	/* aka "LEICA V-LUX1" */
 	{ 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } },
     { "Panasonic DMC-L10", 15, 0xf96,
@@ -6428,8 +6409,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 9082,-2907,-925,-6119,13377,3058,-1797,2641,5609 } },
     { "Panasonic DMC-G1", 15, 0xfff,
 	{ 8199,-2065,-1056,-8124,16156,2033,-2458,3022,7220 } },
-    { "Panasonic DMC-GH1", 15, 0xfff,	/* DJC */
-	{ 7808,-2387,-480,-2859,10002,2857,-1001,2012,4915 } },
+    { "Panasonic DMC-GH1", 15, 0xfff,
+	{ 6299,-1466,-532,-6535,13852,2969,-2331,3112,5984 } },
     { "Phase One H 20", 0, 0,		/* DJC */
 	{ 1313,1855,-109,-6715,15908,808,-327,1840,6020 } },
     { "Phase One P 2", 0, 0,
@@ -6456,10 +6437,16 @@ void CLASS adobe_coeff (const char *make, const char *model)
 	{ 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } },
     { "SONY DSLR-A200", 0, 0,
 	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
+    { "SONY DSLR-A230", 0, 0,	/* copied */
+	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
     { "SONY DSLR-A300", 0, 0,
 	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
+    { "SONY DSLR-A330", 0, 0,
+	{ 9847,-3091,-929,-8485,16346,2225,-714,595,7103 } },
     { "SONY DSLR-A350", 0, 0xffc,
 	{ 6038,-1484,-578,-9146,16746,2513,-875,746,7217 } },
+    { "SONY DSLR-A380", 0, 0,	/* copied */
+	{ 6038,-1484,-578,-9146,16746,2513,-875,746,7217 } },
     { "SONY DSLR-A700", 254, 0x1ffe,
 	{ 5775,-805,-359,-8574,16295,2391,-1943,2341,7249 } },
     { "SONY DSLR-A900", 254, 0x1ffe,
@@ -6474,9 +6461,11 @@ void CLASS adobe_coeff (const char *make, const char *model)
     if (!strncmp (name, table[i].prefix, strlen(table[i].prefix))) {
       if (table[i].black)   black   = (ushort) table[i].black;
       if (table[i].maximum) maximum = (ushort) table[i].maximum;
-      for (j=0; j < 12; j++)
-	cam_xyz[0][j] = table[i].trans[j] / 10000.0;
-      cam_xyz_coeff (cam_xyz);
+      if (table[i].trans[0]) {
+	for (j=0; j < 12; j++)
+	  cam_xyz[0][j] = table[i].trans[j] / 10000.0;
+	cam_xyz_coeff (cam_xyz);
+      }
       break;
     }
 }
@@ -6520,6 +6509,31 @@ short CLASS guess_byte_order (int words)
   return sum[0] < sum[1] ? 0x4d4d : 0x4949;
 }
 
+float CLASS find_green (int bps, int bite, int off0, int off1)
+{
+  UINT64 bitbuf=0;
+  int vbits, col, i, c;
+  ushort img[2][2064];
+  double sum[]={0,0};
+
+  FORC(2) {
+    fseek (ifp, c ? off1:off0, SEEK_SET);
+    for (vbits=col=0; col < width; col++) {
+      for (vbits -= bps; vbits < 0; vbits += bite) {
+	bitbuf <<= bite;
+	for (i=0; i < bite; i+=8)
+	  bitbuf |= (unsigned) (fgetc(ifp) << i);
+      }
+      img[c][col] = bitbuf << (64-bps-vbits) >> (64-bps);
+    }
+  }
+  FORC(width-1) {
+    sum[ c & 1] += ABS(img[0][c]-img[1][c+1]);
+    sum[~c & 1] += ABS(img[1][c]-img[0][c+1]);
+  }
+  return 100 * log(sum[0]/sum[1]);
+}
+
 /*
    Identify which camera created this file, and set global variables
    accordingly.
@@ -6527,7 +6541,7 @@ short CLASS guess_byte_order (int words)
 void CLASS identify()
 {
   char head[32], *cp;
-  unsigned hlen, fsize, i, c, is_canon;
+  int hlen, fsize, i, c, is_canon;
   struct jhead jh;
   static const struct {
     int fsize;
@@ -6544,7 +6558,6 @@ void CLASS identify()
     {  6166488, "Kodak",    "C603"            ,0 },
     {  9116448, "Kodak",    "C603y"           ,0 },
     {   311696, "ST Micro", "STV680 VGA"      ,0 },  /* SPYz */
-    {   614400, "Kodak",    "KAI-0340"        ,0 },
     {   787456, "Creative", "PC-CAM 600"      ,0 },
     {  1138688, "Minolta",  "RD175"           ,0 },
     {  3840000, "Foculus",  "531C"            ,0 },
@@ -6564,6 +6577,7 @@ void CLASS identify()
     {  6653280, "Canon",    "PowerShot A530"  ,0 },
     {  6573120, "Canon",    "PowerShot A610"  ,0 },
     {  9219600, "Canon",    "PowerShot A620"  ,0 },
+    {  9243240, "Canon",    "PowerShot A470"  ,0 },
     { 10341600, "Canon",    "PowerShot A720"  ,0 },
     { 10383120, "Canon",    "PowerShot A630"  ,0 },
     { 12945240, "Canon",    "PowerShot A640"  ,0 },
@@ -6591,6 +6605,8 @@ void CLASS identify()
     {  4948608, "CASIO",    "EX-S100"         ,1 },
     {  7542528, "CASIO",    "EX-Z50"          ,1 },
     {  7753344, "CASIO",    "EX-Z55"          ,1 },
+    {  7816704, "CASIO",    "EX-Z60"          ,1 },
+    { 10843712, "CASIO",    "EX-Z75"          ,1 },
     {  7426656, "CASIO",    "EX-P505"         ,1 },
     {  9313536, "CASIO",    "EX-P600"         ,1 },
     { 10979200, "CASIO",    "EX-P700"         ,1 },
@@ -6632,7 +6648,6 @@ void CLASS identify()
     FORC3 rgb_cam[c][i] = c == i;
   }
   colors = 3;
-  tiff_bps = 12;
   for (i=0; i < 0x4000; i++) curve[i] = i;
 
   order = get2();
@@ -6730,7 +6745,8 @@ void CLASS identify()
     if (strstr (make, corp[i]))		/* Simplify company names */
 	strcpy (make, corp[i]);
   if (!strncmp (make,"KODAK",5) &&
-	((cp = strstr(model,"DIGITAL CAMERA")) ||
+	((cp = strstr(model," DIGITAL CAMERA")) ||
+	 (cp = strstr(model," Digital Camera")) ||
 	 (cp = strstr(model,"FILE VERSION"))))
      *cp = 0;
   cp = make + strlen(make);		/* Remove trailing spaces */
@@ -6745,7 +6761,6 @@ void CLASS identify()
   desc[511] = artist[63] = make[63] = model[63] = model2[63] = 0;
   if (!is_raw) goto notraw;
 
-  if (!maximum) maximum = (1 << tiff_bps) - 1;
   if (!height) height = raw_height;
   if (!width)  width  = raw_width;
   if (fuji_width) {
@@ -6757,6 +6772,9 @@ void CLASS identify()
     { height  = 2616;   width  = 3896; }
   if (height == 3136 && width == 4864)	/* Pentax K20D */
     { height  = 3124;   width  = 4688; }
+  if (height == 3136 && width == 4736)	/* Pentax K-7 */
+    { height  = 3122;   width  = 4684;
+      top_margin = 2;  filters = 0x16161616; }
   if (height == 3014 && width == 4096)	/* Ricoh GX200 */
 			width  = 4014;
   if (dng_version) {
@@ -6774,12 +6792,12 @@ void CLASS identify()
 	&CLASS lossless_jpeg_load_raw : &CLASS canon_compressed_load_raw;
   if (!strcmp(make,"NIKON")) {
     if (!load_raw)
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
     if (model[0] == 'E')
       load_flags |= !data_offset << 2 | 2;
   }
   if (!strcmp(make,"CASIO")) {
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     maximum = 0xf7f;
   }
 
@@ -6814,20 +6832,20 @@ void CLASS identify()
     pixel_aspect = 256/235.0;
     colors = 4;
     filters = 0x1e4e1e4e;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A50")) {
     height =  968;
     width  = 1290;
     raw_width = 1320;
     colors = 4;
     filters = 0x1b4e4b1e;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot Pro70")) {
     height = 1024;
     width  = 1552;
     colors = 4;
     filters = 0x1e4b4e1b;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot SD300")) {
     height = 1752;
     width  = 2344;
@@ -6835,7 +6853,7 @@ void CLASS identify()
     raw_width  = 2400;
     top_margin  = 12;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A460")) {
     height = 1960;
     width  = 2616;
@@ -6843,7 +6861,7 @@ void CLASS identify()
     raw_width  = 2664;
     top_margin  = 4;
     left_margin = 4;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A530")) {
     height = 1984;
     width  = 2620;
@@ -6851,8 +6869,7 @@ void CLASS identify()
     raw_width  = 2672;
     top_margin  = 6;
     left_margin = 10;
-    load_raw = &CLASS canon_a5_load_raw;
-    raw_color = 0;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A610")) {
     if (canon_s2is()) strcpy (model+10, "S2 IS");
     height = 1960;
@@ -6861,7 +6878,7 @@ void CLASS identify()
     raw_width  = 2672;
     top_margin  = 8;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A620")) {
     height = 2328;
     width  = 3112;
@@ -6869,7 +6886,15 @@ void CLASS identify()
     raw_width  = 3152;
     top_margin  = 12;
     left_margin = 36;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
+  } else if (!strcmp(model,"PowerShot A470")) {
+    height = 2328;
+    width  = 3096;
+    raw_height = 2346;
+    raw_width  = 3152;
+    top_margin  = 6;
+    left_margin = 12;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A720")) {
     height = 2472;
     width  = 3298;
@@ -6877,7 +6902,7 @@ void CLASS identify()
     raw_width  = 3336;
     top_margin  = 5;
     left_margin = 6;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A630")) {
     height = 2472;
     width  = 3288;
@@ -6885,7 +6910,7 @@ void CLASS identify()
     raw_width  = 3344;
     top_margin  = 6;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A640")) {
     height = 2760;
     width  = 3672;
@@ -6893,7 +6918,7 @@ void CLASS identify()
     raw_width  = 3736;
     top_margin  = 6;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A650")) {
     height = 3024;
     width  = 4032;
@@ -6901,7 +6926,7 @@ void CLASS identify()
     raw_width  = 4104;
     top_margin  = 12;
     left_margin = 48;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot S3 IS")) {
     height = 2128;
     width  = 2840;
@@ -6909,7 +6934,11 @@ void CLASS identify()
     raw_width  = 2888;
     top_margin  = 8;
     left_margin = 44;
-    load_raw = &CLASS canon_a5_load_raw;
+canon_a5:
+    tiff_bps = 10;
+    load_raw = &CLASS packed_load_raw;
+    load_flags = 40;
+    if (raw_width > 1600) zero_is_bad = 1;
   } else if (!strcmp(model,"PowerShot SX110 IS")) {
     height = 2760;
     width  = 3684;
@@ -6917,7 +6946,7 @@ void CLASS identify()
     raw_width  = 3720;
     top_margin  = 12;
     left_margin = 6;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 40;
     zero_is_bad = 1;
   } else if (!strcmp(model,"PowerShot Pro90 IS")) {
@@ -6978,6 +7007,11 @@ void CLASS identify()
     top_margin  = 12;
     left_margin = 74;
     goto canon_cr2;
+  } else if (is_canon && raw_width == 3744) {
+    height = 2760;
+    width  = 3684;
+    top_margin  = 16;
+    left_margin = 8;
   } else if (is_canon && raw_width == 3944) {
     height = 2602;
     width  = 3908;
@@ -7027,6 +7061,8 @@ void CLASS identify()
     top_margin = unique_id == 0x80000261 ? 51:26;
     left_margin = 62;
     raw_width = width *= 4;
+    if (unique_id == 0x80000252)
+      adobe_coeff ("Canon","EOS 500D");
     goto canon_cr2;
   } else if (is_canon && raw_width == 1448) {
     top_margin  = 51;
@@ -7052,13 +7088,16 @@ canon_cr2:
     pixel_aspect = 0.5;
   } else if (!strcmp(model,"D40X") ||
 	     !strcmp(model,"D60")  ||
-	     !strcmp(model,"D80")) {
+	     !strcmp(model,"D80")  ||
+	     !strcmp(model,"D3000")) {
     height -= 3;
     width  -= 4;
   } else if (!strcmp(model,"D3")   ||
 	     !strcmp(model,"D700")) {
     width -= 4;
     left_margin = 2;
+  } else if (!strcmp(model,"D5000")) {
+    width -= 42;
   } else if (!strncmp(model,"D40",3) ||
 	     !strncmp(model,"D50",3) ||
 	     !strncmp(model,"D70",3)) {
@@ -7067,7 +7106,7 @@ canon_cr2:
     width -= 42;
   } else if (!strcmp(model,"D100")) {
     if (tiff_compress == 34713 && !nikon_is_compressed()) {
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
       load_flags |= 1;
       raw_width = (width += 3) + 3;
     }
@@ -7081,7 +7120,7 @@ canon_cr2:
   } else if (!strncmp(model,"D2X",3)) {
     if (width == 3264) width -= 32;
     else width -= 8;
-  } else if (!strcmp(model,"D300")) {
+  } else if (!strncmp(model,"D300",4)) {
     width -= 32;
   } else if (!strcmp(model,"COOLPIX P6000")) {
     load_flags = 24;
@@ -7090,7 +7129,6 @@ canon_cr2:
     height = 963;
     width = 1287;
     raw_width = 1632;
-    load_raw = &CLASS nikon_e900_load_raw;
     maximum = 0x3f4;
     colors = 4;
     filters = 0x1e1e1e1e;
@@ -7098,20 +7136,24 @@ canon_cr2:
     pre_mul[0] = 1.2085;
     pre_mul[1] = 1.0943;
     pre_mul[3] = 1.1103;
+    goto e900;
   } else if (fsize == 2465792) {
     height = 1203;
     width  = 1616;
     raw_width = 2048;
-    load_raw = &CLASS nikon_e900_load_raw;
     colors = 4;
     filters = 0x4b4b4b4b;
     adobe_coeff ("NIKON","E950");
+e900:
+    tiff_bps = 10;
+    load_raw = &CLASS packed_load_raw;
+    load_flags = 6;
   } else if (fsize == 4771840) {
     height = 1540;
     width  = 2064;
     colors = 4;
     filters = 0xe1e1e1e1;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 6;
     if (!timestamp && nikon_e995())
       strcpy (model, "E995");
@@ -7137,7 +7179,7 @@ cp_e2500:
   } else if (fsize == 4775936) {
     height = 1542;
     width  = 2064;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
     if (!timestamp) nikon_3700();
     if (model[0] == 'E' && atoi(model+1) < 3700)
@@ -7146,6 +7188,15 @@ cp_e2500:
       flip = 1;
       filters = 0x16161616;
     }
+    if (make[0] == 'O') {
+      i = find_green (12, 32, 0, fsize/2);
+      c = find_green (12, 32, 0, 3096);
+      if (abs(i) < abs(c)) {
+	SWAP(i,c);
+	load_flags = 24;
+      }
+      if (i < 0) filters = 0x61616161;
+    }
   } else if (fsize == 5869568) {
     height = 1710;
     width  = 2288;
@@ -7154,7 +7205,7 @@ cp_e2500:
       strcpy (make, "Minolta");
       strcpy (model,"DiMAGE Z2");
     }
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 6 + 24*(make[0] == 'M');
   } else if (!strcmp(model,"E4500")) {
     height = 1708;
@@ -7170,7 +7221,7 @@ cp_e2500:
     height = 2118;
     width  = 2832;
     maximum = 0xf83;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
   } else if (!strcmp(model,"FinePix S5100") ||
 	     !strcmp(model,"FinePix S5500")) {
@@ -7215,13 +7266,14 @@ cp_e2500:
     if (!strncmp(model,"DiMAGE A",8)) {
       if (!strcmp(model,"DiMAGE A200"))
 	filters = 0x49494949;
-      load_raw = &CLASS packed_12_load_raw;
+      tiff_bps = 12;
+      load_raw = &CLASS packed_load_raw;
     } else if (!strncmp(model,"ALPHA",5) ||
 	       !strncmp(model,"DYNAX",5) ||
 	       !strncmp(model,"MAXXUM",6)) {
       sprintf (model+20, "DYNAX %-10s", model+6+(model[0]=='M'));
       adobe_coeff (make, model+20);
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
     } else if (!strncmp(model,"DiMAGE G",8)) {
       if (model[8] == '4') {
 	height = 1716;
@@ -7257,19 +7309,19 @@ konica_400z:
       height = 1544;
       width  = 2068;
       raw_width = 3136;
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
       maximum = 0xf7c;
     }
   } else if (fsize == 6114240) {
     height = 1737;
     width  = 2324;
     raw_width = 3520;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     maximum = 0xf7a;
   } else if (!strcmp(model,"Optio 750Z")) {
     height = 2302;
     width  = 3072;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
   } else if (!strcmp(model,"DC-833m")) {
     height = 2448;
@@ -7292,12 +7344,6 @@ konica_400z:
     flip = 2;
     filters = 0x16161616;
     black = 16;
-  } else if (!strcmp(model,"KAI-0340")) {
-    height = 477;
-    width  = 640;
-    order = 0x4949;
-    data_offset = 3840;
-    load_raw = &CLASS unpacked_load_raw;
   } else if (!strcmp(model,"N95")) {
     height = raw_height - (top_margin = 2);
   } else if (!strcmp(model,"531C")) {
@@ -7504,16 +7550,21 @@ lx3:	filters = 0x16161616;
 	zero_is_bad = 1;
 	adobe_coeff ("Panasonic","DMC-LX1");  break;
       case 4060:
-	if (!strcmp(model,"DMC-GH1")) goto gh1;
 	width = 3982;
 	if (height == 2250) goto lx3;
 	width = 4018;
+	filters = 0x16161616;
+	if (!strncmp(model,"DMC-FZ3",7)) {
+	  height -= 2;
+	  adobe_coeff ("Panasonic","DMC-FZ35");  break;
+	}
 	filters = 0x49494949;
+	if (!strcmp(model,"DMC-GH1")) break;
 	zero_is_bad = 1;
 	adobe_coeff ("Panasonic","DMC-G1");  break;
       case 4172:
       case 4396:
-gh1:	width -= 28;
+	width -= 28;
 	filters = 0x49494949;
 	adobe_coeff ("Panasonic","DMC-GH1");  break;
       case 4290:
@@ -7536,13 +7587,14 @@ gh1:	width -= 28;
     height = 1718;
     width  = 2304;
     filters = 0x16161616;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
   } else if (!strcmp(make,"OLYMPUS")) {
     height += height & 1;
     filters = exif_cfa;
     if (width == 4100) width -= 4;
-    if (load_raw == &CLASS olympus_e410_load_raw) {
+    if (load_raw == &CLASS olympus_load_raw) {
+      tiff_bps = 12;
       black >>= 4;
     } else if (!strcmp(model,"E-10") ||
 	      !strncmp(model,"E-20",4)) {
@@ -7568,7 +7620,7 @@ gh1:	width -= 28;
     width  = 3072;
     filters = 0x61616161;
     data_offset = 0x1a00;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
   } else if (!strcmp(model,"DSC-F828")) {
     width = 3288;
     left_margin = 5;
@@ -7588,6 +7640,8 @@ gh1:	width -= 28;
     order = 0x4d4d;
   } else if (!strcmp(model,"DSLR-A100")) {
     height--;
+    width = ++raw_width;
+    filters = 0x61616161;
   } else if (!strcmp(model,"DSLR-A350")) {
     height -= 4;
   } else if (!strcmp(model,"PIXL")) {
@@ -7597,7 +7651,12 @@ gh1:	width -= 28;
   } else if (!strcmp(model,"C603v")) {
     height = 480;
     width  = 640;
-    goto c603v;
+    if (fsize < 614400 || find_green (16, 16, 3840, 5120) < 25) goto c603v;
+    strcpy (model,"KAI-0340");
+    height -= 3;
+    data_offset = 3840;
+    order = 0x4949;
+    load_raw = &CLASS unpacked_load_raw;
   } else if (!strcmp(model,"C603y")) {
     height = 2134;
     width  = 2848;
@@ -7626,8 +7685,13 @@ c603:
   } else if (!strcmp(model,"EASYSHARE Z1015 IS")) {
     height = 2742;
     width  = 3664;
+    goto ezshare;
+  } else if (!strcmp(model,"EasyShare Z980")) {
+    height = 3006;
+    width  = 4016;
+ezshare:
     data_offset = 0x15000;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
   } else if (!strcasecmp(make,"KODAK")) {
     if (filters == UINT_MAX) filters = 0x61616161;
     if (!strncmp(model,"NC2000",6)) {
@@ -7778,7 +7842,8 @@ c603:
   } else if (!strcmp(model,"QV-5700")) {
     height = 1924;
     width  = 2576;
-    load_raw = &CLASS casio_qv5700_load_raw;
+    raw_width = 3232;
+    tiff_bps = 10;
   } else if (!strcmp(model,"QV-R41")) {
     height = 1720;
     width  = 2312;
@@ -7805,6 +7870,16 @@ c603:
     height = 1960;
     width  = 2570;
     raw_width = 3904;
+  } else if (!strcmp(model,"EX-Z60")) {
+    height = 2145;
+    width  = 2833;
+    raw_width = 3584;
+    filters = 0x16161616;
+    tiff_bps = 10;
+  } else if (!strcmp(model,"EX-Z75")) {
+    height = 2321;
+    width  = 3089;
+    raw_width = 4672;
   } else if (!strcmp(model,"EX-P505")) {
     height = 1928;
     width  = 2568;
@@ -7833,6 +7908,8 @@ c603:
     }
   }
 dng_skip:
+  if (!tiff_bps) tiff_bps = 12;
+  if (!maximum) maximum = (1 << tiff_bps) - 1;
   if (!load_raw || height < 22) is_raw = 0;
 #ifdef NO_JPEG
   if (load_raw == &CLASS kodak_jpeg_load_raw) {
@@ -8354,7 +8431,7 @@ int CLASS main (int argc, const char **argv)
   argv[argc] = "";
   for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; ) {
     opt = argv[arg++][1];
-    if ((cp = strchr (sp="nbrkStqmHACg", opt)))
+    if ((cp = (char *) strchr (sp="nbrkStqmHACg", opt)))
       for (i=0; i < "114111111422"[cp-sp]-'0'; i++)
 	if (!isdigit(argv[arg+i][0])) {
 	  fprintf (stderr,_("Non-numeric argument to \"-%c\"\n"), opt);
diff --git a/lib/libfspotraw/LibRaw/internal/dcraw_common.cpp b/lib/libfspotraw/LibRaw/internal/dcraw_common.cpp
index c0bacfd..86900ef 100644
--- a/lib/libfspotraw/LibRaw/internal/dcraw_common.cpp
+++ b/lib/libfspotraw/LibRaw/internal/dcraw_common.cpp
@@ -1,6 +1,6 @@
 /* 
    GENERATED FILE, DO NOT EDIT
-   Generated from dcraw/dcraw.c at Tue Jul 21 20:35:34 2009
+   Generated from dcraw/dcraw.c at Wed Sep  2 11:06:05 2009
    Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
    for copyright information.
 */
@@ -333,37 +333,6 @@ int CLASS canon_s2is()
   return 0;
 }
 
-void CLASS canon_a5_load_raw()
-{
-  ushort data[2565], *dp, pixel;
-  int vbits=0, buf=0, row, col, bc=0;
-
-  order = 0x4949;
-  for (row=-top_margin; row < raw_height-top_margin; row++) {
-    read_shorts (dp=data, raw_width * 10 / 16);
-    for (col=-left_margin; col < raw_width-left_margin; col++) {
-      if ((vbits -= 10) < 0)
-	buf = (vbits += 16, (buf << 16) + *dp++);
-      pixel = buf >> vbits & 0x3ff;
-#ifdef LIBRAW_LIBRARY_BUILD
-          ushort *dfp = get_masked_pointer(row+top_margin,col+left_margin);
-          if(dfp) *dfp = pixel;
-#endif
-      if ((unsigned) row < height && (unsigned) col < width)
-	BAYER(row,col) = pixel;
-      else if (col > 1-left_margin && col != width)
-	black += (bc++,pixel);
-    }
-  }
-  if (bc) black /= bc;
-  maximum = 0x3ff;
-
-#ifdef LIBRAW_LIBRARY_BUILD
-  if(!(filtering_mode & LIBRAW_FILTERING_NOZEROES))
-#endif
-  if (raw_width > 1600) remove_zeroes();
-}
-
 /*
    getbits(-1) initializes the buffer
    getbits(n) where 0 <= n <= 25 returns an n-bit integer
@@ -935,7 +904,7 @@ void CLASS adobe_dng_load_raw_nc()
   free (pixel);
 }
 
-void CLASS pentax_k10_load_raw()
+void CLASS pentax_load_raw()
 {
   ushort bit[2][13], huff[4097];
   int row, col, diff, c, i;
@@ -959,8 +928,8 @@ void CLASS pentax_k10_load_raw()
       diff = ljpeg_diff (huff);
       if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
       else	   hpred[col & 1] += diff;
-      if (col < width && row < height)
-	BAYER(row,col) = hpred[col & 1];
+      if ((unsigned) (row-top_margin) < height && col < width)
+	BAYER(row-top_margin,col) = hpred[col & 1];
 #ifdef LIBRAW_LIBRARY_BUILD
       else
         {
@@ -1156,23 +1125,6 @@ int CLASS minolta_z2()
   return nz > 20;
 }
 
-/* Here raw_width is in bytes, not pixels. */
-void CLASS nikon_e900_load_raw()
-{
-  int offset=0, irow, row, col;
-
-  for (irow=0; irow < height; irow++) {
-    row = irow * 2 % height;
-    if (row == 1)
-      offset = - (-offset & -4096);
-    fseek (ifp, offset, SEEK_SET);
-    offset += raw_width;
-    getbits(-1);
-    for (col=0; col < width; col++)
-      BAYER(row,col) = getbits(10);
-  }
-}
-
 /*
    The Fuji Super CCD is just a Bayer grid rotated 45 degrees.
  */
@@ -1693,12 +1645,12 @@ void CLASS hasselblad_load_raw()
 	  diff -= (1 << len[c]) - 1;
 	if (diff == 65535) diff = -32768;
 	pred[c] += diff;
-	if (row >= 0 && (unsigned)(col+c) < width)
+	if (row >= 0 && row < height && (unsigned)(col+c) < width)
 	  BAYER(row,col+c) = pred[c];
 #ifdef LIBRAW_LIBRARY_BUILD
         else
             {
-                ushort *dfp = get_masked_pointer(row+top_margin,col+left_margin);
+                ushort *dfp = get_masked_pointer(row+top_margin,col+left_margin+c);
                 if(dfp) *dfp = pred[c];
             }
 #endif
@@ -1780,38 +1732,38 @@ void CLASS imacon_full_load_raw()
       read_shorts (image[row*width+col], 3);
 }
 
-void CLASS packed_12_load_raw()
+void CLASS packed_load_raw()
 {
-  int vbits=0, rbits=0, bwide, bite, irow, row, col, val, i;
+  int vbits=0, bwide, pwide, rbits, bite, half, irow, row, col, val, i;
   UINT64 bitbuf=0;
 
-  if (raw_width * 2 >= width * 3) {	/* If raw_width is in bytes, */
-    rbits = (bwide = raw_width) * 8;
-    raw_width = raw_width * 2 / 3;	/* convert it to pixels and  */
-    rbits -= raw_width * 12;		/* save the remainder.       */
-  } else bwide = raw_width * 3 / 2;
+  if (raw_width * 8 >= width * tiff_bps)	/* Is raw_width in bytes? */
+       pwide = (bwide = raw_width) * 8 / tiff_bps;
+  else bwide = (pwide = raw_width) * tiff_bps / 8;
+  rbits = bwide * 8 - pwide * tiff_bps;
   if (load_flags & 1) bwide = bwide * 16 / 15;
   fseek (ifp, top_margin*bwide, SEEK_CUR);
   bite = 8 + (load_flags & 24);
+  half = (height+1) >> 1;
   for (irow=0; irow < height; irow++) {
     row = irow;
     if (load_flags & 2 &&
-	(row = irow * 2 % height + irow / (height/2)) == 1 &&
+	(row = irow % half * 2 + irow / half) == 1 &&
 	load_flags & 4) {
       if (vbits=0, tiff_compress)
-	fseek (ifp, data_offset - (-width*height*3/4 & -2048), SEEK_SET);
+	fseek (ifp, data_offset - (-half*bwide & -2048), SEEK_SET);
       else {
 	fseek (ifp, 0, SEEK_END);
-	fseek (ifp, ftell(ifp)/2, SEEK_SET);
+	fseek (ifp, ftell(ifp) >> 3 << 2, SEEK_SET);
       }
     }
-    for (col=0; col < raw_width; col++) {
-      for (vbits -= 12; vbits < 0; vbits += bite) {
+    for (col=0; col < pwide; col++) {
+      for (vbits -= tiff_bps; vbits < 0; vbits += bite) {
 	bitbuf <<= bite;
 	for (i=0; i < bite; i+=8)
 	  bitbuf |= (unsigned) (fgetc(ifp) << i);
       }
-      val = bitbuf << (52-vbits) >> 52;
+      val = bitbuf << (64-tiff_bps-vbits) >> (64-tiff_bps);
       i = (col ^ (bite == 24)) - left_margin;
       if ((unsigned) i < width)
 	BAYER(row,i) = val << (load_flags >> 6);
@@ -1830,8 +1782,8 @@ void CLASS packed_12_load_raw()
     }
     vbits -= rbits;
   }
-  if (load_flags & 32 && raw_width > width)
-    black /= (raw_width - width) * height;
+  if (load_flags & 32 && pwide > width)
+    black /= (pwide - width) * height;
 }
 
 void CLASS unpacked_load_raw()
@@ -1965,7 +1917,7 @@ void CLASS panasonic_load_raw()
     }
 }
 
-void CLASS olympus_e410_load_raw()
+void CLASS olympus_load_raw()
 {
   ushort huff[4096];
   int row, col, nbits, sign, low, high, i, c, w, n, nw;
@@ -2037,26 +1989,6 @@ void CLASS minolta_rd175_load_raw()
   maximum = 0xff << 1;
 }
 
-void CLASS casio_qv5700_load_raw()
-{
-  uchar  data[3232],  *dp;
-  ushort pixel[2576], *pix;
-  int row, col;
-
-  for (row=0; row < height; row++) {
-    fread (data, 1, 3232, ifp);
-    for (dp=data, pix=pixel; dp < data+3220; dp+=5, pix+=4) {
-      pix[0] = (dp[0] << 2) + (dp[1] >> 6);
-      pix[1] = (dp[1] << 4) + (dp[2] >> 4);
-      pix[2] = (dp[2] << 6) + (dp[3] >> 2);
-      pix[3] = (dp[3] << 8) + (dp[4]     );
-    }
-    for (col=0; col < width; col++)
-      BAYER(row,col) = (pixel[col] & 0x3ff);
-  }
-  maximum = 0x3fc;
-}
-
 void CLASS quicktake_100_load_raw()
 {
   uchar pixel[484][644];
@@ -4267,6 +4199,14 @@ void CLASS parse_makernote (int base, int uptag)
       wbi = (get2(),get2());
       shot_order = (get2(),get2());
     }
+    if ((tag == 4 || tag == 0x114) && !strncmp(make,"KONICA",6)) {
+      fseek (ifp, tag == 4 ? 140:160, SEEK_CUR);
+      switch (get2()) {
+	case 72:  flip = 0;  break;
+	case 76:  flip = 6;  break;
+	case 82:  flip = 5;  break;
+      }
+    }
     if (tag == 7 && type == 2 && len > 20)
       fgets (model2, 64, ifp);
     if (tag == 8 && type == 4)
@@ -4449,7 +4389,7 @@ get2_256:
     if ((tag | 0x70) == 0x2070 && type == 4)
       fseek (ifp, get4()+base, SEEK_SET);
     if (tag == 0x2010 && type != 7)
-      load_raw = &CLASS olympus_e410_load_raw;
+      load_raw = &CLASS olympus_load_raw;
     if (tag == 0x2020)
       parse_thumb_note (base, 257, 258);
     if (tag == 0x2040)
@@ -4656,6 +4596,7 @@ void CLASS parse_kodak_ifd (int base)
   unsigned entries, tag, type, len, save;
   int i, c, wbi=-2, wbtemp=6500;
   float mul[3], num;
+  static const int wbtag[]={ 0xfa25,0xfa28,0xfa27,0xfa29,-1,-1,0xfa2a };
 
   entries = get2();
   if (entries > 1024) return;
@@ -4686,6 +4627,9 @@ void CLASS parse_kodak_ifd (int base)
         }
     if (tag == 2317) linear_table (len);
     if (tag == 6020) iso_speed = getint(type);
+    if (tag == 0xfa0d) wbi = fgetc(ifp);
+    if ((unsigned) wbi < 7 && tag == wbtag[wbi])
+      FORC3 cam_mul[c] = get4();
     fseek (ifp, save, SEEK_SET);
   }
 }
@@ -4884,6 +4828,7 @@ int CLASS parse_tiff_ifd (int base)
 	if (cfa == 072) memcpy (cfa_pc,"\005\003\004\001",4);	/* GMCY */
 	goto guess_cfa_pc;
       case 33424:
+      case 65024:
 	fseek (ifp, get4()+base, SEEK_SET);
 	parse_kodak_ifd (base);
 	break;
@@ -5098,7 +5043,7 @@ guess_cfa_pc:
 	data_offset = get4();
 	fseek (ifp, 28, SEEK_CUR);
 	data_offset += get4();
-	load_raw = &CLASS packed_12_load_raw;
+	load_raw = &CLASS packed_load_raw;
 	break;
       case 65026:
 	if (type == 2) fgets (model2, 64, ifp);
@@ -5201,7 +5146,7 @@ void CLASS parse_tiff (int base)
       case 0:  case 1:
 	switch (tiff_bps) {
 	  case  8: load_raw = &CLASS eight_bit_load_raw;	break;
-	  case 12: load_raw = &CLASS packed_12_load_raw;
+	  case 12: load_raw = &CLASS packed_load_raw;
 		   if (tiff_ifd[raw].phint == 2)
 		     load_flags = 6;
 		   if (strncmp(make,"PENTAX",6)) break;
@@ -5209,7 +5154,9 @@ void CLASS parse_tiff (int base)
 	  case 16: load_raw = &CLASS unpacked_load_raw;		break;
 	}
 	if (tiff_ifd[raw].bytes*5 == raw_width*raw_height*8) {
-	  load_raw = &CLASS packed_12_load_raw;
+	  tiff_bps = 12;
+	  maximum = 0xffff;
+	  load_raw = &CLASS packed_load_raw;
 	  load_flags = 273;
 	}
 	break;
@@ -5230,11 +5177,11 @@ void CLASS parse_tiff (int base)
       case 32769:
 	load_flags++;
       case 32773:
-	load_raw = &CLASS packed_12_load_raw;			break;
+	load_raw = &CLASS packed_load_raw;			break;
       case 34713:
 	load_raw = &CLASS nikon_compressed_load_raw;		break;
       case 65535:
-	load_raw = &CLASS pentax_k10_load_raw;			break;
+	load_raw = &CLASS pentax_load_raw;			break;
       case 65000:
 	switch (tiff_ifd[raw].phint) {
 	  case 2: load_raw = &CLASS kodak_rgb_load_raw;   filters = 0;  break;
@@ -5905,6 +5852,8 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 } },
     { "Canon EOS 450D", 0, 0x390d,
 	{ 5784,-262,-821,-7539,15064,2672,-1982,2681,7427 } },
+    { "Canon EOS 500D", 0, 0x3479,
+	{ 4763,712,-646,-6821,14399,2640,-1921,3276,6561 } },
     { "Canon EOS 1000D", 0, 0xe43,
 	{ 6771,-1139,-977,-7818,15123,2928,-1244,1437,7533 } },
     { "Canon EOS-1Ds Mark III", 0, 0x3bb0,
@@ -5923,12 +5872,16 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 } },
     { "Canon EOS", 0, 0,
 	{ 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } },
+    { "Canon PowerShot A530", 0, 0,
+	{ 0 } },	/* don't want the A5 matrix */
     { "Canon PowerShot A50", 0, 0,
 	{ -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 } },
     { "Canon PowerShot A5", 0, 0,
 	{ -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547 } },
     { "Canon PowerShot G10", 0, 0,
 	{ 11093,-3906,-1028,-5047,12492,2879,-1003,1750,5561 } },
+    { "Canon PowerShot G11", 0, 0,
+	{ 0 } },	/* don't want the G1 matrix */
     { "Canon PowerShot G1", 0, 0,
 	{ -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557 } },
     { "Canon PowerShot G2", 0, 0,
@@ -5959,6 +5912,8 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 8795,-2482,-797,-7804,15403,2573,-1422,1996,7082 } },
     { "Canon PowerShot S70", 0, 0,
 	{ 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } },
+    { "Canon PowerShot A470", 0, 0,	/* DJC */
+	{ 12513,-4407,-1242,-2680,10276,2405,-878,2215,4734 } },
     { "Canon PowerShot A610", 0, 0,	/* DJC */
 	{ 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 } },
     { "Canon PowerShot A620", 0, 0,	/* DJC */
@@ -5973,8 +5928,8 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 14573,-5482,-1546,-1266,9799,1468,-1040,1912,3810 } },
     { "Canon PowerShot S3 IS", 0, 0,	/* DJC */
 	{ 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 } },
-    { "Canon PowerShot SX1 IS", 0, 0,	/* DJC */
-	{ 10013,-2214,-1111,-3650,11589,2062,342,685,3617 } },
+    { "Canon PowerShot SX1 IS", 0, 0,
+	{ 6578,-259,-502,-5974,13030,3309,-308,1058,4970 } },
     { "Canon PowerShot SX110 IS", 0, 0,	/* DJC */
         { 14134,-5576,-1527,-1991,10719,1273,-1158,1929,3581 } },
     { "CASIO EX-S20", 0, 0,		/* DJC */
@@ -6079,6 +6034,10 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 10511,-3836,-1102,-6946,14587,2558,-1481,1792,6246 } },
     { "KODAK P880", 0, 0xfff,
 	{ 12805,-4662,-1376,-7480,15267,2360,-1626,2194,7904 } },
+    { "KODAK EasyShare Z980", 0, 0,
+	{ 11313,-3559,-1101,-3893,11891,2257,-1214,2398,4908 } },
+    { "KODAK EASYSHARE Z1015", 0, 0xef1,
+	{ 11265,-4286,-992,-4694,12343,2647,-1090,1523,5447 } },
     { "Leaf CMost", 0, 0,
 	{ 3952,2189,449,-6701,14585,2275,-4536,7349,6536 } },
     { "Leaf Valeo 6", 0, 0,
@@ -6123,14 +6082,26 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 7702,-2245,-975,-9114,17242,1875,-2679,3055,8521 } },
     { "NIKON D1", 0, 0, /* multiplied by 2.218750, 1.0, 1.148438 */
 	{ 16772,-4726,-2141,-7611,15713,1972,-2846,3494,9521 } },
+    { "NIKON D200", 0, 0xfbc,
+	{ 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 } },
     { "NIKON D2H", 0, 0,
 	{ 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 } },
     { "NIKON D2X", 0, 0,
 	{ 10231,-2769,-1255,-8301,15900,2552,-797,680,7148 } },
+    { "NIKON D3000", 0, 0,
+	{ 8736,-2458,-935,-9075,16894,2251,-1354,1242,8263 } },
+    { "NIKON D300", 0, 0,
+	{ 9030,-1992,-715,-8465,16302,2255,-2689,3217,8069 } },
+    { "NIKON D3X", 0, 0,
+	{ 7171,-1986,-648,-8085,15555,2718,-2170,2512,7457 } },
+    { "NIKON D3", 0, 0,
+	{ 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } },
     { "NIKON D40X", 0, 0,
 	{ 8819,-2543,-911,-9025,16928,2151,-1329,1213,8449 } },
     { "NIKON D40", 0, 0,
 	{ 6992,-1668,-806,-8138,15748,2543,-874,850,7897 } },
+    { "NIKON D5000", 0, 0xf00,
+	{ 7309,-1403,-519,-8474,16008,2622,-2433,2826,8064 } },
     { "NIKON D50", 0, 0,
 	{ 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } },
     { "NIKON D60", 0, 0,
@@ -6143,14 +6114,6 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 8629,-2410,-883,-9055,16940,2171,-1490,1363,8520 } },
     { "NIKON D90", 0, 0xf00,
 	{ 7309,-1403,-519,-8474,16008,2622,-2434,2826,8064 } },
-    { "NIKON D200", 0, 0xfbc,
-	{ 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 } },
-    { "NIKON D300", 0, 0,
-	{ 9030,-1992,-715,-8465,16302,2255,-2689,3217,8069 } },
-    { "NIKON D3X", 0, 0,
-	{ 7171,-1986,-648,-8085,15555,2718,-2170,2512,7457 } },
-    { "NIKON D3", 0, 0,
-	{ 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } },
     { "NIKON E950", 0, 0x3dd,		/* DJC */
 	{ -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 } },
     { "NIKON E995", 0, 0,	/* copied from E5000 */
@@ -6197,7 +6160,7 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 } },
     { "OLYMPUS E-330", 0, 0,
 	{ 8961,-2473,-1084,-7979,15990,2067,-2319,3035,8249 } },
-    { "OLYMPUS E-30", 0, 0,
+    { "OLYMPUS E-30", 0, 0xfbc,
 	{ 8144,-1861,-1111,-7763,15894,1929,-1865,2542,7607 } },
     { "OLYMPUS E-3", 0, 0xf99,
 	{ 9487,-2875,-1115,-7533,15606,2010,-1618,2100,7389 } },
@@ -6207,12 +6170,18 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 8856,-2582,-1026,-7761,15766,2082,-2009,2575,7469 } },
     { "OLYMPUS E-420", 0, 0xfd7,
 	{ 8746,-2425,-1095,-7594,15612,2073,-1780,2309,7416 } },
-    { "OLYMPUS E-500", 0, 0,
+    { "OLYMPUS E-450", 0, 0xfd2,
+	{ 8745,-2425,-1095,-7594,15613,2073,-1780,2309,7416 } },
+    { "OLYMPUS E-500", 0, 0xfff0,
 	{ 8136,-1968,-299,-5481,13742,1871,-2556,4205,6630 } },
     { "OLYMPUS E-510", 0, 0xf6a,
 	{ 8785,-2529,-1033,-7639,15624,2112,-1783,2300,7817 } },
     { "OLYMPUS E-520", 0, 0xfd2,
 	{ 8344,-2322,-1020,-7596,15635,2048,-1748,2269,7287 } },
+    { "OLYMPUS E-620", 0, 0xfb9,
+	{ 8453,-2198,-1092,-7609,15681,2008,-1725,2337,7824 } },
+    { "OLYMPUS E-P1", 0, 0xffd,
+	{ 8343,-2050,-1021,-7715,15705,2103,-1831,2380,8235 } },
     { "OLYMPUS SP350", 0, 0,
 	{ 12078,-4836,-1069,-6671,14306,2578,-786,939,7418 } },
     { "OLYMPUS SP3", 0, 0,
@@ -6249,6 +6218,8 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 11057,-3604,-1155,-5152,13046,2329,-282,375,8104 } },
     { "PENTAX K-m", 0, 0,
 	{ 11057,-3604,-1155,-5152,13046,2329,-282,375,8104 } },
+    { "PENTAX K-7", 0, 0,
+	{ 9142,-2947,-678,-8648,16967,1663,-2224,2898,8615 } },
     { "Panasonic DMC-FZ8", 0, 0xf7f0,
 	{ 8986,-2755,-802,-6341,13575,3077,-1476,2144,6379 } },
     { "Panasonic DMC-FZ18", 0, 0,
@@ -6257,6 +6228,8 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 10109,-3488,-993,-5412,12812,2916,-1305,2140,5543 } },
     { "Panasonic DMC-FZ30", 0, 0xf94c,
 	{ 10976,-4029,-1141,-7918,15491,2600,-1670,2071,8246 } },
+    { "Panasonic DMC-FZ35", 147, 0xfff,
+	{ 9938,-2780,-890,-4604,12393,2480,-1117,2304,4620 } },
     { "Panasonic DMC-FZ50", 0, 0xfff0,	/* aka "LEICA V-LUX1" */
 	{ 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } },
     { "Panasonic DMC-L10", 15, 0xf96,
@@ -6275,8 +6248,8 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 9082,-2907,-925,-6119,13377,3058,-1797,2641,5609 } },
     { "Panasonic DMC-G1", 15, 0xfff,
 	{ 8199,-2065,-1056,-8124,16156,2033,-2458,3022,7220 } },
-    { "Panasonic DMC-GH1", 15, 0xfff,	/* DJC */
-	{ 7808,-2387,-480,-2859,10002,2857,-1001,2012,4915 } },
+    { "Panasonic DMC-GH1", 15, 0xfff,
+	{ 6299,-1466,-532,-6535,13852,2969,-2331,3112,5984 } },
     { "Phase One H 20", 0, 0,		/* DJC */
 	{ 1313,1855,-109,-6715,15908,808,-327,1840,6020 } },
     { "Phase One P 2", 0, 0,
@@ -6303,10 +6276,16 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
 	{ 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } },
     { "SONY DSLR-A200", 0, 0,
 	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
+    { "SONY DSLR-A230", 0, 0,	/* copied */
+	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
     { "SONY DSLR-A300", 0, 0,
 	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
+    { "SONY DSLR-A330", 0, 0,
+	{ 9847,-3091,-929,-8485,16346,2225,-714,595,7103 } },
     { "SONY DSLR-A350", 0, 0xffc,
 	{ 6038,-1484,-578,-9146,16746,2513,-875,746,7217 } },
+    { "SONY DSLR-A380", 0, 0,	/* copied */
+	{ 6038,-1484,-578,-9146,16746,2513,-875,746,7217 } },
     { "SONY DSLR-A700", 254, 0x1ffe,
 	{ 5775,-805,-359,-8574,16295,2391,-1943,2341,7249 } },
     { "SONY DSLR-A900", 254, 0x1ffe,
@@ -6321,12 +6300,14 @@ void CLASS adobe_coeff (const char *p_make, const char *p_model)
     if (!strncmp (name, table[i].prefix, strlen(table[i].prefix))) {
       if (table[i].t_black)   black   = (ushort) table[i].t_black;
       if (table[i].t_maximum) maximum = (ushort) table[i].t_maximum;
-      for (j=0; j < 12; j++)
+      if (table[i].trans[0]) {
+        for (j=0; j < 12; j++)
 #ifdef LIBRAW_LIBRARY_BUILD
           imgdata.color.cam_xyz[0][j] = 
 #endif
-	cam_xyz[0][j] = table[i].trans[j] / 10000.0;
+	  cam_xyz[0][j] = table[i].trans[j] / 10000.0;
       cam_xyz_coeff (cam_xyz);
+      }
       break;
     }
 }
@@ -6374,6 +6355,31 @@ short CLASS guess_byte_order (int words)
 }
 
 
+float CLASS find_green (int bps, int bite, int off0, int off1)
+{
+  UINT64 bitbuf=0;
+  int vbits, col, i, c;
+  ushort img[2][2064];
+  double sum[]={0,0};
+
+  FORC(2) {
+    fseek (ifp, c ? off1:off0, SEEK_SET);
+    for (vbits=col=0; col < width; col++) {
+      for (vbits -= bps; vbits < 0; vbits += bite) {
+	bitbuf <<= bite;
+	for (i=0; i < bite; i+=8)
+	  bitbuf |= (unsigned) (fgetc(ifp) << i);
+      }
+      img[c][col] = bitbuf << (64-bps-vbits) >> (64-bps);
+    }
+  }
+  FORC(width-1) {
+    sum[ c & 1] += ABS(img[0][c]-img[1][c+1]);
+    sum[~c & 1] += ABS(img[1][c]-img[0][c+1]);
+  }
+  return 100 * log(sum[0]/sum[1]);
+}
+
 /*
    Identify which camera created this file, and set global variables
    accordingly.
@@ -6381,7 +6387,7 @@ short CLASS guess_byte_order (int words)
 void CLASS identify()
 {
   char head[32], *cp;
-  unsigned hlen, fsize, i, c, is_canon;
+  int hlen, fsize, i, c, is_canon;
   struct jhead jh;
   static const struct {
     int fsize;
@@ -6398,7 +6404,6 @@ void CLASS identify()
     {  6166488, "Kodak",    "C603"            ,0 },
     {  9116448, "Kodak",    "C603y"           ,0 },
     {   311696, "ST Micro", "STV680 VGA"      ,0 },  /* SPYz */
-    {   614400, "Kodak",    "KAI-0340"        ,0 },
     {   787456, "Creative", "PC-CAM 600"      ,0 },
     {  1138688, "Minolta",  "RD175"           ,0 },
     {  3840000, "Foculus",  "531C"            ,0 },
@@ -6418,6 +6423,7 @@ void CLASS identify()
     {  6653280, "Canon",    "PowerShot A530"  ,0 },
     {  6573120, "Canon",    "PowerShot A610"  ,0 },
     {  9219600, "Canon",    "PowerShot A620"  ,0 },
+    {  9243240, "Canon",    "PowerShot A470"  ,0 },
     { 10341600, "Canon",    "PowerShot A720"  ,0 },
     { 10383120, "Canon",    "PowerShot A630"  ,0 },
     { 12945240, "Canon",    "PowerShot A640"  ,0 },
@@ -6445,6 +6451,8 @@ void CLASS identify()
     {  4948608, "CASIO",    "EX-S100"         ,1 },
     {  7542528, "CASIO",    "EX-Z50"          ,1 },
     {  7753344, "CASIO",    "EX-Z55"          ,1 },
+    {  7816704, "CASIO",    "EX-Z60"          ,1 },
+    { 10843712, "CASIO",    "EX-Z75"          ,1 },
     {  7426656, "CASIO",    "EX-P505"         ,1 },
     {  9313536, "CASIO",    "EX-P600"         ,1 },
     { 10979200, "CASIO",    "EX-P700"         ,1 },
@@ -6496,7 +6504,6 @@ void CLASS identify()
   color_flags.cam_mul_state = LIBRAW_COLORSTATE_INIT;
 #endif
   colors = 3;
-  tiff_bps = 12;
   for (i=0; i < 0x4000; i++) curve[i] = i;
 #ifdef LIBRAW_LIBRARY_BUILD
   color_flags.curve_state = LIBRAW_COLORSTATE_INIT;
@@ -6600,7 +6607,8 @@ void CLASS identify()
     if (strstr (make, corp[i]))		/* Simplify company names */
 	strcpy (make, corp[i]);
   if (!strncmp (make,"KODAK",5) &&
-	((cp = strstr(model,"DIGITAL CAMERA")) ||
+	((cp = strstr(model," DIGITAL CAMERA")) ||
+	 (cp = strstr(model," Digital Camera")) ||
 	 (cp = strstr(model,"FILE VERSION"))))
      *cp = 0;
   cp = make + strlen(make);		/* Remove trailing spaces */
@@ -6615,7 +6623,6 @@ void CLASS identify()
   desc[511] = artist[63] = make[63] = model[63] = model2[63] = 0;
   if (!is_raw) goto notraw;
 
-  if (!maximum) maximum = (1 << tiff_bps) - 1;
   if (!height) height = raw_height;
   if (!width)  width  = raw_width;
   if (fuji_width) {
@@ -6627,6 +6634,9 @@ void CLASS identify()
     { height  = 2616;   width  = 3896; }
   if (height == 3136 && width == 4864)	/* Pentax K20D */
     { height  = 3124;   width  = 4688; }
+  if (height == 3136 && width == 4736)	/* Pentax K-7 */
+    { height  = 3122;   width  = 4684;
+      top_margin = 2;  filters = 0x16161616; }
   if (height == 3014 && width == 4096)	/* Ricoh GX200 */
 			width  = 4014;
   if (dng_version) {
@@ -6644,12 +6654,12 @@ void CLASS identify()
 	&CLASS lossless_jpeg_load_raw : &CLASS canon_compressed_load_raw;
   if (!strcmp(make,"NIKON")) {
     if (!load_raw)
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
     if (model[0] == 'E')
       load_flags |= !data_offset << 2 | 2;
   }
   if (!strcmp(make,"CASIO")) {
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     maximum = 0xf7f;
   }
 
@@ -6684,20 +6694,20 @@ void CLASS identify()
     pixel_aspect = 256/235.0;
     colors = 4;
     filters = 0x1e4e1e4e;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A50")) {
     height =  968;
     width  = 1290;
     raw_width = 1320;
     colors = 4;
     filters = 0x1b4e4b1e;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot Pro70")) {
     height = 1024;
     width  = 1552;
     colors = 4;
     filters = 0x1e4b4e1b;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot SD300")) {
     height = 1752;
     width  = 2344;
@@ -6705,7 +6715,7 @@ void CLASS identify()
     raw_width  = 2400;
     top_margin  = 12;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A460")) {
     height = 1960;
     width  = 2616;
@@ -6713,7 +6723,7 @@ void CLASS identify()
     raw_width  = 2664;
     top_margin  = 4;
     left_margin = 4;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A530")) {
     height = 1984;
     width  = 2620;
@@ -6721,8 +6731,7 @@ void CLASS identify()
     raw_width  = 2672;
     top_margin  = 6;
     left_margin = 10;
-    load_raw = &CLASS canon_a5_load_raw;
-    raw_color = 0;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A610")) {
     if (canon_s2is()) strcpy (model+10, "S2 IS");
     height = 1960;
@@ -6731,7 +6740,7 @@ void CLASS identify()
     raw_width  = 2672;
     top_margin  = 8;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A620")) {
     height = 2328;
     width  = 3112;
@@ -6739,7 +6748,15 @@ void CLASS identify()
     raw_width  = 3152;
     top_margin  = 12;
     left_margin = 36;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
+  } else if (!strcmp(model,"PowerShot A470")) {
+    height = 2328;
+    width  = 3096;
+    raw_height = 2346;
+    raw_width  = 3152;
+    top_margin  = 6;
+    left_margin = 12;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A720")) {
     height = 2472;
     width  = 3298;
@@ -6747,7 +6764,7 @@ void CLASS identify()
     raw_width  = 3336;
     top_margin  = 5;
     left_margin = 6;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A630")) {
     height = 2472;
     width  = 3288;
@@ -6755,7 +6772,7 @@ void CLASS identify()
     raw_width  = 3344;
     top_margin  = 6;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A640")) {
     height = 2760;
     width  = 3672;
@@ -6763,7 +6780,7 @@ void CLASS identify()
     raw_width  = 3736;
     top_margin  = 6;
     left_margin = 12;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot A650")) {
     height = 3024;
     width  = 4032;
@@ -6771,7 +6788,7 @@ void CLASS identify()
     raw_width  = 4104;
     top_margin  = 12;
     left_margin = 48;
-    load_raw = &CLASS canon_a5_load_raw;
+    goto canon_a5;
   } else if (!strcmp(model,"PowerShot S3 IS")) {
     height = 2128;
     width  = 2840;
@@ -6779,7 +6796,11 @@ void CLASS identify()
     raw_width  = 2888;
     top_margin  = 8;
     left_margin = 44;
-    load_raw = &CLASS canon_a5_load_raw;
+canon_a5:
+    tiff_bps = 10;
+    load_raw = &CLASS packed_load_raw;
+    load_flags = 40;
+    if (raw_width > 1600) zero_is_bad = 1;
   } else if (!strcmp(model,"PowerShot SX110 IS")) {
     height = 2760;
     width  = 3684;
@@ -6787,7 +6808,7 @@ void CLASS identify()
     raw_width  = 3720;
     top_margin  = 12;
     left_margin = 6;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 40;
     zero_is_bad = 1;
   } else if (!strcmp(model,"PowerShot Pro90 IS")) {
@@ -6848,6 +6869,11 @@ void CLASS identify()
     top_margin  = 12;
     left_margin = 74;
     goto canon_cr2;
+  } else if (is_canon && raw_width == 3744) {
+    height = 2760;
+    width  = 3684;
+    top_margin  = 16;
+    left_margin = 8;
   } else if (is_canon && raw_width == 3944) {
     height = 2602;
     width  = 3908;
@@ -6897,6 +6923,8 @@ void CLASS identify()
     top_margin = unique_id == 0x80000261 ? 51:26;
     left_margin = 62;
     raw_width = width *= 4;
+    if (unique_id == 0x80000252)
+      adobe_coeff ("Canon","EOS 500D");
     goto canon_cr2;
   } else if (is_canon && raw_width == 1448) {
     top_margin  = 51;
@@ -6922,15 +6950,16 @@ canon_cr2:
     pixel_aspect = 0.5;
   } else if (!strcmp(model,"D40X") ||
 	     !strcmp(model,"D60")  ||
-	     !strcmp(model,"D80")) {
+	     !strcmp(model,"D80")  ||
+	     !strcmp(model,"D3000")) {
     height -= 3;
     width  -= 4;
   } else if (!strcmp(model,"D3")   ||
 	     !strcmp(model,"D700")) {
     width -= 4;
     left_margin = 2;
-  } else if(!strcmp(model,"D5000")) {
-      width-=42;
+  } else if (!strcmp(model,"D5000")) {
+    width -= 42;
   } else if (!strncmp(model,"D40",3) ||
 	     !strncmp(model,"D50",3) ||
 	     !strncmp(model,"D70",3)) {
@@ -6939,7 +6968,7 @@ canon_cr2:
     width -= 42;
   } else if (!strcmp(model,"D100")) {
     if (tiff_compress == 34713 && !nikon_is_compressed()) {
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
       load_flags |= 1;
       raw_width = (width += 3) + 3;
     }
@@ -6953,7 +6982,7 @@ canon_cr2:
   } else if (!strncmp(model,"D2X",3)) {
     if (width == 3264) width -= 32;
     else width -= 8;
-  } else if (!strcmp(model,"D300")) {
+  } else if (!strncmp(model,"D300",4)) {
     width -= 32;
   } else if (!strcmp(model,"COOLPIX P6000")) {
     load_flags = 24;
@@ -6962,7 +6991,6 @@ canon_cr2:
     height = 963;
     width = 1287;
     raw_width = 1632;
-    load_raw = &CLASS nikon_e900_load_raw;
     maximum = 0x3f4;
     colors = 4;
     filters = 0x1e1e1e1e;
@@ -6973,20 +7001,24 @@ canon_cr2:
 #ifdef LIBRAW_LIBRARY_BUILD
     color_flags.pre_mul_state = LIBRAW_COLORSTATE_CONST;
 #endif
+    goto e900;
   } else if (fsize == 2465792) {
     height = 1203;
     width  = 1616;
     raw_width = 2048;
-    load_raw = &CLASS nikon_e900_load_raw;
     colors = 4;
     filters = 0x4b4b4b4b;
     adobe_coeff ("NIKON","E950");
+e900:
+    tiff_bps = 10;
+    load_raw = &CLASS packed_load_raw;
+    load_flags = 6;
   } else if (fsize == 4771840) {
     height = 1540;
     width  = 2064;
     colors = 4;
     filters = 0xe1e1e1e1;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 6;
     if (!timestamp && nikon_e995())
       strcpy (model, "E995");
@@ -7015,7 +7047,7 @@ cp_e2500:
   } else if (fsize == 4775936) {
     height = 1542;
     width  = 2064;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
     if (!timestamp) nikon_3700();
     if (model[0] == 'E' && atoi(model+1) < 3700)
@@ -7024,6 +7056,15 @@ cp_e2500:
       flip = 1;
       filters = 0x16161616;
     }
+    if (make[0] == 'O') {
+      i = find_green (12, 32, 0, fsize/2);
+      c = find_green (12, 32, 0, 3096);
+      if (abs(i) < abs(c)) {
+	SWAP(i,c);
+	load_flags = 24;
+      }
+      if (i < 0) filters = 0x61616161;
+    }
   } else if (fsize == 5869568) {
     height = 1710;
     width  = 2288;
@@ -7032,7 +7073,7 @@ cp_e2500:
       strcpy (make, "Minolta");
       strcpy (model,"DiMAGE Z2");
     }
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 6 + 24*(make[0] == 'M');
   } else if (!strcmp(model,"E4500")) {
     height = 1708;
@@ -7048,7 +7089,7 @@ cp_e2500:
     height = 2118;
     width  = 2832;
     maximum = 0xf83;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
   } else if (!strcmp(model,"FinePix S5100") ||
 	     !strcmp(model,"FinePix S5500")) {
@@ -7093,13 +7134,14 @@ cp_e2500:
     if (!strncmp(model,"DiMAGE A",8)) {
       if (!strcmp(model,"DiMAGE A200"))
 	filters = 0x49494949;
-      load_raw = &CLASS packed_12_load_raw;
+      tiff_bps = 12;
+      load_raw = &CLASS packed_load_raw;
     } else if (!strncmp(model,"ALPHA",5) ||
 	       !strncmp(model,"DYNAX",5) ||
 	       !strncmp(model,"MAXXUM",6)) {
       sprintf (model+20, "DYNAX %-10s", model+6+(model[0]=='M'));
       adobe_coeff (make, model+20);
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
     } else if (!strncmp(model,"DiMAGE G",8)) {
       if (model[8] == '4') {
 	height = 1716;
@@ -7135,19 +7177,19 @@ konica_400z:
       height = 1544;
       width  = 2068;
       raw_width = 3136;
-      load_raw = &CLASS packed_12_load_raw;
+      load_raw = &CLASS packed_load_raw;
       maximum = 0xf7c;
     }
   } else if (fsize == 6114240) {
     height = 1737;
     width  = 2324;
     raw_width = 3520;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     maximum = 0xf7a;
   } else if (!strcmp(model,"Optio 750Z")) {
     height = 2302;
     width  = 3072;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
   } else if (!strcmp(model,"DC-833m")) {
     height = 2448;
@@ -7170,12 +7212,6 @@ konica_400z:
     flip = 2;
     filters = 0x16161616;
     black = 16;
-  } else if (!strcmp(model,"KAI-0340")) {
-    height = 477;
-    width  = 640;
-    order = 0x4949;
-    data_offset = 3840;
-    load_raw = &CLASS unpacked_load_raw;
   } else if (!strcmp(model,"N95")) {
     height = raw_height - (top_margin = 2);
   } else if (!strcmp(model,"531C")) {
@@ -7382,16 +7418,21 @@ lx3:	filters = 0x16161616;
 	zero_is_bad = 1;
 	adobe_coeff ("Panasonic","DMC-LX1");  break;
       case 4060:
-	if (!strcmp(model,"DMC-GH1")) goto gh1;
 	width = 3982;
 	if (height == 2250) goto lx3;
 	width = 4018;
+	filters = 0x16161616;
+	if (!strncmp(model,"DMC-FZ3",7)) {
+	  height -= 2;
+	  adobe_coeff ("Panasonic","DMC-FZ35");  break;
+	}
 	filters = 0x49494949;
+	if (!strcmp(model,"DMC-GH1")) break;
 	zero_is_bad = 1;
 	adobe_coeff ("Panasonic","DMC-G1");  break;
       case 4172:
       case 4396:
-gh1:	width -= 28;
+	width -= 28;
 	filters = 0x49494949;
 	adobe_coeff ("Panasonic","DMC-GH1");  break;
       case 4290:
@@ -7414,13 +7455,14 @@ gh1:	width -= 28;
     height = 1718;
     width  = 2304;
     filters = 0x16161616;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
     load_flags = 30;
   } else if (!strcmp(make,"OLYMPUS")) {
     height += height & 1;
     filters = exif_cfa;
     if (width == 4100) width -= 4;
-    if (load_raw == &CLASS olympus_e410_load_raw) {
+    if (load_raw == &CLASS olympus_load_raw) {
+      tiff_bps = 12;
       black >>= 4;
     } else if (!strcmp(model,"E-10") ||
 	      !strncmp(model,"E-20",4)) {
@@ -7446,7 +7488,7 @@ gh1:	width -= 28;
     width  = 3072;
     filters = 0x61616161;
     data_offset = 0x1a00;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
   } else if (!strcmp(model,"DSC-F828")) {
     width = 3288;
     left_margin = 5;
@@ -7466,6 +7508,8 @@ gh1:	width -= 28;
     order = 0x4d4d;
   } else if (!strcmp(model,"DSLR-A100")) {
     height--;
+    width = ++raw_width;
+    filters = 0x61616161;
   } else if (!strcmp(model,"DSLR-A350")) {
     height -= 4;
   } else if (!strcmp(model,"PIXL")) {
@@ -7475,7 +7519,12 @@ gh1:	width -= 28;
   } else if (!strcmp(model,"C603v")) {
     height = 480;
     width  = 640;
-    goto c603v;
+    if (fsize < 614400 || find_green (16, 16, 3840, 5120) < 25) goto c603v;
+    strcpy (model,"KAI-0340");
+    height -= 3;
+    data_offset = 3840;
+    order = 0x4949;
+    load_raw = &CLASS unpacked_load_raw;
   } else if (!strcmp(model,"C603y")) {
     height = 2134;
     width  = 2848;
@@ -7507,8 +7556,13 @@ c603:
   } else if (!strcmp(model,"EASYSHARE Z1015 IS")) {
     height = 2742;
     width  = 3664;
+    goto ezshare;
+  } else if (!strcmp(model,"EasyShare Z980")) {
+    height = 3006;
+    width  = 4016;
+ezshare:
     data_offset = 0x15000;
-    load_raw = &CLASS packed_12_load_raw;
+    load_raw = &CLASS packed_load_raw;
   } else if (!strcasecmp(make,"KODAK")) {
     if (filters == UINT_MAX) filters = 0x61616161;
     if (!strncmp(model,"NC2000",6)) {
@@ -7667,7 +7721,8 @@ c603:
   } else if (!strcmp(model,"QV-5700")) {
     height = 1924;
     width  = 2576;
-    load_raw = &CLASS casio_qv5700_load_raw;
+    raw_width = 3232;
+    tiff_bps = 10;
   } else if (!strcmp(model,"QV-R41")) {
     height = 1720;
     width  = 2312;
@@ -7694,6 +7749,16 @@ c603:
     height = 1960;
     width  = 2570;
     raw_width = 3904;
+  } else if (!strcmp(model,"EX-Z60")) {
+    height = 2145;
+    width  = 2833;
+    raw_width = 3584;
+    filters = 0x16161616;
+    tiff_bps = 10;
+  } else if (!strcmp(model,"EX-Z75")) {
+    height = 2321;
+    width  = 3089;
+    raw_width = 4672;
   } else if (!strcmp(model,"EX-P505")) {
     height = 1928;
     width  = 2568;
@@ -7723,6 +7788,8 @@ c603:
     }
   }
 dng_skip:
+  if (!tiff_bps) tiff_bps = 12;
+  if (!maximum) maximum = (1 << tiff_bps) - 1;
   if (!load_raw || height < 22) is_raw = 0;
 #ifdef NO_JPEG
   if (load_raw == &CLASS kodak_jpeg_load_raw) {
@@ -7774,7 +7841,8 @@ void CLASS identify2(unsigned fsize)
   } else if (!strcmp(model,"QV-5700")) {
     height = 1924;
     width  = 2576;
-    load_raw = &CLASS casio_qv5700_load_raw;
+    raw_width = 3232;
+    tiff_bps = 10;
   } else if (!strcmp(model,"QV-R41")) {
     height = 1720;
     width  = 2312;
@@ -7801,6 +7869,16 @@ void CLASS identify2(unsigned fsize)
     height = 1960;
     width  = 2570;
     raw_width = 3904;
+  } else if (!strcmp(model,"EX-Z60")) {
+    height = 2145;
+    width  = 2833;
+    raw_width = 3584;
+    filters = 0x16161616;
+    tiff_bps = 10;
+  } else if (!strcmp(model,"EX-Z75")) {
+    height = 2321;
+    width  = 3089;
+    raw_width = 4672;
   } else if (!strcmp(model,"EX-P505")) {
     height = 1928;
     width  = 2568;
diff --git a/lib/libfspotraw/LibRaw/internal/dcraw_fileio.cpp b/lib/libfspotraw/LibRaw/internal/dcraw_fileio.cpp
index d6b0e6f..9ad80a7 100644
--- a/lib/libfspotraw/LibRaw/internal/dcraw_fileio.cpp
+++ b/lib/libfspotraw/LibRaw/internal/dcraw_fileio.cpp
@@ -1,6 +1,6 @@
 /* 
    GENERATED FILE, DO NOT EDIT
-   Generated from dcraw/dcraw.c at Tue Jul 21 20:35:36 2009
+   Generated from dcraw/dcraw.c at Wed Sep  2 11:06:07 2009
    Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
    for copyright information.
 */
diff --git a/lib/libfspotraw/LibRaw/internal/defines.h b/lib/libfspotraw/LibRaw/internal/defines.h
index 2a69a00..cadc068 100644
--- a/lib/libfspotraw/LibRaw/internal/defines.h
+++ b/lib/libfspotraw/LibRaw/internal/defines.h
@@ -1,12 +1,12 @@
 /* 
    GENERATED FILE, DO NOT EDIT
-   Generated from dcraw/dcraw.c at Tue Jul 21 20:35:34 2009
+   Generated from dcraw/dcraw.c at Wed Sep  2 11:06:05 2009
    Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
    for copyright information.
 */
 
 #define NO_JPEG
-#define VERSION "8.95"
+#define VERSION "8.97"
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
@@ -53,14 +53,10 @@
 #define snprintf _snprintf
 #define strcasecmp _stricmp
 #define strncasecmp strnicmp
-typedef __int64 INT64;
-typedef unsigned __int64 UINT64;
 #else
 #include <unistd.h>
 #include <utime.h>
 #include <netinet/in.h>
-typedef long long INT64;
-typedef unsigned long long UINT64;
 #endif
 
 #ifdef LJPEG_DECODE
diff --git a/lib/libfspotraw/LibRaw/internal/foveon.cpp b/lib/libfspotraw/LibRaw/internal/foveon.cpp
index 3304365..c795063 100644
--- a/lib/libfspotraw/LibRaw/internal/foveon.cpp
+++ b/lib/libfspotraw/LibRaw/internal/foveon.cpp
@@ -1,6 +1,6 @@
 /* 
    GENERATED FILE, DO NOT EDIT
-   Generated from dcraw/dcraw.c at Tue Jul 21 20:35:34 2009
+   Generated from dcraw/dcraw.c at Wed Sep  2 11:06:05 2009
    Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
    for copyright information.
 */
@@ -16,6 +16,9 @@
 #define SRC_USES_CURVE
 #include "internal/var_defines.h"
 #define sget4(s) sget4((uchar *)s)
+#ifndef M_PI
+#define	M_PI		3.14159265358979323846
+#endif
 
 /* RESTRICTED code starts here */
 
diff --git a/lib/libfspotraw/LibRaw/internal/libraw_internal_funcs.h b/lib/libfspotraw/LibRaw/internal/libraw_internal_funcs.h
index df33302..4dd5919 100644
--- a/lib/libfspotraw/LibRaw/internal/libraw_internal_funcs.h
+++ b/lib/libfspotraw/LibRaw/internal/libraw_internal_funcs.h
@@ -43,7 +43,6 @@
     void        canon_600_coeff();
     void        canon_600_load_raw();
     int         canon_s2is();
-    void        canon_a5_load_raw();
     void        parse_ciff (int offset, int length);
     void        ciff_block_1030();
 
@@ -70,7 +69,7 @@ void        canon_black(double *, int nblack);
     void        adobe_dng_load_raw_nc();
 
 // Pentax
-    void        pentax_k10_load_raw();
+    void        pentax_load_raw();
     void        pentax_tree();
 
 // Nikon (and Minolta Z2)
@@ -81,7 +80,6 @@ void        canon_black(double *, int nblack);
     int         nikon_e2100();
     void        nikon_3700();
     int         minolta_z2();
-    void        nikon_e900_load_raw();
     void        nikon_e2100_load_raw();
 
 // Fuji
@@ -106,7 +104,8 @@ void        canon_black(double *, int nblack);
     void        leaf_hdr_load_raw();
     void        sinar_4shot_load_raw();
     void        imacon_full_load_raw();
-    void        packed_12_load_raw();
+    void        packed_load_raw();
+    float	find_green(int,int,int,int);
     void        unpacked_load_raw();
     void        parse_sinar_ia();
     void        parse_phase_one (int base);
@@ -115,10 +114,9 @@ void        canon_black(double *, int nblack);
     void        nokia_load_raw();
     unsigned    pana_bits (int nbits);
     void        panasonic_load_raw();
-    void        olympus_e410_load_raw();
+    void        olympus_load_raw();
     void        olympus_cseries_load_raw();
     void        minolta_rd175_load_raw();
-    void        casio_qv5700_load_raw();
     void        quicktake_100_load_raw();
     const int*  make_decoder_int (const int *source, int level);
     int         radc_token (int tree);
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw.h b/lib/libfspotraw/LibRaw/libraw/libraw.h
index ac697a8..519dc72 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw.h
@@ -24,6 +24,10 @@
 #ifndef _LIBRAW_CLASS_H
 #define _LIBRAW_CLASS_H
 
+#ifdef __linux__
+#define _FILE_OFFSET_BITS 64
+#endif
+
 #include <limits.h>
 #include <memory.h>
 #include <stdio.h>
@@ -101,12 +105,12 @@ class DllDef LibRaw
     void                        set_progress_handler(progress_callback pcb, void *data) { callbacks.progresscb_data = data; callbacks.progress_cb = pcb;}
 
     /* helpers */
-    static const char*          version() { return LIBRAW_VERSION_STR;}
-    static int                  versionNumber() { return LIBRAW_VERSION; }
+    static const char*          version();
+    static int                  versionNumber();
     static const char**         cameraList();
     static int                  cameraCount();
     static const char*          strprogress(enum LibRaw_progress);
-    static const char*          strerror(int p) { return libraw_strerror(p);}
+    static const char*          strerror(int p);
     /* dcraw emulation */
     int                         dcraw_document_mode_processing();
     int                         dcraw_ppm_tiff_writer(const char *filename);
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw_alloc.h b/lib/libfspotraw/LibRaw/libraw/libraw_alloc.h
index bfcf067..7f2e9f7 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw_alloc.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw_alloc.h
@@ -26,11 +26,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#ifdef WIN32
-#define bzero(p,sz) memset(p,0,sz)
-#else
-#include <strings.h>
-#endif
 
 #ifdef __cplusplus
 
@@ -41,7 +36,7 @@ class libraw_memmgr
   public:
     libraw_memmgr()
         {
-            bzero(mems,sizeof(mems));
+            memset(mems,0,sizeof(mems));
             calloc_cnt=0;
         }
     void *malloc(size_t sz)
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw_const.h b/lib/libfspotraw/LibRaw/libraw/libraw_const.h
index e78d586..15a573f 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw_const.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw_const.h
@@ -153,8 +153,8 @@ enum LibRaw_thumbnail_formats
 
 enum LibRaw_image_formats
 {
-    LIBRAW_IMAGE_BITMAP=1,
-    LIBRAW_IMAGE_JPEG=2
+    LIBRAW_IMAGE_JPEG=1,
+    LIBRAW_IMAGE_BITMAP=2
 };
 
 #endif
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw_datastream.h b/lib/libfspotraw/LibRaw/libraw/libraw_datastream.h
index 6616077..9175315 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw_datastream.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw_datastream.h
@@ -36,6 +36,7 @@ struct LibRaw_abstract_datastream;
 #else /* __cplusplus */
 
 #include "libraw_const.h"
+#include "libraw_types.h"
 
 class LibRaw_buffer_datastream;
 
@@ -46,8 +47,8 @@ class LibRaw_abstract_datastream
     virtual             ~LibRaw_abstract_datastream(void){if(substream) delete substream;}
     virtual int         valid(){return 0;}
     virtual int         read(void *,size_t, size_t ){ return -1;}
-    virtual int         seek(off_t , int ){return -1;}
-    virtual int         tell(){return -1;}
+    virtual int         seek(INT64 , int ){return -1;}
+    virtual INT64       tell(){return -1;}
     virtual int         get_char(){return -1;}
     virtual char*       gets(char *, int){ return NULL;}
     virtual int         scanf_one(const char *, void *){return -1;}
@@ -95,15 +96,31 @@ class LibRaw_file_datastream : public LibRaw_abstract_datastream
         CHK(); 
         return substream?substream->eof():feof(f);
     }
-    virtual int seek(off_t o, int whence) 
+    virtual int seek(INT64 o, int whence)
     { 
         CHK(); 
+#if defined (WIN32)
+#if __MSVCRT_VERSION__ >= 0x800
+        return substream?substream->seek(o,whence):_fseeki64(f,o,whence);
+#else
         return substream?substream->seek(o,whence):fseek(f,o,whence);
+#endif
+#else
+        return substream?substream->seek(o,whence):fseeko(f,o,whence);
+#endif
     }
-    virtual int tell() 
+    virtual INT64 tell()
     { 
         CHK(); 
+#if defined (WIN32)
+#if __MSVCRT_VERSION__ >= 0x800
+        return substream?substream->tell():_ftelli64(f);
+#else
         return substream?substream->tell():ftell(f);
+#endif
+#else
+        return substream?substream->tell():ftello(f);
+#endif
     }
     virtual int get_char() 
     { 
@@ -179,7 +196,7 @@ class LibRaw_buffer_datastream : public LibRaw_abstract_datastream
         return streampos >= streamsize;
     }
 
-    virtual int seek(off_t o, int whence) 
+    virtual int seek(INT64 o, int whence)
     { 
         if(substream) return substream->seek(o,whence);
         switch(whence)
@@ -221,10 +238,10 @@ class LibRaw_buffer_datastream : public LibRaw_abstract_datastream
             }
     }
     
-    virtual int tell() 
+    virtual INT64 tell()
     { 
         if(substream) return substream->tell();
-        return int(streampos);
+        return INT64(streampos);
     }
 
     virtual int get_char() 
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw_internal.h b/lib/libfspotraw/LibRaw/libraw/libraw_internal.h
index 7fe6898..6dbc487 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw_internal.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw_internal.h
@@ -86,9 +86,6 @@ class LibRaw_constants
 };
 #endif /* __cplusplus */
 
-#ifdef WIN32
-typedef long off_t;
-#endif
 
 typedef struct
 {
@@ -99,8 +96,8 @@ typedef struct
     FILE        *output;
     int         input_internal;
     char        *meta_data;
-    off_t       profile_offset;
-    off_t       toffset;
+    INT64       profile_offset;
+    INT64       toffset;
 
 } internal_data_t;
 
@@ -134,8 +131,8 @@ typedef struct
     short       order; 
     ushort      sraw_mul[4],cr2_slice[3];
     unsigned    kodak_cbpp;
-    off_t       strip_offset, data_offset;
-    off_t       meta_offset;
+    INT64       strip_offset, data_offset;
+    INT64       meta_offset;
     unsigned     meta_length;
     unsigned    thumb_misc;
     unsigned    fuji_layout;
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw_types.h b/lib/libfspotraw/LibRaw/libraw/libraw_types.h
index 8289b00..6920e1a 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw_types.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw_types.h
@@ -24,6 +24,7 @@
 #ifndef _LIBRAW_TYPES_H
 #define _LIBRAW_TYPES_H
 
+#include <sys/types.h>
 #ifndef WIN32
 #include <sys/time.h>
 #endif
@@ -44,8 +45,14 @@ extern "C" {
 #include "libraw_const.h"
 #include "libraw_version.h"
 
+#ifdef WIN32
+typedef __int64 INT64;
+typedef unsigned __int64 UINT64;
+#else
 typedef long long INT64;
 typedef unsigned long long UINT64;
+#endif
+
 typedef unsigned char uchar;
 typedef unsigned short ushort;
 
diff --git a/lib/libfspotraw/LibRaw/libraw/libraw_version.h b/lib/libfspotraw/LibRaw/libraw/libraw_version.h
index 35e04f0..e2e3e6c 100644
--- a/lib/libfspotraw/LibRaw/libraw/libraw_version.h
+++ b/lib/libfspotraw/LibRaw/libraw/libraw_version.h
@@ -26,8 +26,8 @@
 
 #define LIBRAW_MAJOR_VERSION  0
 #define LIBRAW_MINOR_VERSION  8
-#define LIBRAW_PATCH_VERSION  0
-#define LIBRAW_VERSION_TAIL   Beta4
+#define LIBRAW_PATCH_VERSION  2
+#define LIBRAW_VERSION_TAIL   Release
 
 #define _LIBRAW_VERSION_MAKE(a,b,c,d) #a"."#b"."#c"-"#d
 #define LIBRAW_VERSION_MAKE(a,b,c,d) _LIBRAW_VERSION_MAKE(a,b,c,d)
diff --git a/lib/libfspotraw/LibRaw/samples/dcraw_half.c b/lib/libfspotraw/LibRaw/samples/dcraw_half.c
index 76f32c6..7b00a8d 100644
--- a/lib/libfspotraw/LibRaw/samples/dcraw_half.c
+++ b/lib/libfspotraw/LibRaw/samples/dcraw_half.c
@@ -48,7 +48,7 @@ int main(int ac, char *av[])
 {
     int i;
     libraw_data_t *iprc = libraw_init(0);
-    
+
     if(!iprc)
         {
             fprintf(stderr,"Cannot create libraw handle\n");
diff --git a/lib/libfspotraw/LibRaw/src/libraw_c_api.cpp b/lib/libfspotraw/LibRaw/src/libraw_c_api.cpp
index d43d8f4..b428617 100644
--- a/lib/libfspotraw/LibRaw/src/libraw_c_api.cpp
+++ b/lib/libfspotraw/LibRaw/src/libraw_c_api.cpp
@@ -142,7 +142,12 @@ extern "C"
         if(!lr) { if(errc) *errc=EINVAL; return NULL;}
         LibRaw *ip = (LibRaw*) lr->parent_class;
         return ip->dcraw_make_mem_image(errc);
-
+    }
+    libraw_processed_image_t *libraw_dcraw_make_mem_thumb(libraw_data_t* lr,int *errc)
+    {
+        if(!lr) { if(errc) *errc=EINVAL; return NULL;}
+        LibRaw *ip = (LibRaw*) lr->parent_class;
+        return ip->dcraw_make_mem_thumb(errc);
     }
 
 #ifdef __cplusplus
diff --git a/lib/libfspotraw/LibRaw/src/libraw_cxx.cpp b/lib/libfspotraw/LibRaw/src/libraw_cxx.cpp
index e30e0ac..14aa57a 100644
--- a/lib/libfspotraw/LibRaw/src/libraw_cxx.cpp
+++ b/lib/libfspotraw/LibRaw/src/libraw_cxx.cpp
@@ -113,6 +113,11 @@ const float LibRaw_constants::d65_white[3] =  { 0.950456, 1, 1.088754 };
             } \
     }while(0)
 
+const char* LibRaw::version() { return LIBRAW_VERSION_STR;}
+int LibRaw::versionNumber() { return LIBRAW_VERSION; }
+const char* LibRaw::strerror(int p) { return libraw_strerror(p);}
+
+
 void LibRaw::derror()
 {
     if (!libraw_internal_data.unpacker_data.data_error && libraw_internal_data.internal_data.input) 
@@ -133,6 +138,10 @@ void LibRaw::derror()
         }
     libraw_internal_data.unpacker_data.data_error = 1;
 }
+
+#define ZERO(a) memset(&a,0,sizeof(a))
+
+
 LibRaw:: LibRaw(unsigned int flags)
 {
     double aber[4] = {1,1,1,1};
@@ -143,9 +152,9 @@ LibRaw:: LibRaw(unsigned int flags)
 #else
     verbose = 0;
 #endif
-    bzero(&imgdata,sizeof(imgdata));
-    bzero(&libraw_internal_data,sizeof(libraw_internal_data));
-    bzero(&callbacks,sizeof(callbacks));
+    ZERO(imgdata);
+    ZERO(libraw_internal_data);
+    ZERO(callbacks);
     callbacks.mem_cb = (flags & LIBRAW_OPIONS_NO_MEMERR_CALLBACK) ? NULL:  &default_memory_callback;
     callbacks.data_cb = (flags & LIBRAW_OPIONS_NO_DATAERR_CALLBACK)? NULL : &default_data_callback;
     memmove(&imgdata.params.aber,&aber,sizeof(aber));
@@ -228,11 +237,9 @@ void LibRaw:: recycle()
     FREE(imgdata.masked_pixels.buffer);
     FREE(imgdata.masked_pixels.ph1_black);
 #undef FREE
-#define ZERO(a) bzero(&a,sizeof(a))
     ZERO(imgdata.masked_pixels);
     ZERO(imgdata.sizes);
     ZERO(libraw_internal_data.internal_output_params);
-#undef ZERO
     memmgr.cleanup();
     imgdata.thumbnail.tformat = LIBRAW_THUMBNAIL_UNKNOWN;
     imgdata.progress_flags = 0;
@@ -249,11 +256,9 @@ const char * LibRaw::unpack_function_name()
     if (load_raw == &LibRaw::adobe_dng_load_raw_nc)     return "adobe_dng_load_raw_nc()";
     if (load_raw == &LibRaw::canon_600_load_raw)        return "canon_600_load_raw()";
 
-    if (load_raw == &LibRaw::canon_a5_load_raw)         return "canon_a5_load_raw()";
     if (load_raw == &LibRaw::canon_compressed_load_raw) return "canon_compressed_load_raw()";
     if (load_raw == &LibRaw::canon_sraw_load_raw)       return "canon_sraw_load_raw()";
 
-    if (load_raw == &LibRaw::casio_qv5700_load_raw )    return "casio_qv5700_load_raw()";
     if (load_raw == &LibRaw::eight_bit_load_raw )       return "eight_bit_load_raw()";
     if (load_raw == &LibRaw::foveon_load_raw )          return "foveon_load_raw()";
     if (load_raw == &LibRaw::fuji_load_raw )            return "fuji_load_raw()";
@@ -276,14 +281,13 @@ const char * LibRaw::unpack_function_name()
     if (load_raw == &LibRaw::minolta_rd175_load_raw )   return "minolta_rd175_load_raw()";
 
     if (load_raw == &LibRaw::nikon_compressed_load_raw) return "nikon_compressed_load_raw()";
-    if (load_raw == &LibRaw::nikon_e900_load_raw )      return "nikon_e900_load_raw()";
     if (load_raw == &LibRaw::nokia_load_raw )           return "nokia_load_raw()";
 
-    if (load_raw == &LibRaw::olympus_e410_load_raw )    return "olympus_e410_load_raw()";
-    if (load_raw == &LibRaw::packed_12_load_raw )       return "packed_12_load_raw()";
+    if (load_raw == &LibRaw::olympus_load_raw )    return "olympus_load_raw()";
+    if (load_raw == &LibRaw::packed_load_raw )       return "packed_load_raw()";
     if (load_raw == &LibRaw::panasonic_load_raw )       return "panasonic_load_raw()";
     // 30
-    if (load_raw == &LibRaw::pentax_k10_load_raw )      return "pentax_k10_load_raw()";
+    if (load_raw == &LibRaw::pentax_load_raw )          return "pentax_load_raw()";
     if (load_raw == &LibRaw::phase_one_load_raw )       return "phase_one_load_raw()";
     if (load_raw == &LibRaw::phase_one_load_raw_c )     return "phase_one_load_raw_c()";
 
@@ -561,10 +565,10 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream)
         int saved_raw_width = S.raw_width;
         int saved_width = S.width;
         // from packed_12_load_raw
-        if ((load_raw == &LibRaw:: packed_12_load_raw) && (S.raw_width * 2 >= S.width * 3))
+        if ((load_raw == &LibRaw:: packed_load_raw) && (S.raw_width * 8U >= S.width * libraw_internal_data.unpacker_data.tiff_bps))
             {	
                 // raw_width is in bytes!
-                S.raw_width = S.raw_width * 2 / 3;	
+                S.raw_width = S.raw_width * 8 / libraw_internal_data.unpacker_data.tiff_bps;
             }
         else if (S.pixel_aspect < 0.95 || S.pixel_aspect > 1.05)
             {
@@ -828,7 +832,7 @@ libraw_processed_image_t * LibRaw::dcraw_make_mem_thumb(int *errcode)
                     return NULL;
                 }
 
-            bzero(ret,sizeof(libraw_processed_image_t));
+            memset(ret,0,sizeof(libraw_processed_image_t));
             ret->type   = LIBRAW_IMAGE_BITMAP;
             ret->height = T.theight;
             ret->width  = T.twidth;
@@ -856,7 +860,7 @@ libraw_processed_image_t * LibRaw::dcraw_make_mem_thumb(int *errcode)
                     return NULL;
                 }
 
-            bzero(ret,sizeof(libraw_processed_image_t));
+            memset(ret,0,sizeof(libraw_processed_image_t));
 
             ret->type = LIBRAW_IMAGE_JPEG;
             ret->data_size = dsize;
@@ -921,7 +925,7 @@ libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)
                 if(errcode) *errcode= ENOMEM;
                 return NULL;
         }
-    bzero(ret,sizeof(libraw_processed_image_t));
+    memset(ret,0,sizeof(libraw_processed_image_t));
     // metadata init
 
     int s_iheight = S.iheight;
@@ -1091,15 +1095,16 @@ void LibRaw::kodak_thumb_loader()
         for (col=0; col < S.width; col++, img+=4)
             {
                 out[0] = out[1] = out[2] = 0;
-                for(int c=0;c<3;c++) 
+                int c;
+                for(c=0;c<3;c++)
                     {
                         out[0] += out_cam[0][c] * img[c];
                         out[1] += out_cam[1][c] * img[c];
                         out[2] += out_cam[2][c] * img[c];
                     }
-                for(int c=0; c<3; c++)
+                for(c=0; c<3; c++)
                     img[c] = CLIP((int) out[c]);
-                for(int c=0; c<P1.colors;c++)
+                for(c=0; c<P1.colors;c++)
                     t_hist[c][img[c] >> 3]++;
                     
             }
@@ -1593,6 +1598,7 @@ static const char  *static_camera_list[] =
 "Canon PowerShot A5 Zoom",
 "Canon PowerShot A50",
 "Canon PowerShot A460 (CHDK hack)",
+"Canon PowerShot A470 (CHDK hack)",
 "Canon PowerShot A530 (CHDK hack)",
 "Canon PowerShot A570 (CHDK hack)",
 "Canon PowerShot A590 (CHDK hack)",
@@ -1614,6 +1620,7 @@ static const char  *static_camera_list[] =
 "Canon PowerShot G7 (CHDK hack)",
 "Canon PowerShot G9",
 "Canon PowerShot G10",
+"Canon PowerShot G11",
 "Canon PowerShot S2 IS (CHDK hack)",
 "Canon PowerShot S3 IS (CHDK hack)",
 "Canon PowerShot S5 IS (CHDK hack)",
@@ -1662,6 +1669,8 @@ static const char  *static_camera_list[] =
 "Casio EX-Z4",
 "Casio EX-Z50",
 "Casio EX-Z55",
+"Casio EX-Z60",
+"Casio EX-Z75",
 "Casio Exlim Pro 505",
 "Casio Exlim Pro 600",
 "Casio Exlim Pro 700",
@@ -1730,6 +1739,7 @@ static const char  *static_camera_list[] =
 "Kodak C603",
 "Kodak P850",
 "Kodak P880",
+"Kodak Z980",
 "Kodak Z1015",
 "Kodak KAI-0340",
 "Konica KD-400Z",
@@ -1796,6 +1806,8 @@ static const char  *static_camera_list[] =
 "Nikon D200",
 "Nikon D300",
 "Nikon D700",
+"Nikon D3000",
+"Nikon D5000",
 "Nikon E700 (\"DIAG RAW\" hack)",
 "Nikon E800 (\"DIAG RAW\" hack)",
 "Nikon E880 (\"DIAG RAW\" hack)",
@@ -1826,6 +1838,7 @@ static const char  *static_camera_list[] =
 "Olympus C740UZ",
 "Olympus C770UZ",
 "Olympus C8080WZ",
+"Olympus X200,D560Z,C350Z",
 "Olympus E-1",
 "Olympus E-3",
 "Olympus E-10",
@@ -1839,6 +1852,8 @@ static const char  *static_camera_list[] =
 "Olympus E-500",
 "Olympus E-510",
 "Olympus E-520",
+"Olympus E-620",
+"Olympus E-P1",
 "Olympus SP310",
 "Olympus SP320",
 "Olympus SP350",
@@ -1851,6 +1866,7 @@ static const char  *static_camera_list[] =
 "Panasonic DMC-FZ18",
 "Panasonic DMC-FZ28",
 "Panasonic DMC-FZ30",
+"Panasonic DMC-FZ35/FZ38",
 "Panasonic DMC-FZ50",
 "Panasonic DMC-FX150",
 "Panasonic DMC-G1",
@@ -1872,6 +1888,7 @@ static const char  *static_camera_list[] =
 "Pentax K100D Super",
 "Pentax K200D",
 "Pentax K2000/K-m",
+"Pentax K-7",
 "Pentax Optio S",
 "Pentax Optio S4",
 "Pentax Optio 33WR",
@@ -1910,6 +1927,7 @@ static const char  *static_camera_list[] =
 "Sony DSLR-A100",
 "Sony DSLR-A200",
 "Sony DSLR-A300",
+"Sony DSLR-A330",
 "Sony DSLR-A350",
 "Sony DSLR-A700",
 "Sony DSLR-A900",
diff --git a/lib/libfspotraw/Makefile.am b/lib/libfspotraw/Makefile.am
index 4cf23e6..71704e0 100644
--- a/lib/libfspotraw/Makefile.am
+++ b/lib/libfspotraw/Makefile.am
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Makefile.include
 
-LIBRAW = LibRaw-0.8.0-Beta4
+LIBRAW = LibRaw-0.8.2
 INCLUDES = -I $(top_srcdir) -I $(srcdir)/LibRaw $(F_CFLAGS)
 
 fspotlibdir = $(libdir)/f-spot



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]