diff -Nru LibRaw-0.18.2/internal/dcraw_common.cpp LibRaw-0.18.2-rawshack/internal/dcraw_common.cpp --- LibRaw-0.18.2/internal/dcraw_common.cpp 2017-03-04 21:36:00.000000000 -0800 +++ LibRaw-0.18.2-rawshack/internal/dcraw_common.cpp 2017-06-03 21:04:49.000000000 -0700 @@ -192,6 +192,16 @@ return u.f; } + +double CLASS getreal5_as_int_and_float(int *pIntHigh, int *pIntLow) +{ + *pIntHigh = get4(); + *pIntLow = get4(); + return (double)*pIntHigh / (unsigned)*pIntLow; + +} + + double CLASS getreal (int type) { union { char c[8]; double d; } u,v; @@ -1263,6 +1273,12 @@ void CLASS nikon_load_raw() { +#define NIKON_TREE_INDEX_0_12_BIT_LOSSY (0) +#define NIKON_TREE_INDEX_1_12_BIT_LOSSY_AFTER_SPLIT (1) +#define NIKON_TREE_INDEX_2_12_BIT_LOSSLESS (2) +#define NIKON_TREE_INDEX_4_14_BIT_LOSSY (3) +#define NIKON_TREE_INDEX_5_14_BIT_LOSSY_AFTER_SPLIT (4) +#define NIKON_TERE_INDEX_6_14_BIT_LOSSLESS (5) static const uchar nikon_tree[][32] = { { 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0, /* 12-bit lossy */ 5,4,3,6,2,7,1,0,8,9,11,10,12 }, @@ -1301,6 +1317,7 @@ } else if (ver0 != 0x46 && csize <= 0x4001) read_shorts (curve, max=csize); while (curve[max-2] == curve[max-1]) max--; + imgdata.idata.bitDepth = tree < NIKON_TREE_INDEX_4_14_BIT_LOSSY ? 12 : 14; huff = make_decoder (nikon_tree[tree]); fseek (ifp, data_offset, SEEK_SET); getbits(-1); @@ -3418,6 +3435,10 @@ imax = 0x0f & val >> 22; imin = 0x0f & val >> 26; for (sh=0; sh < 4 && 0x80 << sh <= max-min; sh++); + if (imgdata.idata.fileSonyCompressionOutput != NULL) + if (1 << sh & imgdata.idata.sonyCompressionShiftThresholdBits) + fprintf(imgdata.idata.fileSonyCompressionOutput, "%d,%d,%d\n", col, row, sh); + #ifdef LIBRAW_LIBRARY_BUILD /* flag checks if outside of loop */ if(! (imgdata.params.raw_processing_options & LIBRAW_PROCESSING_SONYARW2_ALLFLAGS) // no flag set @@ -9756,9 +9777,19 @@ imgdata.lens.EXIF_MaxAp = powf64(2.0f, (getreal(type) / 2.0f)); break; #endif - case 33434: tiff_ifd[tiff_nifds-1].t_shutter = - shutter = getreal(type); break; - case 33437: aperture = getreal(type); break; // 0x829d FNumber + case 33434: + if (type == 5) + shutter = getreal5_as_int_and_float(&shutterIntNumerator, &shutterIntDenominator); + else + shutter = getreal(type); + tiff_ifd[tiff_nifds - 1].t_shutter = shutter; + break; + case 33437: // 0x829d FNumber + if (type == 5) + aperture = getreal5_as_int_and_float(&apertureIntNumerator, &apertureIntDenominator); + else + aperture = getreal(type); + break; case 34855: iso_speed = get2(); break; case 34866: if (iso_speed == 0xffff && (!strncasecmp(make, "SONY",4) || !strncasecmp(make, "CANON",5))) diff -Nru LibRaw-0.18.2/internal/libraw_internal_funcs.h LibRaw-0.18.2-rawshack/internal/libraw_internal_funcs.h --- LibRaw-0.18.2/internal/libraw_internal_funcs.h 2017-03-04 21:33:42.000000000 -0800 +++ LibRaw-0.18.2-rawshack/internal/libraw_internal_funcs.h 2017-06-03 20:57:38.000000000 -0700 @@ -54,6 +54,7 @@ unsigned getint (int type); float int_to_float (int i); double getreal (int type); + double getreal5_as_int_and_float(int *pIntHigh, int *pIntLow); void read_shorts (ushort *pixel, int count); /* Canon P&S cameras */ diff -Nru LibRaw-0.18.2/internal/var_defines.h LibRaw-0.18.2-rawshack/internal/var_defines.h --- LibRaw-0.18.2/internal/var_defines.h 2017-03-04 21:33:42.000000000 -0800 +++ LibRaw-0.18.2-rawshack/internal/var_defines.h 2017-06-03 21:03:16.000000000 -0700 @@ -89,6 +89,11 @@ #define iso_speed (imgdata.other.iso_speed) #define shutter (imgdata.other.shutter) #define aperture (imgdata.other.aperture) +#define shutterIntNumerator (imgdata.other.shutterIntNumerator) +#define shutterIntDenominator (imgdata.other.shutterIntDenominator) +#define apertureIntNumerator (imgdata.other.apertureIntNumerator) +#define apertureIntDenominator (imgdata.other.apertureIntDenominator) + #define focal_len (imgdata.other.focal_len) #define timestamp (imgdata.other.timestamp) #define shot_order (imgdata.other.shot_order) diff -Nru LibRaw-0.18.2/libraw/libraw_types.h LibRaw-0.18.2-rawshack/libraw/libraw_types.h --- LibRaw-0.18.2/libraw/libraw_types.h 2017-03-04 21:33:42.000000000 -0800 +++ LibRaw-0.18.2-rawshack/libraw/libraw_types.h 2017-06-03 21:03:03.000000000 -0700 @@ -179,6 +179,9 @@ char xtrans[6][6]; char xtrans_abs[6][6]; char cdesc[5]; + int bitDepth; + FILE *fileSonyCompressionOutput; + unsigned sonyCompressionShiftThresholdBits; unsigned xmplen; char *xmpdata; @@ -451,6 +454,8 @@ float iso_speed; float shutter; float aperture; + int shutterIntNumerator, shutterIntDenominator; + int apertureIntNumerator, apertureIntDenominator; float focal_len; time_t timestamp; unsigned shot_order;