From: Niels K. B. J. <nk...@us...> - 2007-06-13 13:29:50
|
Update of /cvsroot/ufraw/ufraw In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv28323 Modified Files: Tag: dcraw-original-branch dcraw.cc Log Message: dcraw original 8.75 (1.385). Index: dcraw.cc =================================================================== RCS file: /cvsroot/ufraw/ufraw/dcraw.cc,v retrieving revision 1.1.2.48 retrieving revision 1.1.2.49 diff -u -d -r1.1.2.48 -r1.1.2.49 --- dcraw.cc 9 Jun 2007 06:07:34 -0000 1.1.2.48 +++ dcraw.cc 13 Jun 2007 13:29:45 -0000 1.1.2.49 @@ -22,7 +22,7 @@ $Date$ */ -#define VERSION "8.74" +#define VERSION "8.75" #define _GNU_SOURCE #define _USE_MATH_DEFINES @@ -113,11 +113,11 @@ ushort (*image)[4], white[8][8], curve[0x1000], cr2_slice[3]; float bright=1, user_mul[4]={0,0,0,0}, threshold=0; int half_size=0, four_color_rgb=0, document_mode=0, highlight=0; -int verbose=0, use_auto_wb=0, use_camera_wb=0, use_camera_matrix=1; +int verbose=0, use_auto_wb=0, use_camera_wb=0, use_camera_matrix=-1; int output_color=1, output_bps=8, output_tiff=0; int fuji_layout, fuji_secondary, shot_select=0; unsigned greybox[4] = { 0, 0, UINT_MAX, UINT_MAX }; -float cam_mul[4], pre_mul[4], rgb_cam[3][4]; /* RGB from camera color */ +float cam_mul[4], pre_mul[4], cmatrix[3][4], rgb_cam[3][4]; const double xyz_rgb[3][3] = { /* XYZ from RGB */ { 0.412453, 0.357580, 0.180423 }, { 0.212671, 0.715160, 0.072169 }, @@ -3623,7 +3623,6 @@ if (half_size) { height = iheight; width = iwidth; - filters = 0; } else { img = (ushort (*)[4]) calloc (height*width, sizeof *img); merror (img, "unshrink()"); @@ -3646,6 +3645,7 @@ filters &= ~((filters & 0x55555555) << 1); } } + if (half_size) filters = 0; } void CLASS border_interpolate (int border) @@ -4403,12 +4403,9 @@ else goto next; goto get2_256; } - if (((tag == 0x1011 && len == 9) || tag == 0x20400200) - && use_camera_matrix) { + if ((tag == 0x1011 && len == 9) || tag == 0x20400200) for (i=0; i < 3; i++) - FORC3 rgb_cam[i][c] = ((short) get2()) / 256.0; - raw_color = rgb_cam[0][0] < 0.25; - } + FORC3 cmatrix[i][c] = ((short) get2()) / 256.0; if ((tag == 0x1012 || tag == 0x20400600) && len == 4) for (black = i=0; i < 4; i++) black += get2() << 2; @@ -4508,10 +4505,10 @@ { -0.008565, -0.153273, 1.161839 } }; int i, j, k; - for (raw_color = i=0; i < 3; i++) + for (i=0; i < 3; i++) for (j=0; j < 3; j++) - for (rgb_cam[i][j] = k=0; k < 3; k++) - rgb_cam[i][j] += rgb_romm[i][k] * romm_cam[k][j]; + for (cmatrix[i][j] = k=0; k < 3; k++) + cmatrix[i][j] += rgb_romm[i][k] * romm_cam[k][j]; } void CLASS parse_mos (int offset) @@ -4544,7 +4541,12 @@ if ((unsigned) i < sizeof mod / sizeof (*mod)) strcpy (model, mod[i]); } - if (!strcmp(data,"CaptProf_color_matrix") && use_camera_matrix) { + if (!strcmp(data,"icc_camera_to_tone_matrix")) { + for (i=0; i < 9; i++) + romm_cam[0][i] = int_to_float(get4()); + romm_coeff (romm_cam); + } + if (!strcmp(data,"CaptProf_color_matrix")) { for (i=0; i < 9; i++) fscanf (ifp, "%f", &romm_cam[0][i]); romm_coeff (romm_cam); @@ -4776,12 +4778,12 @@ FORC4 cam_mul[c ^ 1] = 4096.0 / get2(); break; case 34307: /* Leaf CatchLight color matrix */ - if (!use_camera_matrix) break; fread (software, 1, 7, ifp); if (strncmp(software,"MATRIX",6)) break; colors = 4; for (raw_color = i=0; i < 3; i++) { FORC4 fscanf (ifp, "%f", &rgb_cam[i][c^1]); + if (!use_camera_wb) continue; num = 0; FORC4 num += rgb_cam[i][c]; FORC4 rgb_cam[i][c] /= num; @@ -5398,7 +5400,6 @@ switch (tag) { case 0x100: flip = "0653"[data & 3]-'0'; break; case 0x106: - if (!use_camera_matrix) break; for (i=0; i < 9; i++) romm_cam[0][i] = getreal(11); romm_coeff (romm_cam); @@ -6123,6 +6124,7 @@ for (i=0; i < 4; i++) { cam_mul[i] = i == 1; pre_mul[i] = i < 3; + FORC3 cmatrix[c][i] = 0; FORC3 rgb_cam[c][i] = c == i; } colors = 3; @@ -7578,7 +7580,7 @@ int arg, status=0, user_flip=-1, user_black=-1, user_qual=-1; int timestamp_only=0, thumbnail_only=0, identify_only=0; int use_fuji_rotate=1, write_to_stdout=0, quality, i, c; - char opt, *ofname, *sp, *cp, *dark_frame=0; + char opm, opt, *ofname, *sp, *cp, *dark_frame=0; const char *write_ext; struct utimbuf ut; FILE *ofp = stdout; @@ -7610,7 +7612,7 @@ puts(_("-a Average the whole image for white balance")); puts(_("-A <x y w h> Average a grey box for white balance")); puts(_("-r <r g b g> Set custom white balance")); - puts(_("-M Don't use an embedded color matrix")); + puts(_("+M/-M Use/don't use an embedded color matrix")); puts(_("-C <r b> Correct chromatic aberration")); puts(_("-b <num> Adjust brightness (default = 1.0)")); puts(_("-n <num> Set threshold for wavelet denoising")); @@ -7636,7 +7638,7 @@ return 1; } argv[argc] = ""; - for (arg=1; argv[arg][0] == '-'; ) { + for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; ) { opt = argv[arg++][1]; if ((cp = strchr (sp="nbrktqsHAC", opt))) for (i=0; i < "1141111142"[cp-sp]-'0'; i++) @@ -7677,7 +7679,7 @@ case 'A': FORC4 greybox[c] = atoi(argv[arg++]); case 'a': use_auto_wb = 1; break; case 'w': use_camera_wb = 1; break; - case 'M': use_camera_matrix = 0; break; + case 'M': use_camera_matrix = (opm == '+'); break; case 'D': case 'd': document_mode = 1 + (opt == 'D'); case 'j': use_fuji_rotate = 0; break; @@ -7689,6 +7691,8 @@ return 1; } } + if (use_camera_matrix < 0) + use_camera_matrix = use_camera_wb; if (arg == argc) { fprintf (stderr,_("No files to process.\n")); return 1; @@ -7832,6 +7836,10 @@ fclose(ifp); continue; } + if (use_camera_matrix && cmatrix[0][0] > 0.25) { + memcpy (rgb_cam, cmatrix, sizeof cmatrix); + raw_color = 0; + } image = (ushort (*)[4]) calloc (iheight*iwidth, sizeof *image); merror (image, "main()"); if (meta_length) { |