SOURCES: dcraw.c - updated to 2005/09/25 22:26:03.

pluto pluto at pld-linux.org
Fri Sep 30 17:37:01 CEST 2005


Author: pluto                        Date: Fri Sep 30 15:37:01 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- updated to 2005/09/25 22:26:03.

---- Files affected:
SOURCES:
   dcraw.c (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: SOURCES/dcraw.c
diff -u SOURCES/dcraw.c:1.4 SOURCES/dcraw.c:1.5
--- SOURCES/dcraw.c:1.4	Tue Sep  6 09:13:40 2005
+++ SOURCES/dcraw.c	Fri Sep 30 17:36:56 2005
@@ -97,7 +97,7 @@
 unsigned filters;
 ushort (*image)[4], white[8][8], curve[0x1000];
 void (*load_raw)();
-float bright=1.0, red_scale=1.0, blue_scale=1.0;
+float bright=1, red_scale=1, blue_scale=1, sigma_d=0, sigma_r=0;
 int four_color_rgb=0, document_mode=0, quick_interpolate=0;
 int verbose=0, use_auto_wb=0, use_camera_wb=0, use_camera_rgb=0;
 int fuji_secondary, use_secondary=0;
@@ -440,26 +440,21 @@
  */
 unsigned CLASS getbits (int nbits)
 {
-  static unsigned long bitbuf=0;
+  static unsigned bitbuf=0;
   static int vbits=0, reset=0;
-  unsigned c, ret;
+  unsigned c;
 
-  if (nbits == 0 || nbits > vbits) return 0;
-  if (nbits == -2)
-    return ftell(ifp) + (-vbits >> 3);
   if (nbits == -1)
-    ret = bitbuf = vbits = reset = 0;
-  else {
-    ret = bitbuf << (LONG_BIT - vbits) >> (LONG_BIT - nbits);
-    vbits -= nbits;
-  }
-  while (!reset && vbits < LONG_BIT - 7) {
+    return bitbuf = vbits = reset = 0;
+  if (nbits == 0 || reset) return 0;
+  while (vbits < nbits) {
     c = fgetc(ifp);
-    if ((reset = zero_after_ff && c == 0xff && fgetc(ifp))) break;
+    if ((reset = zero_after_ff && c == 0xff && fgetc(ifp))) return 0;
     bitbuf = (bitbuf << 8) + c;
     vbits += 8;
   }
-  return ret;
+  vbits -= nbits;
+  return bitbuf << (32-nbits-vbits) >> (32-nbits);
 }
 
 void CLASS init_decoder ()
@@ -756,6 +751,7 @@
 
   if (jrow * jh->wide % jh->restart == 0) {
     FORC4 jh->vpred[c] = 1 << (jh->bits-1);
+    if (jrow) get2();			/* Eat the FF Dx marker */
     getbits(-1);
   }
   for (col=0; col < jh->wide; col++)
@@ -879,12 +875,19 @@
 void CLASS adobe_dng_load_raw_nc()
 {
   ushort *pixel, *rp;
-  int row, col;
+  int row, col, nbits;
 
   pixel = calloc (raw_width * tiff_samples, sizeof *pixel);
   merror (pixel, "adobe_dng_load_raw_nc()");
+  for (nbits=0; 1 << nbits <= maximum; nbits++);
   for (row=0; row < raw_height; row++) {
-    read_shorts (pixel, raw_width * tiff_samples);
+    if (nbits == 16)
+      read_shorts (pixel, raw_width * tiff_samples);
+    else {
+      getbits(-1);
+      for (col=0; col < raw_width * tiff_samples; col++)
+	pixel[col] = getbits(nbits);
+    }
     for (rp=pixel, col=0; col < raw_width; col++)
       adobe_copy_pixel (row, col, &rp);
   }
@@ -1892,7 +1895,7 @@
     diff = sym[2] << 5 | sym[1] << 2 | (sym[0] & 3);
     if (sym[0] & 4)
       diff = diff ? -diff : 0x80;
-    if (getbits(-2) + 12 > seg[1][1])
+    if (ftell(ifp) + 12 >= seg[1][1])
       diff = 0;
     pred[pix & 1] += diff;
     row = pix / raw_width - top_margin;
@@ -2748,6 +2751,7 @@
     for   (row=cut[sq][3]; row < cut[sq][3]+cut[sq][1]; row++)
       for (col=cut[sq][2]; col < cut[sq][2]+cut[sq][0]; col++) {
 	c = FC(row,col);
+	if (c >= colors) c -= 2;
 	gmb_cam[sq][c] += BAYER(row,col);
 	count[c]++;
       }
@@ -2794,11 +2798,11 @@
 
   maximum -= black;
   if (use_auto_wb || (use_camera_wb && camera_red == -1)) {
-    FORCC min[c] = INT_MAX;
-    FORCC max[c] = count[c] = sum[c] = 0;
+    FORC4 min[c] = INT_MAX;
+    FORC4 max[c] = count[c] = sum[c] = 0;
     for (row=0; row < height; row++)
       for (col=0; col < width; col++)
-	FORCC {
+	FORC4 {
 	  val = image[row*width+col][c];
 	  if (!val) continue;
 	  if (min[c] > val) min[c] = val;
@@ -2809,10 +2813,10 @@
 	  sum[c] += val;
 	  count[c]++;
 	}
-    FORCC pre_mul[c] = count[c] / sum[c];
+    FORC4 if (sum[c]) pre_mul[c] = count[c] / sum[c];
   }
   if (use_camera_wb && camera_red != -1) {
-    FORCC count[c] = sum[c] = 0;
+    FORC4 count[c] = sum[c] = 0;
     for (row=0; row < 8; row++)
       for (col=0; col < 8; col++) {
 	c = FC(row,col);
@@ -2820,10 +2824,8 @@
 	  sum[c] += val;
 	count[c]++;
       }
-    val = 1;
-    FORCC if (sum[c] == 0) val = 0;
-    if (val)
-      FORCC pre_mul[c] = count[c] / sum[c];
+    if (sum[0] && sum[1] && sum[2] && sum[3])
+      FORC4 pre_mul[c] = count[c] / sum[c];
     else if (camera_red && camera_blue)
       memcpy (pre_mul, cam_mul, sizeof pre_mul);
     else
@@ -2833,36 +2835,48 @@
     pre_mul[0] *= red_scale;
     pre_mul[2] *= blue_scale;
   }
+  if (pre_mul[3] == 0) pre_mul[3] = colors < 4 ? pre_mul[1] : 1;
   dmin = DBL_MAX;
-  FORCC if (dmin > pre_mul[c])
+  FORC4 if (dmin > pre_mul[c])
 	    dmin = pre_mul[c];
-  FORCC pre_mul[c] /= dmin;
+  FORC4 pre_mul[c] /= dmin;
 
   while (maximum << shift < 0x8000) shift++;
-  FORCC pre_mul[c] *= 1 << shift;
+  FORC4 pre_mul[c] *= 1 << shift;
   maximum <<= shift;
 
   if (write_fun != write_ppm || bright < 1) {
     maximum *= bright;
     if (maximum > 0xffff)
 	maximum = 0xffff;
-    FORCC pre_mul[c] *= bright;
+    FORC4 pre_mul[c] *= bright;
   }
   if (verbose) {
     fprintf (stderr, "Scaling with black=%d, pre_mul[] =", black);
-    FORCC fprintf (stderr, " %f", pre_mul[c]);
+    FORC4 fprintf (stderr, " %f", pre_mul[c]);
     fputc ('\n', stderr);
   }
   clip_max = clip_color ? maximum : 0xffff;
   for (row=0; row < height; row++)
     for (col=0; col < width; col++)
-      FORCC {
+      FORC4 {
 	val = image[row*width+col][c];
 	if (!val) continue;
 	val -= black;
 	val *= pre_mul[c];
 	image[row*width+col][c] = CLIP(val);
       }
+  if (filters && colors == 3) {
+    if (four_color_rgb) {
+      colors++;
+      FORC3 rgb_cam[c][3] = rgb_cam[c][1] /= 2;
+    } else {
+      for (row = FC(1,0) >> 1; row < height; row+=2)
+	for (col = FC(row,1) & 1; col < width; col+=2)
+	  image[row*width+col][1] = image[row*width+col][3];
+      filters &= ~((filters & 0x55555555) << 1);
+    }
+  }
 }
 
 /*
@@ -3033,6 +3047,34 @@
   free (brow[4]);
 }
 
+void CLASS cam_to_cielab (ushort cam[4], float lab[3])
+{
+  int c, i, j, k;
+  float r, xyz[3];
+  static const float d65[3] = { 0.950456, 1, 1.088754 };
+  static float cbrt[0x10000], xyz_cam[3][3];
+
+  if (cam == NULL) {
+    for (i=0; i < 0x10000; i++) {
+      r = (float) i / maximum;
+      cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0;
+    }
+    for (i=0; i < 3; i++)
+      for (j=0; j < colors; j++)
+        for (xyz_cam[i][j] = k=0; k < 3; k++)
+	  xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j] / d65[i];
+  } else {
+    for (i=0; i < 3; i++) {
+      for (xyz[i]=0.5, c=0; c < colors; c++)
+	xyz[i] += xyz_cam[i][c] * cam[c];
+      xyz[i] = cbrt[CLIP((int) xyz[i])];
+    }
+    lab[0] = 116 * xyz[1] - 16;
+    lab[1] = 500 * (xyz[0] - xyz[1]);
+    lab[2] = 200 * (xyz[1] - xyz[2]);
+  }
+}
+
 /*
    Adaptive Homogeneity-Directed interpolation is based on
    the work of Keigo Hirakawa, Thomas Parks, and Paul Lee.
@@ -3041,37 +3083,25 @@
 
 void CLASS ahd_interpolate()
 {
-  int i, j, k, top, left, row, col, tr, tc, fc, c, d, val;
-  int west, east, north, south, num, total[3], hm[3];
+  int i, j, top, left, row, col, tr, tc, fc, c, d, val, hm[2];
   ushort (*pix)[4], (*rix)[3];
   static const int dir[4] = { -1, 1, -TS, TS };
-  unsigned ldiff[3][4], abdiff[3][4], leps, abeps;
-  float r, *cbrt, xyz[3], xyz_cam[3][3];
+  unsigned ldiff[2][4], abdiff[2][4], leps, abeps;
+  float flab[3];
   ushort (*rgb)[TS][TS][3];
    short (*lab)[TS][TS][3];
    char (*homo)[TS][TS], *buffer;
 
   if (verbose) fprintf (stderr, "AHD interpolation...\n");
-  buffer = malloc (0x40000 + 39*TS*TS);		/* 2752 kB */
+  buffer = malloc (26*TS*TS);			/* 1664 kB */
   merror (buffer, "ahd_interpolate()");
-  cbrt = (void *) buffer;
-  rgb  = (void *) (buffer + 0x40000);
-  lab  = (void *) (buffer + 0x40000 + 18*TS*TS);
-  homo = (void *) (buffer + 0x40000 + 36*TS*TS);
-
-/*  Prepare conversion from raw color to CIELab:		*/
-  for (i=0; i < 0x10000; i++) {
-    r = (float) i / maximum;
-    cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0;
-  }
-  for (i=0; i < 3; i++)
-    for (j=0; j < 3; j++)
-      for (xyz_cam[i][j] = k=0; k < 3; k++)
-	xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j];
+  rgb  = (void *) buffer;
+  lab  = (void *) (buffer + 12*TS*TS);
+  homo = (void *) (buffer + 24*TS*TS);
 
   for (top=0; top < height; top += TS-6)
     for (left=0; left < width; left += TS-6) {
-      memset (rgb, 0, 18*TS*TS);
+      memset (rgb, 0, 12*TS*TS);
 
 /*  Horizontally interpolate green into rgb[0]:			*/
       for (row = top; row < top+TS && row < height; row++) {
@@ -3094,31 +3124,8 @@
 	  rgb[1][row-top][col-left][1] = CLIP(val);
 	}
       }
-/*  Combine these into rgb[2] using edge-sensing:		*/
-      for (row = top < 1 ? 1:top; row < top+TS && row < height-1; row++) {
-	tr = row - top;
-	col = left + (FC(row,left) == 1);
-	if (col < 1) col += 2;
-	for ( ; col < left+TS && col < width-1; col+=2) {
-	  tc = col - left;
-	  pix = image + row*width + col;
-	  west  = rgb[0][tr][tc][1] - pix[-1][1];
-	  east  = rgb[0][tr][tc][1] - pix[+1][1];
-	  north = rgb[1][tr][tc][1] - pix[-width][1];
-	  south = rgb[1][tr][tc][1] - pix[+width][1];
-	  if ((val = ABS(west) + ABS(east) - ABS(north) - ABS(south)))
-	    rgb[2][tr][tc][1] = rgb[val > 0][tr][tc][1];
-	  else {
-	    west *= east;
-	    north *= south;
-	    rgb[2][tr][tc][1] = (west*north < 0)
-		?  rgb[west > 0][tr][tc][1]
-		: (rgb[0][tr][tc][1] + rgb[1][tr][tc][1]) >> 1;
-	  }
-	}
-      }
 /*  Interpolate red and blue, and convert to CIELab:		*/
-      for (d=0; d < 3; d++)
+      for (d=0; d < 2; d++)
 	for (row=top+1; row < top+TS-1 && row < height-1; row++) {
 	  tr = row-top;
 	  for (col=left+1; col < left+TS-1 && col < width-1; col++) {
@@ -3127,55 +3134,42 @@
 	    rix = &rgb[d][tr][tc];
 	    if ((c = 2 - FC(row,col)) == 1) {
 	      c = FC(row+1,col);
-	      val = ( pix[-1][2-c] + pix[1][2-c] +
-			2*pix[0][1] - rix[-1][1] - rix[1][1] ) >> 1;
+	      val = pix[0][1] + (( pix[-1][2-c] + pix[1][2-c]
+				 - rix[-1][1] - rix[1][1] ) >> 1);
 	      rix[0][2-c] = CLIP(val);
-	      val = ( pix[-width][c] + pix[width][c] +
-			2*pix[0][1] - rix[-TS][1] - rix[TS][1] ) >> 1;
-	    } else {
-	      north = 2*rix[0][1] - (rix[-TS-1][1] + rix[TS+1][1]);
-	      west  = 2*rix[0][1] - (rix[-TS+1][1] + rix[TS-1][1]);
-	      val = (d < 2) ? 0 :
-		   ABS(pix[-width-1][c] - pix[width+1][c]) + ABS(north)
-		 - ABS(pix[-width+1][c] - pix[width-1][c]) - ABS(west);
-	      north += pix[-width-1][c] + pix[width+1][c];
-	      west  += pix[-width+1][c] + pix[width-1][c];
-	      if     (val == 0) val = (north + west) >> 2;
-	      else if (val < 0) val = north >> 1;
-	      else		val = west  >> 1;
-	    }
+	      val = pix[0][1] + (( pix[-width][c] + pix[width][c]
+				 - rix[-TS][1] - rix[TS][1] ) >> 1);
+	    } else
+	      val = rix[0][1] + (( pix[-width-1][c] + pix[-width+1][c]
+				 + pix[+width-1][c] + pix[+width+1][c]
+				 - rix[-TS-1][1] - rix[-TS+1][1]
+				 - rix[+TS-1][1] - rix[+TS+1][1] + 1) >> 2);
 	    rix[0][c] = CLIP(val);
 	    c = FC(row,col);
 	    rix[0][c] = pix[0][c];
-	    for (i=0; i < 3; i++) {
-	      for (xyz[i]=0.5, c=0; c < 3; c++)
-		xyz[i] += xyz_cam[i][c] * rix[0][c];
-	      xyz[i] = cbrt[CLIP((int) xyz[i])];
-	    }
-	    lab[d][tr][tc][0] = 32*116 * xyz[1] - 32*16;
-	    lab[d][tr][tc][1] = 32*500 * (xyz[0] - xyz[1]);
-	    lab[d][tr][tc][2] = 32*200 * (xyz[1] - xyz[2]);
+	    cam_to_cielab (rix[0], flab);
+	    FORC3 lab[d][tr][tc][c] = 64*flab[c];
 	  }
 	}
 /*  Build homogeneity maps from the CIELab images:		*/
-      memset (homo, 0, 3*TS*TS);
+      memset (homo, 0, 2*TS*TS);
       for (row=top+2; row < top+TS-2 && row < height; row++) {
 	tr = row-top;
 	for (col=left+2; col < left+TS-2 && col < width; col++) {
 	  tc = col-left;
-	  for (d=0; d < 3; d++)
+	  for (d=0; d < 2; d++)
 	    for (i=0; i < 4; i++)
 	      ldiff[d][i] = ABS(lab[d][tr][tc][0]-lab[d][tr][tc+dir[i]][0]);
 	  leps = MIN(MAX(ldiff[0][0],ldiff[0][1]),
 		     MAX(ldiff[1][2],ldiff[1][3]));
-	  for (d=0; d < 3; d++)
+	  for (d=0; d < 2; d++)
 	    for (i=0; i < 4; i++)
 	      if (i >> 1 == d || ldiff[d][i] <= leps)
 		abdiff[d][i] = SQR(lab[d][tr][tc][1]-lab[d][tr][tc+dir[i]][1])
 			     + SQR(lab[d][tr][tc][2]-lab[d][tr][tc+dir[i]][2]);
 	  abeps = MIN(MAX(abdiff[0][0],abdiff[0][1]),
 		      MAX(abdiff[1][2],abdiff[1][3]));
-	  for (d=0; d < 3; d++)
+	  for (d=0; d < 2; d++)
 	    for (i=0; i < 4; i++)
 	      if (ldiff[d][i] <= leps && abdiff[d][i] <= abeps)
 		homo[d][tr][tc]++;
@@ -3186,17 +3180,15 @@
 	tr = row-top;
 	for (col=left+3; col < left+TS-3 && col < width-3; col++) {
 	  tc = col-left;
-	  for (d=0; d < 3; d++)
+	  for (d=0; d < 2; d++)
 	    for (hm[d]=0, i=tr-1; i <= tr+1; i++)
 	      for (j=tc-1; j <= tc+1; j++)
 		hm[d] += homo[d][i][j];
-	  FORC3 total[c] = 0;
-	  for (num=d=0; d < 3; d++)
-	    if (hm[d] >= hm[0] && hm[d] >= hm[1] && hm[d] >= hm[2]) {
-	      FORC3 total[c] += rgb[d][tr][tc][c];
-	      num++;
-	    }
-	  FORC3 image[row*width+col][c] = total[c] / num;
+	  if (hm[0] != hm[1])
+	    FORC3 image[row*width+col][c] = rgb[hm[1] > hm[0]][tr][tc][c];
+	  else
+	    FORC3 image[row*width+col][c] =
+		(rgb[0][tr][tc][c] + rgb[1][tr][tc][c]) >> 1;
 	}
       }
     }
@@ -3205,6 +3197,63 @@
 }
 #undef TS
 
+/*
+   Bilateral Filtering was developed by C. Tomasi and R. Manduchi.
+ */
+void CLASS bilateral_filter()
+{
+  float (**window)[7], *kernel, scale_r, elut[1024], sum[5];
+  int c, i, wr, ws, wlast, row, col, y, x;
+  unsigned sep;
+
+  if (verbose) fprintf (stderr, "Bilateral filtering...\n");
+
+  wr = ceil(sigma_d*2);		/* window radius */
+  ws = 2*wr + 1;		/* window size */
+  window = calloc ((ws+1)*sizeof  *window +
+		 ws*width*sizeof **window + ws*sizeof *kernel, 1);
+  merror (window, "bilateral_filter()");
+  for (i=0; i <= ws; i++)
+    window[i] = (float(*)[7]) (window+ws+1) + i*width;
+  kernel = (float *) window[ws] + wr;
+  for (i=-wr; i <= wr; i++)
+    kernel[i] = 256 / (2*SQR(sigma_d)) * i*i + 0.25;
+  scale_r     = 256 / (2*SQR(sigma_r));
+  for (i=0; i < 1024; i++)
+    elut[i] = exp (-i/256.0);
+
+  for (wlast=-1, row=0; row < height; row++) {
+    while (wlast < row+wr) {
+      wlast++;
+      for (i=0; i <= ws; i++)	/* rotate window rows */
+	window[(ws+i) % (ws+1)] = window[i];
+      if (wlast < height)
+	for (col=0; col < width; col++) {
+	  FORCC window[ws-1][col][c] = image[wlast*width+col][c];
+	  cam_to_cielab (image[wlast*width+col], window[ws-1][col]+4);
+	}
+    }
+    for (col=0; col < width; col++) {
+      memset (sum, 0, sizeof sum);
+      for (y=-wr; y <= wr; y++)
+	if ((unsigned)(row+y) < height)
+	  for (x=-wr; x <= wr; x++)
+	    if ((unsigned)(col+x) < width) {
+	      sep = ( SQR(window[wr+y][col+x][4] - window[wr][col][4])
+		    + SQR(window[wr+y][col+x][5] - window[wr][col][5])
+		    + SQR(window[wr+y][col+x][6] - window[wr][col][6]) )
+			* scale_r + kernel[y] + kernel[x];
+	      if (sep < 1024) {
+		FORCC sum[c] += elut[sep] * window[wr+y][col+x][c];
+		sum[4] += elut[sep];
+	      }
+	    }
+      FORCC image[row*width+col][c] = sum[c]/sum[4];
+    }
+  }
+  free (window);
+}
+
 void CLASS parse_makernote()
 {
   static const uchar xlat[2][256] = {
@@ -3396,6 +3445,7 @@
   char str[20];
   int i;
 
+  if (timestamp) return;
   str[19] = 0;
   if (reversed)
     for (i=19; i--; ) str[i] = fgetc(ifp);
@@ -3425,12 +3475,8 @@
     fseek (ifp, base+val, SEEK_SET);
     if (tag == 0x9003 || tag == 0x9004)
       get_timestamp(0);
-    if (tag == 0x927c) {
-      if (!strncmp(make,"SONY",4))
-	data_offset = base+val+len;
-      else
-	parse_makernote();
-    }
+    if (tag == 0x927c)
+      parse_makernote();
     fseek (ifp, save, SEEK_SET);
   }
 }
@@ -3828,6 +3874,7 @@
 	camera_red   =(get2() ^ key[1]) / camera_red;
 	camera_blue  = get2() ^ key[0];
 	camera_blue /= get2() ^ key[1];
+	if (!wbi) camera_red = -1;	/* Use my auto WB for this photo */
       } else if (!strcmp(model,"Canon PowerShot G6") ||
 		 !strcmp(model,"Canon PowerShot S60") ||
 		 !strcmp(model,"Canon PowerShot S70")) {
@@ -3882,8 +3929,6 @@
       parse_ciff(aoff, len);
     fseek (ifp, save, SEEK_SET);
   }
-  if (wbi == 0 && !strcmp(model,"Canon EOS D30"))
-    camera_red = -1;			/* Use my auto WB for this photo */
 }
 
 void CLASS parse_rollei()
@@ -3928,7 +3973,7 @@
 void CLASS parse_mos (int offset)
 {
   uchar data[40];
-  int skip, from, i, neut[4];
+  int skip, from, i, c, neut[4];
   static const unsigned bayer[] =
 	{ 0x94949494, 0x61616161, 0x16161616, 0x49494949 };
 
@@ -3956,8 +4001,7 @@
     if (!strcmp(data,"NeutObj_neutrals")) {
       for (i=0; i < 4; i++)
 	fscanf (ifp, "%d", neut+i);
-      camera_red  = (float) neut[2] / neut[1];
-      camera_blue = (float) neut[2] / neut[3];
+      FORC3 cam_mul[c] = 1.0 / neut[c+1];
     }
     parse_mos (from);
     fseek (ifp, skip+from, SEEK_SET);
@@ -4353,6 +4397,8 @@
 	{ 10473,-3277,-1222,-6421,14252,2352,-1907,2596,7460 } },
     { "SONY DSC-F828",
 	{ 7924,-1910,-777,-8226,15459,2998,-1517,2199,6818,-7242,11401,3481 } },
+    { "SONY DSC-R1",		/* DJC */
+	{ 10528,-3695,-517,-2822,10699,2124,406,1240,5342 } },
     { "SONY DSC-V3",
 	{ 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } }
   };
@@ -4457,7 +4503,7 @@
     {  6114240, "PENTAX",   "Optio S4"   ,1 },  /* or S4i */
     { 12582980, "Sinar",    ""           ,0 } };
   static const char *corp[] =
-    { "Canon", "NIKON", "EPSON", "Kodak", "OLYMPUS", "PENTAX",
+    { "Canon", "NIKON", "EPSON", "KODAK", "Kodak", "OLYMPUS", "PENTAX",
       "MINOLTA", "Minolta", "Konica", "CASIO" };
 
 /*  What format is this file?  Set make[] if we recognize it. */
@@ -4473,8 +4519,8 @@
   raw_color = use_gamma = xmag = ymag = 1;
   filters = UINT_MAX;	/* 0 = no filters, UINT_MAX = unknown */
   for (i=0; i < 4; i++) {
-    cam_mul[i] = 1 & i;
-    pre_mul[i] = 1;
+    cam_mul[i] = i == 1;
+    pre_mul[i] = i < 3;
     FORC3 rgb_cam[c][i] = c == i;
   }
   colors = 3;
@@ -5117,6 +5163,7 @@
   } else if (!strcmp(model,"DSC-F828")) {
     width = 3288;
     left_margin = 5;
+    data_offset = 862144;
     load_raw = sony_load_raw;
     filters = 0x9c9c9c9c;
     colors = 4;
@@ -5124,7 +5171,19 @@
   } else if (!strcmp(model,"DSC-V3")) {
     width = 3109;
     left_margin = 59;
+    data_offset = 787392;
     load_raw = sony_load_raw;
+  } else if (!strcmp(model,"DSC-R1")) {
+    width = 3925;
+    order = 0x4d4d;
+    load_raw = unpacked_load_raw;
+    black = 512;
+  } else if (!strncmp(model,"P850",4)) {
+    height = 1950;
+    width  = 2608;
+    data_offset = 76456;
+    filters = 0x16161616;
+    load_raw = packed_12_load_raw;
   } else if (!strcasecmp(make,"KODAK")) {
     filters = 0x61616161;
     if (!strcmp(model,"NC2000F")) {
@@ -5362,18 +5421,13 @@
     rgb_cam[0][c] *= red_scale;
     rgb_cam[2][c] *= blue_scale;
   }
-  if (four_color_rgb && filters && colors == 3) {
+  if (filters && colors == 3)
     for (i=0; i < 32; i+=4) {
       if ((filters >> i & 15) == 9)
 	filters |= 2 << i;
       if ((filters >> i & 15) == 6)
 	filters |= 8 << i;
     }
-    colors++;
-    cam_mul[3] = cam_mul[1];
-    pre_mul[3] = pre_mul[1];
-    FORC3 rgb_cam[c][3] = rgb_cam[c][1] /= 2;
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/dcraw.c?r1=1.4&r2=1.5&f=u




More information about the pld-cvs-commit mailing list