From 376ec67ddfb1cff1cd4ef7f7e7c63062d95066bb Mon Sep 17 00:00:00 2001 From: KITAGAWA Masahiro Date: Sun, 3 Jun 2018 23:07:05 +0900 Subject: [PATCH] Update dcraw 9.28 (1.478) - Remove patch for fixed bug - Fix compiler warning - Refactor xtrans OpenMP patch --- .gitignore | 1 + lightcrafts/coprocesses/dcraw/.pc/.version | 1 + .../coprocesses/dcraw/.pc/applied-patches | 11 +- lightcrafts/coprocesses/dcraw/dcraw_lz.c | 632 +++++++++++------- .../dcraw/patches/Sony-DSC-RX1RM2.patch | 24 - .../dcraw/patches/dcraw_indi.patch | 126 ++-- .../coprocesses/dcraw/patches/lightzone.patch | 18 +- .../coprocesses/dcraw/patches/strnlen.patch | 2 +- .../dcraw/patches/xtrans_yama1968.patch | 152 ++--- lightcrafts/coprocesses/dcraw/series | 1 - 10 files changed, 490 insertions(+), 478 deletions(-) create mode 100644 lightcrafts/coprocesses/dcraw/.pc/.version delete mode 100644 lightcrafts/coprocesses/dcraw/patches/Sony-DSC-RX1RM2.patch diff --git a/.gitignore b/.gitignore index 9c4f6ba96..9aebfcf97 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ *.0 .idea/** lightcrafts/build +lightcrafts/coprocesses/dcraw/\.pc/*.patch lightcrafts/extbuild lightcrafts/products lightcrafts/jnisrc/*/javah diff --git a/lightcrafts/coprocesses/dcraw/.pc/.version b/lightcrafts/coprocesses/dcraw/.pc/.version new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/lightcrafts/coprocesses/dcraw/.pc/.version @@ -0,0 +1 @@ +2 diff --git a/lightcrafts/coprocesses/dcraw/.pc/applied-patches b/lightcrafts/coprocesses/dcraw/.pc/applied-patches index 4330013e4..bf22514dd 100644 --- a/lightcrafts/coprocesses/dcraw/.pc/applied-patches +++ b/lightcrafts/coprocesses/dcraw/.pc/applied-patches @@ -1,6 +1,5 @@ -dcraw_indi.patch -xtrans_yama1968.patch -lightzone.patch -strnlen.patch -Sony-DSC-RX1RM2.patch -MSVC.patch +dcraw_indi.patch +xtrans_yama1968.patch +lightzone.patch +strnlen.patch +MSVC.patch diff --git a/lightcrafts/coprocesses/dcraw/dcraw_lz.c b/lightcrafts/coprocesses/dcraw/dcraw_lz.c index 96c8d2dbd..d0d95ab63 100644 --- a/lightcrafts/coprocesses/dcraw/dcraw_lz.c +++ b/lightcrafts/coprocesses/dcraw/dcraw_lz.c @@ -4,7 +4,7 @@ */ /* dcraw.c -- Dave Coffin's raw photo decoder - Copyright 1997-2016 by Dave Coffin, dcoffin a cybercom o net + Copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net This is a command-line ANSI C program to convert raw photos from any digital camera on any computer running any operating system. @@ -23,11 +23,11 @@ *If you have not modified dcraw.c in any way, a link to my homepage qualifies as "full source code". - $Revision: 1.477 $ - $Date: 2016/05/10 21:30:43 $ + $Revision: 1.478 $ + $Date: 2018/06/01 20:36:25 $ */ -#define DCRAW_VERSION "9.27" +#define DCRAW_VERSION "9.28" #ifndef _GNU_SOURCE #define _GNU_SOURCE @@ -111,8 +111,9 @@ typedef unsigned long long UINT64; /* All global variables are defined here, and all functions that - access them are prefixed with "CLASS". Note that a thread-safe - C++ class cannot have non-const static local variables. + access them are prefixed with "CLASS". For thread-safety, all + non-const static local variables except cbrt[] must be declared + "thread_local". */ FILE *ifp, *ofp; short order; @@ -1656,7 +1657,7 @@ void CLASS phase_one_correct() for (col = (qc ? ph1.split_col : 0); col < (qc ? raw_width : ph1.split_col); col++) RAW(row,col) = curve[RAW(row,col)]; - } + } } qmult_applied = 1; qlin_applied = 1; @@ -1939,10 +1940,10 @@ void CLASS packed_load_raw() UINT64 bitbuf=0; bwide = raw_width * tiff_bps / 8; - bwide += bwide & load_flags >> 7; + bwide += bwide & load_flags >> 9; rbits = bwide * 8 - raw_width * tiff_bps; if (load_flags & 1) bwide = bwide * 16 / 15; - bite = 8 + (load_flags & 24); + bite = 8 + (load_flags & 56); half = (raw_height+1) >> 1; for (irow=0; irow < raw_height; irow++) { row = irow; @@ -1960,10 +1961,10 @@ void CLASS packed_load_raw() for (vbits -= tiff_bps; vbits < 0; vbits += bite) { bitbuf <<= bite; for (i=0; i < bite; i+=8) - bitbuf |= (unsigned) (fgetc(ifp) << i); + bitbuf |= ((UINT64) fgetc(ifp) << i); } val = bitbuf << (64-tiff_bps-vbits) >> (64-tiff_bps); - RAW(row,col ^ (load_flags >> 6 & 1)) = val; + RAW(row,col ^ (load_flags >> 6 & 3)) = val; if (load_flags & 1 && (col % 10) == 9 && fgetc(ifp) && row < height+top_margin && col < width+left_margin) derror(); } @@ -2100,6 +2101,14 @@ void CLASS olympus_load_raw() } } +void CLASS canon_crx_load_raw() +{ +} + +void CLASS fuji_xtrans_load_raw() +{ +} + void CLASS minolta_rd175_load_raw() { uchar pixel[768]; @@ -2779,7 +2788,7 @@ void CLASS samsung_load_raw() } for (c=0; c < 16; c+=2) { i = len[((c & 1) << 1) | (c >> 3)]; - RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) + + RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) + (dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128); if (c == 14) c = -1; } @@ -3792,7 +3801,7 @@ void CLASS crop_masked_pixels() load_raw == &CLASS sony_load_raw || (load_raw == &CLASS eight_bit_load_raw && strncmp(model,"DC2",3)) || load_raw == &CLASS kodak_262_load_raw || - (load_raw == &CLASS packed_load_raw && (load_flags & 32))) { + (load_raw == &CLASS packed_load_raw && (load_flags & 256))) { sides: mask[0][0] = mask[1][0] = top_margin; mask[0][2] = mask[1][2] = top_margin+height; @@ -4139,18 +4148,12 @@ void CLASS wavelet_denoise() merror (fimg, "wavelet_denoise()"); temp = fimg + size*3; if ((nc = colors) == 3 && filters) nc++; -#ifdef _OPENMP #if defined(__sun) && !defined(__GNUC__) /* Fix UFRaw bug #3205673 - NKBJ */ - #pragma omp parallel for \ - default(none) \ - shared(nc,image,scale,size,noise) \ + #pragma omp parallel for default(shared) \ private(c,i,hpass,lev,lpass,row,col,thold,fimg,temp) #else - #pragma omp parallel for \ - default(none) \ - shared(nc,image,iheight,iwidth,scale,threshold,size) \ + #pragma omp parallel for default(shared) \ private(c,i,hpass,lev,lpass,row,col,thold,fimg,temp) -#endif #endif FORC(nc) { /* denoise R,G1,B,G3 individually */ for (i=0; i < size; i++) @@ -4378,9 +4381,7 @@ void CLASS border_interpolate (int border) int row; unsigned col, y, x, f, c, sum[8]; -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=0; row < height; row++) for (col=0; col < width; col++) { if (col==border && row >= border && row < height-border) @@ -4407,15 +4408,11 @@ void CLASS lin_interpolate() if (verbose) fprintf (stderr,_("Bilinear interpolation...\n")); if (filters == 9) size = 6; -#ifdef _OPENMP - #pragma omp parallel default(shared) \ - private(ip, sum, f, c, i, x, y, row, col, shift, color, pix) -#endif +#pragma omp parallel default(shared) \ + private(ip, sum, f, c, i, x, y, row, col, shift, color, pix) { border_interpolate(1); -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=0; row < size; row++) for (col=0; col < size; col++) { ip = code[row][col]+1; @@ -4438,9 +4435,7 @@ void CLASS lin_interpolate() *ip++ = 256 / sum[c]; } } -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=1; row < height-1; row++) for (col=1; col < width-1; col++) { pix = image[row*width+col]; @@ -4532,15 +4527,11 @@ void CLASS vng_interpolate() *ip++ = 0; } } -#ifdef _OPENMP - #pragma omp parallel \ - default(none) \ - shared(image,code,prow,pcol,width,height,colors) \ - private(row,col,g,brow,pix,ip,gval,diff,gmin,gmax,thold,sum,color,num,c,t) -#endif +#pragma omp parallel default(shared) \ + private(row,col,g,brow,pix,ip,gval,diff,gmin,gmax,thold,sum,color,num,c,t) { ushort (*rowtmp)[4]; - rowtmp = (ushort*)malloc(4 * width * 4 * sizeof(ushort)); + rowtmp = (ushort(*)[4])malloc(4 * width * 4 * sizeof(ushort)); int slice = (height - 4) / uf_omp_get_num_threads(); int start_row = 2 + slice * uf_omp_get_thread_num(); int end_row = MIN(start_row + slice, height - 2); @@ -4548,7 +4539,6 @@ void CLASS vng_interpolate() for (g = 0; g < 4; g++) brow[g] = &rowtmp[(row + g - 2) % 4]; - for (col=2; col < width-2; col++) { pix = image[row*width+col]; ip = code[row % prow][col % pcol]; @@ -4614,18 +4604,11 @@ void CLASS ppg_interpolate() if (verbose) fprintf (stderr,_("PPG interpolation...\n")); -#ifdef _OPENMP - #pragma omp parallel \ - default(none) \ - shared(image,dir,diff,width,height,filters) \ - private(row,col,i,d,c,pix,guess) -#endif +#pragma omp parallel default(shared) private(row,col,i,d,c,pix,guess) { border_interpolate(3); /* Fill in the green layer with gradients and pattern recognition: */ -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=3; row < height-3; row++) for (col=3+(FC(row,3) & 1), c=FC(row,col); col < width-3; col+=2) { pix = image + row*width+col; @@ -4642,9 +4625,7 @@ void CLASS ppg_interpolate() pix[0][1] = ULIM(guess[i] >> 2, pix[d][1], pix[-d][1]); } /* Calculate red and blue for each green pixel: */ -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=1; row < height-1; row++) for (col=1+(FC(row,2) & 1), c=FC(row,col+1); col < width-1; col+=2) { pix = image + row*width+col; @@ -4653,9 +4634,7 @@ void CLASS ppg_interpolate() - pix[-d][1] - pix[d][1]) >> 1); } /* Calculate blue for red pixels and vice versa: */ -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=1; row < height-1; row++) for (col=1+(FC(row,1) & 1), c=2-FC(row,col); col < width-1; col+=2) { pix = image + row*width+col; @@ -4674,45 +4653,6 @@ void CLASS ppg_interpolate() } /* pragma omp parallel */ } -void CLASS cielab3 (ushort rgb[3], short lab[3]) -{ - int c, i, j, k; - float r, xyz[3]; - static float cbrt[0x10000], xyz_cam[3][4]; - - if (!rgb) { -#ifdef _OPENMP - #pragma omp for -#endif - for (i=0; i < 0x10000; i++) { - r = i / 65535.0; - cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0; - } -#ifdef _OPENMP - #pragma omp for -#endif - for (i=0; i < 3; i++) - for (j=0; j < colors; j++) - for (xyz_cam[i][j] = k=0; k < 3; k++) -#ifdef _OPENMP - #pragma omp atomic -#endif - xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j] / d65_white[i]; - return; - } - xyz[0] = xyz[1] = xyz[2] = 0.5; - - FORC(3) { - xyz[c] += xyz_cam[c][0] * rgb [0] + xyz_cam[c][1] * rgb [1] + xyz_cam[c][2] * rgb [2]; - } - xyz[0] = cbrt[CLIP((int) xyz[0])]; - xyz[1] = cbrt[CLIP((int) xyz[1])]; - xyz[2] = cbrt[CLIP((int) xyz[2])]; - lab[0] = 64 * (116 * xyz[1] - 16); - lab[1] = 64 * 500 * (xyz[0] - xyz[1]); - lab[2] = 64 * 200 * (xyz[1] - xyz[2]); -} - void CLASS cielab (ushort rgb[3], short lab[3]) { int c, i, j, k; @@ -4720,22 +4660,16 @@ void CLASS cielab (ushort rgb[3], short lab[3]) static float cbrt[0x10000], xyz_cam[3][4]; if (!rgb) { -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (i=0; i < 0x10000; i++) { r = i / 65535.0; cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0; } -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (i=0; i < 3; i++) for (j=0; j < colors; j++) for (xyz_cam[i][j] = k=0; k < 3; k++) -#ifdef _OPENMP - #pragma omp atomic -#endif +#pragma omp atomic xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j] / d65_white[i]; return; } @@ -4756,23 +4690,27 @@ void CLASS cielab (ushort rgb[3], short lab[3]) #define TS 512 /* Tile Size */ #define fcol(row,col) xtrans[(row+6) % 6][(col+6) % 6] -#if ! defined(_OPENMP) -// Makes a 10% difference in performances in sequential version, but none at all with OPENMP... -// And _STATIC_BUFFER is delicate to manage -#define _STATIC_BUFFER -#define _FIXED_NDIR +#ifndef _OPENMP +// Makes a 10% difference in performances in sequential version, but none at all +// with OPENMP... +// And STATIC_BUFFER is delicate to manage +#define STATIC_BUFFER +#define FIXED_NDIR #endif -/* Allow each tile to be calculate independently from the others - Explanation: the border pixels from each tiles start from the border pixel of other tiles +/* Allow each tile to be calculate independently from the others. + Explanation: the border pixels from each tiles start from the border pixel of + other tiles. This goes from top to bottom: - the first pixels of each tile depend on the last ones of the previous tile - the last ones depend on the first ones of the next tile - In sequential mode, the first pixels use the calculated values from the previous tiles and fresh values from the next tile. - In OpenMP / parallel mode, the first pixels of the next files might have been already calculated. - The STRIC_IMAGE makes it possible to use indeed fresh values, always + In sequential mode, the first pixels use the calculated values from the + previous tiles and fresh values from the next tile. + In OpenMP / parallel mode, the first pixels of the next files might have been + already calculated. + The STRICT_IMAGE makes it possible to use indeed fresh values, always. */ -#define _STRICT_IMAGE +#define STRICT_IMAGE /* Frank Markesteijn's algorithm for Fuji X-Trans sensors @@ -4780,9 +4718,8 @@ void CLASS cielab (ushort rgb[3], short lab[3]) void CLASS xtrans_interpolate (int passes) { int c, d, f, g, h, i, v, ng, row, col, top, left, mrow, mcol; - // int val, ndir, pass, hm[8], avg[4], color[3][8]; int val, pass, hm[8], avg[4], color[3][8]; -#if defined(_FIXED_NDIR) +#ifdef FIXED_NDIR const int ndir = 4 << 1; #else int ndir = 4 << (passes > 1); @@ -4798,47 +4735,36 @@ void CLASS xtrans_interpolate (int passes) short (*lab) [TS][3], (*lix)[3]; float (*drv)[TS][TS], diff[6], tr; char (*homo)[TS][TS]; -#if defined(_STATIC_BUFFER) +#ifdef STATIC_BUFFER static char buffer [TS*TS*(8*11+6)] __attribute__((aligned(64))); #else char *buffer; #endif if (verbose) -#if defined(_OPENMP) - fprintf (stderr,_("%d-pass X-Trans interpolation with %d max threads...\n"), - passes, omp_get_max_threads ()); -#else fprintf (stderr,_("%d-pass X-Trans interpolation...\n"), passes); -#endif if ((4 << (passes > 1)) != ndir) fprintf (stderr,_("4 << (passes > 1) = %d != ndir = %d\n"), (4 << (passes > 1)), ndir); -#ifdef _FIXED_NDIR -#pragma omp parallel default (none) \ - shared (height, width, image, allhex, sgrow, sgcol, xtrans, \ - top_margin, left_margin, passes, verbose, iwidth, iheight) \ +#ifdef FIXED_NDIR +#pragma omp parallel default (shared) \ private (top, left, mrow, mcol, row, col, color, pix, hex, c, pass, rix, \ val, h, f, d, g, tr, v, hm, max, avg, lix, diff, i, \ buffer, rgb, lab, drv, homo, ng, min) #else -#pragma omp parallel default (none) \ - shared (height, width, image, allhex, ndir, sgrow, sgcol, xtrans, \ - top_margin, left_margin, passes, verbose, iwidth, iheight) \ +#pragma omp parallel default (shared) \ private (top, left, mrow, mcol, row, col, color, pix, hex, c, pass, rix, \ val, h, f, d, g, tr, v, hm, max, avg, lix, diff, i, \ buffer, rgb, lab, drv, homo, ng, min) #endif { - cielab3 (0,0); + cielab(0,0); border_interpolate(6); /* Map a green hexagon around each non-green pixel and vice versa: */ -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (row=0; row < 3; row++) for (col=0; col < 3; col++) for (ng=d=0; d < 10; d+=2) { @@ -4855,9 +4781,7 @@ void CLASS xtrans_interpolate (int passes) /* Set green1 and green3 to the minimum and maximum allowed values: */ -#ifdef _OPENMP - #pragma omp single -#endif +#pragma omp single for (row=2; row < height-2; row++) for (min=~(max=0), col=2; col < width-2; col++) { if (fcol(row,col) == 1 && (min=~(max=0))) continue; @@ -4876,14 +4800,14 @@ void CLASS xtrans_interpolate (int passes) } } -#if defined(_STRICT_IMAGE) +#ifdef STRICT_IMAGE ushort (*working_image)[4]; working_image = (ushort (*)[4]) calloc (iheight, iwidth*sizeof *image); memcpy (working_image, image, iheight * iwidth * sizeof *image); merror (working_image, "xtrans_interpolate working_image"); #endif -#if ! defined(_STATIC_BUFFER) +#ifndef STATIC_BUFFER buffer = (char *) malloc (TS*TS*(ndir*11+6)); merror (buffer, "xtrans_interpolate()"); #endif @@ -4900,10 +4824,10 @@ void CLASS xtrans_interpolate (int passes) mcol = MIN (left+TS, width-3); for (row=top; row < mrow; row++) for (col=left; col < mcol; col++) -#if defined(_STRICT_IMAGE) +#ifdef STRICT_IMAGE memcpy (rgb[0][row-top][col-left], working_image[row*width+col], 6); #else - memcpy (rgb[0][row-top][col-left], image[row*width+col], 6); + memcpy (rgb[0][row-top][col-left], image[row*width+col], 6); #endif FORC3 memcpy (rgb[c+1], rgb[0], sizeof *rgb); @@ -4911,7 +4835,7 @@ void CLASS xtrans_interpolate (int passes) for (row=top; row < mrow; row++) for (col=left; col < mcol; col++) { if ((f = fcol(row,col)) == 1) continue; -#if defined(_STRICT_IMAGE) +#ifdef STRICT_IMAGE pix = working_image + row*width + col; #else pix = image + row*width + col; @@ -4937,7 +4861,7 @@ void CLASS xtrans_interpolate (int passes) for (row=top+2; row < mrow-2; row++) for (col=left+2; col < mcol-2; col++) { if ((f = fcol(row,col)) == 1) continue; -#if defined(_STRICT_IMAGE) +#ifdef STRICT_IMAGE pix = working_image + row*width + col; #else pix = image + row*width + col; @@ -5017,9 +4941,8 @@ void CLASS xtrans_interpolate (int passes) for (d=0; d < ndir; d++) { for (row=2; row < mrow-2; row++) for (col=2; col < mcol-2; col++) - cielab3 (rgb[d][row][col], lab[row][col]); // use cielab3 because X-trans is 3 colors - f=dir[d & 3]; - for (row=3; row < mrow-3; row++) + cielab (rgb[d][row][col], lab[row][col]); + for (f=dir[d & 3],row=3; row < mrow-3; row++) for (col=3; col < mcol-3; col++) { lix = &lab[row][col]; g = 2*lix[0][0] - lix[f][0] - lix[-f][0]; @@ -5049,17 +4972,11 @@ void CLASS xtrans_interpolate (int passes) for (col = MIN(left,8); col < mcol-8; col++) { for (d=0; d < ndir; d++) for (hm[d]=0, v=-2; v <= 2; v++) - /* - for (h=-2; h <= 2; h++) - hm[d] += homo[d][row+v][col+h]; - */ - /* */ hm[d] += homo[d][row+v][col-2] + homo[d][row+v][col-1] + homo[d][row+v][col+0] + homo[d][row+v][col+1] + homo[d][row+v][col+2]; - /* */ for (d=0; d < ndir-4; d++) if (hm[d] < hm[d+4]) hm[d ] = 0; else if (hm[d] > hm[d+4]) hm[d+4] = 0; @@ -5078,7 +4995,7 @@ void CLASS xtrans_interpolate (int passes) FORC3 image[(row+top)*width+col+left][c] = avg[c]/avg[3]; } } -#if ! defined(_STATIC_BUFFER) +#ifndef STATIC_BUFFER free(buffer); #endif border_interpolate(8); @@ -5101,11 +5018,9 @@ void CLASS ahd_interpolate() if (verbose) fprintf (stderr,_("AHD interpolation...\n")); -#ifdef _OPENMP - #pragma omp parallel \ - default(shared) \ - private(top, left, row, col, pix, rix, lix, c, val, d, tc, tr, i, j, ldiff, abdiff, leps, abeps, hm, buffer, rgb, lab, homo) -#endif +#pragma omp parallel default(shared) \ + private(top,left,row,col,pix,rix,lix,c,val,d,tc,tr,i,j,ldiff,abdiff,leps, \ + abeps,hm,buffer,rgb,lab,homo) { cielab (0,0); border_interpolate(5); @@ -5115,9 +5030,7 @@ void CLASS ahd_interpolate() lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS); homo = (char (*)[TS][TS]) (buffer + 24*TS*TS); -#ifdef _OPENMP - #pragma omp for -#endif +#pragma omp for for (top=2; top < height-5; top += TS-6) for (left=2; left < width-5; left += TS-6) { @@ -5442,7 +5355,7 @@ void CLASS parse_makernote (int base, int uptag) offset = get4(); fseek (ifp, offset-8, SEEK_CUR); } else if (!strcmp (buf,"OLYMPUS") || - !strcmp (buf,"PENTAX ")) { + !strcmp (buf,"PENTAX ")) { base = ftell(ifp)-10; fseek (ifp, -2, SEEK_CUR); order = get2(); @@ -5967,14 +5880,13 @@ int CLASS parse_tiff_ifd (int base) case 258: /* BitsPerSample */ case 61443: tiff_ifd[ifd].samples = len & 7; - tiff_ifd[ifd].bps = getint(type); + if ((tiff_ifd[ifd].bps = getint(type)) > 32) + tiff_ifd[ifd].bps = 8; if (tiff_bps < tiff_ifd[ifd].bps) tiff_bps = tiff_ifd[ifd].bps; break; case 61446: raw_height = 0; - if (tiff_ifd[ifd].bps > 12) break; - load_raw = &CLASS packed_load_raw; load_flags = get4() ? 24:80; break; case 259: /* Compression */ @@ -6262,7 +6174,7 @@ int CLASS parse_tiff_ifd (int base) case 50708: /* UniqueCameraModel */ if (model[0]) break; fgets (make, 64, ifp); - if ((cp = strchr(make,' '))) { + if ((cp = strchr(make,' '))) { strcpy(model,cp+1); *cp = 0; } @@ -6353,7 +6265,7 @@ int CLASS parse_tiff_ifd (int base) width = getint(type) - left_margin; break; case 50830: /* MaskedAreas */ - for (i=0; i < len && i < 32; i++) + for (i=0; i < len && i < 32; i++) ((int *)mask)[i] = getint(type); black = 0; break; @@ -6475,6 +6387,7 @@ void CLASS apply_tiff() case 32767: if (tiff_ifd[raw].bytes == raw_width*raw_height) { tiff_bps = 12; + maximum = 4095; load_raw = &CLASS sony_arw2_load_raw; break; } if (tiff_ifd[raw].bytes*8 != raw_width*raw_height*tiff_bps) { @@ -6490,6 +6403,9 @@ void CLASS apply_tiff() if (!strncmp(make,"OLYMPUS",7) && tiff_ifd[raw].bytes*2 == raw_width*raw_height*3) load_flags = 24; + if (!strcmp(make,"SONY") && tiff_bps < 14 && + tiff_ifd[raw].bytes == raw_width*raw_height*2) + tiff_bps = 14; if (tiff_ifd[raw].bytes*5 == raw_width*raw_height*8) { load_flags = 81; tiff_bps = 12; @@ -6499,12 +6415,16 @@ void CLASS apply_tiff() case 12: if (tiff_ifd[raw].phint == 2) load_flags = 6; load_raw = &CLASS packed_load_raw; break; - case 14: load_flags = 0; + case 14: load_raw = &CLASS packed_load_raw; + if (tiff_ifd[raw].bytes*4 == raw_width*raw_height*7) break; + load_flags = 0; case 16: load_raw = &CLASS unpacked_load_raw; if (!strncmp(make,"OLYMPUS",7) && tiff_ifd[raw].bytes*7 > raw_width*raw_height) load_raw = &CLASS olympus_load_raw; } + if (filters == 9 && tiff_ifd[raw].bytes*8 < raw_width*raw_height*tiff_bps) + load_raw = &CLASS fuji_xtrans_load_raw; break; case 6: case 7: case 99: load_raw = &CLASS lossless_jpeg_load_raw; break; @@ -6960,7 +6880,7 @@ void CLASS parse_fuji (int offset) FORC(36) xtrans_abs[0][35-c] = fgetc(ifp) & 3; } else if (tag == 0x2ff0) { FORC4 cam_mul[c ^ 1] = get2(); - } else if (tag == 0xc000) { + } else if (tag == 0xc000 && len > 20000) { c = order; order = 0x4949; while ((tag = get4()) > raw_width); @@ -7040,6 +6960,72 @@ void CLASS parse_riff() fseek (ifp, size, SEEK_CUR); } +void CLASS parse_crx (int end) +{ + unsigned i, save, size, tag, base; + static int index=0, wide, high, off, len; + + order = 0x4d4d; + while (ftell(ifp)+7 < end) { + save = ftell(ifp); + if ((size = get4()) < 8) break; + switch (tag = get4()) { + case 0x6d6f6f76: /* moov */ + case 0x7472616b: /* trak */ + case 0x6d646961: /* mdia */ + case 0x6d696e66: /* minf */ + case 0x7374626c: /* stbl */ + parse_crx (save+size); + break; + case 0x75756964: /* uuid */ + switch (i=get4()) { + case 0xeaf42b5e: fseek (ifp, 8, SEEK_CUR); + case 0x85c0b687: fseek (ifp, 12, SEEK_CUR); + parse_crx (save+size); + } + break; + case 0x434d5431: /* CMT1 */ + case 0x434d5432: /* CMT2 */ + base = ftell(ifp); + order = get2(); + fseek (ifp, 6, SEEK_CUR); + tag & 1 ? parse_tiff_ifd (base) : parse_exif (base); + order = 0x4d4d; + break; + case 0x746b6864: /* tkhd */ + fseek (ifp, 12, SEEK_CUR); + index = get4(); + fseek (ifp, 58, SEEK_CUR); + wide = get4(); + high = get4(); + break; + case 0x7374737a: /* stsz */ + len = (get4(),get4()); + break; + case 0x636f3634: /* co64 */ + fseek (ifp, 12, SEEK_CUR); + off = get4(); + switch (index) { + case 1: /* 1 = full size, 2 = 27% size */ + thumb_width = wide; + thumb_height = high; + thumb_length = len; + thumb_offset = off; + break; + case 3: + raw_width = wide; + raw_height = high; + data_offset = off; + load_raw = &CLASS canon_crx_load_raw; + } + break; + case 0x50525657: /* PRVW */ + fseek (ifp, 6, SEEK_CUR); + } + fseek (ifp, save+size, SEEK_SET); + } +} + void CLASS parse_qt (int end) { unsigned save, size; @@ -7281,12 +7267,16 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6188,-1341,-890,-7168,14489,2937,-2640,3228,8483 } }, { "Canon EOS 5DS", 0, 0x3c96, { 6250,-711,-808,-5153,12794,2636,-1249,2198,5610 } }, + { "Canon EOS 5D Mark IV", 0, 0, + { 6446,-366,-864,-4436,12204,2513,-952,2496,6348 } }, { "Canon EOS 5D Mark III", 0, 0x3c80, { 6722,-635,-963,-4287,12460,2028,-908,2162,5668 } }, { "Canon EOS 5D Mark II", 0, 0x3cf0, { 4716,603,-830,-7798,15474,2480,-1496,1937,6651 } }, { "Canon EOS 5D", 0, 0xe6c, { 6347,-479,-972,-8297,15954,2480,-1968,2131,7649 } }, + { "Canon EOS 6D Mark II", 0, 0, + { 6875,-970,-932,-4691,12459,2501,-874,1953,5809 } }, { "Canon EOS 6D", 0, 0x3c82, { 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } }, { "Canon EOS 7D Mark II", 0, 0x3510, @@ -7309,10 +7299,14 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6719,-994,-925,-4408,12426,2211,-887,2129,6051 } }, { "Canon EOS 70D", 0, 0x3bc7, { 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } }, + { "Canon EOS 77D", 0, 0, + { 7377,-742,-998,-4235,11981,2549,-673,1918,5538 } }, { "Canon EOS 80D", 0, 0, { 7457,-671,-937,-4849,12495,2643,-1213,2354,5492 } }, { "Canon EOS 100D", 0, 0x350f, { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, + { "Canon EOS 200D", 0, 0, + { 7377,-742,-998,-4235,11981,2549,-673,1918,5538 } }, { "Canon EOS 300D", 0, 0xfa0, { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } }, { "Canon EOS 350D", 0, 0xfff, @@ -7335,6 +7329,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, { "Canon EOS 760D", 0, 0x350f, { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, + { "Canon EOS 800D", 0, 0, + { 6970,-512,-968,-4425,12161,2553,-739,1982,5601 } }, { "Canon EOS 1000D", 0, 0xe43, { 6771,-1139,-977,-7818,15123,2928,-1244,1437,7533 } }, { "Canon EOS 1100D", 0, 0x3510, @@ -7343,8 +7339,18 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } }, { "Canon EOS 1300D", 0, 0x3510, { 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } }, + { "Canon EOS 1500D", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { "Canon EOS 3000D", 0, 0, + { 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } }, + { "Canon EOS M6", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { "Canon EOS M5", 0, 0, /* also M50 */ + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, { "Canon EOS M3", 0, 0, { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, + { "Canon EOS M100", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, { "Canon EOS M10", 0, 0, { 6400,-480,-888,-5294,13416,2047,-1296,2203,6137 } }, { "Canon EOS M", 0, 0, @@ -7389,6 +7395,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 7474,-2301,-567,-4056,11456,2975,-222,716,4181 } }, { "Canon PowerShot G16", 0, 0, { 8020,-2687,-682,-3704,11879,2052,-965,1921,5556 } }, + { "Canon PowerShot G1 X Mark III", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, { "Canon PowerShot G1 X", 0, 0, { 7378,-1255,-1043,-4088,12251,2048,-876,1946,5805 } }, { "Canon PowerShot G1", 0, 0, @@ -7407,6 +7415,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } }, { "Canon PowerShot G7 X", 0, 0, { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, + { "Canon PowerShot G9 X Mark II", 0, 0, + { 10056,-4131,-944,-2576,11143,1625,-238,1294,5179 } }, { "Canon PowerShot G9 X", 0, 0, { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, { "Canon PowerShot G9", 0, 0, @@ -7501,6 +7511,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, { "Fujifilm F8", 0, 0, { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { "Fujifilm GFX 50S", 0, 0, + { 11756,-4754,-874,-3056,11045,2305,-381,1457,6006 } }, { "Fujifilm S100FS", 514, 0, { 11521,-4355,-1065,-6524,13767,3058,-1466,1984,6045 } }, { "Fujifilm S1", 0, 0, @@ -7509,9 +7521,9 @@ void CLASS adobe_coeff (const char *make, const char *model) { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, { "Fujifilm S20", 512, 0x3fff, { 11401,-4498,-1312,-5088,12751,2613,-838,1568,5941 } }, - { "Fujifilm S2Pro", 128, 0, + { "Fujifilm S2Pro", 128, 0xf15, { 12492,-4690,-1402,-7033,15423,1647,-1507,2111,7697 } }, - { "Fujifilm S3Pro", 0, 0, + { "Fujifilm S3Pro", 0, 0x3dff, { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } }, { "Fujifilm S5Pro", 0, 0, { 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } }, @@ -7545,7 +7557,7 @@ void CLASS adobe_coeff (const char *make, const char *model) { 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } }, { "Fujifilm HS10 HS11", 0, 0xf68, { 12440,-3954,-1183,-1123,9674,1708,-83,1614,4086 } }, - { "Fujifilm HS2", 0, 0, + { "Fujifilm HS2", 0, 0xfef, { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, { "Fujifilm HS3", 0, 0, { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, @@ -7553,6 +7565,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } }, { "Fujifilm F900EXR", 0, 0, { 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } }, + { "Fujifilm X100F", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, { "Fujifilm X100S", 0, 0, { 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } }, { "Fujifilm X100T", 0, 0, @@ -7571,26 +7585,42 @@ void CLASS adobe_coeff (const char *make, const char *model) { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, { "Fujifilm X-Pro2", 0, 0, { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { "Fujifilm X-A10", 0, 0, + { 11540,-4999,-991,-2949,10963,2278,-382,1049,5605 } }, + { "Fujifilm X-A20", 0, 0, + { 11540,-4999,-991,-2949,10963,2278,-382,1049,5605 } }, { "Fujifilm X-A1", 0, 0, { 11086,-4555,-839,-3512,11310,2517,-815,1341,5940 } }, { "Fujifilm X-A2", 0, 0, { 10763,-4560,-917,-3346,11311,2322,-475,1135,5843 } }, + { "Fujifilm X-A3", 0, 0, + { 12407,-5222,-1086,-2971,11116,2120,-294,1029,5284 } }, + { "Fujifilm X-A5", 0, 0, + { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, { "Fujifilm X-E1", 0, 0, { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, { "Fujifilm X-E2S", 0, 0, { 11562,-5118,-961,-3022,11007,2311,-525,1569,6097 } }, { "Fujifilm X-E2", 0, 0, { 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } }, + { "Fujifilm X-E3", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { "Fujifilm X-H1", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, { "Fujifilm X-M1", 0, 0, { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, { "Fujifilm X-S1", 0, 0, { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, { "Fujifilm X-T1", 0, 0, /* also X-T10 */ { 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } }, + { "Fujifilm X-T2", 0, 0, /* also X-T20 */ + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, { "Fujifilm XF1", 0, 0, { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, { "Fujifilm XQ", 0, 0, /* XQ1 and XQ2 */ { 9252,-2704,-1064,-5893,14265,1717,-1101,2341,4349 } }, + { "GoPro HERO5 Black", 0, 0, + { 10344,-4210,-620,-2315,10625,1948,93,1058,5541 } }, { "Imacon Ixpress", 0, 0, /* DJC */ { 7025,-1415,-704,-5188,13765,1424,-1248,2742,6038 } }, { "Kodak NC2000", 0, 0, @@ -7703,6 +7733,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 7013,-1408,-635,-5268,12902,2640,-1470,2801,7379 } }, { "Nikon D3300", 0, 0, { 6988,-1384,-714,-5631,13410,2447,-1485,2204,7318 } }, + { "Nikon D3400", 0, 0, + { 6988,-1384,-714,-5631,13410,2447,-1485,2204,7318 } }, { "Nikon D300", 0, 0, { 9030,-1992,-715,-8465,16302,2255,-2689,3217,8069 } }, { "Nikon D3X", 0, 0, @@ -7731,6 +7763,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6988,-1384,-714,-5631,13410,2447,-1485,2204,7318 } }, { "Nikon D5500", 0, 0, { 8821,-2938,-785,-4178,12142,2287,-824,1651,6860 } }, + { "Nikon D5600", 0, 0, + { 8821,-2938,-785,-4178,12142,2287,-824,1651,6860 } }, { "Nikon D500", 0, 0, { 8813,-3210,-1036,-4703,12868,2021,-1054,1940,6129 } }, { "Nikon D50", 0, 0, @@ -7749,12 +7783,16 @@ void CLASS adobe_coeff (const char *make, const char *model) { 8322,-3112,-1047,-6367,14342,2179,-988,1638,6394 } }, { "Nikon D7200", 0, 0, { 8322,-3112,-1047,-6367,14342,2179,-988,1638,6394 } }, + { "Nikon D7500", 0, 0, + { 8813,-3210,-1036,-4703,12868,2021,-1054,1940,6129 } }, { "Nikon D750", 0, 0, { 9020,-2890,-715,-4535,12436,2348,-934,1919,7086 } }, { "Nikon D700", 0, 0, { 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } }, { "Nikon D70", 0, 0, { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } }, + { "Nikon D850", 0, 0, + { 10405,-3755,-1270,-5461,13787,1793,-1040,2015,6785 } }, { "Nikon D810", 0, 0, { 9369,-3195,-791,-4488,12430,2301,-893,1796,6872 } }, { "Nikon D800", 0, 0, @@ -7795,6 +7833,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 } }, { "Nikon COOLPIX A", 0, 0, { 8198,-2239,-724,-4871,12389,2798,-1043,2050,7181 } }, + { "Nikon COOLPIX B700", 200, 0, + { 14387,-6014,-1299,-1357,9975,1616,467,1047,4744 } }, { "Nikon COOLPIX P330", 200, 0, { 10321,-3920,-931,-2750,11146,1824,-442,1545,5539 } }, { "Nikon COOLPIX P340", 200, 0, @@ -7893,12 +7933,18 @@ void CLASS adobe_coeff (const char *make, const char *model) { 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } }, { "Olympus E-PL7", 0, 0, { 9197,-3190,-659,-2606,10830,2039,-458,1250,5458 } }, + { "Olympus E-PL8", 0, 0, + { 9197,-3190,-659,-2606,10830,2039,-458,1250,5458 } }, + { "Olympus E-PL9", 0, 0, + { 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } }, { "Olympus E-PM1", 0, 0, { 7575,-2159,-571,-3722,11341,2725,-1434,2819,6271 } }, { "Olympus E-PM2", 0, 0, { 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } }, - { "Olympus E-M10", 0, 0, /* also E-M10 Mark II */ + { "Olympus E-M10", 0, 0, /* also E-M10 Mark II & III */ { 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } }, + { "Olympus E-M1Mark II", 0, 0, + { 9383,-3170,-763,-2457,10702,2020,-384,1236,5552 } }, { "Olympus E-M1", 0, 0, { 7687,-1984,-606,-4327,11928,2721,-1381,2339,6452 } }, { "Olympus E-M5MarkII", 0, 0, @@ -7927,6 +7973,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 8360,-2420,-880,-3928,12353,1739,-1381,2416,5173 } }, { "Olympus TG-4", 0, 0, { 11426,-4159,-1126,-2066,10678,1593,-120,1327,4998 } }, + { "Olympus TG-5", 0, 0, + { 10899,-3833,-1082,-2112,10736,1575,-267,1452,5269 } }, { "Olympus XZ-10", 0, 0, { 9777,-3483,-925,-2886,11297,1800,-602,1663,5134 } }, { "Olympus XZ-1", 0, 0, @@ -7962,7 +8010,7 @@ void CLASS adobe_coeff (const char *make, const char *model) { "Pentax K-r", 0, 0, { 9895,-3077,-850,-5304,13035,2521,-883,1768,6936 } }, { "Pentax K-1", 0, 0, - { 8566,-2746,-1201,-3612,12204,1550,-893,1680,6264 } }, + { 8596,-2981,-639,-4202,12046,2431,-685,1424,6122 } }, { "Pentax K-30", 0, 0, { 8710,-2632,-1167,-3995,12301,1881,-981,1719,6535 } }, { "Pentax K-3 II", 0, 0, @@ -7973,37 +8021,45 @@ void CLASS adobe_coeff (const char *make, const char *model) { 8170,-2725,-639,-4440,12017,2744,-771,1465,6599 } }, { "Pentax K-5", 0, 0, { 8713,-2833,-743,-4342,11900,2772,-722,1543,6247 } }, + { "Pentax K-70", 0, 0, + { 8270,-2117,-1299,-4359,12953,1515,-1078,1933,5975 } }, { "Pentax K-7", 0, 0, { 9142,-2947,-678,-8648,16967,1663,-2224,2898,8615 } }, { "Pentax K-S1", 0, 0, { 8512,-3211,-787,-4167,11966,2487,-638,1288,6054 } }, { "Pentax K-S2", 0, 0, { 8662,-3280,-798,-3928,11771,2444,-586,1232,6054 } }, + { "Pentax KP", 0, 0, + { 8617,-3228,-1034,-4674,12821,2044,-803,1577,5728 } }, { "Pentax Q-S1", 0, 0, { 12995,-5593,-1107,-1879,10139,2027,-64,1233,4919 } }, { "Pentax 645D", 0, 0x3e00, { 10646,-3593,-1158,-3329,11699,1831,-667,2874,6287 } }, { "Panasonic DMC-CM1", 15, 0, { 8770,-3194,-820,-2871,11281,1803,-513,1552,4434 } }, + { "Panasonic DC-FZ80", 0, 0, + { 8550,-2908,-842,-3195,11529,1881,-338,1603,4631 } }, { "Panasonic DMC-FZ8", 0, 0xf7f, { 8986,-2755,-802,-6341,13575,3077,-1476,2144,6379 } }, { "Panasonic DMC-FZ18", 0, 0, { 9932,-3060,-935,-5809,13331,2753,-1267,2155,5575 } }, { "Panasonic DMC-FZ28", 15, 0xf96, { 10109,-3488,-993,-5412,12812,2916,-1305,2140,5543 } }, + { "Panasonic DMC-FZ2500", 15, 0, + { 7386,-2443,-743,-3437,11864,1757,-608,1660,4766 } }, { "Panasonic DMC-FZ330", 15, 0, { 8378,-2798,-769,-3068,11410,1877,-538,1792,4623 } }, { "Panasonic DMC-FZ300", 15, 0, { 8378,-2798,-769,-3068,11410,1877,-538,1792,4623 } }, { "Panasonic DMC-FZ30", 0, 0xf94, { 10976,-4029,-1141,-7918,15491,2600,-1670,2071,8246 } }, - { "Panasonic DMC-FZ3", 15, 0, + { "Panasonic DMC-FZ3", 15, 0, /* FZ35, FZ38 */ { 9938,-2780,-890,-4604,12393,2480,-1117,2304,4620 } }, - { "Panasonic DMC-FZ4", 15, 0, + { "Panasonic DMC-FZ4", 15, 0, /* FZ40, FZ45 */ { 13639,-5535,-1371,-1698,9633,2430,316,1152,4108 } }, { "Panasonic DMC-FZ50", 0, 0, { 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } }, - { "Panasonic DMC-FZ7", 15, 0, + { "Panasonic DMC-FZ7", 15, 0, /* FZ70, FZ72 */ { 11532,-4324,-1066,-2375,10847,1749,-564,1699,4351 } }, { "Leica V-LUX1", 0, 0, { 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } }, @@ -8045,6 +8101,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 10148,-3743,-991,-2837,11366,1659,-701,1893,4899 } }, { "Leica D-LUX 6", 15, 0, { 10148,-3743,-991,-2837,11366,1659,-701,1893,4899 } }, + { "Panasonic DMC-LX9", 15, 0, + { 7790,-2736,-755,-3452,11870,1769,-628,1647,4898 } }, { "Panasonic DMC-FZ1000", 15, 0, { 7830,-2696,-763,-3325,11667,1866,-641,1712,4824 } }, { "Leica V-LUX (Typ 114)", 15, 0, @@ -8077,6 +8135,10 @@ void CLASS adobe_coeff (const char *make, const char *model) { 8294,-2891,-651,-3869,11590,2595,-1183,2267,5352 } }, { "Panasonic DMC-G7", 15, 0xfff, { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, + { "Panasonic DMC-G8", 15, 0xfff, /* G8, G80, G81, G85 */ + { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, + { "Panasonic DC-G9", 15, 0xfff, + { 7685,-2375,-634,-3687,11700,2249,-748,1546,5111 } }, { "Panasonic DMC-GF1", 15, 0xf92, { 7888,-1902,-1011,-8106,16085,2099,-2353,2866,7330 } }, { "Panasonic DMC-GF2", 15, 0xfff, @@ -8091,6 +8153,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, { "Panasonic DMC-GF8", 15, 0, { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, + { "Panasonic DC-GF9", 15, 0, + { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, { "Panasonic DMC-GH1", 15, 0xf92, { 6299,-1466,-532,-6535,13852,2969,-2331,3112,5984 } }, { "Panasonic DMC-GH2", 15, 0xf95, @@ -8099,6 +8163,10 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6559,-1752,-491,-3672,11407,2586,-962,1875,5130 } }, { "Panasonic DMC-GH4", 15, 0, { 7122,-2108,-512,-3155,11201,2231,-541,1423,5045 } }, + { "Panasonic DC-GH5S", 15, 0, + { 6929,-2355,-708,-4192,12534,1828,-1097,1989,5195 } }, + { "Panasonic DC-GH5", 15, 0, + { 7641,-2336,-605,-3218,11299,2187,-485,1338,5121 } }, { "Panasonic DMC-GM1", 15, 0, { 6770,-1895,-744,-5232,13145,2303,-1664,2691,5703 } }, { "Panasonic DMC-GM5", 15, 0, @@ -8107,24 +8175,26 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6763,-1919,-863,-3868,11515,2684,-1216,2387,5879 } }, { "Panasonic DMC-GX7", 15, 0, { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, + { "Panasonic DMC-GX85", 15, 0, + { 7771,-3020,-629,-4029,11950,2345,-821,1977,6119 } }, { "Panasonic DMC-GX8", 15, 0, { 7564,-2263,-606,-3148,11239,2177,-540,1435,4853 } }, - { "Panasonic DMC-TZ1", 15, 0, + { "Panasonic DC-GX9", 15, 0, + { 7564,-2263,-606,-3148,11239,2177,-540,1435,4853 } }, + { "Panasonic DMC-ZS100", 15, 0, { 7790,-2736,-755,-3452,11870,1769,-628,1647,4898 } }, - { "Panasonic DMC-ZS1", 15, 0, + { "Panasonic DC-ZS200", 15, 0, { 7790,-2736,-755,-3452,11870,1769,-628,1647,4898 } }, - { "Panasonic DMC-TZ6", 15, 0, + { "Panasonic DMC-ZS40", 15, 0, { 8607,-2822,-808,-3755,11930,2049,-820,2060,5224 } }, - { "Panasonic DMC-ZS4", 15, 0, - { 8607,-2822,-808,-3755,11930,2049,-820,2060,5224 } }, - { "Panasonic DMC-TZ7", 15, 0, - { 8802,-3135,-789,-3151,11468,1904,-550,1745,4810 } }, - { "Panasonic DMC-ZS5", 15, 0, + { "Panasonic DMC-ZS50", 15, 0, { 8802,-3135,-789,-3151,11468,1904,-550,1745,4810 } }, - { "Panasonic DMC-TZ8", 15, 0, + { "Panasonic DMC-TZ82", 15, 0, { 8550,-2908,-842,-3195,11529,1881,-338,1603,4631 } }, { "Panasonic DMC-ZS6", 15, 0, { 8550,-2908,-842,-3195,11529,1881,-338,1603,4631 } }, + { "Panasonic DMC-ZS70", 15, 0, + { 9052,-3117,-883,-3045,11346,1927,-205,1520,4730 } }, { "Leica S (Typ 007)", 0, 0, { 6063,-2234,-231,-5210,13787,1500,-1043,2866,6997 } }, { "Leica X", 0, 0, /* X and X-U, both (Typ 113) */ @@ -8134,7 +8204,15 @@ void CLASS adobe_coeff (const char *make, const char *model) { "Leica M (Typ 262)", 0, 0, { 6653,-1486,-611,-4221,13303,929,-881,2416,7226 } }, { "Leica SL (Typ 601)", 0, 0, - { 11865,-4523,-1441,-5423,14458,935,-1587,2687,4830} }, + { 11865,-4523,-1441,-5423,14458,935,-1587,2687,4830 } }, + { "Leica TL2", 0, 0, + { 5836,-1626,-647,-5384,13326,2261,-1207,2129,5861 } }, + { "Leica TL", 0, 0, + { 5463,-988,-364,-4634,12036,2946,-766,1389,6522 } }, + { "Leica CL", 0, 0, + { 7414,-2393,-840,-5127,13180,2138,-1585,2468,5064 } }, + { "Leica M10", 0, 0, + { 8249,-2849,-620,-5415,14756,565,-957,3074,6517 } }, { "Phase One H 20", 0, 0, /* DJC */ { 1313,1855,-109,-6715,15908,808,-327,1840,6020 } }, { "Phase One H 25", 0, 0, @@ -8205,16 +8283,20 @@ void CLASS adobe_coeff (const char *make, const char *model) { 8512,-2641,-694,-8042,15670,2526,-1821,2117,7414 } }, { "Sony DSC-V3", 0, 0, { 7511,-2571,-692,-7894,15088,3060,-948,1111,8128 } }, - { "Sony DSC-RX100M", 0, 0, /* M2, M3, and M4 */ + { "Sony DSC-RX100M", 0, 0, /* M2, M3, M4, and M5 */ { 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-RX10M4", 0, 0, + { 7699,-2566,-629,-2967,11270,1928,-378,1286,4807 } }, + { "Sony DSC-RX10", 0, 0, /* also RX10M2, RX10M3 */ { 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 } }, + { "Sony DSC-RX0", 200, 0, + { 9396,-3507,-843,-2497,11111,1572,-343,1355,5089 } }, { "Sony DSLR-A100", 0, 0xfeb, { 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } }, { "Sony DSLR-A290", 0, 0, @@ -8249,18 +8331,26 @@ void CLASS adobe_coeff (const char *make, const char *model) { 6435,-1903,-536,-4722,12449,2550,-663,1363,6517 } }, { "Sony ILCA-77M2", 0, 0, { 5991,-1732,-443,-4100,11989,2381,-704,1467,5992 } }, - { "Sony ILCE-6300", 0, 0, + { "Sony ILCA-99M2", 0, 0, + { 6660,-1918,-471,-4613,12398,2485,-649,1433,6447 } }, + { "Sony ILCE-6", 0, 0, /* 6300, 6500 */ { 5973,-1695,-419,-3826,11797,2293,-639,1398,5789 } }, { "Sony ILCE-7M2", 0, 0, { 5271,-712,-347,-6153,13653,2763,-1601,2366,7242 } }, + { "Sony ILCE-7M3", 0, 0, + { 7374,-2389,-551,-5435,13162,2519,-1006,1795,6552 } }, { "Sony ILCE-7S", 0, 0, /* also ILCE-7SM2 */ { 5838,-1430,-246,-3497,11477,2297,-748,1885,5778 } }, + { "Sony ILCE-7RM3", 0, 0, + { 6640,-1847,-503,-5238,13010,2474,-993,1673,6527 } }, { "Sony ILCE-7RM2", 0, 0, { 6629,-1900,-483,-4618,12349,2550,-622,1381,6514 } }, { "Sony ILCE-7R", 0, 0, { 4913,-541,-202,-6130,13513,2906,-1564,2151,7183 } }, { "Sony ILCE-7", 0, 0, { 5271,-712,-347,-6153,13653,2763,-1601,2366,7242 } }, + { "Sony ILCE-9", 0, 0, + { 6389,-1703,-378,-4562,12265,2587,-670,1489,6550 } }, { "Sony ILCE", 0, 0, /* 3000, 5000, 5100, 6000, and QX1 */ { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } }, { "Sony NEX-5N", 0, 0, @@ -8303,6 +8393,8 @@ void CLASS adobe_coeff (const char *make, const char *model) { 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } }, { "Sony SLT-A99", 0, 0, { 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } }, + { "YI M1", 0, 0, + { 7712,-2059,-653,-3882,11494,2726,-710,1332,5958 } }, }; double cam_xyz[4][3]; char name[130]; @@ -8458,8 +8550,11 @@ void CLASS identify() { 5712, 3774, 62, 20, 10, 2 }, { 5792, 3804, 158, 51, 0, 0 }, { 5920, 3950, 122, 80, 2, 0 }, + { 6096, 4051, 76, 35, 0, 0 }, { 6096, 4056, 72, 34, 0, 0 }, - { 6288, 4056, 264, 34, 0, 0 }, + { 6288, 4056, 264, 36, 0, 0 }, + { 6384, 4224, 120, 44, 0, 0 }, + { 6880, 4544, 136, 42, 0, 0 }, { 8896, 5920, 160, 64, 0, 0 }, }; static const struct { @@ -8473,7 +8568,10 @@ void CLASS identify() { 0x261, "EOS 50D" }, { 0x281, "EOS-1D Mark IV" }, { 0x287, "EOS 60D" }, { 0x167, "EOS-1DS" }, { 0x325, "EOS 70D" }, + { 0x408, "EOS 77D" }, { 0x331, "EOS M" }, { 0x350, "EOS 80D" }, { 0x328, "EOS-1D X Mark II" }, + { 0x346, "EOS 100D" }, + { 0x417, "EOS 200D" }, { 0x170, "EOS 300D" }, { 0x188, "EOS-1Ds Mark II" }, { 0x176, "EOS 450D" }, { 0x215, "EOS-1Ds Mark III" }, { 0x189, "EOS 350D" }, { 0x324, "EOS-1D C" }, @@ -8484,12 +8582,14 @@ void CLASS identify() { 0x301, "EOS 650D" }, { 0x302, "EOS 6D" }, { 0x326, "EOS 700D" }, { 0x250, "EOS 7D" }, { 0x393, "EOS 750D" }, { 0x289, "EOS 7D Mark II" }, - { 0x347, "EOS 760D" }, + { 0x347, "EOS 760D" }, { 0x406, "EOS 6D Mark II" }, + { 0x405, "EOS 800D" }, { 0x349, "EOS 5D Mark IV" }, { 0x254, "EOS 1000D" }, { 0x288, "EOS 1100D" }, - { 0x327, "EOS 1200D" }, { 0x382, "Canon EOS 5DS" }, - { 0x404, "EOS 1300D" }, { 0x401, "Canon EOS 5DS R" }, - { 0x346, "EOS 100D" }, + { 0x327, "EOS 1200D" }, { 0x382, "EOS 5DS" }, + { 0x404, "EOS 1300D" }, { 0x401, "EOS 5DS R" }, + { 0x422, "EOS 1500D" }, + { 0x432, "EOS 3000D" }, }, sonique[] = { { 0x002, "DSC-R1" }, { 0x100, "DSLR-A100" }, { 0x101, "DSLR-A900" }, { 0x102, "DSLR-A700" }, @@ -8519,7 +8619,30 @@ void CLASS identify() { 0x155, "DSC-RX100M4" },{ 0x156, "DSC-RX10M2" }, { 0x158, "DSC-RX1RM2" }, { 0x15a, "ILCE-QX1" }, { 0x15b, "ILCE-7RM2" }, { 0x15e, "ILCE-7SM2" }, - { 0x161, "ILCA-68" }, { 0x165, "ILCE-6300" }, + { 0x161, "ILCA-68" }, { 0x162, "ILCA-99M2" }, + { 0x163, "DSC-RX10M3" }, { 0x164, "DSC-RX100M5" }, + { 0x165, "ILCE-6300" }, { 0x166, "ILCE-9" }, + { 0x168, "ILCE-6500" }, { 0x16a, "ILCE-7RM3" }, + { 0x16b, "ILCE-7M3" }, { 0x16c, "DSC-RX0" }, + { 0x16d, "DSC-RX10M4" }, + }; + static const char *orig, panalias[][12] = { + "@DC-FZ80", "DC-FZ82", "DC-FZ85", + "@DC-FZ81", "DC-FZ83", + "@DC-GF9", "DC-GX800", "DC-GX850", + "@DC-GF10", "DC-GF90", + "@DC-GX9", "DC-GX7MK3", + "@DC-ZS70", "DC-TZ90", "DC-TZ91", "DC-TZ92", "DC-TZ93", + "@DMC-FZ40", "DMC-FZ45", + "@DMC-FZ2500", "DMC-FZ2000", "DMC-FZH1", + "@DMC-G8", "DMC-G80", "DMC-G81", "DMC-G85", + "@DMC-GX85", "DMC-GX80", "DMC-GX7MK2", + "@DMC-LX9", "DMC-LX10", "DMC-LX15", + "@DMC-ZS40", "DMC-TZ60", "DMC-TZ61", + "@DMC-ZS50", "DMC-TZ70", "DMC-TZ71", + "@DMC-ZS60", "DMC-TZ80", "DMC-TZ81", "DMC-TZ85", + "@DMC-ZS100", "DMC-ZS110", "DMC-TZ100", "DMC-TZ101", "DMC-TZ110", "DMC-TX1", + "@DC-ZS200", "DC-TX2", "DC-TZ200", "DC-TZ202", "DC-TZ220", "DC-ZS220", }; static const struct { unsigned fsize; @@ -8539,24 +8662,24 @@ void CLASS identify() { 15980544,3264,2448, 0, 0, 0, 0, 8,0x61,0,1,"AgfaPhoto","DC-833m" }, { 9631728,2532,1902, 0, 0, 0, 0,96,0x61,0,0,"Alcatel","5035D" }, { 2868726,1384,1036, 0, 0, 0, 0,64,0x49,0,8,"Baumer","TXG14",1078 }, - { 5298000,2400,1766,12,12,44, 2,40,0x94,0,2,"Canon","PowerShot SD300" }, - { 6553440,2664,1968, 4, 4,44, 4,40,0x94,0,2,"Canon","PowerShot A460" }, - { 6573120,2672,1968,12, 8,44, 0,40,0x94,0,2,"Canon","PowerShot A610" }, - { 6653280,2672,1992,10, 6,42, 2,40,0x94,0,2,"Canon","PowerShot A530" }, - { 7710960,2888,2136,44, 8, 4, 0,40,0x94,0,2,"Canon","PowerShot S3 IS" }, - { 9219600,3152,2340,36,12, 4, 0,40,0x94,0,2,"Canon","PowerShot A620" }, - { 9243240,3152,2346,12, 7,44,13,40,0x49,0,2,"Canon","PowerShot A470" }, - { 10341600,3336,2480, 6, 5,32, 3,40,0x94,0,2,"Canon","PowerShot A720 IS" }, - { 10383120,3344,2484,12, 6,44, 6,40,0x94,0,2,"Canon","PowerShot A630" }, - { 12945240,3736,2772,12, 6,52, 6,40,0x94,0,2,"Canon","PowerShot A640" }, - { 15636240,4104,3048,48,12,24,12,40,0x94,0,2,"Canon","PowerShot A650" }, - { 15467760,3720,2772, 6,12,30, 0,40,0x94,0,2,"Canon","PowerShot SX110 IS" }, - { 15534576,3728,2778,12, 9,44, 9,40,0x94,0,2,"Canon","PowerShot SX120 IS" }, - { 18653760,4080,3048,24,12,24,12,40,0x94,0,2,"Canon","PowerShot SX20 IS" }, - { 19131120,4168,3060,92,16, 4, 1,40,0x94,0,2,"Canon","PowerShot SX220 HS" }, - { 21936096,4464,3276,25,10,73,12,40,0x16,0,2,"Canon","PowerShot SX30 IS" }, - { 24724224,4704,3504, 8,16,56, 8,40,0x94,0,2,"Canon","PowerShot A3300 IS" }, - { 30858240,5248,3920, 8,16,56,16,40,0x94,0,2,"Canon","IXUS 160" }, + { 5298000,2400,1766,12,12,44, 2, 8,0x94,0,2,"Canon","PowerShot SD300" }, + { 6553440,2664,1968, 4, 4,44, 4, 8,0x94,0,2,"Canon","PowerShot A460" }, + { 6573120,2672,1968,12, 8,44, 0, 8,0x94,0,2,"Canon","PowerShot A610" }, + { 6653280,2672,1992,10, 6,42, 2, 8,0x94,0,2,"Canon","PowerShot A530" }, + { 7710960,2888,2136,44, 8, 4, 0, 8,0x94,0,2,"Canon","PowerShot S3 IS" }, + { 9219600,3152,2340,36,12, 4, 0, 8,0x94,0,2,"Canon","PowerShot A620" }, + { 9243240,3152,2346,12, 7,44,13, 8,0x49,0,2,"Canon","PowerShot A470" }, + { 10341600,3336,2480, 6, 5,32, 3, 8,0x94,0,2,"Canon","PowerShot A720 IS" }, + { 10383120,3344,2484,12, 6,44, 6, 8,0x94,0,2,"Canon","PowerShot A630" }, + { 12945240,3736,2772,12, 6,52, 6, 8,0x94,0,2,"Canon","PowerShot A640" }, + { 15636240,4104,3048,48,12,24,12, 8,0x94,0,2,"Canon","PowerShot A650" }, + { 15467760,3720,2772, 6,12,30, 0, 8,0x94,0,2,"Canon","PowerShot SX110 IS" }, + { 15534576,3728,2778,12, 9,44, 9, 8,0x94,0,2,"Canon","PowerShot SX120 IS" }, + { 18653760,4080,3048,24,12,24,12, 8,0x94,0,2,"Canon","PowerShot SX20 IS" }, + { 19131120,4168,3060,92,16, 4, 1, 8,0x94,0,2,"Canon","PowerShot SX220 HS" }, + { 21936096,4464,3276,25,10,73,12, 8,0x16,0,2,"Canon","PowerShot SX30 IS" }, + { 24724224,4704,3504, 8,16,56, 8, 8,0x94,0,2,"Canon","PowerShot A3300 IS" }, + { 30858240,5248,3920, 8,16,56,16, 8,0x94,0,2,"Canon","IXUS 160" }, { 1976352,1632,1211, 0, 2, 0, 1, 0,0x94,0,1,"Casio","QV-2000UX" }, { 3217760,2080,1547, 0, 0,10, 1, 0,0x94,0,1,"Casio","QV-3*00EX" }, { 6218368,2585,1924, 0, 0, 9, 0, 0,0x94,0,1,"Casio","QV-5700" }, @@ -8629,12 +8752,13 @@ void CLASS identify() { 44390468,4080,5440, 0, 0, 0, 0,33,0x61,0,0,"Sinar","",68 }, { 1409024,1376,1024, 0, 0, 1, 0, 0,0x49,0,0,"Sony","XCD-SX910CR" }, { 2818048,1376,1024, 0, 0, 1, 0,97,0x49,0,0,"Sony","XCD-SX910CR" }, + { 17496000,4320,3240, 0, 0, 0,0,224,0x94,0,0,"Xiro","Xplorer V" }, }; static const char *corp[] = { "AgfaPhoto", "Canon", "Casio", "Epson", "Fujifilm", "Mamiya", "Minolta", "Motorola", "Kodak", "Konica", "Leica", "Nikon", "Nokia", "Olympus", "Ricoh", "Pentax", "Phase One", - "Samsung", "Sigma", "Sinar", "Sony" }; + "Samsung", "Sigma", "Sinar", "Sony", "YI" }; char head[32], *cp; int hlen, flen, fsize, zero_fsize=1, i, c; struct jhead jh; @@ -8722,14 +8846,20 @@ void CLASS identify() if (is_raw == 2 && shot_select) parse_fuji (i); } - load_raw = &CLASS unpacked_load_raw; fseek (ifp, 100+28*(shot_select > 0), SEEK_SET); parse_tiff (data_offset = get4()); parse_tiff (thumb_offset+12); apply_tiff(); + if (!load_raw) { + load_raw = &CLASS unpacked_load_raw; + tiff_bps = 14; + } } else if (!memcmp (head,"RIFF",4)) { fseek (ifp, 0, SEEK_SET); parse_riff(); + } else if (!memcmp (head+4,"ftypcrx ",8)) { + fseek (ifp, 0, SEEK_SET); + parse_crx (fsize); } else if (!memcmp (head+4,"ftypqt ",9)) { fseek (ifp, 0, SEEK_SET); parse_qt (fsize); @@ -8825,7 +8955,8 @@ void CLASS identify() case 8: load_raw = &CLASS eight_bit_load_raw; break; case 10: case 12: - load_flags |= 128; + load_flags |= 512; + if (!strcmp(make,"Canon")) load_flags |= 256; load_raw = &CLASS packed_load_raw; break; case 16: order = 0x4949 | 0x404 * (load_flags & 1); @@ -8880,17 +9011,25 @@ void CLASS identify() { height = 2616; width = 3896; } 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"))) + if (raw_height == 2868 && (!strcmp(model,"K-r") || !strcmp(model,"K-x"))) { width = 4309; filters = 0x16161616; } - if (width >= 4960 && !strncmp(model,"K-5",3)) - { left_margin = 10; width = 4950; filters = 0x16161616; } - if (width == 4736 && !strcmp(model,"K-7")) + if (raw_height == 3136 && !strcmp(model,"K-7")) { height = 3122; width = 4684; filters = 0x16161616; top_margin = 2; } - if (width == 6080 && !strcmp(model,"K-3")) - { left_margin = 4; width = 6040; } - if (width == 7424 && !strcmp(model,"645D")) - { height = 5502; width = 7328; filters = 0x61616161; top_margin = 29; - left_margin = 48; } + if (raw_height == 3284 && !strncmp(model,"K-5",3)) + { left_margin = 10; width = 4950; filters = 0x16161616; } + if (raw_height == 3300 && !strncmp(model,"K-50",4)) + { height = 3288, width = 4952; left_margin = 0; top_margin = 12; } + if (raw_height == 3664 && !strncmp(model,"K-S",3)) + { width = 5492; left_margin = 0; } + if (raw_height == 4032 && !strcmp(model,"K-3")) + { height = 4032; width = 6040; left_margin = 4; } + if (raw_height == 4060 && !strcmp(model,"KP")) + { height = 4032; width = 6032; left_margin = 52; top_margin = 28; } + if (raw_height == 4950 && !strcmp(model,"K-1")) + { height = 4932; width = 7380; left_margin = 4; top_margin = 18; } + if (raw_height == 5552 && !strcmp(model,"645D")) + { height = 5502; width = 7328; left_margin = 48; top_margin = 29; + filters = 0x61616161; } if (height == 3014 && width == 4096) /* Ricoh GX200 */ width = 4014; if (dng_version) { @@ -8935,6 +9074,10 @@ void CLASS identify() for (i=0; i < sizeof sonique / sizeof *sonique; i++) if (unique_id == sonique[i].id) strcpy (model, sonique[i].model); + for (i=0; i < sizeof panalias / sizeof *panalias; i++) + if (panalias[i][0] == '@') orig = panalias[i]+1; + else if (!strcmp(model,panalias[i])) + adobe_coeff ("Panasonic", orig); if (!strcmp(make,"Nikon")) { if (!load_raw) load_raw = &CLASS packed_load_raw; @@ -9002,7 +9145,7 @@ void CLASS identify() colors = 4; tiff_bps = 10; load_raw = &CLASS packed_load_raw; - load_flags = 40; + load_flags = 264; } else if (!strcmp(model,"PowerShot Pro90 IS") || !strcmp(model,"PowerShot G1")) { colors = 4; @@ -9014,6 +9157,9 @@ void CLASS identify() } else if (!strcmp(model,"EOS D2000C")) { filters = 0x61616161; black = curve[200]; + } else if (!strcmp(model,"EOS 80D")) { + top_margin -= 2; + height += 2; } else if (!strcmp(model,"D1")) { cam_mul[0] *= 256/527.0; cam_mul[2] *= 256/317.0; @@ -9068,6 +9214,8 @@ void CLASS identify() else width -= 8; } else if (!strncmp(model,"D300",4)) { width -= 32; + } else if (!strncmp(model,"COOLPIX B",9)) { + load_flags = 24; } else if (!strncmp(model,"COOLPIX P",9) && raw_width != 4032) { load_flags = 24; filters = 0x94949494; @@ -9140,12 +9288,11 @@ void CLASS identify() height = 2144; width = 2880; flip = 6; - } else if (load_raw != &CLASS packed_load_raw) - maximum = (is_raw == 2 && shot_select) ? 0x2f00 : 0x3e00; + } top_margin = (raw_height - height) >> 2 << 1; left_margin = (raw_width - width ) >> 2 << 1; if (width == 2848 || width == 3664) filters = 0x16161616; - if (width == 4032 || width == 4952 || width == 6032) left_margin = 0; + if (width == 4032 || width == 4952 || width == 6032 || width == 8280) left_margin = 0; if (width == 3328 && (width -= 66)) left_margin = 34; if (width == 4936) left_margin = 4; if (!strcmp(model,"HS50EXR") || @@ -9207,7 +9354,7 @@ void CLASS identify() } else if (!strcmp(make,"Samsung") && raw_width == 4704) { height -= top_margin = 8; width -= 2 * (left_margin = 8); - load_flags = 32; + load_flags = 256; } else if (!strcmp(make,"Samsung") && raw_height == 3714) { height -= top_margin = 18; left_margin = raw_width - (width = 5536); @@ -9277,6 +9424,11 @@ void CLASS identify() top_margin = 4; left_margin = 41; filters = 0x61616161; + } else if (raw_width == 8384) { + height = 6208; + width = 8280; + top_margin = 96; + left_margin = 46; } else if (raw_width == 9044) { height = 6716; width = 8964; @@ -9390,6 +9542,8 @@ void CLASS identify() thumb_width = 640; } else if (!strcmp(model,"TG-4")) { width -= 16; + } else if (!strcmp(model,"TG-5")) { + width -= 6; } } else if (!strcmp(model,"N Digital")) { height = 2047; @@ -9435,14 +9589,6 @@ void CLASS identify() width -= 30; } else if (!strcmp(make,"Sony") && raw_width == 8000) { width -= 32; - // This was introduced with update to dcraw 9.27, - // but led to broken decode for compressed files from Sony DSC-RX1RM. - // c.f. https://github.com/Beep6581/RawTherapee/issues/3358 - // if (!strncmp(model,"DSC",3)) { - // tiff_bps = 14; - // load_raw = &CLASS unpacked_load_raw; - // black = 512; - // } } else if (!strcmp(model,"DSLR-A100")) { if (width == 3880) { height--; @@ -9815,9 +9961,7 @@ void CLASS fuji_rotate() img = (ushort (*)[4]) calloc (high, wide*sizeof *img); merror (img, "fuji_rotate()"); -#ifdef _OPENMP - #pragma omp parallel for default(shared) private(row,col,ur,uc,r,c,fr,fc,pix,i) -#endif +#pragma omp parallel for default(shared) private(row,col,ur,uc,r,c,fr,fc,pix,i) for (row=0; row < high; row++) for (col=0; col < wide; col++) { ur = r = fuji_width + (row-col)*step; @@ -10531,3 +10675,5 @@ int CLASS main (int argc, const char **argv) } return status; } + +/* vim:set noet sw=8 ts=8: */ diff --git a/lightcrafts/coprocesses/dcraw/patches/Sony-DSC-RX1RM2.patch b/lightcrafts/coprocesses/dcraw/patches/Sony-DSC-RX1RM2.patch deleted file mode 100644 index 885a08ee0..000000000 --- a/lightcrafts/coprocesses/dcraw/patches/Sony-DSC-RX1RM2.patch +++ /dev/null @@ -1,24 +0,0 @@ -Index: dcraw/dcraw_lz.c -=================================================================== ---- dcraw.orig/dcraw_lz.c -+++ dcraw/dcraw_lz.c -@@ -9435,11 +9435,14 @@ konica_400z: - width -= 30; - } else if (!strcmp(make,"Sony") && raw_width == 8000) { - width -= 32; -- if (!strncmp(model,"DSC",3)) { -- tiff_bps = 14; -- load_raw = &CLASS unpacked_load_raw; -- black = 512; -- } -+ // This was introduced with update to dcraw 9.27, -+ // but led to broken decode for compressed files from Sony DSC-RX1RM. -+ // c.f. https://github.com/Beep6581/RawTherapee/issues/3358 -+ // if (!strncmp(model,"DSC",3)) { -+ // tiff_bps = 14; -+ // load_raw = &CLASS unpacked_load_raw; -+ // black = 512; -+ // } - } else if (!strcmp(model,"DSLR-A100")) { - if (width == 3880) { - height--; diff --git a/lightcrafts/coprocesses/dcraw/patches/dcraw_indi.patch b/lightcrafts/coprocesses/dcraw/patches/dcraw_indi.patch index 62deda857..cd7ee1a7e 100644 --- a/lightcrafts/coprocesses/dcraw/patches/dcraw_indi.patch +++ b/lightcrafts/coprocesses/dcraw/patches/dcraw_indi.patch @@ -9,7 +9,7 @@ Index: dcraw/dcraw_lz.c + */ +/* dcraw.c -- Dave Coffin's raw photo decoder - Copyright 1997-2016 by Dave Coffin, dcoffin a cybercom o net + Copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net @@ -96,6 +100,15 @@ typedef unsigned long long UINT64; #define ushort unsigned short @@ -26,28 +26,22 @@ Index: dcraw/dcraw_lz.c + /* All global variables are defined here, and all functions that - access them are prefixed with "CLASS". Note that a thread-safe -@@ -4123,6 +4136,19 @@ void CLASS wavelet_denoise() + access them are prefixed with "CLASS". For thread-safety, all +@@ -4132,6 +4145,13 @@ void CLASS wavelet_denoise() merror (fimg, "wavelet_denoise()"); temp = fimg + size*3; if ((nc = colors) == 3 && filters) nc++; -+#ifdef _OPENMP +#if defined(__sun) && !defined(__GNUC__) /* Fix UFRaw bug #3205673 - NKBJ */ -+ #pragma omp parallel for \ -+ default(none) \ -+ shared(nc,image,scale,size,noise) \ ++ #pragma omp parallel for default(shared) \ + private(c,i,hpass,lev,lpass,row,col,thold,fimg,temp) +#else -+ #pragma omp parallel for \ -+ default(none) \ -+ shared(nc,image,iheight,iwidth,scale,threshold,size) \ ++ #pragma omp parallel for default(shared) \ + private(c,i,hpass,lev,lpass,row,col,thold,fimg,temp) -+#endif +#endif FORC(nc) { /* denoise R,G1,B,G3 individually */ for (i=0; i < size; i++) fimg[i] = 256 * sqrt(image[i][c] << scale); -@@ -4346,8 +4372,12 @@ void CLASS pre_interpolate() +@@ -4355,8 +4375,10 @@ void CLASS pre_interpolate() void CLASS border_interpolate (int border) { @@ -55,39 +49,31 @@ Index: dcraw/dcraw_lz.c + int row; + unsigned col, y, x, f, c, sum[8]; -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=0; row < height; row++) for (col=0; col < width; col++) { if (col==border && row >= border && row < height-border) -@@ -4374,7 +4404,15 @@ void CLASS lin_interpolate() +@@ -4383,7 +4405,11 @@ void CLASS lin_interpolate() if (verbose) fprintf (stderr,_("Bilinear interpolation...\n")); if (filters == 9) size = 6; -+#ifdef _OPENMP -+ #pragma omp parallel default(shared) \ -+ private(ip, sum, f, c, i, x, y, row, col, shift, color, pix) -+#endif ++#pragma omp parallel default(shared) \ ++ private(ip, sum, f, c, i, x, y, row, col, shift, color, pix) +{ border_interpolate(1); -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=0; row < size; row++) for (col=0; col < size; col++) { ip = code[row][col]+1; -@@ -4397,6 +4435,9 @@ void CLASS lin_interpolate() +@@ -4406,6 +4432,7 @@ void CLASS lin_interpolate() *ip++ = 256 / sum[c]; } } -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=1; row < height-1; row++) for (col=1; col < width-1; col++) { pix = image[row*width+col]; -@@ -4407,6 +4448,7 @@ void CLASS lin_interpolate() +@@ -4416,6 +4443,7 @@ void CLASS lin_interpolate() for (i=colors; --i; ip+=2) pix[ip[0]] = sum[ip[0]] * ip[1] >> 8; } @@ -95,7 +81,7 @@ Index: dcraw/dcraw_lz.c } /* -@@ -4445,7 +4487,7 @@ void CLASS vng_interpolate() +@@ -4454,7 +4482,7 @@ void CLASS vng_interpolate() +1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40, +1,+0,+2,+1,0,0x10 }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 }; @@ -104,7 +90,7 @@ Index: dcraw/dcraw_lz.c int prow=8, pcol=2, *ip, *code[16][16], gval[8], gmin, gmax, sum[4]; int row, col, x, y, x1, x2, y1, y2, t, weight, grads, color, diag; int g, diff, thold, num, c; -@@ -4455,7 +4497,7 @@ void CLASS vng_interpolate() +@@ -4464,7 +4492,7 @@ void CLASS vng_interpolate() if (filters == 1) prow = pcol = 16; if (filters == 9) prow = pcol = 6; @@ -113,7 +99,7 @@ Index: dcraw/dcraw_lz.c merror (ip, "vng_interpolate()"); for (row=0; row < prow; row++) /* Precalculate for VNG */ for (col=0; col < pcol; col++) { -@@ -4487,11 +4529,23 @@ void CLASS vng_interpolate() +@@ -4496,11 +4524,18 @@ void CLASS vng_interpolate() *ip++ = 0; } } @@ -122,15 +108,11 @@ Index: dcraw/dcraw_lz.c - for (row=0; row < 3; row++) - brow[row] = brow[4] + row*width; - for (row=2; row < height-2; row++) { /* Do VNG interpolation */ -+#ifdef _OPENMP -+ #pragma omp parallel \ -+ default(none) \ -+ shared(image,code,prow,pcol,width,height,colors) \ -+ private(row,col,g,brow,pix,ip,gval,diff,gmin,gmax,thold,sum,color,num,c,t) -+#endif ++#pragma omp parallel default(shared) \ ++ private(row,col,g,brow,pix,ip,gval,diff,gmin,gmax,thold,sum,color,num,c,t) +{ + ushort (*rowtmp)[4]; -+ rowtmp = (ushort*)malloc(4 * width * 4 * sizeof(ushort)); ++ rowtmp = (ushort(*)[4])malloc(4 * width * 4 * sizeof(ushort)); + int slice = (height - 4) / uf_omp_get_num_threads(); + int start_row = 2 + slice * uf_omp_get_thread_num(); + int end_row = MIN(start_row + slice, height - 2); @@ -138,11 +120,10 @@ Index: dcraw/dcraw_lz.c + + for (g = 0; g < 4; g++) + brow[g] = &rowtmp[(row + g - 2) % 4]; -+ for (col=2; col < width-2; col++) { pix = image[row*width+col]; ip = code[row % prow][col % pcol]; -@@ -4535,15 +4589,15 @@ void CLASS vng_interpolate() +@@ -4544,15 +4579,15 @@ void CLASS vng_interpolate() brow[2][col][c] = CLIP(t); } } @@ -165,49 +146,38 @@ Index: dcraw/dcraw_lz.c } /* -@@ -4555,10 +4609,20 @@ void CLASS ppg_interpolate() +@@ -4564,10 +4599,13 @@ void CLASS ppg_interpolate() int row, col, diff[2], guess[2], c, d, i; ushort (*pix)[4]; - border_interpolate(3); if (verbose) fprintf (stderr,_("PPG interpolation...\n")); -+#ifdef _OPENMP -+ #pragma omp parallel \ -+ default(none) \ -+ shared(image,dir,diff,width,height,filters) \ -+ private(row,col,i,d,c,pix,guess) -+#endif ++#pragma omp parallel default(shared) private(row,col,i,d,c,pix,guess) +{ + border_interpolate(3); /* Fill in the green layer with gradients and pattern recognition: */ -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=3; row < height-3; row++) for (col=3+(FC(row,3) & 1), c=FC(row,col); col < width-3; col+=2) { pix = image + row*width+col; -@@ -4575,6 +4639,9 @@ void CLASS ppg_interpolate() +@@ -4584,6 +4622,7 @@ void CLASS ppg_interpolate() pix[0][1] = ULIM(guess[i] >> 2, pix[d][1], pix[-d][1]); } /* Calculate red and blue for each green pixel: */ -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=1; row < height-1; row++) for (col=1+(FC(row,2) & 1), c=FC(row,col+1); col < width-1; col+=2) { pix = image + row*width+col; -@@ -4583,6 +4650,9 @@ void CLASS ppg_interpolate() +@@ -4592,6 +4631,7 @@ void CLASS ppg_interpolate() - pix[-d][1] - pix[d][1]) >> 1); } /* Calculate blue for red pixels and vice versa: */ -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=1; row < height-1; row++) for (col=1+(FC(row,1) & 1), c=2-FC(row,col); col < width-1; col+=2) { pix = image + row*width+col; -@@ -4598,6 +4668,7 @@ void CLASS ppg_interpolate() +@@ -4607,6 +4647,7 @@ void CLASS ppg_interpolate() else pix[0][c] = CLIP((guess[0]+guess[1]) >> 2); } @@ -215,53 +185,43 @@ Index: dcraw/dcraw_lz.c } void CLASS cielab (ushort rgb[3], short lab[3]) -@@ -4607,13 +4678,22 @@ void CLASS cielab (ushort rgb[3], short +@@ -4616,13 +4657,16 @@ void CLASS cielab (ushort rgb[3], short static float cbrt[0x10000], xyz_cam[3][4]; if (!rgb) { -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (i=0; i < 0x10000; i++) { r = i / 65535.0; cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0; } -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (i=0; i < 3; i++) for (j=0; j < colors; j++) for (xyz_cam[i][j] = k=0; k < 3; k++) -+#ifdef _OPENMP -+ #pragma omp atomic -+#endif ++#pragma omp atomic xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j] / d65_white[i]; return; } -@@ -4879,6 +4959,12 @@ void CLASS ahd_interpolate() +@@ -4888,6 +4932,10 @@ void CLASS ahd_interpolate() if (verbose) fprintf (stderr,_("AHD interpolation...\n")); -+#ifdef _OPENMP -+ #pragma omp parallel \ -+ default(shared) \ -+ private(top, left, row, col, pix, rix, lix, c, val, d, tc, tr, i, j, ldiff, abdiff, leps, abeps, hm, buffer, rgb, lab, homo) -+#endif ++#pragma omp parallel default(shared) \ ++ private(top,left,row,col,pix,rix,lix,c,val,d,tc,tr,i,j,ldiff,abdiff,leps, \ ++ abeps,hm,buffer,rgb,lab,homo) +{ cielab (0,0); border_interpolate(5); buffer = (char *) malloc (26*TS*TS); -@@ -4887,6 +4973,9 @@ void CLASS ahd_interpolate() +@@ -4896,6 +4944,7 @@ void CLASS ahd_interpolate() lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS); homo = (char (*)[TS][TS]) (buffer + 24*TS*TS); -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (top=2; top < height-5; top += TS-6) for (left=2; left < width-5; left += TS-6) { -@@ -4969,6 +5058,7 @@ void CLASS ahd_interpolate() +@@ -4978,6 +5027,7 @@ void CLASS ahd_interpolate() } } free (buffer); @@ -269,13 +229,11 @@ Index: dcraw/dcraw_lz.c } #undef TS -@@ -9580,6 +9670,9 @@ void CLASS fuji_rotate() +@@ -9825,6 +9875,7 @@ void CLASS fuji_rotate() img = (ushort (*)[4]) calloc (high, wide*sizeof *img); merror (img, "fuji_rotate()"); -+#ifdef _OPENMP -+ #pragma omp parallel for default(shared) private(row,col,ur,uc,r,c,fr,fc,pix,i) -+#endif ++#pragma omp parallel for default(shared) private(row,col,ur,uc,r,c,fr,fc,pix,i) for (row=0; row < high; row++) for (col=0; col < wide; col++) { ur = r = fuji_width + (row-col)*step; diff --git a/lightcrafts/coprocesses/dcraw/patches/lightzone.patch b/lightcrafts/coprocesses/dcraw/patches/lightzone.patch index 6280cb497..a5cb441fd 100644 --- a/lightcrafts/coprocesses/dcraw/patches/lightzone.patch +++ b/lightcrafts/coprocesses/dcraw/patches/lightzone.patch @@ -2,7 +2,7 @@ Index: dcraw/dcraw_lz.c =================================================================== --- dcraw.orig/dcraw_lz.c +++ dcraw/dcraw_lz.c -@@ -144,7 +144,10 @@ int output_color=1, output_bps=8, output +@@ -145,7 +145,10 @@ int output_color=1, output_bps=8, output int no_auto_bright=0; unsigned greybox[4] = { 0, 0, UINT_MAX, UINT_MAX }; float cam_mul[4], pre_mul[4], cmatrix[3][4], rgb_cam[3][4]; @@ -14,7 +14,7 @@ Index: dcraw/dcraw_lz.c { 0.412453, 0.357580, 0.180423 }, { 0.212671, 0.715160, 0.072169 }, { 0.019334, 0.119193, 0.950227 } }; -@@ -10080,6 +10083,9 @@ int CLASS main (int argc, const char **a +@@ -10227,6 +10230,9 @@ int CLASS main (int argc, const char **a #ifndef NO_LCMS const char *cam_profile=0, *out_profile=0; #endif @@ -24,7 +24,7 @@ Index: dcraw/dcraw_lz.c #ifndef LOCALTIME putenv ((char *) "TZ=UTC"); -@@ -10174,6 +10180,9 @@ int CLASS main (int argc, const char **a +@@ -10321,6 +10327,9 @@ int CLASS main (int argc, const char **a case 'p': cam_profile = argv[arg++]; #endif break; @@ -34,7 +34,7 @@ Index: dcraw/dcraw_lz.c case 'P': bpfile = argv[arg++]; break; case 'K': dark_frame = argv[arg++]; break; case 'z': timestamp_only = 1; break; -@@ -10202,6 +10211,19 @@ int CLASS main (int argc, const char **a +@@ -10349,6 +10358,19 @@ int CLASS main (int argc, const char **a return 1; } } @@ -54,7 +54,7 @@ Index: dcraw/dcraw_lz.c if (arg == argc) { fprintf (stderr,_("No files to process.\n")); return 1; -@@ -10346,6 +10368,10 @@ int CLASS main (int argc, const char **a +@@ -10493,6 +10515,10 @@ int CLASS main (int argc, const char **a for (c = i && putchar('/') && 0; c < fwide; c++) putchar (cdesc[fcol(i,c)]); } @@ -65,7 +65,7 @@ Index: dcraw/dcraw_lz.c printf (_("\nDaylight multipliers:")); FORCC printf (" %f", pre_mul[c]); if (cam_mul[0] > 0) { -@@ -10458,6 +10484,11 @@ thumbnail: +@@ -10605,6 +10631,11 @@ thumbnail: if (write_to_stdout) strcpy (ofname,_("standard output")); else { @@ -77,3 +77,9 @@ Index: dcraw/dcraw_lz.c strcpy (ofname, ifname); if ((cp = strrchr (ofname, '.'))) *cp = 0; if (multi_out) +@@ -10637,3 +10668,5 @@ cleanup: + } + return status; + } ++ ++/* vim:set noet sw=8 ts=8: */ diff --git a/lightcrafts/coprocesses/dcraw/patches/strnlen.patch b/lightcrafts/coprocesses/dcraw/patches/strnlen.patch index 7c2f5a3fc..de800cd1e 100644 --- a/lightcrafts/coprocesses/dcraw/patches/strnlen.patch +++ b/lightcrafts/coprocesses/dcraw/patches/strnlen.patch @@ -2,7 +2,7 @@ Index: dcraw/dcraw_lz.c =================================================================== --- dcraw.orig/dcraw_lz.c +++ dcraw/dcraw_lz.c -@@ -9902,6 +9902,13 @@ struct tiff_hdr { +@@ -10049,6 +10049,13 @@ struct tiff_hdr { char desc[512], make[64], model[64], soft[32], date[20], artist[64]; }; diff --git a/lightcrafts/coprocesses/dcraw/patches/xtrans_yama1968.patch b/lightcrafts/coprocesses/dcraw/patches/xtrans_yama1968.patch index 858c5f6af..858a25f8c 100644 --- a/lightcrafts/coprocesses/dcraw/patches/xtrans_yama1968.patch +++ b/lightcrafts/coprocesses/dcraw/patches/xtrans_yama1968.patch @@ -2,73 +2,31 @@ Index: dcraw/dcraw_lz.c =================================================================== --- dcraw.orig/dcraw_lz.c +++ dcraw/dcraw_lz.c -@@ -4671,6 +4671,45 @@ void CLASS ppg_interpolate() - } /* pragma omp parallel */ - } - -+void CLASS cielab3 (ushort rgb[3], short lab[3]) -+{ -+ int c, i, j, k; -+ float r, xyz[3]; -+ static float cbrt[0x10000], xyz_cam[3][4]; -+ -+ if (!rgb) { -+#ifdef _OPENMP -+ #pragma omp for -+#endif -+ for (i=0; i < 0x10000; i++) { -+ r = i / 65535.0; -+ cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0; -+ } -+#ifdef _OPENMP -+ #pragma omp for -+#endif -+ for (i=0; i < 3; i++) -+ for (j=0; j < colors; j++) -+ for (xyz_cam[i][j] = k=0; k < 3; k++) -+#ifdef _OPENMP -+ #pragma omp atomic -+#endif -+ xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j] / d65_white[i]; -+ return; -+ } -+ xyz[0] = xyz[1] = xyz[2] = 0.5; -+ -+ FORC(3) { -+ xyz[c] += xyz_cam[c][0] * rgb [0] + xyz_cam[c][1] * rgb [1] + xyz_cam[c][2] * rgb [2]; -+ } -+ xyz[0] = cbrt[CLIP((int) xyz[0])]; -+ xyz[1] = cbrt[CLIP((int) xyz[1])]; -+ xyz[2] = cbrt[CLIP((int) xyz[2])]; -+ lab[0] = 64 * (116 * xyz[1] - 16); -+ lab[1] = 64 * 500 * (xyz[0] - xyz[1]); -+ lab[2] = 64 * 200 * (xyz[1] - xyz[2]); -+} -+ - void CLASS cielab (ushort rgb[3], short lab[3]) - { - int c, i, j, k; -@@ -4714,13 +4753,38 @@ void CLASS cielab (ushort rgb[3], short +@@ -4687,13 +4687,41 @@ void CLASS cielab (ushort rgb[3], short #define TS 512 /* Tile Size */ #define fcol(row,col) xtrans[(row+6) % 6][(col+6) % 6] -+#if ! defined(_OPENMP) -+// Makes a 10% difference in performances in sequential version, but none at all with OPENMP... -+// And _STATIC_BUFFER is delicate to manage -+#define _STATIC_BUFFER -+#define _FIXED_NDIR ++#ifndef _OPENMP ++// Makes a 10% difference in performances in sequential version, but none at all ++// with OPENMP... ++// And STATIC_BUFFER is delicate to manage ++#define STATIC_BUFFER ++#define FIXED_NDIR +#endif + -+/* Allow each tile to be calculate independently from the others -+ Explanation: the border pixels from each tiles start from the border pixel of other tiles ++/* Allow each tile to be calculate independently from the others. ++ Explanation: the border pixels from each tiles start from the border pixel of ++ other tiles. + This goes from top to bottom: + - the first pixels of each tile depend on the last ones of the previous tile + - the last ones depend on the first ones of the next tile -+ In sequential mode, the first pixels use the calculated values from the previous tiles and fresh values from the next tile. -+ In OpenMP / parallel mode, the first pixels of the next files might have been already calculated. -+ The STRIC_IMAGE makes it possible to use indeed fresh values, always ++ In sequential mode, the first pixels use the calculated values from the ++ previous tiles and fresh values from the next tile. ++ In OpenMP / parallel mode, the first pixels of the next files might have been ++ already calculated. ++ The STRICT_IMAGE makes it possible to use indeed fresh values, always. +*/ -+#define _STRICT_IMAGE ++#define STRICT_IMAGE + /* Frank Markesteijn's algorithm for Fuji X-Trans sensors @@ -77,9 +35,8 @@ Index: dcraw/dcraw_lz.c { int c, d, f, g, h, i, v, ng, row, col, top, left, mrow, mcol; - int val, ndir, pass, hm[8], avg[4], color[3][8]; -+ // int val, ndir, pass, hm[8], avg[4], color[3][8]; + int val, pass, hm[8], avg[4], color[3][8]; -+#if defined(_FIXED_NDIR) ++#ifdef FIXED_NDIR + const int ndir = 4 << 1; +#else + int ndir = 4 << (passes > 1); @@ -88,25 +45,20 @@ Index: dcraw/dcraw_lz.c static const short orth[12] = { 1,0,0,1,-1,0,0,-1,1,0,0,1 }, patt[2][16] = { { 0,1,0,-1,2,0,-1,0,1,1,1,-1,0,0,0,0 }, { 0,1,0,-2,1,0,-2,0,1,1,-2,-2,1,-1,-1,1 } }, -@@ -4730,21 +4794,48 @@ void CLASS xtrans_interpolate (int passe +@@ -4703,21 +4731,37 @@ void CLASS xtrans_interpolate (int passe ushort (*rgb)[TS][TS][3], (*rix)[3], (*pix)[4]; short (*lab) [TS][3], (*lix)[3]; float (*drv)[TS][TS], diff[6], tr; - char (*homo)[TS][TS], *buffer; + char (*homo)[TS][TS]; -+#if defined(_STATIC_BUFFER) ++#ifdef STATIC_BUFFER + static char buffer [TS*TS*(8*11+6)] __attribute__((aligned(64))); +#else + char *buffer; +#endif if (verbose) -+#if defined(_OPENMP) -+ fprintf (stderr,_("%d-pass X-Trans interpolation with %d max threads...\n"), -+ passes, omp_get_max_threads ()); -+#else fprintf (stderr,_("%d-pass X-Trans interpolation...\n"), passes); -+#endif - cielab (0,0); - ndir = 4 << (passes > 1); @@ -120,56 +72,48 @@ Index: dcraw/dcraw_lz.c + fprintf (stderr,_("4 << (passes > 1) = %d != ndir = %d\n"), + (4 << (passes > 1)), ndir); + -+#ifdef _FIXED_NDIR -+#pragma omp parallel default (none) \ -+ shared (height, width, image, allhex, sgrow, sgcol, xtrans, \ -+ top_margin, left_margin, passes, verbose, iwidth, iheight) \ ++#ifdef FIXED_NDIR ++#pragma omp parallel default (shared) \ + private (top, left, mrow, mcol, row, col, color, pix, hex, c, pass, rix, \ + val, h, f, d, g, tr, v, hm, max, avg, lix, diff, i, \ + buffer, rgb, lab, drv, homo, ng, min) +#else -+#pragma omp parallel default (none) \ -+ shared (height, width, image, allhex, ndir, sgrow, sgcol, xtrans, \ -+ top_margin, left_margin, passes, verbose, iwidth, iheight) \ ++#pragma omp parallel default (shared) \ + private (top, left, mrow, mcol, row, col, color, pix, hex, c, pass, rix, \ + val, h, f, d, g, tr, v, hm, max, avg, lix, diff, i, \ + buffer, rgb, lab, drv, homo, ng, min) +#endif + { -+ cielab3 (0,0); ++ cielab(0,0); + border_interpolate(6); /* Map a green hexagon around each non-green pixel and vice versa: */ -+#ifdef _OPENMP -+ #pragma omp for -+#endif ++#pragma omp for for (row=0; row < 3; row++) for (col=0; col < 3; col++) for (ng=d=0; d < 10; d+=2) { -@@ -4759,7 +4850,11 @@ void CLASS xtrans_interpolate (int passe +@@ -4732,7 +4776,9 @@ void CLASS xtrans_interpolate (int passe } } + /* Set green1 and green3 to the minimum and maximum allowed values: */ -+#ifdef _OPENMP -+ #pragma omp single -+#endif ++#pragma omp single for (row=2; row < height-2; row++) for (min=~(max=0), col=2; col < width-2; col++) { if (fcol(row,col) == 1 && (min=~(max=0))) continue; -@@ -4778,20 +4873,46 @@ void CLASS xtrans_interpolate (int passe +@@ -4751,20 +4797,46 @@ void CLASS xtrans_interpolate (int passe } } -+#if defined(_STRICT_IMAGE) ++#ifdef STRICT_IMAGE + ushort (*working_image)[4]; + working_image = (ushort (*)[4]) calloc (iheight, iwidth*sizeof *image); + memcpy (working_image, image, iheight * iwidth * sizeof *image); + merror (working_image, "xtrans_interpolate working_image"); +#endif + -+#if ! defined(_STATIC_BUFFER) ++#ifndef STATIC_BUFFER + buffer = (char *) malloc (TS*TS*(ndir*11+6)); + merror (buffer, "xtrans_interpolate()"); +#endif @@ -186,11 +130,10 @@ Index: dcraw/dcraw_lz.c mcol = MIN (left+TS, width-3); for (row=top; row < mrow; row++) for (col=left; col < mcol; col++) -- memcpy (rgb[0][row-top][col-left], image[row*width+col], 6); -+#if defined(_STRICT_IMAGE) ++#ifdef STRICT_IMAGE + memcpy (rgb[0][row-top][col-left], working_image[row*width+col], 6); +#else -+ memcpy (rgb[0][row-top][col-left], image[row*width+col], 6); + memcpy (rgb[0][row-top][col-left], image[row*width+col], 6); +#endif FORC3 memcpy (rgb[c+1], rgb[0], sizeof *rgb); @@ -198,7 +141,7 @@ Index: dcraw/dcraw_lz.c for (row=top; row < mrow; row++) for (col=left; col < mcol; col++) { if ((f = fcol(row,col)) == 1) continue; -+#if defined(_STRICT_IMAGE) ++#ifdef STRICT_IMAGE + pix = working_image + row*width + col; +#else pix = image + row*width + col; @@ -206,11 +149,11 @@ Index: dcraw/dcraw_lz.c hex = allhex[row % 3][col % 3][0]; color[1][0] = 174 * (pix[ hex[1]][1] + pix[ hex[0]][1]) - 46 * (pix[2*hex[1]][1] + pix[2*hex[0]][1]); -@@ -4813,7 +4934,11 @@ void CLASS xtrans_interpolate (int passe +@@ -4786,7 +4858,11 @@ void CLASS xtrans_interpolate (int passe for (row=top+2; row < mrow-2; row++) for (col=left+2; col < mcol-2; col++) { if ((f = fcol(row,col)) == 1) continue; -+#if defined(_STRICT_IMAGE) ++#ifdef STRICT_IMAGE + pix = working_image + row*width + col; +#else pix = image + row*width + col; @@ -218,19 +161,7 @@ Index: dcraw/dcraw_lz.c hex = allhex[row % 3][col % 3][1]; for (d=3; d < 6; d++) { rix = &rgb[(d-2)^!((row-sgrow) % 3)][row-top][col-left]; -@@ -4889,8 +5014,9 @@ void CLASS xtrans_interpolate (int passe - for (d=0; d < ndir; d++) { - for (row=2; row < mrow-2; row++) - for (col=2; col < mcol-2; col++) -- cielab (rgb[d][row][col], lab[row][col]); -- for (f=dir[d & 3],row=3; row < mrow-3; row++) -+ cielab3 (rgb[d][row][col], lab[row][col]); // use cielab3 because X-trans is 3 colors -+ f=dir[d & 3]; -+ for (row=3; row < mrow-3; row++) - for (col=3; col < mcol-3; col++) { - lix = &lab[row][col]; - g = 2*lix[0][0] - lix[f][0] - lix[-f][0]; -@@ -4905,14 +5031,12 @@ void CLASS xtrans_interpolate (int passe +@@ -4878,14 +4954,12 @@ void CLASS xtrans_interpolate (int passe for (row=4; row < mrow-4; row++) for (col=4; col < mcol-4; col++) { for (tr=FLT_MAX, d=0; d < ndir; d++) @@ -247,26 +178,21 @@ Index: dcraw/dcraw_lz.c } /* Average the most homogenous pixels for the final result: */ -@@ -4922,8 +5046,17 @@ void CLASS xtrans_interpolate (int passe +@@ -4895,8 +4969,11 @@ void CLASS xtrans_interpolate (int passe for (col = MIN(left,8); col < mcol-8; col++) { for (d=0; d < ndir; d++) for (hm[d]=0, v=-2; v <= 2; v++) - for (h=-2; h <= 2; h++) -+ /* -+ for (h=-2; h <= 2; h++) - hm[d] += homo[d][row+v][col+h]; -+ */ -+ /* */ +- hm[d] += homo[d][row+v][col+h]; + hm[d] += homo[d][row+v][col-2] + + homo[d][row+v][col-1] + + homo[d][row+v][col+0] + + homo[d][row+v][col+1] + + homo[d][row+v][col+2]; -+ /* */ for (d=0; d < ndir-4; d++) if (hm[d] < hm[d+4]) hm[d ] = 0; else if (hm[d] > hm[d+4]) hm[d+4] = 0; -@@ -4933,14 +5066,20 @@ void CLASS xtrans_interpolate (int passe +@@ -4906,14 +4983,20 @@ void CLASS xtrans_interpolate (int passe memset (avg, 0, sizeof avg); for (d=0; d < ndir; d++) if (hm[d] >= max) { @@ -280,7 +206,7 @@ Index: dcraw/dcraw_lz.c FORC3 image[(row+top)*width+col+left][c] = avg[c]/avg[3]; } } -+#if ! defined(_STATIC_BUFFER) ++#ifndef STATIC_BUFFER free(buffer); +#endif border_interpolate(8); diff --git a/lightcrafts/coprocesses/dcraw/series b/lightcrafts/coprocesses/dcraw/series index 4330013e4..9e2e99c12 100644 --- a/lightcrafts/coprocesses/dcraw/series +++ b/lightcrafts/coprocesses/dcraw/series @@ -2,5 +2,4 @@ dcraw_indi.patch xtrans_yama1968.patch lightzone.patch strnlen.patch -Sony-DSC-RX1RM2.patch MSVC.patch