Merge pull request #3316 from Beep6581/dcrawupdate

Update to dcraw 9.27
This commit is contained in:
Ingo Weyrich 2016-05-29 22:39:56 +02:00
commit fe8c8bfc99
5 changed files with 929 additions and 473 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -127,6 +127,7 @@ protected:
struct tiff_ifd { struct tiff_ifd {
int width, height, bps, comp, phint, offset, flip, samples, bytes; int width, height, bps, comp, phint, offset, flip, samples, bytes;
int tile_width, tile_length, sample_format, predictor; int tile_width, tile_length, sample_format, predictor;
float shutter;
} tiff_ifd[10]; } tiff_ifd[10];
struct ph1 { struct ph1 {
@ -139,8 +140,8 @@ protected:
} hbd; } hbd;
struct jhead { struct jhead {
int bits, high, wide, clrs, sraw, psv, restart, vpred[6]; int algo, bits, high, wide, clrs, sraw, psv, restart, vpred[6];
ushort *huff[6], *free[4], *row; ushort quant[64], idct[64], *huff[20], *free[20], *row;
}; };
struct tiff_tag { struct tiff_tag {
@ -217,6 +218,8 @@ void ljpeg_end (struct jhead *jh);
int ljpeg_diff (ushort *huff); int ljpeg_diff (ushort *huff);
ushort * ljpeg_row (int jrow, struct jhead *jh); ushort * ljpeg_row (int jrow, struct jhead *jh);
void lossless_jpeg_load_raw(); void lossless_jpeg_load_raw();
void ljpeg_idct (struct jhead *jh);
void canon_sraw_load_raw(); void canon_sraw_load_raw();
void adobe_copy_pixel (unsigned row, unsigned col, ushort **rp); void adobe_copy_pixel (unsigned row, unsigned col, ushort **rp);

View File

@ -1,5 +1,5 @@
--- dcraw.c 2016-02-11 22:56:58.043957200 +0100 --- dcraw.c 2016-05-29 22:32:01.173135400 +0200
+++ dcraw.cc 2016-02-11 23:13:28.708268000 +0100 +++ dcraw.cc 2016-05-29 21:57:44.144527700 +0200
@@ -1,3 +1,15 @@ @@ -1,3 +1,15 @@
+/*RT*/#include <glib.h> +/*RT*/#include <glib.h>
+/*RT*/#include <glib/gstdio.h> +/*RT*/#include <glib/gstdio.h>
@ -15,7 +15,7 @@
+ +
/* /*
dcraw.c -- Dave Coffin's raw photo decoder dcraw.c -- Dave Coffin's raw photo decoder
Copyright 1997-2015 by Dave Coffin, dcoffin a cybercom o net Copyright 1997-2016 by Dave Coffin, dcoffin a cybercom o net
@@ -29,17 +41,17 @@ @@ -29,17 +41,17 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#endif #endif
@ -52,8 +52,8 @@
#define snprintf _snprintf #define snprintf _snprintf
#define strcasecmp stricmp #define strcasecmp stricmp
#define strncasecmp strnicmp #define strncasecmp strnicmp
@@ -98,88 +109,38 @@ @@ -89,89 +100,38 @@
#define LONG_BIT (8 * sizeof (long)) #define _(String) (String)
#endif #endif
-#if !defined(uchar) -#if !defined(uchar)
@ -123,6 +123,7 @@
-struct tiff_ifd { -struct tiff_ifd {
- int width, height, bps, comp, phint, offset, flip, samples, bytes; - int width, height, bps, comp, phint, offset, flip, samples, bytes;
- int tile_width, tile_length; - int tile_width, tile_length;
- float shutter;
-} tiff_ifd[10]; -} tiff_ifd[10];
- -
-struct ph1 { -struct ph1 {
@ -147,7 +148,7 @@
-#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#define LIM(x,min,max) MAX(min,MIN(x,max)) -#define LIM(x,min,max) MAX(min,MIN(x,max))
-#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y)) -#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
-#define CLIP(x) LIM(x,0,65535) -#define CLIP(x) LIM((int)(x),0,65535)
+#define MIN(a,b) rtengine::min(a,static_cast<__typeof__(a)>(b)) +#define MIN(a,b) rtengine::min(a,static_cast<__typeof__(a)>(b))
+#define MAX(a,b) rtengine::max(a,static_cast<__typeof__(a)>(b)) +#define MAX(a,b) rtengine::max(a,static_cast<__typeof__(a)>(b))
+#define LIM(x,min,max) rtengine::LIM(x,static_cast<__typeof__(x)>(min),static_cast<__typeof__(x)>(max)) +#define LIM(x,min,max) rtengine::LIM(x,static_cast<__typeof__(x)>(min),static_cast<__typeof__(x)>(max))
@ -156,7 +157,7 @@
#define SWAP(a,b) { a=a+b; b=a-b; a=a-b; } #define SWAP(a,b) { a=a+b; b=a-b; a=a-b; }
/* /*
@@ -255,6 +216,7 @@ @@ -247,6 +207,7 @@
if (filters == 1) return filter[(row+top_margin)&15][(col+left_margin)&15]; if (filters == 1) return filter[(row+top_margin)&15][(col+left_margin)&15];
if (filters == 9) return xtrans[(row+6) % 6][(col+6) % 6]; if (filters == 9) return xtrans[(row+6) % 6][(col+6) % 6];
@ -164,7 +165,7 @@
return FC(row,col); return FC(row,col);
} }
@@ -297,6 +259,7 @@ @@ -289,6 +250,7 @@
fprintf (stderr,_("Corrupt data near 0x%llx\n"), (INT64) ftello(ifp)); fprintf (stderr,_("Corrupt data near 0x%llx\n"), (INT64) ftello(ifp));
} }
data_error++; data_error++;
@ -172,7 +173,7 @@
} }
ushort CLASS sget2 (uchar *s) ushort CLASS sget2 (uchar *s)
@@ -370,7 +333,7 @@ @@ -362,7 +324,7 @@
{ {
if (fread (pixel, 2, count, ifp) < count) derror(); if (fread (pixel, 2, count, ifp) < count) derror();
if ((order == 0x4949) == (ntohs(0x1234) == 0x1234)) if ((order == 0x4949) == (ntohs(0x1234) == 0x1234))
@ -181,7 +182,7 @@
} }
void CLASS cubic_spline (const int *x_, const int *y_, const int len) void CLASS cubic_spline (const int *x_, const int *y_, const int len)
@@ -597,10 +560,10 @@ @@ -589,10 +551,10 @@
return 0; return 0;
} }
@ -195,17 +196,45 @@
unsigned c; unsigned c;
if (nbits > 25) return 0; if (nbits > 25) return 0;
@@ -824,7 +787,8 @@ @@ -805,9 +767,13 @@
FORC(2) free (huff[c]);
}
+/*
+ Not a full implementation of Lossless JPEG, just
+ enough to decode Canon, Kodak and Adobe DNG images.
+ */
struct jhead {
- int algo, bits, high, wide, clrs, sraw, psv, restart, vpred[6];
- ushort quant[64], idct[64], *huff[20], *free[20], *row;
+ int bits, high, wide, clrs, sraw, psv, restart, vpred[6];
+ ushort *huff[6], *free[4], *row;
};
int CLASS ljpeg_start (struct jhead *jh, int info_only) int CLASS ljpeg_start (struct jhead *jh, int info_only)
{ @@ -828,9 +794,9 @@
- int c, tag, len; switch (tag) {
+ int c, tag; case 0xffc3:
+ ushort len; jh->sraw = ((data[7] >> 4) * (data[7] & 15) - 1) & 3;
uchar data[0x10000]; - case 0xffc1:
const uchar *dp; + case 0xffc1:
case 0xffc0:
@@ -1284,14 +1248,14 @@ - jh->algo = tag & 0xff;
+ jh->algo = tag & 0xff;
jh->bits = data[0];
jh->high = data[1] << 8 | data[2];
jh->wide = data[3] << 8 | data[4];
@@ -1124,8 +1090,7 @@
if (++col >= tile_width || col >= raw_width)
row += 1 + (col = 0);
}
- }
- }
+ } }
fseek (ifp, save+4, SEEK_SET);
if ((tcol += tile_width) >= raw_width)
trow += tile_length + (tcol = 0);
@@ -1332,14 +1297,14 @@
int i, nz; int i, nz;
char tail[424]; char tail[424];
@ -222,7 +251,7 @@
void CLASS ppm_thumb() void CLASS ppm_thumb()
{ {
@@ -1653,10 +1617,10 @@ @@ -1701,10 +1666,10 @@
} }
} }
@ -236,17 +265,7 @@
unsigned c; unsigned c;
if (nbits == -1) if (nbits == -1)
@@ -1721,7 +1685,8 @@ @@ -1779,6 +1744,338 @@
pixel[col] = curve[pixel[col]];
}
for (col=0; col < raw_width; col++) {
- i = (pixel[col] << 2) - ph1.black
+ if (ph1.format != 8) pixel[col] <<= 2;
+ i = pixel[col] - ph1.black
+ cblack[row][col >= ph1.split_col]
+ rblack[col][row >= ph1.split_row];
if (i > 0) RAW(row,col) = i;
@@ -1731,6 +1696,338 @@
maximum = 0xfffc - ph1.black; maximum = 0xfffc - ph1.black;
} }
@ -585,7 +604,7 @@
void CLASS hasselblad_load_raw() void CLASS hasselblad_load_raw()
{ {
struct jhead jh; struct jhead jh;
@@ -1954,10 +2251,10 @@ @@ -2002,10 +2299,10 @@
maximum = curve[0x3ff]; maximum = curve[0x3ff];
} }
@ -599,7 +618,7 @@
int byte; int byte;
if (!nbits) return vbits=0; if (!nbits) return vbits=0;
@@ -2140,7 +2437,7 @@ @@ -2188,7 +2485,7 @@
void CLASS kodak_radc_load_raw() void CLASS kodak_radc_load_raw()
{ {
@ -608,7 +627,7 @@
1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8, 1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8,
1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8, 1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8,
2,1, 2,3, 3,0, 3,2, 3,4, 4,6, 5,5, 6,7, 6,8, 2,1, 2,3, 3,0, 3,2, 3,4, 4,6, 5,5, 6,7, 6,8,
@@ -2246,11 +2543,11 @@ @@ -2294,11 +2591,11 @@
METHODDEF(boolean) METHODDEF(boolean)
fill_input_buffer (j_decompress_ptr cinfo) fill_input_buffer (j_decompress_ptr cinfo)
{ {
@ -622,7 +641,7 @@
cinfo->src->next_input_byte = jpeg_buffer; cinfo->src->next_input_byte = jpeg_buffer;
cinfo->src->bytes_in_buffer = nbytes; cinfo->src->bytes_in_buffer = nbytes;
return TRUE; return TRUE;
@@ -2600,10 +2897,9 @@ @@ -2648,10 +2945,9 @@
maximum = (1 << (thumb_misc & 31)) - 1; maximum = (1 << (thumb_misc & 31)) - 1;
} }
@ -635,7 +654,7 @@
if (start) { if (start) {
for (p=0; p < 4; p++) for (p=0; p < 4; p++)
pad[p] = key = key * 48828125 + 1; pad[p] = key = key * 48828125 + 1;
@@ -2688,11 +2984,13 @@ @@ -2736,11 +3032,13 @@
bit += 7; bit += 7;
} }
for (i=0; i < 16; i++, col+=2) for (i=0; i < 16; i++, col+=2)
@ -650,7 +669,7 @@
} }
void CLASS samsung_load_raw() void CLASS samsung_load_raw()
@@ -2988,7 +3286,7 @@ @@ -3038,7 +3336,7 @@
void CLASS foveon_decoder (unsigned size, unsigned code) void CLASS foveon_decoder (unsigned size, unsigned code)
{ {
@ -659,7 +678,7 @@
struct decode *cur; struct decode *cur;
int i, len; int i, len;
@@ -3085,7 +3383,7 @@ @@ -3135,7 +3433,7 @@
pred[c] += diff[dindex->leaf]; pred[c] += diff[dindex->leaf];
if (pred[c] >> 16 && ~pred[c] >> 16) derror(); if (pred[c] >> 16 && ~pred[c] >> 16) derror();
} }
@ -668,7 +687,7 @@
} }
} }
} }
@@ -3696,6 +3994,8 @@ @@ -3746,6 +4044,8 @@
if (load_raw == &CLASS phase_one_load_raw || if (load_raw == &CLASS phase_one_load_raw ||
load_raw == &CLASS phase_one_load_raw_c) load_raw == &CLASS phase_one_load_raw_c)
phase_one_correct(); phase_one_correct();
@ -677,7 +696,7 @@
if (fuji_width) { if (fuji_width) {
for (row=0; row < raw_height-top_margin*2; row++) { for (row=0; row < raw_height-top_margin*2; row++) {
for (col=0; col < fuji_width << !fuji_layout; col++) { for (col=0; col < fuji_width << !fuji_layout; col++) {
@@ -3711,10 +4011,13 @@ @@ -3761,10 +4061,13 @@
} }
} }
} else { } else {
@ -693,7 +712,7 @@
if (mask[0][3] > 0) goto mask_set; if (mask[0][3] > 0) goto mask_set;
if (load_raw == &CLASS canon_load_raw || if (load_raw == &CLASS canon_load_raw ||
load_raw == &CLASS lossless_jpeg_load_raw) { load_raw == &CLASS lossless_jpeg_load_raw) {
@@ -4316,239 +4619,8 @@ @@ -4366,239 +4669,8 @@
} }
} }
@ -702,8 +721,7 @@
- int code[16][16][32], size=16, *ip, sum[4]; - int code[16][16][32], size=16, *ip, sum[4];
- int f, c, i, x, y, row, col, shift, color; - int f, c, i, x, y, row, col, shift, color;
- ushort *pix; - ushort *pix;
+/* RT: delete interpolation functions */ -
- if (verbose) fprintf (stderr,_("Bilinear interpolation...\n")); - if (verbose) fprintf (stderr,_("Bilinear interpolation...\n"));
- if (filters == 9) size = 6; - if (filters == 9) size = 6;
- border_interpolate(1); - border_interpolate(1);
@ -886,7 +904,8 @@
- int dir[5] = { 1, width, -1, -width, 1 }; - int dir[5] = { 1, width, -1, -width, 1 };
- int row, col, diff[2], guess[2], c, d, i; - int row, col, diff[2], guess[2], c, d, i;
- ushort (*pix)[4]; - ushort (*pix)[4];
- +/* RT: delete interpolation functions */
- border_interpolate(3); - border_interpolate(3);
- if (verbose) fprintf (stderr,_("PPG interpolation...\n")); - if (verbose) fprintf (stderr,_("PPG interpolation...\n"));
- -
@ -934,7 +953,7 @@
void CLASS cielab (ushort rgb[3], short lab[3]) void CLASS cielab (ushort rgb[3], short lab[3])
{ {
@@ -4814,112 +4886,7 @@ @@ -4864,112 +4936,7 @@
} }
#undef fcol #undef fcol
@ -952,7 +971,7 @@
- char (*homo)[TS][TS], *buffer; - char (*homo)[TS][TS], *buffer;
- -
- if (verbose) fprintf (stderr,_("AHD interpolation...\n")); - if (verbose) fprintf (stderr,_("AHD interpolation...\n"));
-
- cielab (0,0); - cielab (0,0);
- border_interpolate(5); - border_interpolate(5);
- buffer = (char *) malloc (26*TS*TS); - buffer = (char *) malloc (26*TS*TS);
@ -960,7 +979,7 @@
- rgb = (ushort(*)[TS][TS][3]) buffer; - rgb = (ushort(*)[TS][TS][3]) buffer;
- lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS); - lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS);
- homo = (char (*)[TS][TS]) (buffer + 24*TS*TS); - homo = (char (*)[TS][TS]) (buffer + 24*TS*TS);
-
- for (top=2; top < height-5; top += TS-6) - for (top=2; top < height-5; top += TS-6)
- for (left=2; left < width-5; left += TS-6) { - for (left=2; left < width-5; left += TS-6) {
- -
@ -1047,7 +1066,7 @@
#undef TS #undef TS
void CLASS median_filter() void CLASS median_filter()
@@ -5089,7 +5056,7 @@ @@ -5139,7 +5106,7 @@
} }
} }
@ -1056,7 +1075,7 @@
void CLASS parse_makernote (int base, int uptag) void CLASS parse_makernote (int base, int uptag)
{ {
@@ -5194,6 +5161,11 @@ @@ -5244,6 +5211,11 @@
tag |= uptag << 16; tag |= uptag << 16;
if (tag == 2 && strstr(make,"NIKON") && !iso_speed) if (tag == 2 && strstr(make,"NIKON") && !iso_speed)
iso_speed = (get2(),get2()); iso_speed = (get2(),get2());
@ -1068,7 +1087,7 @@
if (tag == 4 && len > 26 && len < 35) { if (tag == 4 && len > 26 && len < 35) {
if ((i=(get4(),get2())) != 0x7fff && !iso_speed) if ((i=(get4(),get2())) != 0x7fff && !iso_speed)
iso_speed = 50 * pow (2, i/32.0 - 4); iso_speed = 50 * pow (2, i/32.0 - 4);
@@ -5246,12 +5218,16 @@ @@ -5296,12 +5268,16 @@
cam_mul[2] = get4() << 2; cam_mul[2] = get4() << 2;
} }
} }
@ -1086,15 +1105,25 @@
if (tag == 0x1d) if (tag == 0x1d)
while ((c = fgetc(ifp)) && c != EOF) while ((c = fgetc(ifp)) && c != EOF)
serial = serial*10 + (isdigit(c) ? c - '0' : c % 10); serial = serial*10 + (isdigit(c) ? c - '0' : c % 10);
@@ -5442,6 +5418,7 @@ @@ -5491,14 +5467,14 @@
case 33434: shutter = getreal(type); break; while (entries--) {
tiff_get (base, &tag, &type, &len, &save);
switch (tag) {
- case 33434: tiff_ifd[tiff_nifds-1].shutter =
- shutter = getreal(type); break;
+ case 33434: tiff_ifd[tiff_nifds-1].shutter = shutter = getreal(type); break;
case 33437: aperture = getreal(type); break; case 33437: aperture = getreal(type); break;
case 34855: iso_speed = get2(); break; case 34855: iso_speed = get2(); break;
+ case 34866: if((!iso_speed) || iso_speed == 65535) iso_speed = get4();break; + case 34866: if((!iso_speed) || iso_speed == 65535) iso_speed = get4();break;
case 36867: case 36867:
case 36868: get_timestamp(0); break; case 36868: get_timestamp(0); break;
case 37377: if ((expo = -getreal(type)) < 128) case 37377: if ((expo = -getreal(type)) < 128)
@@ -5613,28 +5590,33 @@ - tiff_ifd[tiff_nifds-1].shutter =
+ tiff_ifd[tiff_nifds-1].shutter =
shutter = pow (2, expo); break;
case 37378: aperture = pow (2, getreal(type)/2); break;
case 37386: focal_len = getreal(type); break;
@@ -5667,28 +5643,33 @@
} }
} }
@ -1134,7 +1163,7 @@
entries = get2(); entries = get2();
if (entries > 512) return 1; if (entries > 512) return 1;
while (entries--) { while (entries--) {
@@ -5702,7 +5684,8 @@ @@ -5758,7 +5739,8 @@
fgets (make, 64, ifp); fgets (make, 64, ifp);
break; break;
case 272: /* Model */ case 272: /* Model */
@ -1144,7 +1173,7 @@
break; break;
case 280: /* Panasonic RW2 offset */ case 280: /* Panasonic RW2 offset */
if (type != 4) break; if (type != 4) break;
@@ -5762,6 +5745,9 @@ @@ -5818,6 +5800,9 @@
case 315: /* Artist */ case 315: /* Artist */
fread (artist, 64, 1, ifp); fread (artist, 64, 1, ifp);
break; break;
@ -1154,7 +1183,7 @@
case 322: /* TileWidth */ case 322: /* TileWidth */
tiff_ifd[ifd].tile_width = getint(type); tiff_ifd[ifd].tile_width = getint(type);
break; break;
@@ -5777,6 +5763,9 @@ @@ -5833,6 +5818,9 @@
is_raw = 5; is_raw = 5;
} }
break; break;
@ -1164,7 +1193,7 @@
case 330: /* SubIFDs */ case 330: /* SubIFDs */
if (!strcmp(model,"DSLR-A100") && tiff_ifd[ifd].width == 3872) { if (!strcmp(model,"DSLR-A100") && tiff_ifd[ifd].width == 3872) {
load_raw = &CLASS sony_arw_load_raw; load_raw = &CLASS sony_arw_load_raw;
@@ -5790,6 +5779,9 @@ @@ -5846,6 +5834,9 @@
fseek (ifp, i+4, SEEK_SET); fseek (ifp, i+4, SEEK_SET);
} }
break; break;
@ -1174,17 +1203,7 @@
case 400: case 400:
strcpy (make, "Sarnoff"); strcpy (make, "Sarnoff");
maximum = 0xfff; maximum = 0xfff;
@@ -5971,6 +5963,9 @@ @@ -6063,12 +6054,21 @@
if (!make[0]) strcpy (make, "DNG");
is_raw = 1;
break;
+ case 50708: /* UniqueCameraModel */
+ fgets (model3, 64, ifp);
+ break;
case 50710: /* CFAPlaneColor */
if (filters == 9) break;
if (len > 4) len = 4;
@@ -6002,12 +5997,21 @@
case 61450: case 61450:
cblack[4] = cblack[5] = MIN(sqrt(len),64); cblack[4] = cblack[5] = MIN(sqrt(len),64);
case 50714: /* BlackLevel */ case 50714: /* BlackLevel */
@ -1211,8 +1230,8 @@
+ break; + break;
case 50715: /* BlackLevelDeltaH */ case 50715: /* BlackLevelDeltaH */
case 50716: /* BlackLevelDeltaV */ case 50716: /* BlackLevelDeltaV */
for (num=i=0; i < len; i++) for (num=i=0; i < (len & 0xffff); i++)
@@ -6024,13 +6028,13 @@ @@ -6085,13 +6085,13 @@
case 50721: /* ColorMatrix1 */ case 50721: /* ColorMatrix1 */
case 50722: /* ColorMatrix2 */ case 50722: /* ColorMatrix2 */
FORCC for (j=0; j < 3; j++) FORCC for (j=0; j < 3; j++)
@ -1228,7 +1247,7 @@
break; break;
case 50727: /* AnalogBalance */ case 50727: /* AnalogBalance */
FORCC ab[c] = getreal(type); FORCC ab[c] = getreal(type);
@@ -6053,6 +6057,11 @@ @@ -6114,6 +6114,11 @@
case 50752: case 50752:
read_shorts (cr2_slice, 3); read_shorts (cr2_slice, 3);
break; break;
@ -1240,7 +1259,7 @@
case 50829: /* ActiveArea */ case 50829: /* ActiveArea */
top_margin = getint(type); top_margin = getint(type);
left_margin = getint(type); left_margin = getint(type);
@@ -6085,21 +6094,27 @@ @@ -6146,21 +6151,27 @@
fread (buf, sony_length, 1, ifp); fread (buf, sony_length, 1, ifp);
sony_decrypt (buf, sony_length/4, 1, sony_key); sony_decrypt (buf, sony_length/4, 1, sony_key);
sfp = ifp; sfp = ifp;
@ -1276,7 +1295,7 @@
cam_xyz_coeff (cmatrix, cam_xyz); cam_xyz_coeff (cmatrix, cam_xyz);
} }
if (asn[0]) { if (asn[0]) {
@@ -6107,13 +6122,14 @@ @@ -6168,13 +6179,14 @@
FORCC cam_mul[c] = 1 / asn[c]; FORCC cam_mul[c] = 1 / asn[c];
} }
if (!use_cm) if (!use_cm)
@ -1292,7 +1311,15 @@
fseek (ifp, base, SEEK_SET); fseek (ifp, base, SEEK_SET);
order = get2(); order = get2();
@@ -6191,7 +6207,12 @@ @@ -6206,6 +6218,7 @@
shutter = tiff_ifd[i].shutter;
tiff_ifd[i].shutter = shutter;
}
+
for (i=0; i < tiff_nifds; i++) {
if (max_samp < tiff_ifd[i].samples)
max_samp = tiff_ifd[i].samples;
@@ -6266,7 +6279,12 @@
case 8: load_raw = &CLASS eight_bit_load_raw; break; case 8: load_raw = &CLASS eight_bit_load_raw; break;
case 12: if (tiff_ifd[raw].phint == 2) case 12: if (tiff_ifd[raw].phint == 2)
load_flags = 6; load_flags = 6;
@ -1306,7 +1333,7 @@
case 14: load_flags = 0; case 14: load_flags = 0;
case 16: load_raw = &CLASS unpacked_load_raw; case 16: load_raw = &CLASS unpacked_load_raw;
if (!strncmp(make,"OLYMPUS",7) && if (!strncmp(make,"OLYMPUS",7) &&
@@ -6230,6 +6251,7 @@ @@ -6305,6 +6323,7 @@
case 32803: load_raw = &CLASS kodak_65000_load_raw; case 32803: load_raw = &CLASS kodak_65000_load_raw;
} }
case 32867: case 34892: break; case 32867: case 34892: break;
@ -1314,7 +1341,7 @@
default: is_raw = 0; default: is_raw = 0;
} }
if (!dng_version) if (!dng_version)
@@ -6315,7 +6337,7 @@ @@ -6390,7 +6409,7 @@
{ {
const char *file, *ext; const char *file, *ext;
char *jname, *jfile, *jext; char *jname, *jfile, *jext;
@ -1323,7 +1350,7 @@
ext = strrchr (ifname, '.'); ext = strrchr (ifname, '.');
file = strrchr (ifname, '/'); file = strrchr (ifname, '/');
@@ -6337,13 +6359,14 @@ @@ -6412,13 +6431,14 @@
} else } else
while (isdigit(*--jext)) { while (isdigit(*--jext)) {
if (*jext != '9') { if (*jext != '9') {
@ -1340,7 +1367,7 @@
if (verbose) if (verbose)
fprintf (stderr,_("Reading metadata from %s ...\n"), jname); fprintf (stderr,_("Reading metadata from %s ...\n"), jname);
parse_tiff (12); parse_tiff (12);
@@ -6620,6 +6643,7 @@ @@ -6693,6 +6713,7 @@
load_raw = ph1.format < 3 ? load_raw = ph1.format < 3 ?
&CLASS phase_one_load_raw : &CLASS phase_one_load_raw_c; &CLASS phase_one_load_raw : &CLASS phase_one_load_raw_c;
maximum = 0xffff; maximum = 0xffff;
@ -1348,16 +1375,7 @@
strcpy (make, "Phase One"); strcpy (make, "Phase One");
if (model[0]) return; if (model[0]) return;
switch (raw_height) { switch (raw_height) {
@@ -6658,7 +6682,7 @@ @@ -6761,7 +6782,11 @@
} else if (tag == 0xc000) {
c = order;
order = 0x4949;
- if ((tag = get4()) > 10000) tag = get4();
+ while ((tag = get4()) > 10000);
width = tag;
height = get4();
order = c;
@@ -6688,7 +6712,11 @@
order = get2(); order = get2();
hlen = get4(); hlen = get4();
if (get4() == 0x48454150) /* "HEAP" */ if (get4() == 0x48454150) /* "HEAP" */
@ -1369,7 +1387,7 @@
if (parse_tiff (save+6)) apply_tiff(); if (parse_tiff (save+6)) apply_tiff();
fseek (ifp, save+len, SEEK_SET); fseek (ifp, save+len, SEEK_SET);
} }
@@ -6960,7 +6988,8 @@ @@ -7033,7 +7058,8 @@
{ {
static const struct { static const struct {
const char *prefix; const char *prefix;
@ -1379,7 +1397,22 @@
} table[] = { } table[] = {
{ "AgfaPhoto DC-833m", 0, 0, /* DJC */ { "AgfaPhoto DC-833m", 0, 0, /* DJC */
{ 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } }, { 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } },
@@ -7919,6 +7948,33 @@ @@ -7977,12 +8003,12 @@
{ 6596,-2079,-562,-4782,13016,1933,-970,1581,5181 } },
{ "Sony DSC-RX100", 0, 0,
{ 8651,-2754,-1057,-3464,12207,1373,-568,1398,4434 } },
- { "Sony DSC-RX10", 0, 0, /* also RX10M2 */
+ { "Sony DSC-RX10", 0, 0,
{ 6679,-1825,-745,-5047,13256,1953,-1580,2422,5183 } },
{ "Sony DSC-RX1RM2", 0, 0,
{ 6629,-1900,-483,-4618,12349,2550,-622,1381,6514 } },
{ "Sony DSC-RX1", 0, 0,
- { 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
+ { 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
{ "Sony DSLR-A100", 0, 0xfeb,
{ 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } },
{ "Sony DSLR-A290", 0, 0,
@@ -8088,6 +8114,33 @@
} }
break; break;
} }
@ -1413,7 +1446,7 @@
} }
void CLASS simple_coeff (int index) void CLASS simple_coeff (int index)
@@ -8229,7 +8285,7 @@ @@ -8410,7 +8463,7 @@
tiff_flip = flip = filters = UINT_MAX; /* unknown */ tiff_flip = flip = filters = UINT_MAX; /* unknown */
raw_height = raw_width = fuji_width = fuji_layout = cr2_slice[0] = 0; raw_height = raw_width = fuji_width = fuji_layout = cr2_slice[0] = 0;
maximum = height = width = top_margin = left_margin = 0; maximum = height = width = top_margin = left_margin = 0;
@ -1422,7 +1455,7 @@
iso_speed = shutter = aperture = focal_len = unique_id = 0; iso_speed = shutter = aperture = focal_len = unique_id = 0;
tiff_nifds = 0; tiff_nifds = 0;
memset (tiff_ifd, 0, sizeof tiff_ifd); memset (tiff_ifd, 0, sizeof tiff_ifd);
@@ -8261,13 +8317,20 @@ @@ -8442,13 +8495,20 @@
fread (head, 1, 32, ifp); fread (head, 1, 32, ifp);
fseek (ifp, 0, SEEK_END); fseek (ifp, 0, SEEK_END);
flen = fsize = ftell(ifp); flen = fsize = ftell(ifp);
@ -1445,7 +1478,7 @@
parse_ciff (hlen, flen-hlen, 0); parse_ciff (hlen, flen-hlen, 0);
load_raw = &CLASS canon_load_raw; load_raw = &CLASS canon_load_raw;
} else if (parse_tiff(0)) apply_tiff(); } else if (parse_tiff(0)) apply_tiff();
@@ -8313,6 +8376,7 @@ @@ -8494,6 +8554,7 @@
fseek (ifp, 100+28*(shot_select > 0), SEEK_SET); fseek (ifp, 100+28*(shot_select > 0), SEEK_SET);
parse_tiff (data_offset = get4()); parse_tiff (data_offset = get4());
parse_tiff (thumb_offset+12); parse_tiff (thumb_offset+12);
@ -1453,7 +1486,7 @@
apply_tiff(); apply_tiff();
} else if (!memcmp (head,"RIFF",4)) { } else if (!memcmp (head,"RIFF",4)) {
fseek (ifp, 0, SEEK_SET); fseek (ifp, 0, SEEK_SET);
@@ -8426,9 +8490,10 @@ @@ -8607,9 +8668,10 @@
if (make[0] == 0) parse_smal (0, flen); if (make[0] == 0) parse_smal (0, flen);
if (make[0] == 0) { if (make[0] == 0) {
parse_jpeg(0); parse_jpeg(0);
@ -1467,7 +1500,7 @@
strcpy (make, "OmniVision"); strcpy (make, "OmniVision");
data_offset = ftell(ifp) + 0x8000-32; data_offset = ftell(ifp) + 0x8000-32;
width = raw_width; width = raw_width;
@@ -8437,6 +8502,7 @@ @@ -8618,6 +8680,7 @@
filters = 0x16161616; filters = 0x16161616;
} else is_raw = 0; } else is_raw = 0;
} }
@ -1475,7 +1508,7 @@
for (i=0; i < sizeof corp / sizeof *corp; i++) for (i=0; i < sizeof corp / sizeof *corp; i++)
if (strcasestr (make, corp[i])) /* Simplify company names */ if (strcasestr (make, corp[i])) /* Simplify company names */
@@ -8468,7 +8534,7 @@ @@ -8649,7 +8712,7 @@
if (height == 3136 && width == 4864) /* Pentax K20D and Samsung GX20 */ if (height == 3136 && width == 4864) /* Pentax K20D and Samsung GX20 */
{ height = 3124; width = 4688; filters = 0x16161616; } { height = 3124; width = 4688; filters = 0x16161616; }
if (width == 4352 && (!strcmp(model,"K-r") || !strcmp(model,"K-x"))) if (width == 4352 && (!strcmp(model,"K-r") || !strcmp(model,"K-x")))
@ -1484,15 +1517,15 @@
if (width >= 4960 && !strncmp(model,"K-5",3)) if (width >= 4960 && !strncmp(model,"K-5",3))
{ left_margin = 10; width = 4950; filters = 0x16161616; } { left_margin = 10; width = 4950; filters = 0x16161616; }
if (width == 4736 && !strcmp(model,"K-7")) if (width == 4736 && !strcmp(model,"K-7"))
@@ -8487,6 +8553,7 @@ @@ -8669,6 +8732,7 @@
switch (tiff_compress) { case 0:
case 1: load_raw = &CLASS packed_dng_load_raw; break; case 1: load_raw = &CLASS packed_dng_load_raw; break;
case 7: load_raw = &CLASS lossless_dng_load_raw; break; case 7: load_raw = &CLASS lossless_dng_load_raw; break;
+ case 8: load_raw = &CLASS deflate_dng_load_raw; break; + case 8: load_raw = &CLASS deflate_dng_load_raw; break;
case 34892: load_raw = &CLASS lossy_dng_load_raw; break; case 34892: load_raw = &CLASS lossy_dng_load_raw; break;
default: load_raw = 0; default: load_raw = 0;
} }
@@ -8541,6 +8608,7 @@ @@ -8725,6 +8789,7 @@
if (height > width) pixel_aspect = 2; if (height > width) pixel_aspect = 2;
filters = 0; filters = 0;
simple_coeff(0); simple_coeff(0);
@ -1500,7 +1533,7 @@
} else if (!strcmp(make,"Canon") && tiff_bps == 15) { } else if (!strcmp(make,"Canon") && tiff_bps == 15) {
switch (width) { switch (width) {
case 3344: width -= 66; case 3344: width -= 66;
@@ -8846,24 +8914,53 @@ @@ -9034,24 +9099,53 @@
if (load_raw == &CLASS lossless_jpeg_load_raw) if (load_raw == &CLASS lossless_jpeg_load_raw)
load_raw = &CLASS hasselblad_load_raw; load_raw = &CLASS hasselblad_load_raw;
if (raw_width == 7262) { if (raw_width == 7262) {
@ -1559,7 +1592,7 @@
} else if (raw_width == 4090) { } else if (raw_width == 4090) {
strcpy (model, "V96C"); strcpy (model, "V96C");
height -= (top_margin = 6); height -= (top_margin = 6);
@@ -8921,6 +9018,7 @@ @@ -9109,6 +9203,7 @@
filters = 0x16161616; filters = 0x16161616;
} }
} else if (!strcmp(make,"Leica") || !strcmp(make,"Panasonic")) { } else if (!strcmp(make,"Leica") || !strcmp(make,"Panasonic")) {
@ -1567,7 +1600,7 @@
if ((flen - data_offset) / (raw_width*8/7) == raw_height) if ((flen - data_offset) / (raw_width*8/7) == raw_height)
load_raw = &CLASS panasonic_load_raw; load_raw = &CLASS panasonic_load_raw;
if (!load_raw) { if (!load_raw) {
@@ -8938,6 +9036,7 @@ @@ -9126,6 +9221,7 @@
} }
filters = 0x01010101 * (uchar) "\x94\x61\x49\x16" filters = 0x01010101 * (uchar) "\x94\x61\x49\x16"
[((filters-1) ^ (left_margin & 1) ^ (top_margin << 1)) & 3]; [((filters-1) ^ (left_margin & 1) ^ (top_margin << 1)) & 3];
@ -1575,7 +1608,7 @@
} else if (!strcmp(model,"C770UZ")) { } else if (!strcmp(model,"C770UZ")) {
height = 1718; height = 1718;
width = 2304; width = 2304;
@@ -9155,6 +9254,18 @@ @@ -9357,6 +9453,18 @@
memcpy (rgb_cam, cmatrix, sizeof cmatrix); memcpy (rgb_cam, cmatrix, sizeof cmatrix);
raw_color = 0; raw_color = 0;
} }
@ -1594,7 +1627,7 @@
if (raw_color) adobe_coeff (make, model); if (raw_color) adobe_coeff (make, model);
if (load_raw == &CLASS kodak_radc_load_raw) if (load_raw == &CLASS kodak_radc_load_raw)
if (raw_color) adobe_coeff ("Apple","Quicktake"); if (raw_color) adobe_coeff ("Apple","Quicktake");
@@ -9169,9 +9280,9 @@ @@ -9371,9 +9479,9 @@
if (raw_width < width ) raw_width = width; if (raw_width < width ) raw_width = width;
} }
if (!tiff_bps) tiff_bps = 12; if (!tiff_bps) tiff_bps = 12;
@ -1606,7 +1639,7 @@
is_raw = 0; is_raw = 0;
#ifdef NO_JASPER #ifdef NO_JASPER
if (load_raw == &CLASS redcine_load_raw) { if (load_raw == &CLASS redcine_load_raw) {
@@ -9250,194 +9361,249 @@ @@ -9452,199 +9560,250 @@
} }
#endif #endif
@ -1634,10 +1667,14 @@
- { { 0.529317, 0.330092, 0.140588 }, - { { 0.529317, 0.330092, 0.140588 },
- { 0.098368, 0.873465, 0.028169 }, - { 0.098368, 0.873465, 0.028169 },
- { 0.016879, 0.117663, 0.865457 } }; - { 0.016879, 0.117663, 0.865457 } };
- static const double aces_rgb[3][3] =
- { { 0.432996, 0.375380, 0.189317 },
- { 0.089427, 0.816523, 0.102989 },
- { 0.019165, 0.118150, 0.941914 } };
- static const double (*out_rgb[])[3] = - static const double (*out_rgb[])[3] =
- { rgb_rgb, adobe_rgb, wide_rgb, prophoto_rgb, xyz_rgb }; - { rgb_rgb, adobe_rgb, wide_rgb, prophoto_rgb, xyz_rgb, aces_rgb };
- static const char *name[] = - static const char *name[] =
- { "sRGB", "Adobe RGB (1998)", "WideGamut D65", "ProPhoto D65", "XYZ" }; - { "sRGB", "Adobe RGB (1998)", "WideGamut D65", "ProPhoto D65", "XYZ", "ACES" };
- static const unsigned phead[] = - static const unsigned phead[] =
- { 1024, 0, 0x2100000, 0x6d6e7472, 0x52474220, 0x58595a20, 0, 0, 0, - { 1024, 0, 0x2100000, 0x6d6e7472, 0x52474220, 0x58595a20, 0, 0, 0,
- 0x61637370, 0, 0, 0x6e6f6e65, 0, 0, 0, 0, 0xf6d6, 0x10000, 0xd32d }; - 0x61637370, 0, 0, 0x6e6f6e65, 0, 0, 0, 0, 0xf6d6, 0x10000, 0xd32d };
@ -1658,7 +1695,7 @@
- gamma_curve (gamm[0], gamm[1], 0, 0); - gamma_curve (gamm[0], gamm[1], 0, 0);
- memcpy (out_cam, rgb_cam, sizeof out_cam); - memcpy (out_cam, rgb_cam, sizeof out_cam);
- raw_color |= colors == 1 || document_mode || - raw_color |= colors == 1 || document_mode ||
- output_color < 1 || output_color > 5; - output_color < 1 || output_color > 6;
- if (!raw_color) { - if (!raw_color) {
- oprof = (unsigned *) calloc (phead[0], 1); - oprof = (unsigned *) calloc (phead[0], 1);
- merror (oprof, "convert_to_rgb()"); - merror (oprof, "convert_to_rgb()");
@ -2023,37 +2060,42 @@
+ +
+ delete [] cBuffer; + delete [] cBuffer;
+ delete [] uBuffer; + delete [] uBuffer;
} +}
+ } + }
+ +
+ if (ifd->sample_format == 3) { // Floating point data + if (ifd->sample_format == 3) { // Floating point data
+ copyFloatDataToInt(float_raw_image, raw_image, raw_width*raw_height, maximum); + copyFloatDataToInt(float_raw_image, raw_image, raw_width*raw_height, maximum);
+ } + }
+} }
+
+/* RT: removed unused functions */
+/* RT: removed unused functions */
+
struct tiff_tag { struct tiff_tag {
ushort tag, type; ushort tag, type;
@@ -9461,590 +9627,11 @@ int count;
@@ -9667,594 +9826,11 @@
char desc[512], make[64], model[64], soft[32], date[20], artist[64]; char desc[512], make[64], model[64], soft[32], date[20], artist[64];
}; };
-void CLASS tiff_set (ushort *ntag, -void CLASS tiff_set (struct tiff_hdr *th, ushort *ntag,
- ushort tag, ushort type, int count, int val) - ushort tag, ushort type, int count, int val)
-{ -{
- struct tiff_tag *tt; - struct tiff_tag *tt;
- int c; - int c;
- -
- tt = (struct tiff_tag *)(ntag+1) + (*ntag)++; - tt = (struct tiff_tag *)(ntag+1) + (*ntag)++;
- tt->tag = tag; - tt->val.i = val;
- tt->type = type; - if (type == 1 && count <= 4)
- tt->count = count;
- if (type < 3 && count <= 4)
- FORC(4) tt->val.c[c] = val >> (c << 3); - FORC(4) tt->val.c[c] = val >> (c << 3);
- else if (type == 3 && count <= 2) - else if (type == 2) {
- count = strnlen((char *)th + val, count-1) + 1;
- if (count <= 4)
- FORC(4) tt->val.c[c] = ((char *)th)[val+c];
- } else if (type == 3 && count <= 2)
- FORC(2) tt->val.s[c] = val >> (c << 4); - FORC(2) tt->val.s[c] = val >> (c << 4);
- else tt->val.i = val; - tt->count = count;
- tt->type = type;
- tt->tag = tag;
-} -}
- -
-#define TOFF(ptr) ((char *)(&(ptr)) - (char *)th) -#define TOFF(ptr) ((char *)(&(ptr)) - (char *)th)
@ -2067,55 +2109,6 @@
- th->order = htonl(0x4d4d4949) >> 16; - th->order = htonl(0x4d4d4949) >> 16;
- th->magic = 42; - th->magic = 42;
- th->ifd = 10; - th->ifd = 10;
- if (full) {
- tiff_set (&th->ntag, 254, 4, 1, 0);
- tiff_set (&th->ntag, 256, 4, 1, width);
- tiff_set (&th->ntag, 257, 4, 1, height);
- tiff_set (&th->ntag, 258, 3, colors, output_bps);
- if (colors > 2)
- th->tag[th->ntag-1].val.i = TOFF(th->bps);
- FORC4 th->bps[c] = output_bps;
- tiff_set (&th->ntag, 259, 3, 1, 1);
- tiff_set (&th->ntag, 262, 3, 1, 1 + (colors > 1));
- }
- tiff_set (&th->ntag, 270, 2, 512, TOFF(th->desc));
- tiff_set (&th->ntag, 271, 2, 64, TOFF(th->make));
- tiff_set (&th->ntag, 272, 2, 64, TOFF(th->model));
- if (full) {
- if (oprof) psize = ntohl(oprof[0]);
- tiff_set (&th->ntag, 273, 4, 1, sizeof *th + psize);
- tiff_set (&th->ntag, 277, 3, 1, colors);
- tiff_set (&th->ntag, 278, 4, 1, height);
- tiff_set (&th->ntag, 279, 4, 1, height*width*colors*output_bps/8);
- } else
- tiff_set (&th->ntag, 274, 3, 1, "12435867"[flip]-'0');
- tiff_set (&th->ntag, 282, 5, 1, TOFF(th->rat[0]));
- tiff_set (&th->ntag, 283, 5, 1, TOFF(th->rat[2]));
- tiff_set (&th->ntag, 284, 3, 1, 1);
- tiff_set (&th->ntag, 296, 3, 1, 2);
- tiff_set (&th->ntag, 305, 2, 32, TOFF(th->soft));
- tiff_set (&th->ntag, 306, 2, 20, TOFF(th->date));
- tiff_set (&th->ntag, 315, 2, 64, TOFF(th->artist));
- tiff_set (&th->ntag, 34665, 4, 1, TOFF(th->nexif));
- if (psize) tiff_set (&th->ntag, 34675, 7, psize, sizeof *th);
- tiff_set (&th->nexif, 33434, 5, 1, TOFF(th->rat[4]));
- tiff_set (&th->nexif, 33437, 5, 1, TOFF(th->rat[6]));
- tiff_set (&th->nexif, 34855, 3, 1, iso_speed);
- tiff_set (&th->nexif, 37386, 5, 1, TOFF(th->rat[8]));
- if (gpsdata[1]) {
- tiff_set (&th->ntag, 34853, 4, 1, TOFF(th->ngps));
- tiff_set (&th->ngps, 0, 1, 4, 0x202);
- tiff_set (&th->ngps, 1, 2, 2, gpsdata[29]);
- tiff_set (&th->ngps, 2, 5, 3, TOFF(th->gps[0]));
- tiff_set (&th->ngps, 3, 2, 2, gpsdata[30]);
- tiff_set (&th->ngps, 4, 5, 3, TOFF(th->gps[6]));
- tiff_set (&th->ngps, 5, 1, 1, gpsdata[31]);
- tiff_set (&th->ngps, 6, 5, 1, TOFF(th->gps[18]));
- tiff_set (&th->ngps, 7, 5, 3, TOFF(th->gps[12]));
- tiff_set (&th->ngps, 18, 2, 12, TOFF(th->gps[20]));
- tiff_set (&th->ngps, 29, 2, 12, TOFF(th->gps[23]));
- memcpy (th->gps, gpsdata, sizeof th->gps);
- }
- th->rat[0] = th->rat[2] = 300; - th->rat[0] = th->rat[2] = 300;
- th->rat[1] = th->rat[3] = 1; - th->rat[1] = th->rat[3] = 1;
- FORC(6) th->rat[4+c] = 1000000; - FORC(6) th->rat[4+c] = 1000000;
@ -2130,6 +2123,55 @@
- sprintf (th->date, "%04d:%02d:%02d %02d:%02d:%02d", - sprintf (th->date, "%04d:%02d:%02d %02d:%02d:%02d",
- t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); - t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
- strncpy (th->artist, artist, 64); - strncpy (th->artist, artist, 64);
- if (full) {
- tiff_set (th, &th->ntag, 254, 4, 1, 0);
- tiff_set (th, &th->ntag, 256, 4, 1, width);
- tiff_set (th, &th->ntag, 257, 4, 1, height);
- tiff_set (th, &th->ntag, 258, 3, colors, output_bps);
- if (colors > 2)
- th->tag[th->ntag-1].val.i = TOFF(th->bps);
- FORC4 th->bps[c] = output_bps;
- tiff_set (th, &th->ntag, 259, 3, 1, 1);
- tiff_set (th, &th->ntag, 262, 3, 1, 1 + (colors > 1));
- }
- tiff_set (th, &th->ntag, 270, 2, 512, TOFF(th->desc));
- tiff_set (th, &th->ntag, 271, 2, 64, TOFF(th->make));
- tiff_set (th, &th->ntag, 272, 2, 64, TOFF(th->model));
- if (full) {
- if (oprof) psize = ntohl(oprof[0]);
- tiff_set (th, &th->ntag, 273, 4, 1, sizeof *th + psize);
- tiff_set (th, &th->ntag, 277, 3, 1, colors);
- tiff_set (th, &th->ntag, 278, 4, 1, height);
- tiff_set (th, &th->ntag, 279, 4, 1, height*width*colors*output_bps/8);
- } else
- tiff_set (th, &th->ntag, 274, 3, 1, "12435867"[flip]-'0');
- tiff_set (th, &th->ntag, 282, 5, 1, TOFF(th->rat[0]));
- tiff_set (th, &th->ntag, 283, 5, 1, TOFF(th->rat[2]));
- tiff_set (th, &th->ntag, 284, 3, 1, 1);
- tiff_set (th, &th->ntag, 296, 3, 1, 2);
- tiff_set (th, &th->ntag, 305, 2, 32, TOFF(th->soft));
- tiff_set (th, &th->ntag, 306, 2, 20, TOFF(th->date));
- tiff_set (th, &th->ntag, 315, 2, 64, TOFF(th->artist));
- tiff_set (th, &th->ntag, 34665, 4, 1, TOFF(th->nexif));
- if (psize) tiff_set (th, &th->ntag, 34675, 7, psize, sizeof *th);
- tiff_set (th, &th->nexif, 33434, 5, 1, TOFF(th->rat[4]));
- tiff_set (th, &th->nexif, 33437, 5, 1, TOFF(th->rat[6]));
- tiff_set (th, &th->nexif, 34855, 3, 1, iso_speed);
- tiff_set (th, &th->nexif, 37386, 5, 1, TOFF(th->rat[8]));
- if (gpsdata[1]) {
- tiff_set (th, &th->ntag, 34853, 4, 1, TOFF(th->ngps));
- tiff_set (th, &th->ngps, 0, 1, 4, 0x202);
- tiff_set (th, &th->ngps, 1, 2, 2, gpsdata[29]);
- tiff_set (th, &th->ngps, 2, 5, 3, TOFF(th->gps[0]));
- tiff_set (th, &th->ngps, 3, 2, 2, gpsdata[30]);
- tiff_set (th, &th->ngps, 4, 5, 3, TOFF(th->gps[6]));
- tiff_set (th, &th->ngps, 5, 1, 1, gpsdata[31]);
- tiff_set (th, &th->ngps, 6, 5, 1, TOFF(th->gps[18]));
- tiff_set (th, &th->ngps, 7, 5, 3, TOFF(th->gps[12]));
- tiff_set (th, &th->ngps, 18, 2, 12, TOFF(th->gps[20]));
- tiff_set (th, &th->ngps, 29, 2, 12, TOFF(th->gps[23]));
- memcpy (th->gps, gpsdata, sizeof th->gps);
- }
-} -}
- -
-void CLASS jpeg_thumb() -void CLASS jpeg_thumb()
@ -2250,7 +2292,7 @@
- puts(_("-n <num> Set threshold for wavelet denoising")); - puts(_("-n <num> Set threshold for wavelet denoising"));
- puts(_("-H [0-9] Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)")); - puts(_("-H [0-9] Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)"));
- puts(_("-t [0-7] Flip image (0=none, 3=180, 5=90CCW, 6=90CW)")); - puts(_("-t [0-7] Flip image (0=none, 3=180, 5=90CCW, 6=90CW)"));
- puts(_("-o [0-5] Output colorspace (raw,sRGB,Adobe,Wide,ProPhoto,XYZ)")); - puts(_("-o [0-6] Output colorspace (raw,sRGB,Adobe,Wide,ProPhoto,XYZ,ACES)"));
-#ifndef NO_LCMS -#ifndef NO_LCMS
- puts(_("-o <file> Apply output ICC profile from file")); - puts(_("-o <file> Apply output ICC profile from file"));
- puts(_("-p <file> Apply camera ICC profile from file or \"embed\"")); - puts(_("-p <file> Apply camera ICC profile from file or \"embed\""));

View File

@ -580,7 +580,9 @@ int RawImage::loadRaw (bool loadData, bool closeFile, ProgressListener *plistene
if (cc) { if (cc) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (RT_blacklevel_from_constant) { if (RT_blacklevel_from_constant) {
black_c4[i] = cblack[i] + cc->get_BlackLevel(i, iso_speed); int blackFromCc = cc->get_BlackLevel(i, iso_speed);
// if black level from camconst > 0xffff it is an absolute value.
black_c4[i] = blackFromCc > 0xffff ? (blackFromCc & 0xffff) : blackFromCc + cblack[i];
} }
// load 4 channel white level here, will be used if available // load 4 channel white level here, will be used if available