Issue 2049: Fuji x100 blacklevels fix

This commit is contained in:
torger 2013-11-18 11:35:15 +01:00
parent 9bf4679f7d
commit ad1b50cbde
3 changed files with 31 additions and 17 deletions

View File

@ -320,6 +320,11 @@ than measure white levels). If you experience a black level issue it's more
likely due to a format parsing bug which should be fixed in DCRaw and/or likely due to a format parsing bug which should be fixed in DCRaw and/or
RawTherapee's raw format parser. RawTherapee's raw format parser.
How does a black level issue look? If the image has a color cast and is
possibly duller than normal it's likely that black levels are off. The color
cast is typically stronger in darker colors but it can be hard to see, it's
more often experienced as a cast over the whole image.
*/ */
{"camera_constants": [ {"camera_constants": [

View File

@ -5278,6 +5278,7 @@ guess_cfa_pc:
break; break;
case 61450: case 61450:
blrr = blrc = 2; blrr = blrc = 2;
if (filters == UINT_MAX) filters = 0x94949494; /* RT: Fuji X100 fix for dcraw 9.19 to get proper black level parsing, hopefully works for other Fuji cameras too! */
case 50714: /* BlackLevel */ case 50714: /* BlackLevel */
black = getreal(type); black = getreal(type);
if ((unsigned)(filters+1) < 1000) break; if ((unsigned)(filters+1) < 1000) break;

42
rtengine/dcraw.patch Normal file → Executable file
View File

@ -1,5 +1,5 @@
--- dcraw.c 2013-08-12 09:32:14.000000000 +0200 --- dcraw.c 2013-11-07 16:47:20.881721251 +0100
+++ dcraw.cc 2013-11-03 10:34:08.000000000 +0100 +++ dcraw.cc 2013-11-18 11:32:46.856425587 +0100
@@ -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>
@ -700,7 +700,15 @@
if (tiff_nifds >= sizeof tiff_ifd / sizeof tiff_ifd[0]) if (tiff_nifds >= sizeof tiff_ifd / sizeof tiff_ifd[0])
return 1; return 1;
@@ -5737,12 +5368,13 @@ @@ -5647,6 +5278,7 @@
break;
case 61450:
blrr = blrc = 2;
+ if (filters == UINT_MAX) filters = 0x94949494; /* RT: Fuji X100 fix for dcraw 9.19 to get proper black level parsing, hopefully works for other Fuji cameras too! */
case 50714: /* BlackLevel */
black = getreal(type);
if ((unsigned)(filters+1) < 1000) break;
@@ -5737,12 +5369,13 @@
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;
@ -720,7 +728,7 @@
ifp = sfp; ifp = sfp;
free (buf); free (buf);
} }
@@ -5766,6 +5398,7 @@ @@ -5766,6 +5399,7 @@
int CLASS parse_tiff (int base) int CLASS parse_tiff (int base)
{ {
int doff; int doff;
@ -728,7 +736,7 @@
fseek (ifp, base, SEEK_SET); fseek (ifp, base, SEEK_SET);
order = get2(); order = get2();
@@ -5843,7 +5476,7 @@ @@ -5843,7 +5477,7 @@
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;
@ -737,7 +745,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) &&
@@ -5959,7 +5592,7 @@ @@ -5959,7 +5593,7 @@
{ {
const char *file, *ext; const char *file, *ext;
char *jname, *jfile, *jext; char *jname, *jfile, *jext;
@ -746,7 +754,7 @@
ext = strrchr (ifname, '.'); ext = strrchr (ifname, '.');
file = strrchr (ifname, '/'); file = strrchr (ifname, '/');
@@ -5981,13 +5614,14 @@ @@ -5981,13 +5615,14 @@
} else } else
while (isdigit(*--jext)) { while (isdigit(*--jext)) {
if (*jext != '9') { if (*jext != '9') {
@ -763,7 +771,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);
@@ -6330,7 +5964,11 @@ @@ -6330,7 +5965,11 @@
order = get2(); order = get2();
hlen = get4(); hlen = get4();
if (get4() == 0x48454150) /* "HEAP" */ if (get4() == 0x48454150) /* "HEAP" */
@ -775,7 +783,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);
} }
@@ -6582,7 +6220,8 @@ @@ -6582,7 +6221,8 @@
{ {
static const struct { static const struct {
const char *prefix; const char *prefix;
@ -785,7 +793,7 @@
} 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 } },
@@ -7383,6 +7022,27 @@ @@ -7383,6 +7023,27 @@
} }
break; break;
} }
@ -813,7 +821,7 @@
} }
void CLASS simple_coeff (int index) void CLASS simple_coeff (int index)
@@ -7682,13 +7342,20 @@ @@ -7682,13 +7343,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);
@ -836,7 +844,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();
@@ -7734,6 +7401,7 @@ @@ -7734,6 +7402,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);
@ -844,7 +852,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);
@@ -7839,15 +7507,18 @@ @@ -7839,15 +7508,18 @@
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);
@ -872,7 +880,7 @@
} }
for (i=0; i < sizeof corp / sizeof *corp; i++) for (i=0; i < sizeof corp / sizeof *corp; i++)
@@ -7878,7 +7549,7 @@ @@ -7878,7 +7550,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")))
@ -881,7 +889,7 @@
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"))
@@ -8026,7 +7697,7 @@ @@ -8026,7 +7698,7 @@
width -= 44; width -= 44;
} else if (!strcmp(model,"D3200") || } else if (!strcmp(model,"D3200") ||
!strcmp(model,"D600") || !strcmp(model,"D600") ||
@ -890,7 +898,7 @@
width -= 46; width -= 46;
} else if (!strcmp(model,"D4")) { } else if (!strcmp(model,"D4")) {
width -= 52; width -= 52;
@@ -8630,195 +8301,8 @@ @@ -8630,195 +8302,8 @@
cmsCloseProfile (hInProfile); cmsCloseProfile (hInProfile);
} }
#endif #endif
@ -1088,7 +1096,7 @@
struct tiff_tag { struct tiff_tag {
ushort tag, type; ushort tag, type;
@@ -8841,584 +8325,12 @@ @@ -8841,584 +8326,12 @@
unsigned gps[26]; unsigned gps[26];
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];
}; };