diff --git a/rtengine/camconst.json b/rtengine/camconst.json index ffd31cdf5..5e1397f27 100644 --- a/rtengine/camconst.json +++ b/rtengine/camconst.json @@ -447,23 +447,23 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "masked_areas": [ 100, 40, 5892, 158 ], // left out 40 first columns from calculations because possibly the BL is still imbalanced there "ranges": { "white": [ - { "iso": 100, "levels": 14650 }, // typical 14733 + { "iso": [ 50, 100 ], "levels": 14650 }, // typical 14733 { "iso": [ 160, 320, 640, 1250, 2500, 5000 ], "levels": 15280 }, // typical 15383 - { "iso": [ 125, 200, 250, 400, 500, 800, 1000, 1600, 2000, 3200 ], "levels": 15280 }, // typical 15383 - { "iso": [ 4000, 6400, 8000, 10000, 12800, 16000, 20000, 25600 ], "levels": 15100 } // clippings at R 15200-15280, G1,G2,B 15360-15390 + { "iso": [ 125, 200, 250, 400, 500, 800, 1000, 1600, 2000 ], "levels": 15280 }, // typical R15330-GB15383 + { "iso": [ 3200, 4000, 6400, 8000, 10000, 12800, 16000, 20000, 25600 ], "levels": 15100 } // clippings at R 15200-15300, G1,G2,B 15360-15390 ], "white_max": 16383, "aperture_scaling": [ - /* note: scale factors measured for f/2.8 only, */ - { "aperture": 1.4, "scale_factor": 1.055 }, // guessed - { "aperture": 1.6, "scale_factor": 1.034 }, // guessed - { "aperture": 1.8, "scale_factor": 1.021 }, // guessed - { "aperture": 2.0, "scale_factor": 1.013 }, // guessed - { "aperture": 2.2, "scale_factor": 1.008 }, // guessed - { "aperture": 2.5, "scale_factor": 1.005 }, // guessed - { "aperture": 2.8, "scale_factor": 1.003 }, // 14783/14733 - { "aperture": 3.2, "scale_factor": 1.000 }, // guessed - { "aperture": 3.5, "scale_factor": 1.000 } + /* note: */ + { "aperture": 1.4, "scale_factor": 1.150 }, // 37/32 6-0-6-0-7-0-6-0-7-0 + { "aperture": 1.6, "scale_factor": 1.070 }, // guessed + { "aperture": 1.8, "scale_factor": 1.040 }, // 15501/14733=1.0521, 15352/14733=1.042 16030/15390 + { "aperture": 2.0, "scale_factor": 1.025 }, // 15129/14733=1.0268 - 15800/15383=1.027 + { "aperture": 2.2, "scale_factor": 1.013 }, // 15591/15383, 14931/14733 + { "aperture": 2.5, "scale_factor": 1.008 }, // 14857/14733guessed + { "aperture": 2.8, "scale_factor": 1.003 }, // 14783/14733 15435/15383 + { "aperture": 3.2, "scale_factor": 1.001 }, // 15409/15383 + { "aperture": 3.5, "scale_factor": 1.000 } // 14733/14733 ] } }, @@ -850,7 +850,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "ranges": { "white": 16300 } }, - { // Quality B, + { // Quality B, "make_model": "Canon PowerShot G7 X", "dcraw_matrix": [ 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 ], // DNG_V8.7 D65 // "raw_crop": [ 116, 24, 5504, 3680 ], // Sensor size 5632x3710. Largest useful frame 120-5616X28-3702 = 5504x3682, 4pix RTborders, Left Border 120-4, Top border 28-4 @@ -859,7 +859,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "ranges": { "white": 4080 } }, - { // Quality B, + { // Quality B, "make_model": "Canon PowerShot G3 X", "dcraw_matrix": [ 9701,-3857,-921,-3149,11537,1817,-786,1817,5147 ], // DNG_V9.1.1 D65 "raw_crop": [ 128, 36, 5480, 3656 ], // Default official 3/2 frame 5472X3648, 4pix borders, Left Border 132-4, Top border 40-4 @@ -881,7 +881,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know // "raw_crop": [ 62, 18, 3666, 2748 ],// max usable "raw_crop": [ 68, 20, 3656, 2744 ],// equal to official Canon frame, 72,24,3719,2759 = 3648x2736 "masked_areas": [ 24, 40, 2770, 44 ],// as declared in maker data - "ranges": { "white": 4080 } // + "ranges": { "white": 4080 } // }, { // Quality B @@ -926,6 +926,20 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "dcraw_matrix": [ 9252,-2704,-1064,-5893,14265,1717,-1101,2341,4349 ], // DNG_v8.8 D65 "ranges": { "white": 4040 } }, + + { // Quality B, Matrix from Adobe's dcp D65 instead of the internal in Leica's DNG + "make_model": [ "LEICA SL (Typ 601)", "LEICA Q (Typ 116)" ], + "dcraw_matrix": [ 10068,-4043,-1068,-5319,14268,1044,-765,1701,6522 ], // DCP D65 + "raw_crop": [ 4, 4, -4, -4 ] // full raw 6016x4016, Official 6000x4000 + }, + + { // Quality B, frame corrections + "make_model": "LG mobile LG-H815", + "dcraw_matrix": [ 5859,547,-1250,-6484,15547,547,-2422,5625,3906 ], // DNG D65 + "raw_crop": [ 0, 0, -8, 0 ], // full frame 5312x2988, 8 black columns at the left + "ranges": { "white_max": 1023 } + }, + { // Quality A "make_model": [ "Nikon 1 V3", "Nikon 1 J4" ], // Same format "dcraw_matrix": [ 5958,-1559,-571,-4021,11453,2939,-634,1548,5087 ], // matrix from DNG_v8.5 d65 @@ -933,7 +947,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "ranges": { "white": 4080 } // Black is auto extracted from exif, lower WL to 4080 from 4095 due to some non linearity detected at raw highlights }, - { // Quality B, + { // Quality B, "make_model": "Nikon 1 J5", // "dcraw_matrix": [ 7520,-2518,-645,-3844,12102,1945,-913,2249,6835 ], // DNG_v9.1 D65 // "dcraw_matrix": [ 7651,-2102,-751,-3299,11101,1651,-1011,2242,5770 ], // matrix from ICC converted to Dcraw format XYZ on ImagingResource stillife sample @@ -952,6 +966,25 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "ranges": { "white": 4080 } // BL autodetected from exif }, + { // quality B, samples by Johan Thor at RT.Issues, measures at long exposures with LENR are missing + // but a safety margin is included - aperture scaling makes no significant difference + "make_model": "Nikon D3S", + "dcraw_matrix": [ 8828,-2406,-694,-4874,12603,2541,-660,1509,7587 ], // dcp d65 + "ranges": { + "white": [ + { "iso": [ 100, 125, 160, 200, 250, 320, 400, 500 ], "levels": 15520 }, // typical G1,G2 15520-15800 R,B 16383 + { "iso": [ 640, 800, 1000, 1250 ], "levels": 15400 }, // typical G1,G2 15520-15800, R,B 16383 + { "iso": [ 1600, 2000, 2500 ], "levels": 15300 }, // typical G1,G2 15520-15800, R,B 16383 + { "iso": [ 3200, 4000, 5000, 6400 ], "levels": 15300 }, // typical G1/G2 15400-15800, R,B 16383 + { "iso": [ 8000, 10000 ], "levels": 15000 }, // typical G1/G2 15400-15800, R,B 16383 + { "iso": [ 12800, 16000 ], "levels": 14500 }, // typical G1/G2 15400-15800, R,B 16383 + { "iso": [ 20000, 25600 ], "levels": 13300 }, // typical G1/G2 15400-15800, R,B 16383 + { "iso": [ 51200, 102400 ], "levels": 12000 } // typical G1,G1 16270-16350, R,B 16383 + ], + "white_max": 16383 + } + }, + { // quality B, lacks aperture and ISO scaling, known to exist, but little to gain as the levels are so close to white_max "make_model": "Nikon D7000", "dcraw_matrix": [ 7530,-1942,-255,-4318,11390,3362,-926,1694,7649 ], // matrix provided by Tanveer(tsk1979) @@ -1104,7 +1137,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know "ranges": { "black": 15, "white": 4050 } // 15 is BL offstet. Dcraw/RT read the base offset from exif and calculates total BL = BLbase+BLoffset }, - { // Quality Β, + { // Quality Β, "make_model": [ "Panasonic DMC-FZ300", "Panasonic DMC-FZ330" ], "dcraw_matrix": [ 8378,-2798,-769,-3068,11410,1877,-538,1792,4623 ], // DNG-V9.1.1 "ranges": { "black": 15, "white": 4050 } // 15 is BL offstet. Dcraw/RT read the base offset from exif and calculates total BL = BLbase+BLoffset @@ -1291,7 +1324,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know } }, - { // Quality A, + { // Quality A, "make_model": [ "Panasonic DMC-G7", "Panasonic DMC-G70" ], "dcraw_matrix": [ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 ],// DNG_v9.1 D65 // "dcraw_matrix": [ 8844,-3538,-768,-3709,11762,2200,-698,1792,5220 ], // LX100, DNG_V8.7 d65 @@ -1304,7 +1337,7 @@ Quality X: unknown, ie we knowing to little about the camera properties to know ] } }, - { // Quality B, + { // Quality B, "make_model": "Panasonic DMC-GX8", "dcraw_matrix": [ 7564,-2263,-606,-3148,11239,2177,-540,1435,4853 ], // DNG_v9.1.1 D65 "ranges": { @@ -1486,13 +1519,13 @@ Quality X: unknown, ie we knowing to little about the camera properties to know { // Quality B, correction for frame width, crop modes not covered "make_model": "Sony ILCE-7RM2", "dcraw_matrix": [ 6629,-1900,-483,-4618,12349,2550,-622,1381,6514 ], // DNG_v9.1.1 D65 - "raw_crop": [ 0, 0, 7964, 5320 ], // full raw frame 8000x5320 - 36 rightmost columns are garbage + "raw_crop": [ 0, 0, 7964, 5320 ], // full raw frame 8000x5320 - 36 rightmost columns are garbage "ranges": { "black": 512, "white": 16300 } }, { // Quality B, correction for frame width - "make_model": "Sony ILCE-7S", - "dcraw_matrix": [ 5838,-1430,-246,-3497,11477,2297,-748,1885,5778 ], // DNG D65 + "make_model": [ "Sony ILCE-7S", "Sony ILCE-7SM2" ], + "dcraw_matrix": [ 5838,-1430,-246,-3497,11477,2297,-748,1885,5778 ], // DNG_v9.2 D65 "raw_crop": [ 0, 0, 4254, 2848 ], "ranges": { "black": 512, "white": 16300 } }, diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc index 8e0a36df2..321cc919f 100644 --- a/rtengine/dcraw.cc +++ b/rtengine/dcraw.cc @@ -1937,9 +1937,11 @@ void CLASS hasselblad_correct() const ushort corners_shift[9] = { 2, 1, 2, 1, 0, 1, 2, 1, 2 }; for (row = 0; row < bh; row++) { const ushort maxdist = bw < bh ? bw/2-1 : bh/2-1; - const unsigned corners[9][2] = {{0,0}, {0,bw/2}, {0,bw-1}, - {bh/2,0},{bh/2,bw/2},{bh/2,bw-1}, - {bh-1,0},{bh-1,bw/2},{bh-1,bw-1}}; + const unsigned bwu = (unsigned)bw; + const unsigned bhu = (unsigned)bh; + const unsigned corners[9][2] = {{0,0}, {0,bwu/2}, {0,bwu-1}, + {bhu/2,0},{bhu/2,bwu/2},{bhu/2,bwu-1}, + {bhu-1,0},{bhu-1,bwu/2},{bhu-1,bwu-1}}; for (col = 0; col < bw; col++) { for (i = 0; i < 9; i++) { ushort dist = (ushort)sqrt(abs(corners[i][0] - row) * abs(corners[i][0] - row) + abs(corners[i][1] - col) * abs(corners[i][1] - col)); @@ -2434,7 +2436,7 @@ void CLASS quicktake_100_load_raw() void CLASS kodak_radc_load_raw() { - static const char src[] = { + static const signed char src[] = { 1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8, 1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8, 2,1, 2,3, 3,0, 3,2, 3,4, 4,6, 5,5, 6,7, 6,8, @@ -5158,6 +5160,11 @@ nf: order = 0x4949; tag |= uptag << 16; if (tag == 2 && strstr(make,"NIKON") && !iso_speed) iso_speed = (get2(),get2()); + if ((tag == 0x25 || tag == 0x28) && strstr(make,"NIKON") && !iso_speed) { // Nikon ISOInfo Tags/ISO & ISO2 + uchar iso[1]; + fread (iso, 1, 1, ifp); + iso_speed = 100 * pow(2,(float)iso[0]/12.0-5); + } if (tag == 4 && len > 26 && len < 35) { if ((i=(get4(),get2())) != 0x7fff && !iso_speed) iso_speed = 50 * pow (2, i/32.0 - 4); @@ -5410,6 +5417,7 @@ void CLASS parse_exif (int base) case 33434: shutter = getreal(type); break; case 33437: aperture = getreal(type); break; case 34855: iso_speed = get2(); break; + case 34866: if((!iso_speed) || iso_speed == 65535) iso_speed = get4();break; case 36867: case 36868: get_timestamp(0); break; case 37377: if ((expo = -getreal(type)) < 128) @@ -9248,6 +9256,10 @@ dng_skip: adobe_coeff (make, model); if(!strncmp(make, "Pentax", 6) && !strncmp(model, "K10D",4)) adobe_coeff (make, model); + if(!strncmp(make, "Leica", 5) && !strncmp(model, "Q",1)) + adobe_coeff (make, model); + if(!strncmp(make, "Leica", 5) && !strncmp(model, "SL",2)) + adobe_coeff (make, model); if (raw_color) adobe_coeff (make, model); if (load_raw == &CLASS kodak_radc_load_raw) if (raw_color) adobe_coeff ("Apple","Quicktake"); diff --git a/rtengine/dcraw.patch b/rtengine/dcraw.patch index db24e7fe8..0b4cd87b4 100644 --- a/rtengine/dcraw.patch +++ b/rtengine/dcraw.patch @@ -1,5 +1,5 @@ ---- dcraw.c 2015-09-21 10:08:04 +0000 -+++ dcraw.cc 2015-10-14 14:29:55 +0000 +--- dcraw.c 2015-11-12 00:28:59 +0000 ++++ dcraw.cc 2015-11-12 00:28:59 +0000 @@ -1,3 +1,15 @@ +/*RT*/#include +/*RT*/#include @@ -236,7 +236,7 @@ unsigned c; if (nbits == -1) -@@ -1731,6 +1695,336 @@ +@@ -1731,6 +1695,338 @@ maximum = 0xfffc - ph1.black; } @@ -482,9 +482,11 @@ + const ushort corners_shift[9] = { 2, 1, 2, 1, 0, 1, 2, 1, 2 }; + for (row = 0; row < bh; row++) { + const ushort maxdist = bw < bh ? bw/2-1 : bh/2-1; -+ const unsigned corners[9][2] = {{0,0}, {0,bw/2}, {0,bw-1}, -+ {bh/2,0},{bh/2,bw/2},{bh/2,bw-1}, -+ {bh-1,0},{bh-1,bw/2},{bh-1,bw-1}}; ++ const unsigned bwu = (unsigned)bw; ++ const unsigned bhu = (unsigned)bh; ++ const unsigned corners[9][2] = {{0,0}, {0,bwu/2}, {0,bwu-1}, ++ {bhu/2,0},{bhu/2,bwu/2},{bhu/2,bwu-1}, ++ {bhu-1,0},{bhu-1,bwu/2},{bhu-1,bwu-1}}; + for (col = 0; col < bw; col++) { + for (i = 0; i < 9; i++) { + ushort dist = (ushort)sqrt(abs(corners[i][0] - row) * abs(corners[i][0] - row) + abs(corners[i][1] - col) * abs(corners[i][1] - col)); @@ -573,7 +575,7 @@ void CLASS hasselblad_load_raw() { struct jhead jh; -@@ -1954,10 +2248,10 @@ +@@ -1954,10 +2250,10 @@ maximum = curve[0x3ff]; } @@ -587,7 +589,16 @@ int byte; if (!nbits) return vbits=0; -@@ -2246,11 +2540,11 @@ +@@ -2140,7 +2436,7 @@ + + void CLASS kodak_radc_load_raw() + { +- static const char src[] = { ++ static const signed char src[] = { + 1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8, + 1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8, + 2,1, 2,3, 3,0, 3,2, 3,4, 4,6, 5,5, 6,7, 6,8, +@@ -2246,11 +2542,11 @@ METHODDEF(boolean) fill_input_buffer (j_decompress_ptr cinfo) { @@ -601,7 +612,7 @@ cinfo->src->next_input_byte = jpeg_buffer; cinfo->src->bytes_in_buffer = nbytes; return TRUE; -@@ -2600,10 +2894,9 @@ +@@ -2600,10 +2896,9 @@ maximum = (1 << (thumb_misc & 31)) - 1; } @@ -614,7 +625,7 @@ if (start) { for (p=0; p < 4; p++) pad[p] = key = key * 48828125 + 1; -@@ -2688,11 +2981,13 @@ +@@ -2688,11 +2983,13 @@ bit += 7; } for (i=0; i < 16; i++, col+=2) @@ -629,7 +640,7 @@ } void CLASS samsung_load_raw() -@@ -2988,7 +3283,7 @@ +@@ -2988,7 +3285,7 @@ void CLASS foveon_decoder (unsigned size, unsigned code) { @@ -638,7 +649,7 @@ struct decode *cur; int i, len; -@@ -3085,7 +3380,7 @@ +@@ -3085,7 +3382,7 @@ pred[c] += diff[dindex->leaf]; if (pred[c] >> 16 && ~pred[c] >> 16) derror(); } @@ -647,7 +658,7 @@ } } } -@@ -3696,6 +3991,8 @@ +@@ -3696,6 +3993,8 @@ if (load_raw == &CLASS phase_one_load_raw || load_raw == &CLASS phase_one_load_raw_c) phase_one_correct(); @@ -656,7 +667,7 @@ if (fuji_width) { for (row=0; row < raw_height-top_margin*2; row++) { for (col=0; col < fuji_width << !fuji_layout; col++) { -@@ -3711,10 +4008,13 @@ +@@ -3711,10 +4010,13 @@ } } } else { @@ -672,7 +683,7 @@ if (mask[0][3] > 0) goto mask_set; if (load_raw == &CLASS canon_load_raw || load_raw == &CLASS lossless_jpeg_load_raw) { -@@ -4316,239 +4616,8 @@ +@@ -4316,239 +4618,8 @@ } } @@ -913,7 +924,7 @@ void CLASS cielab (ushort rgb[3], short lab[3]) { -@@ -4814,112 +4883,7 @@ +@@ -4814,112 +4885,7 @@ } #undef fcol @@ -1026,7 +1037,7 @@ #undef TS void CLASS median_filter() -@@ -5089,7 +5053,7 @@ +@@ -5089,7 +5055,7 @@ } } @@ -1035,7 +1046,19 @@ void CLASS parse_makernote (int base, int uptag) { -@@ -5246,12 +5210,16 @@ +@@ -5194,6 +5160,11 @@ + tag |= uptag << 16; + if (tag == 2 && strstr(make,"NIKON") && !iso_speed) + iso_speed = (get2(),get2()); ++ if ((tag == 0x25 || tag == 0x28) && strstr(make,"NIKON") && !iso_speed) { // Nikon ISOInfo Tags/ISO & ISO2 ++ uchar iso[1]; ++ fread (iso, 1, 1, ifp); ++ iso_speed = 100 * pow(2,(float)iso[0]/12.0-5); ++ } + if (tag == 4 && len > 26 && len < 35) { + if ((i=(get4(),get2())) != 0x7fff && !iso_speed) + iso_speed = 50 * pow (2, i/32.0 - 4); +@@ -5246,12 +5217,16 @@ cam_mul[2] = get4() << 2; } } @@ -1053,7 +1076,15 @@ if (tag == 0x1d) while ((c = fgetc(ifp)) && c != EOF) serial = serial*10 + (isdigit(c) ? c - '0' : c % 10); -@@ -5613,28 +5581,33 @@ +@@ -5442,6 +5417,7 @@ + case 33434: shutter = getreal(type); break; + case 33437: aperture = getreal(type); break; + case 34855: iso_speed = get2(); break; ++ case 34866: if((!iso_speed) || iso_speed == 65535) iso_speed = get4();break; + case 36867: + case 36868: get_timestamp(0); break; + case 37377: if ((expo = -getreal(type)) < 128) +@@ -5613,28 +5589,33 @@ } } @@ -1093,7 +1124,7 @@ entries = get2(); if (entries > 512) return 1; while (entries--) { -@@ -5702,7 +5675,8 @@ +@@ -5702,7 +5683,8 @@ fgets (make, 64, ifp); break; case 272: /* Model */ @@ -1103,7 +1134,7 @@ break; case 280: /* Panasonic RW2 offset */ if (type != 4) break; -@@ -5762,6 +5736,9 @@ +@@ -5762,6 +5744,9 @@ case 315: /* Artist */ fread (artist, 64, 1, ifp); break; @@ -1113,7 +1144,7 @@ case 322: /* TileWidth */ tiff_ifd[ifd].tile_width = getint(type); break; -@@ -5777,6 +5754,9 @@ +@@ -5777,6 +5762,9 @@ is_raw = 5; } break; @@ -1123,7 +1154,7 @@ case 330: /* SubIFDs */ if (!strcmp(model,"DSLR-A100") && tiff_ifd[ifd].width == 3872) { load_raw = &CLASS sony_arw_load_raw; -@@ -5790,6 +5770,9 @@ +@@ -5790,6 +5778,9 @@ fseek (ifp, i+4, SEEK_SET); } break; @@ -1133,7 +1164,7 @@ case 400: strcpy (make, "Sarnoff"); maximum = 0xfff; -@@ -5971,6 +5954,9 @@ +@@ -5971,6 +5962,9 @@ if (!make[0]) strcpy (make, "DNG"); is_raw = 1; break; @@ -1143,7 +1174,7 @@ case 50710: /* CFAPlaneColor */ if (filters == 9) break; if (len > 4) len = 4; -@@ -6002,12 +5988,21 @@ +@@ -6002,12 +5996,21 @@ case 61450: cblack[4] = cblack[5] = MIN(sqrt(len),64); case 50714: /* BlackLevel */ @@ -1171,7 +1202,7 @@ case 50715: /* BlackLevelDeltaH */ case 50716: /* BlackLevelDeltaV */ for (num=i=0; i < len; i++) -@@ -6024,13 +6019,13 @@ +@@ -6024,13 +6027,13 @@ case 50721: /* ColorMatrix1 */ case 50722: /* ColorMatrix2 */ FORCC for (j=0; j < 3; j++) @@ -1187,7 +1218,7 @@ break; case 50727: /* AnalogBalance */ FORCC ab[c] = getreal(type); -@@ -6053,6 +6048,11 @@ +@@ -6053,6 +6056,11 @@ case 50752: read_shorts (cr2_slice, 3); break; @@ -1199,7 +1230,7 @@ case 50829: /* ActiveArea */ top_margin = getint(type); left_margin = getint(type); -@@ -6085,21 +6085,27 @@ +@@ -6085,21 +6093,27 @@ fread (buf, sony_length, 1, ifp); sony_decrypt (buf, sony_length/4, 1, sony_key); sfp = ifp; @@ -1235,7 +1266,7 @@ cam_xyz_coeff (cmatrix, cam_xyz); } if (asn[0]) { -@@ -6107,13 +6113,14 @@ +@@ -6107,13 +6121,14 @@ FORCC cam_mul[c] = 1 / asn[c]; } if (!use_cm) @@ -1251,7 +1282,7 @@ fseek (ifp, base, SEEK_SET); order = get2(); -@@ -6191,7 +6198,7 @@ +@@ -6191,7 +6206,7 @@ case 8: load_raw = &CLASS eight_bit_load_raw; break; case 12: if (tiff_ifd[raw].phint == 2) load_flags = 6; @@ -1260,7 +1291,7 @@ case 14: load_flags = 0; case 16: load_raw = &CLASS unpacked_load_raw; if (!strncmp(make,"OLYMPUS",7) && -@@ -6230,6 +6237,7 @@ +@@ -6230,6 +6245,7 @@ case 32803: load_raw = &CLASS kodak_65000_load_raw; } case 32867: case 34892: break; @@ -1268,7 +1299,7 @@ default: is_raw = 0; } if (!dng_version) -@@ -6315,7 +6323,7 @@ +@@ -6315,7 +6331,7 @@ { const char *file, *ext; char *jname, *jfile, *jext; @@ -1277,7 +1308,7 @@ ext = strrchr (ifname, '.'); file = strrchr (ifname, '/'); -@@ -6337,13 +6345,14 @@ +@@ -6337,13 +6353,14 @@ } else while (isdigit(*--jext)) { if (*jext != '9') { @@ -1294,7 +1325,7 @@ if (verbose) fprintf (stderr,_("Reading metadata from %s ...\n"), jname); parse_tiff (12); -@@ -6620,6 +6629,7 @@ +@@ -6620,6 +6637,7 @@ load_raw = ph1.format < 3 ? &CLASS phase_one_load_raw : &CLASS phase_one_load_raw_c; maximum = 0xffff; @@ -1302,7 +1333,7 @@ strcpy (make, "Phase One"); if (model[0]) return; switch (raw_height) { -@@ -6688,7 +6698,11 @@ +@@ -6688,7 +6706,11 @@ order = get2(); hlen = get4(); if (get4() == 0x48454150) /* "HEAP" */ @@ -1314,7 +1345,7 @@ if (parse_tiff (save+6)) apply_tiff(); fseek (ifp, save+len, SEEK_SET); } -@@ -6960,7 +6974,8 @@ +@@ -6960,7 +6982,8 @@ { static const struct { const char *prefix; @@ -1324,7 +1355,7 @@ } table[] = { { "AgfaPhoto DC-833m", 0, 0, /* DJC */ { 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } }, -@@ -7919,6 +7934,33 @@ +@@ -7919,6 +7942,33 @@ } break; } @@ -1358,7 +1389,7 @@ } void CLASS simple_coeff (int index) -@@ -8229,7 +8271,7 @@ +@@ -8229,7 +8279,7 @@ tiff_flip = flip = filters = UINT_MAX; /* unknown */ raw_height = raw_width = fuji_width = fuji_layout = cr2_slice[0] = 0; maximum = height = width = top_margin = left_margin = 0; @@ -1367,7 +1398,7 @@ iso_speed = shutter = aperture = focal_len = unique_id = 0; tiff_nifds = 0; memset (tiff_ifd, 0, sizeof tiff_ifd); -@@ -8261,13 +8303,20 @@ +@@ -8261,13 +8311,20 @@ fread (head, 1, 32, ifp); fseek (ifp, 0, SEEK_END); flen = fsize = ftell(ifp); @@ -1390,7 +1421,7 @@ parse_ciff (hlen, flen-hlen, 0); load_raw = &CLASS canon_load_raw; } else if (parse_tiff(0)) apply_tiff(); -@@ -8313,6 +8362,7 @@ +@@ -8313,6 +8370,7 @@ fseek (ifp, 100+28*(shot_select > 0), SEEK_SET); parse_tiff (data_offset = get4()); parse_tiff (thumb_offset+12); @@ -1398,7 +1429,7 @@ apply_tiff(); } else if (!memcmp (head,"RIFF",4)) { fseek (ifp, 0, SEEK_SET); -@@ -8426,9 +8476,10 @@ +@@ -8426,9 +8484,10 @@ if (make[0] == 0) parse_smal (0, flen); if (make[0] == 0) { parse_jpeg(0); @@ -1412,7 +1443,7 @@ strcpy (make, "OmniVision"); data_offset = ftell(ifp) + 0x8000-32; width = raw_width; -@@ -8437,6 +8488,7 @@ +@@ -8437,6 +8496,7 @@ filters = 0x16161616; } else is_raw = 0; } @@ -1420,7 +1451,7 @@ for (i=0; i < sizeof corp / sizeof *corp; i++) if (strcasestr (make, corp[i])) /* Simplify company names */ -@@ -8468,7 +8520,7 @@ +@@ -8468,7 +8528,7 @@ if (height == 3136 && width == 4864) /* Pentax K20D and Samsung GX20 */ { height = 3124; width = 4688; filters = 0x16161616; } if (width == 4352 && (!strcmp(model,"K-r") || !strcmp(model,"K-x"))) @@ -1429,7 +1460,7 @@ if (width >= 4960 && !strncmp(model,"K-5",3)) { left_margin = 10; width = 4950; filters = 0x16161616; } if (width == 4736 && !strcmp(model,"K-7")) -@@ -8487,6 +8539,7 @@ +@@ -8487,6 +8547,7 @@ switch (tiff_compress) { case 1: load_raw = &CLASS packed_dng_load_raw; break; case 7: load_raw = &CLASS lossless_dng_load_raw; break; @@ -1437,7 +1468,7 @@ case 34892: load_raw = &CLASS lossy_dng_load_raw; break; default: load_raw = 0; } -@@ -8541,6 +8594,7 @@ +@@ -8541,6 +8602,7 @@ if (height > width) pixel_aspect = 2; filters = 0; simple_coeff(0); @@ -1445,7 +1476,7 @@ } else if (!strcmp(make,"Canon") && tiff_bps == 15) { switch (width) { case 3344: width -= 66; -@@ -8846,24 +8900,53 @@ +@@ -8846,24 +8908,53 @@ if (load_raw == &CLASS lossless_jpeg_load_raw) load_raw = &CLASS hasselblad_load_raw; if (raw_width == 7262) { @@ -1504,7 +1535,7 @@ } else if (raw_width == 4090) { strcpy (model, "V96C"); height -= (top_margin = 6); -@@ -8921,6 +9004,7 @@ +@@ -8921,6 +9012,7 @@ filters = 0x16161616; } } else if (!strcmp(make,"Leica") || !strcmp(make,"Panasonic")) { @@ -1512,7 +1543,7 @@ if ((flen - data_offset) / (raw_width*8/7) == raw_height) load_raw = &CLASS panasonic_load_raw; if (!load_raw) { -@@ -8938,6 +9022,7 @@ +@@ -8938,6 +9030,7 @@ } filters = 0x01010101 * (uchar) "\x94\x61\x49\x16" [((filters-1) ^ (left_margin & 1) ^ (top_margin << 1)) & 3]; @@ -1520,7 +1551,7 @@ } else if (!strcmp(model,"C770UZ")) { height = 1718; width = 2304; -@@ -9155,6 +9240,14 @@ +@@ -9155,6 +9248,18 @@ memcpy (rgb_cam, cmatrix, sizeof cmatrix); raw_color = 0; } @@ -1532,10 +1563,14 @@ + adobe_coeff (make, model); + if(!strncmp(make, "Pentax", 6) && !strncmp(model, "K10D",4)) + adobe_coeff (make, model); ++ if(!strncmp(make, "Leica", 5) && !strncmp(model, "Q",1)) ++ adobe_coeff (make, model); ++ if(!strncmp(make, "Leica", 5) && !strncmp(model, "SL",2)) ++ adobe_coeff (make, model); if (raw_color) adobe_coeff (make, model); if (load_raw == &CLASS kodak_radc_load_raw) if (raw_color) adobe_coeff ("Apple","Quicktake"); -@@ -9169,9 +9262,9 @@ +@@ -9169,9 +9274,9 @@ if (raw_width < width ) raw_width = width; } if (!tiff_bps) tiff_bps = 12; @@ -1547,7 +1582,7 @@ is_raw = 0; #ifdef NO_JASPER if (load_raw == &CLASS redcine_load_raw) { -@@ -9250,194 +9343,249 @@ +@@ -9250,194 +9355,249 @@ } #endif @@ -1976,7 +2011,7 @@ struct tiff_tag { ushort tag, type; -@@ -9461,590 +9609,11 @@ +@@ -9461,590 +9621,11 @@ char desc[512], make[64], model[64], soft[32], date[20], artist[64]; }; diff --git a/rtengine/imagedata.cc b/rtengine/imagedata.cc index 6d4df4890..11ca6f2ea 100644 --- a/rtengine/imagedata.cc +++ b/rtengine/imagedata.cc @@ -272,7 +272,15 @@ void ImageData::extractInfo () if(exif->getTag ("LensModel")) { lens = exif->getTag ("LensModel")->valueToString (); } - } else if (root->findTag("MakerNote")) { + } else if(!make.compare (0, 4, "SONY")) { + if (iso_speed == 65535 || iso_speed == 0) { + rtexif::Tag* isoTag = exif->getTag ("RecommendedExposureIndex"); + if(isoTag) + iso_speed = isoTag->toDouble(); + } + + } + else if (root->findTag("MakerNote")) { rtexif::TagDirectory* mnote = root->findTag("MakerNote")->getDirectory(); if (mnote && !make.compare (0, 5, "NIKON")) { diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 88ed3f777..8180c353f 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -2004,9 +2004,9 @@ void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int //matrix for current working space TMatrix wiprof = iccStore->workingSpaceInverseMatrix (params->icm.working); const float wip[3][3] = { - {wiprof[0][0], wiprof[0][1], wiprof[0][2]}, - {wiprof[1][0], wiprof[1][1], wiprof[1][2]}, - {wiprof[2][0], wiprof[2][1], wiprof[2][2]} + {(float)wiprof[0][0], (float)wiprof[0][1], (float)wiprof[0][2]}, + {(float)wiprof[1][0], (float)wiprof[1][1], (float)wiprof[1][2]}, + {(float)wiprof[2][0], (float)wiprof[2][1], (float)wiprof[2][2]} }; #ifdef __SSE2__ diff --git a/rtengine/ipwavelet.cc b/rtengine/ipwavelet.cc index 6bc7507d4..8680a17dc 100644 --- a/rtengine/ipwavelet.cc +++ b/rtengine/ipwavelet.cc @@ -1377,8 +1377,17 @@ void ImProcFunctions::Aver( float * RESTRICT DataList, int datalen, float &aver } } - averagePlus = averaP / countP; - averageNeg = averaN / countN; + if(countP > 0) { + averagePlus = averaP / countP; + } else { + averagePlus = 0; + } + + if(countN > 0) { + averageNeg = averaN / countN; + } else { + averageNeg = 0; + } } @@ -1403,8 +1412,17 @@ void ImProcFunctions::Sigma( float * RESTRICT DataList, int datalen, float aver } } - sigmaPlus = sqrt(variP / countP); - sigmaNeg = sqrt(variN / countN); + if(countP > 0) { + sigmaPlus = sqrt(variP / countP); + } else { + sigmaPlus = 0; + } + + if(countN > 0) { + sigmaNeg = sqrt(variN / countN); + } else { + sigmaNeg = 0; + } } @@ -1744,7 +1762,7 @@ void ImProcFunctions::EPDToneMapResid(float * WavCoeffs_L0, unsigned int Iterat } } -void ImProcFunctions::WaveletcontAllLfinal(wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean,float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL) +void ImProcFunctions::WaveletcontAllLfinal(wavelet_decomposition &WaveletCoeffs_L, struct cont_params &cp, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL) { int maxlvl = WaveletCoeffs_L.maxlevel(); float * WavCoeffs_L0 = WaveletCoeffs_L.coeff0; @@ -2516,7 +2534,7 @@ void ImProcFunctions::calckoe(float ** WavCoeffs_LL, struct cont_params cp, floa void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, int level, int dir, struct cont_params &cp, int W_L, int H_L, float *mean, float *sigma, float *MaxP, const WavOpacityCurveWL & waOpacityCurveWL) { - if(cp.diagcurv && cp.finena) {//curve + if(cp.diagcurv && cp.finena && MaxP[level] > 0.f && mean[level] != 0.f && sigma[level] != 0.f ) { //curve float insigma = 0.666f; //SD float logmax = log(MaxP[level]); //log Max float rapX = (mean[level] + sigma[level]) / MaxP[level]; //rapport between sD / max @@ -2530,6 +2548,7 @@ void ImProcFunctions::finalContAllL (float ** WavCoeffs_L, float * WavCoeffs_L0, #ifdef _RT_NESTED_OPENMP #pragma omp parallel for schedule(dynamic, W_L * 16) num_threads(wavNestedLevels) if(wavNestedLevels>1) #endif + for (int i = 0; i < W_L * H_L; i++) { float absciss; diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index 32d91be64..02e851414 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2745,7 +2745,10 @@ void RawImageSource::processFlatField(const RAWParams &raw, RawImage *riFlatFile */ void RawImageSource::copyOriginalPixels(const RAWParams &raw, RawImage *src, RawImage *riDark, RawImage *riFlatFile ) { - unsigned short black[4] = {ri->get_cblack(0), ri->get_cblack(1), ri->get_cblack(2), ri->get_cblack(3)}; + // TODO: Change type of black[] to float to avoid conversions + unsigned short black[4] = { + (unsigned short)ri->get_cblack(0), (unsigned short)ri->get_cblack(1), + (unsigned short)ri->get_cblack(2), (unsigned short)ri->get_cblack(3)}; if (ri->getSensorType() == ST_BAYER || ri->getSensorType() == ST_FUJI_XTRANS) { if (!rawData) { @@ -4218,7 +4221,10 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU histRedRaw.clear(); histGreenRaw.clear(); histBlueRaw.clear(); - const float mult[4] = { 65535.0 / ri->get_white(0), 65535.0 / ri->get_white(1), 65535.0 / ri->get_white(2), 65535.0 / ri->get_white(3) }; + const float mult[4] = { 65535.0f / ri->get_white(0), + 65535.0f / ri->get_white(1), + 65535.0f / ri->get_white(2), + 65535.0f / ri->get_white(3) }; #ifdef _OPENMP int numThreads; diff --git a/rtexif/stdattribs.cc b/rtexif/stdattribs.cc index e50299c3e..0d7c38ff9 100644 --- a/rtexif/stdattribs.cc +++ b/rtexif/stdattribs.cc @@ -540,6 +540,7 @@ const TagAttrib exifAttribs[] = { {0, AC_WRITE, 0, 0, 0x8824, AUTO, "SpectralSensitivity", &stdInterpreter}, {0, AC_WRITE, 0, 0, 0x8827, AUTO, "ISOSpeedRatings", &stdInterpreter}, {0, AC_WRITE, 0, 0, 0x8828, AUTO, "OECF", &stdInterpreter}, + {0, AC_WRITE, 0, 0, 0x8832, AUTO, "RecommendedExposureIndex", &stdInterpreter}, {0, AC_WRITE, 0, 0, 0x9000, AUTO, "ExifVersion", &stdInterpreter}, {0, AC_WRITE, 0, 0, 0x9003, AUTO, "DateTimeOriginal", &stdInterpreter}, {0, AC_WRITE, 0, 0, 0x9004, AUTO, "DateTimeDigitized", &stdInterpreter},