Update to dcraw 9.21, Revision 1.463

This commit is contained in:
Ingo
2014-06-17 22:55:16 +02:00
parent 54b3cbd86a
commit 12d0638982
6 changed files with 878 additions and 835 deletions

View File

@@ -1,5 +1,5 @@
--- dcraw.c 2014-02-19 17:25:45.051457734 +0100
+++ dcraw.cc 2014-05-26 14:28:48.785835594 +0200
--- dcraw.c 2014-06-17 19:24:34 +0000
+++ dcraw.cc 2014-06-17 19:58:03 +0000
@@ -1,3 +1,15 @@
+/*RT*/#include <glib.h>
+/*RT*/#include <glib/gstdio.h>
@@ -52,7 +52,7 @@
#define snprintf _snprintf
#define strcasecmp stricmp
#define strncasecmp strnicmp
@@ -98,87 +109,38 @@
@@ -98,88 +109,38 @@
#define LONG_BIT (8 * sizeof (long))
#endif
@@ -127,7 +127,8 @@
-} tiff_ifd[10];
-
-struct ph1 {
- int format, key_off, black, black_off, split_col, tag_21a;
- int format, key_off, tag_21a;
- int black, split_col, black_col, split_row, black_row;
- float tag_210;
-} ph1;
@@ -156,7 +157,7 @@
#define SWAP(a,b) { a=a+b; b=a-b; a=a-b; }
/*
@@ -254,6 +216,7 @@
@@ -255,6 +216,7 @@
if (filters == 1) return filter[(row+top_margin)&15][(col+left_margin)&15];
if (filters == 9) return xtrans[(row+top_margin+6)%6][(col+left_margin+6)%6];
@@ -164,7 +165,7 @@
return FC(row,col);
}
@@ -296,6 +259,7 @@
@@ -297,6 +259,7 @@
fprintf (stderr,_("Corrupt data near 0x%llx\n"), (INT64) ftello(ifp));
}
data_error++;
@@ -172,73 +173,16 @@
}
ushort CLASS sget2 (uchar *s)
@@ -369,7 +333,64 @@
@@ -370,7 +333,7 @@
{
if (fread (pixel, 2, count, ifp) < count) derror();
if ((order == 0x4949) == (ntohs(0x1234) == 0x1234))
- swab (pixel, pixel, count*2);
+ swab ((char*)pixel, (char*)pixel, count*2);
+}
+
+/* spline interpolation to 16 bit curve */
+void CLASS cubic_spline(const int *x_, const int *y_, const int len)
+{
+ float A[2*len][2*len], b[2*len], c[2*len], d[2*len];
+ float x[len], y[len];
+ int i, j;
+
+ memset(A, 0, sizeof(A));
+ memset(b, 0, sizeof(b));
+ memset(c, 0, sizeof(c));
+ memset(d, 0, sizeof(d));
+ for (i = 0; i < len; i++) {
+ x[i] = x_[i] / 65535.0;
+ y[i] = y_[i] / 65535.0;
+ }
+
+ for (i = len-1; i > 0; i--) {
+ b[i] = (y[i] - y[i-1]) / (x[i] - x[i-1]);
+ d[i-1] = x[i] - x[i-1];
+ }
+ for (i = 1; i < len-1; i++) {
+ A[i][i] = 2 * (d[i-1] + d[i]);
+ if (i > 1) {
+ A[i][i-1] = d[i-1];
+ A[i-1][i] = d[i-1];
+ }
+ A[i][len-1] = 6 * (b[i+1] - b[i]);
+ }
+ for(i = 1; i < len-2; i++) {
+ float v = A[i+1][i] / A[i][i];
+ for(j = 1; j <= len-1; j++) {
+ A[i+1][j] -= v * A[i][j];
+ }
+ }
+ for(i = len-2; i > 0; i--) {
+ float acc = 0;
+ for(j = i; j <= len-2; j++) {
+ acc += A[i][j]*c[j];
+ }
+ c[i] = (A[i][len-1] - acc) / A[i][i];
+ }
+ for (i = 0; i < 0x10000; i++) {
+ float x_out = (float)(i / 65535.0);
+ float y_out = 0;
+ for (j = 0; j < len-1; j++) {
+ if (x[j] <= x_out && x_out <= x[j+1]) {
+ float v = x_out - x[j];
+ y_out = y[j] +
+ ((y[j+1] - y[j]) / d[j] - (2 * d[j] * c[j] + c[j+1] * d[j]) / 6) * v +
+ (c[j] * 0.5) * v*v +
+ ((c[j+1] - c[j]) / (6 * d[j])) * v*v*v;
+ }
+ }
+ curve[i] = y_out < 0.0 ? 0 : (y_out >= 1.0 ? 65535 : (ushort)nearbyintf(y_out * 65535.0));
+ }
}
void CLASS canon_600_fixed_wb (int temp)
@@ -541,10 +562,10 @@
void CLASS cubic_spline (const int *x_, const int *y_, const int len)
@@ -595,10 +558,10 @@
return 0;
}
@@ -252,7 +196,7 @@
unsigned c;
if (nbits > 25) return 0;
@@ -1209,14 +1230,14 @@
@@ -1263,14 +1226,14 @@
int i, nz;
char tail[424];
@@ -269,207 +213,7 @@
void CLASS ppm_thumb()
{
@@ -1310,14 +1331,16 @@
void CLASS phase_one_flat_field (int is_float, int nc)
{
ushort head[8];
- unsigned wide, y, x, c, rend, cend, row, col;
+ unsigned wide, high, y, x, c, rend, cend, row, col;
float *mrow, num, mult[4];
read_shorts (head, 8);
- wide = head[2] / head[4];
+ if (head[2] == 0 || head[3] == 0 || head[4] == 0 || head[5] == 0) return; // RT: should not really happen, but when reverse-engineering IIQ files zero'd calibration data was used, so it's nice if not crashing.
+ wide = head[2] / head[4] + (head[2] % head[4] != 0);
+ high = head[3] / head[5] + (head[3] % head[5] != 0);
mrow = (float *) calloc (nc*wide, sizeof *mrow);
merror (mrow, "phase_one_flat_field()");
- for (y=0; y < head[3] / head[5]; y++) {
+ for (y=0; y < high; y++) {
for (x=0; x < wide; x++)
for (c=0; c < nc; c+=2) {
num = is_float ? getreal(11) : get2()/32768.0;
@@ -1326,14 +1349,14 @@
}
if (y==0) continue;
rend = head[1] + y*head[5];
- for (row = rend-head[5]; row < raw_height && row < rend; row++) {
+ for (row = rend-head[5]; row < raw_height && row < rend && row < head[1]+head[3]-head[5]; row++) {
for (x=1; x < wide; x++) {
for (c=0; c < nc; c+=2) {
mult[c] = mrow[c*wide+x-1];
mult[c+1] = (mrow[c*wide+x] - mult[c]) / head[4];
}
cend = head[0] + x*head[4];
- for (col = cend-head[4]; col < raw_width && col < cend; col++) {
+ for (col = cend-head[4]; col < raw_width && col < cend && col < head[0]+head[2]-head[4]; col++) {
c = nc > 2 ? FC(row-top_margin,col-left_margin) : 0;
if (!(c & 1)) {
c = RAW(row,col) * mult[c];
@@ -1361,6 +1384,7 @@
{-2,-2}, {-2,2}, {2,-2}, {2,2} };
float poly[8], num, cfrac, frac, mult[2], *yval[2];
ushort *xval[2];
+ int qmult_applied = 0, qlin_applied = 0;
if (half_size || !meta_length) return;
if (verbose) fprintf (stderr,_("Phase One correction...\n"));
@@ -1437,6 +1461,154 @@
mindiff = diff;
off_412 = ftell(ifp) - 38;
}
+ } else if (tag == 0x41f && !qlin_applied) { /* Per quadrant linearization, P40+/P65+ */
+ ushort lc[2][2][16], ref[16];
+ int qr, qc;
+ /* Get curves for each quadrant (ordered top left, top right, bottom left, bottom right) */
+ for (qr = 0; qr < 2; qr++) {
+ for (qc = 0; qc < 2; qc++) {
+ for (i = 0; i < 16; i++) {
+ lc[qr][qc][i] = (ushort)get4();
+ }
+ }
+ }
+ /*
+ Each curve hold values along some exponential function, from ~20 to about ~50000, example:
+ 28 41 64 106 172 282 462 762 1240 2353 5111 10127 17867 27385 39122 58451
+ */
+
+ /* Derive a reference curve, by taking the average value in each column. Note: seems to work well,
+ but not 100% sure this is how the reference curve should be derived. */
+ for (i = 0; i < 16; i++) {
+ int v = 0;
+ for (qr = 0; qr < 2; qr++) {
+ for (qc = 0; qc < 2; qc++) {
+ v += lc[qr][qc][i];
+ }
+ }
+ ref[i] = (v + 2) >> 2;
+ }
+
+ /* Interpolate full calibration curves and apply. Spline interpolation used here,
+ as the curves are so coarsely specified and would get sharp corners if linearly
+ interpolated. */
+ for (qr = 0; qr < 2; qr++) {
+ for (qc = 0; qc < 2; qc++) {
+ int cx[18];
+ int cf[18];
+ for (i = 0; i < 16; i++) {
+ cx[1+i] = lc[qr][qc][i];
+ cf[1+i] = ref[i];
+ }
+ cx[0] = cf[0] = 0;
+ cx[17] = cf[17] = ((unsigned int)ref[15] * 65535) / lc[qr][qc][15];
+ cubic_spline(cx, cf, 18);
+ /* Apply curve in designated quadrant */
+ for (row = (qr ? ph1.split_row : 0); row < (qr ? raw_height : ph1.split_row); row++) {
+ for (col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++) {
+ RAW(row,col) = curve[RAW(row,col)];
+ }
+ }
+ }
+ }
+ /* By some unknown reason some backs provide more than one copy of this tag, make sure
+ that we only apply this once. */
+ qlin_applied = 1;
+ } else if (tag == 0x41e && !qmult_applied) { /* Per quadrant multipliers P40+/P65+ */
+ float qmult[2][2] = { { 1, 1 }, { 1, 1 } };
+
+ /*
+ This tag has not been fully reverse-engineered, seems to be used only on P40+ and P65+ backs,
+ and will then have most values set to zero.
+
+ Layout:
+
+ - First 4 bytes contains 'II' (or 'MM' I guess if file is big endian, but don't think there are
+ any such backs produced) plus short integer 1
+ - The remaining 80 bytes seems to be 20 floats, most of them always zero. Example contents,
+ with map:
+
+ 0.000000, 0.000000, 0.080410, 0.078530,
+ 0.000000, 0.000000, 0.000000, 0.000000,
+ 0.104100, 0.103500, 0.000000, 0.000000,
+ 0.000000, 0.000000, 0.000000, 0.000000,
+ 0.089540, 0.092230, 0.000000, 0.000000
+
+ noeffect, noeffect, noeffect, topleft ,
+ noeffect, TL++ , global , noeffect,
+ noeffect, topright, , TR++ ,
+ , bottmlft, , BL++ ,
+ noeffect, bottmrgt, , BR++ ,
+
+ 'noeffect' tested with no effect, empty not tested, the ++ versions are stronger effect
+ multpliers that doesn't seem to be used, the global multiplier seems to unused as well.
+
+ It seems like one quadrant always is generally used as reference, (ie value 0 => multiplier 1.0),
+ but it's not always the same quadrant for different backs.
+
+ The 'noeffect' fields which actually have values are suspicious, maybe these multipliers are
+ used in Sensor+ or at some different ISO or something? They seem to be close to the ordinary
+ multipliers though so using the 'wrong' ones in some special case should yield quite good
+ result still.
+ */
+
+ /* We only read out the multipliers that are used and seem to have any effect and are used */
+ get4(); get4(); get4(); get4();
+ qmult[0][0] = 1.0 + getreal(11);
+ get4(); get4(); get4(); get4(); get4();
+ qmult[0][1] = 1.0 + getreal(11);
+ get4(); get4(); get4();
+ qmult[1][0] = 1.0 + getreal(11);
+ get4(); get4(); get4();
+ qmult[1][1] = 1.0 + getreal(11);
+ for (row=0; row < raw_height; row++) {
+ for (col=0; col < raw_width; col++) {
+ i = qmult[row >= ph1.split_row][col >= ph1.split_col] * RAW(row,col);
+ RAW(row,col) = LIM(i,0,65535);
+ }
+ }
+ /* By some unknown reason some backs provide more than one copy of this tag, make sure
+ that we only apply this once. */
+ qmult_applied = 1;
+ } else if (tag == 0x431 && !qmult_applied) { /* Per quadrant multiplication and linearization, IQ series backs */
+ ushort lc[2][2][7], ref[7];
+ int qr, qc;
+
+ /* Read reference curve */
+ for (i = 0; i < 7; i++) {
+ ref[i] = (ushort)get4();
+ }
+
+ /* Get multipliers for each quadrant */
+ for (qr = 0; qr < 2; qr++) {
+ for (qc = 0; qc < 2; qc++) {
+ for (i = 0; i < 7; i++) {
+ lc[qr][qc][i] = (ushort)get4();
+ }
+ }
+ }
+ /* Spline interpolation and apply in each quadrant */
+ for (qr = 0; qr < 2; qr++) {
+ for (qc = 0; qc < 2; qc++) {
+ int cx[9];
+ int cf[9];
+ for (i = 0; i < 7; i++) {
+ cx[1+i] = ref[i];
+ cf[1+i] = ((unsigned int)ref[i] * lc[qr][qc][i]) / 10000;
+ }
+ cx[0] = cf[0] = 0;
+ cx[8] = cf[8] = 65535;
+ cubic_spline(cx, cf, 9);
+ for (row = (qr ? ph1.split_row : 0); row < (qr ? raw_height : ph1.split_row); row++) {
+ for (col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++) {
+ RAW(row,col) = curve[RAW(row,col)];
+ }
+ }
+ }
+ }
+ /* not seen any backs that have this tag multiplied, but just to make sure */
+ qmult_applied = 1;
+ qlin_applied = 1;
}
fseek (ifp, save, SEEK_SET);
}
@@ -1494,10 +1666,10 @@
@@ -1632,10 +1595,10 @@
}
}
@@ -483,43 +227,7 @@
unsigned c;
if (nbits == -1)
@@ -1523,8 +1695,10 @@
static const int length[] = { 8,7,6,9,11,10,5,12,14,13 };
int *offset, len[2], pred[2], row, col, i, j;
ushort *pixel;
- short (*black)[2];
+ short (*black)[2], (*black2)[2];
+ black2 = (short (*)[2]) calloc (raw_width*2, 2);
+ merror (black2, "phase_one_load_raw_c()");
pixel = (ushort *) calloc (raw_width + raw_height*4, 2);
merror (pixel, "phase_one_load_raw_c()");
offset = (int *) (pixel + raw_width);
@@ -1535,6 +1709,9 @@
fseek (ifp, ph1.black_off, SEEK_SET);
if (ph1.black_off)
read_shorts ((ushort *) black[0], raw_height*2);
+ fseek (ifp, ph1.black_off2, SEEK_SET);
+ if (ph1.black_off2)
+ read_shorts ((ushort *) black2[0], raw_width*2);
for (i=0; i < 256; i++)
curve[i] = i*i / 3.969 + 0.5;
for (row=0; row < raw_height; row++) {
@@ -1558,11 +1735,12 @@
pixel[col] = curve[pixel[col]];
}
for (col=0; col < raw_width; col++) {
- i = (pixel[col] << 2) - ph1.black + black[row][col >= ph1.split_col];
+ i = (pixel[col] << 2) - ph1.black + black[row][col >= ph1.split_col] + black2[col][row >= ph1.split_row];
if (i > 0) RAW(row,col) = i;
}
}
free (pixel);
+ free (black2);
maximum = 0xfffc - ph1.black;
}
@@ -1757,10 +1935,10 @@
@@ -1901,10 +1864,10 @@
maximum = curve[0x3ff];
}
@@ -533,7 +241,7 @@
int byte;
if (!nbits) return vbits=0;
@@ -2049,11 +2227,11 @@
@@ -2193,11 +2156,11 @@
METHODDEF(boolean)
fill_input_buffer (j_decompress_ptr cinfo)
{
@@ -547,7 +255,7 @@
cinfo->src->next_input_byte = jpeg_buffer;
cinfo->src->bytes_in_buffer = nbytes;
return TRUE;
@@ -2371,10 +2549,9 @@
@@ -2522,10 +2485,9 @@
maximum = (1 << (thumb_misc & 31)) - 1;
}
@@ -560,7 +268,7 @@
if (start) {
for (p=0; p < 4; p++)
pad[p] = key = key * 48828125 + 1;
@@ -2462,11 +2639,13 @@
@@ -2610,11 +2572,13 @@
bit += 7;
}
for (i=0; i < 16; i++, col+=2)
@@ -575,7 +283,7 @@
}
void CLASS samsung_load_raw()
@@ -2691,7 +2870,7 @@
@@ -2861,7 +2825,7 @@
void CLASS foveon_decoder (unsigned size, unsigned code)
{
@@ -584,7 +292,7 @@
struct decode *cur;
int i, len;
@@ -3414,10 +3593,13 @@
@@ -3584,10 +3548,13 @@
}
}
} else {
@@ -600,7 +308,7 @@
if (mask[0][3] > 0) goto mask_set;
if (load_raw == &CLASS canon_load_raw ||
load_raw == &CLASS lossless_jpeg_load_raw) {
@@ -4011,239 +4193,8 @@
@@ -4183,239 +4150,8 @@
}
}
@@ -609,8 +317,7 @@
- int code[16][16][32], size=16, *ip, sum[4];
- int f, c, i, x, y, row, col, shift, color;
- ushort *pix;
+/* RT: delete interpolation functions */
-
- if (verbose) fprintf (stderr,_("Bilinear interpolation...\n"));
- if (filters == 9) size = 6;
- border_interpolate(1);
@@ -652,7 +359,8 @@
- This algorithm is officially called:
-
- "Interpolation using a Threshold-based variable number of gradients"
-
+/* RT: delete interpolation functions */
- described in http://scien.stanford.edu/pages/labsite/1999/psych221/projects/99/tingchen/algodep/vargra.html
-
- I've extended the basic idea to work with non-Bayer filter arrays.
@@ -841,7 +549,7 @@
void CLASS cielab (ushort rgb[3], short lab[3])
{
@@ -4504,112 +4455,7 @@
@@ -4676,112 +4412,7 @@
}
#undef fcol
@@ -859,7 +567,7 @@
- char (*homo)[TS][TS], *buffer;
-
- if (verbose) fprintf (stderr,_("AHD interpolation...\n"));
-
- cielab (0,0);
- border_interpolate(5);
- buffer = (char *) malloc (26*TS*TS);
@@ -867,7 +575,7 @@
- rgb = (ushort(*)[TS][TS][3]) buffer;
- lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS);
- homo = (char (*)[TS][TS]) (buffer + 24*TS*TS);
-
- for (top=2; top < height-5; top += TS-6)
- for (left=2; left < width-5; left += TS-6) {
-
@@ -954,7 +662,7 @@
#undef TS
void CLASS median_filter()
@@ -4779,7 +4625,7 @@
@@ -4951,7 +4582,7 @@
}
}
@@ -963,7 +671,7 @@
void CLASS parse_makernote (int base, int uptag)
{
@@ -4936,7 +4782,8 @@
@@ -5108,7 +4739,8 @@
cam_mul[2] = get4() << 2;
}
}
@@ -973,7 +681,7 @@
fread (model, 64, 1, ifp);
if (strstr(make,"PENTAX")) {
if (tag == 0x1b) tag = 0x1018;
@@ -5187,7 +5034,7 @@
@@ -5359,7 +4991,7 @@
{ "","DCB2","Volare","Cantare","CMost","Valeo 6","Valeo 11","Valeo 22",
"Valeo 11p","Valeo 17","","Aptus 17","Aptus 22","Aptus 75","Aptus 65",
"Aptus 54S","Aptus 65S","Aptus 75S","AFi 5","AFi 6","AFi 7",
@@ -982,7 +690,7 @@
"","","","","Aptus-II 10R","Aptus-II 8","","Aptus-II 12","","AFi-II 12" };
float romm_cam[3][3];
@@ -5276,6 +5123,8 @@
@@ -5448,6 +5080,8 @@
wbi = -2;
}
if (tag == 2118) wbtemp = getint(type);
@@ -991,7 +699,7 @@
if (tag == 2130 + wbi)
FORC3 mul[c] = getreal(type);
if (tag == 2140 + wbi && wbi >= 0)
@@ -5295,8 +5144,8 @@
@@ -5467,8 +5101,8 @@
}
}
@@ -1002,7 +710,7 @@
int CLASS parse_tiff_ifd (int base)
{
@@ -5309,7 +5158,7 @@
@@ -5481,7 +5115,7 @@
unsigned sony_curve[] = { 0,0,0,0,0,4095 };
unsigned *buf, sony_offset=0, sony_length=0, sony_key=0;
struct jhead jh;
@@ -1011,7 +719,7 @@
if (tiff_nifds >= sizeof tiff_ifd / sizeof tiff_ifd[0])
return 1;
@@ -5379,7 +5228,8 @@
@@ -5555,7 +5189,8 @@
fgets (make, 64, ifp);
break;
case 272: /* Model */
@@ -1021,7 +729,7 @@
break;
case 280: /* Panasonic RW2 offset */
if (type != 4) break;
@@ -5435,6 +5285,9 @@
@@ -5611,6 +5246,9 @@
case 315: /* Artist */
fread (artist, 64, 1, ifp);
break;
@@ -1031,7 +739,7 @@
case 322: /* TileWidth */
tiff_ifd[ifd].tile_width = getint(type);
break;
@@ -5448,6 +5301,9 @@
@@ -5626,6 +5264,9 @@
is_raw = 5;
}
break;
@@ -1041,7 +749,7 @@
case 330: /* SubIFDs */
if (!strcmp(model,"DSLR-A100") && tiff_ifd[ifd].width == 3872) {
load_raw = &CLASS sony_arw_load_raw;
@@ -5461,6 +5317,9 @@
@@ -5639,6 +5280,9 @@
fseek (ifp, i+4, SEEK_SET);
}
break;
@@ -1051,7 +759,7 @@
case 400:
strcpy (make, "Sarnoff");
maximum = 0xfff;
@@ -5630,6 +5489,9 @@
@@ -5820,6 +5464,9 @@
if (!make[0]) strcpy (make, "DNG");
is_raw = 1;
break;
@@ -1059,9 +767,9 @@
+ fgets (model3, 64, ifp);
+ break;
case 50710: /* CFAPlaneColor */
if (filters == 9) break;
if (len > 4) len = 4;
colors = len;
@@ -5660,10 +5522,21 @@
@@ -5851,10 +5498,21 @@
case 61450:
cblack[4] = cblack[5] = MIN(sqrt(len),64);
case 50714: /* BlackLevel */
@@ -1087,7 +795,7 @@
case 50715: /* BlackLevelDeltaH */
case 50716: /* BlackLevelDeltaV */
for (num=i=0; i < len; i++)
@@ -5741,12 +5614,15 @@
@@ -5932,12 +5590,15 @@
fread (buf, sony_length, 1, ifp);
sony_decrypt (buf, sony_length/4, 1, sony_key);
sfp = ifp;
@@ -1109,7 +817,7 @@
ifp = sfp;
free (buf);
}
@@ -5770,6 +5646,7 @@
@@ -5961,6 +5622,7 @@
int CLASS parse_tiff (int base)
{
int doff;
@@ -1117,7 +825,7 @@
fseek (ifp, base, SEEK_SET);
order = get2();
@@ -5847,7 +5724,7 @@
@@ -6038,7 +5700,7 @@
case 8: load_raw = &CLASS eight_bit_load_raw; break;
case 12: if (tiff_ifd[raw].phint == 2)
load_flags = 6;
@@ -1126,7 +834,7 @@
case 14: load_flags = 0;
case 16: load_raw = &CLASS unpacked_load_raw;
if (!strncmp(make,"OLYMPUS",7) &&
@@ -5878,6 +5755,7 @@
@@ -6071,6 +5733,7 @@
case 32803: load_raw = &CLASS kodak_65000_load_raw;
}
case 32867: case 34892: break;
@@ -1134,7 +842,7 @@
default: is_raw = 0;
}
if (!dng_version)
@@ -5963,7 +5841,7 @@
@@ -6156,7 +5819,7 @@
{
const char *file, *ext;
char *jname, *jfile, *jext;
@@ -1143,7 +851,7 @@
ext = strrchr (ifname, '.');
file = strrchr (ifname, '/');
@@ -5985,13 +5863,14 @@
@@ -6178,13 +5841,14 @@
} else
while (isdigit(*--jext)) {
if (*jext != '9') {
@@ -1160,16 +868,7 @@
if (verbose)
fprintf (stderr,_("Reading metadata from %s ...\n"), jname);
parse_tiff (12);
@@ -6256,6 +6135,8 @@
case 0x21d: ph1.black = data; break;
case 0x222: ph1.split_col = data; break;
case 0x223: ph1.black_off = data+base; break;
+ case 0x224: ph1.split_row = data; break;
+ case 0x225: ph1.black_off2= data+base; break;
case 0x301:
model[63] = 0;
fread (model, 1, 63, ifp);
@@ -6334,7 +6215,11 @@
@@ -6529,7 +6193,11 @@
order = get2();
hlen = get4();
if (get4() == 0x48454150) /* "HEAP" */
@@ -1181,7 +880,7 @@
if (parse_tiff (save+6)) apply_tiff();
fseek (ifp, save+len, SEEK_SET);
}
@@ -6586,7 +6471,8 @@
@@ -6781,7 +6449,8 @@
{
static const struct {
const char *prefix;
@@ -1191,7 +890,7 @@
} table[] = {
{ "AgfaPhoto DC-833m", 0, 0, /* DJC */
{ 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } },
@@ -7457,6 +7343,27 @@
@@ -7668,6 +7337,27 @@
}
break;
}
@@ -1219,7 +918,7 @@
}
void CLASS simple_coeff (int index)
@@ -7732,7 +7639,7 @@
@@ -7945,7 +7635,7 @@
tiff_flip = flip = filters = UINT_MAX; /* unknown */
raw_height = raw_width = fuji_width = fuji_layout = cr2_slice[0] = 0;
maximum = height = width = top_margin = left_margin = 0;
@@ -1228,7 +927,7 @@
iso_speed = shutter = aperture = focal_len = unique_id = 0;
tiff_nifds = 0;
memset (tiff_ifd, 0, sizeof tiff_ifd);
@@ -7764,13 +7671,20 @@
@@ -7977,13 +7667,20 @@
fread (head, 1, 32, ifp);
fseek (ifp, 0, SEEK_END);
flen = fsize = ftell(ifp);
@@ -1251,7 +950,7 @@
parse_ciff (hlen, flen-hlen, 0);
load_raw = &CLASS canon_load_raw;
} else if (parse_tiff(0)) apply_tiff();
@@ -7816,6 +7730,7 @@
@@ -8029,6 +7726,7 @@
fseek (ifp, 100+28*(shot_select > 0), SEEK_SET);
parse_tiff (data_offset = get4());
parse_tiff (thumb_offset+12);
@@ -1259,7 +958,7 @@
apply_tiff();
} else if (!memcmp (head,"RIFF",4)) {
fseek (ifp, 0, SEEK_SET);
@@ -7925,15 +7840,18 @@
@@ -8138,15 +7836,18 @@
if (make[0] == 0) parse_smal (0, flen);
if (make[0] == 0) {
parse_jpeg(0);
@@ -1287,7 +986,7 @@
}
for (i=0; i < sizeof corp / sizeof *corp; i++)
@@ -7966,7 +7884,7 @@
@@ -8179,7 +7880,7 @@
if (height == 3136 && width == 4864) /* Pentax K20D and Samsung GX20 */
{ height = 3124; width = 4688; filters = 0x16161616; }
if (width == 4352 && (!strcmp(model,"K-r") || !strcmp(model,"K-x")))
@@ -1296,7 +995,7 @@
if (width >= 4960 && !strncmp(model,"K-5",3))
{ left_margin = 10; width = 4950; filters = 0x16161616; }
if (width == 4736 && !strcmp(model,"K-7"))
@@ -7985,6 +7903,7 @@
@@ -8198,6 +7899,7 @@
switch (tiff_compress) {
case 1: load_raw = &CLASS packed_dng_load_raw; break;
case 7: load_raw = &CLASS lossless_dng_load_raw; break;
@@ -1304,7 +1003,7 @@
case 34892: load_raw = &CLASS lossy_dng_load_raw; break;
default: load_raw = 0;
}
@@ -8112,7 +8031,7 @@
@@ -8325,7 +8027,7 @@
width -= 44;
} else if (!strcmp(model,"D3200") ||
!strcmp(model,"D600") ||
@@ -1313,7 +1012,7 @@
width -= 46;
} else if (!strcmp(model,"D4") ||
!strcmp(model,"Df")) {
@@ -8324,6 +8243,7 @@
@@ -8542,6 +8244,7 @@
if (load_raw == &CLASS lossless_jpeg_load_raw)
load_raw = &CLASS hasselblad_load_raw;
if (raw_width == 7262) {
@@ -1321,7 +1020,7 @@
height = 5444;
width = 7248;
top_margin = 4;
@@ -8335,13 +8255,31 @@
@@ -8553,13 +8256,31 @@
top_margin = 4;
left_margin = 41;
filters = 0x61616161;
@@ -1355,7 +1054,7 @@
} else if (raw_width == 4090) {
strcpy (model, "V96C");
height -= (top_margin = 6);
@@ -8394,6 +8332,7 @@
@@ -8612,6 +8333,7 @@
filters = 0x16161616;
}
} else if (!strcmp(make,"Leica") || !strcmp(make,"Panasonic")) {
@@ -1363,7 +1062,7 @@
if ((flen - data_offset) / (raw_width*8/7) == raw_height)
load_raw = &CLASS panasonic_load_raw;
if (!load_raw) {
@@ -8411,6 +8350,7 @@
@@ -8629,6 +8351,7 @@
}
filters = 0x01010101 * (uchar) "\x94\x61\x49\x16"
[((filters-1) ^ (left_margin & 1) ^ (top_margin << 1)) & 3];
@@ -1371,7 +1070,7 @@
} else if (!strcmp(model,"C770UZ")) {
height = 1718;
width = 2304;
@@ -8630,6 +8570,10 @@
@@ -8856,6 +8579,10 @@
memcpy (rgb_cam, cmatrix, sizeof cmatrix);
raw_color = 0;
}
@@ -1382,7 +1081,7 @@
if (raw_color) adobe_coeff (make, model);
if (load_raw == &CLASS kodak_radc_load_raw)
if (raw_color) adobe_coeff ("Apple","Quicktake");
@@ -8646,7 +8590,7 @@
@@ -8872,7 +8599,7 @@
if (!tiff_bps) tiff_bps = 12;
if (!maximum) maximum = (1 << tiff_bps) - 1;
if (!load_raw || height < 22 || width < 22 ||
@@ -1391,7 +1090,7 @@
is_raw = 0;
#ifdef NO_JASPER
if (load_raw == &CLASS redcine_load_raw) {
@@ -8725,194 +8669,268 @@
@@ -8951,194 +8678,268 @@
}
#endif
@@ -1566,8 +1265,13 @@
+ }
+ }
+
+}
+
}
-void CLASS stretch()
-{
- ushort newdim, (*img)[4], *pix0, *pix1;
- int row, col, c;
- double rc, frac;
+// From DNG SDK dng_utils.h
+static inline uint32_t DNG_HalfToFloat(uint16_t halfValue) {
+ int32_t sign = (halfValue >> 15) & 0x00000001;
@@ -1600,14 +1304,8 @@
+ mantissa <<= 13;
+ // Assemble sign, exponent and mantissa.
+ return (uint32_t) ((sign << 31) | (exponent << 23) | mantissa);
}
+}
-void CLASS stretch()
-{
- ushort newdim, (*img)[4], *pix0, *pix1;
- int row, col, c;
- double rc, frac;
-
- if (pixel_aspect == 1) return;
- if (verbose) fprintf (stderr,_("Stretching the image...\n"));
- if (pixel_aspect < 1) {
@@ -1835,7 +1533,7 @@
struct tiff_tag {
ushort tag, type;
@@ -8935,585 +8953,12 @@
@@ -9161,585 +8962,12 @@
unsigned gps[26];
char desc[512], make[64], model[64], soft[32], date[20], artist[64];
};