From 225c0ed64191dbc8ed8a236dbc008ef3724630c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 30 Oct 2008 09:29:14 +0000 Subject: [PATCH] * Reverted parts of r28370: - the check for compression when counting valid images was wrong, and broke all RAW formats that weren't using this compression. - COMPRESSION_PACKBITS was defined twice. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28374 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/translators/raw/RAW.cpp | 604 +++++++++++++++------------- src/add-ons/translators/raw/RAW.h | 7 +- 2 files changed, 325 insertions(+), 286 deletions(-) diff --git a/src/add-ons/translators/raw/RAW.cpp b/src/add-ons/translators/raw/RAW.cpp index 6d75e7cb44..9cfb30ddfa 100644 --- a/src/add-ons/translators/raw/RAW.cpp +++ b/src/add-ons/translators/raw/RAW.cpp @@ -36,9 +36,6 @@ (fFilters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3) -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ - - static const uint32 kImageBufferCount = 10; static const uint32 kDecodeBufferCount = 2048; @@ -46,7 +43,7 @@ const double xyz_rgb[3][3] = { /* XYZ from RGB */ { 0.412453, 0.357580, 0.180423 }, { 0.212671, 0.715160, 0.072169 }, { 0.019334, 0.119193, 0.950227 } }; -const float d65_white[3] = { 0.950456, 1, 1.088754 }; +const float kD65White[3] = { 0.950456, 1, 1.088754 }; struct decode { struct decode *branch[2]; @@ -402,7 +399,8 @@ DCRaw::_ParseManufacturerTag(off_t baseOffset) uint32 whiteBalance[4] = {0, 0, 0, 0}; off_t offset; - while ((offset = fRead.Position()) < image.data_offset && offset < 16384) { + while ((offset = fRead.Position()) < image.data_offset + && offset < 16384) { whiteBalance[0] = whiteBalance[2]; whiteBalance[2] = whiteBalance[1]; whiteBalance[1] = whiteBalance[3]; @@ -460,7 +458,8 @@ DCRaw::_ParseManufacturerTag(off_t baseOffset) off_t nextOffset; tiff_tag tag; _ParseTIFFTag(baseOffset, tag, nextOffset); - TAG(("Manufacturer tag %u (type %u, length %lu)\n", tag.tag, tag.type, tag.length)); + TAG(("Manufacturer tag %u (type %u, length %lu)\n", tag.tag, tag.type, + tag.length)); if (strstr(fMeta.manufacturer, "PENTAX")) { if (tag.tag == 0x1b) @@ -491,7 +490,8 @@ DCRaw::_ParseManufacturerTag(off_t baseOffset) if (tag.tag == 0x10 && tag.type == 4) fUniqueID = fRead.Next(); if (tag.tag == 0x11) { - if (_ParseTIFFImageFileDirectory(baseOffset, fRead.Next()) == B_OK) + if (_ParseTIFFImageFileDirectory(baseOffset, fRead.Next()) + == B_OK) fNumImages++; } if (tag.tag == 0x14 && tag.length == 2560 && tag.type == 7) { @@ -517,7 +517,8 @@ DCRaw::_ParseManufacturerTag(off_t baseOffset) _Thumb().data_offset = fRead.Position(); _Thumb().bytes = tag.length; } - if (tag.tag == 0x88 && tag.type == 4 && (_Thumb().data_offset = fRead.Next())) { + if (tag.tag == 0x88 && tag.type == 4 + && (_Thumb().data_offset = fRead.Next())) { _Thumb().data_offset += baseOffset; } if (tag.tag == 0x89 && tag.type == 4) @@ -563,10 +564,12 @@ DCRaw::_ParseManufacturerTag(off_t baseOffset) buf97[i] ^= (cj += ci * ck++); } for (uint32 i = 0; i < 4; i++) { - uint16* data = (uint16*)(buf97 + (ver97 == 0x205 ? 14 : 6) + i*2); + uint16* data = (uint16*)(buf97 + + (ver97 == 0x205 ? 14 : 6) + i * 2); if (fRead.IsSwapping()) { - fMeta.camera_multipliers[i ^ (i >> 1)] = __swap_int16(*data); + fMeta.camera_multipliers[i ^ (i >> 1)] + = __swap_int16(*data); } else { fMeta.camera_multipliers[i ^ (i >> 1)] = *data; } @@ -607,8 +610,10 @@ DCRaw::_ParseManufacturerTag(off_t baseOffset) } if (tag.tag == 0xe80 && tag.length == 256 && tag.type == 7) { fRead.Seek(48, SEEK_CUR); - fMeta.camera_multipliers[0] = fRead.Next() * 508 * 1.078 / 0x10000; - fMeta.camera_multipliers[2] = fRead.Next() * 382 * 1.173 / 0x10000; + fMeta.camera_multipliers[0] + = fRead.Next() * 508 * 1.078 / 0x10000; + fMeta.camera_multipliers[2] + = fRead.Next() * 382 * 1.173 / 0x10000; } if (tag.tag == 0xf00 && tag.type == 7) { if (tag.length == 614) @@ -659,7 +664,8 @@ get2_256: if (tag.tag == 0x4001) { { - off_t offset = tag.length == 582 ? 50 : tag.length == 653 ? 68 : 126; + off_t offset = tag.length == 582 ? 50 : tag.length == 653 + ? 68 : 126; fRead.Seek(offset, SEEK_CUR); } get2_rggb: @@ -689,7 +695,8 @@ DCRaw::_ParseEXIF(off_t baseOffset) off_t nextOffset; tiff_tag tag; _ParseTIFFTag(baseOffset, tag, nextOffset); - TAG(("EXIF tag %u (type %u, length %lu)\n", tag.tag, tag.type, tag.length)); + TAG(("EXIF tag %u (type %u, length %lu)\n", tag.tag, tag.type, + tag.length)); switch (tag.tag) { #if 0 @@ -718,7 +725,8 @@ DCRaw::_ParseEXIF(off_t baseOffset) break; } case 37378: - fMeta.aperture = pow(2, fRead.NextDouble(TIFF_FRACTION_TYPE) / 2); + fMeta.aperture + = pow(2, fRead.NextDouble(TIFF_FRACTION_TYPE) / 2); break; case 37386: fMeta.focal_length = fRead.NextDouble(TIFF_FRACTION_TYPE); @@ -765,8 +773,7 @@ DCRaw::_ParseLinearTable(uint32 length) } -/*! - This (lengthy) method contains fixes for the values in the image data to +/*! This (lengthy) method contains fixes for the values in the image data to be able to actually read the image data correctly. */ void @@ -974,8 +981,10 @@ DCRaw::_ScaleColors() } - if (fUserMultipliers[0]) - memcpy(fMeta.pre_multipliers, fUserMultipliers, sizeof(fMeta.pre_multipliers)); + if (fUserMultipliers[0]) { + memcpy(fMeta.pre_multipliers, fUserMultipliers, + sizeof(fMeta.pre_multipliers)); + } if (fMeta.pre_multipliers[3] == 0) fMeta.pre_multipliers[3] = fColors < 4 ? fMeta.pre_multipliers[1] : 1; @@ -995,10 +1004,11 @@ DCRaw::_ScaleColors() dmax = dmin; for (int c = 0; c < 4; c++) { - scale_mul[c] = (fMeta.pre_multipliers[c] /= dmax) * 65535.0 / fMeta.maximum; + scale_mul[c] = (fMeta.pre_multipliers[c] /= dmax) * 65535.0 + / fMeta.maximum; } -#if 1 +#if 0 if (1/*verbose*/) { fprintf(stderr, "Scaling with black %d, multipliers", dblack); for (int c = 0; c < 4; c++) { @@ -1068,25 +1078,26 @@ DCRaw::_WaveletDenoise() for (sh = 0; sh <= dim; sh += dim) { for (i = 0; i < size; i++) { for (j = 0; j < size; j++) { - temp[j] = fimg[(i << (dim-sh))+(j << sh)]; + temp[j] = fimg[(i << (dim - sh)) + (j << sh)]; } for (k = 1; k < 5; k += 2) { temp[size] = temp[size - 2]; for (m = 1; m < size; m += 2) { - temp[m] += wlet[k] * (temp[m-1] + temp[m+1]); + temp[m] += wlet[k] * (temp[m - 1] + temp[m + 1]); } temp[-1] = temp[1]; for (m = 0; m < size; m += 2) { - temp[m] += wlet[k+1] * (temp[m-1] + temp[m+1]); + temp[m] += wlet[k + 1] + * (temp[m - 1] + temp[m + 1]); } } for (m = 0; m < size; m++) { - temp[m] *= (m & 1) ? 1/wlet[0] : wlet[0]; + temp[m] *= (m & 1) ? 1 / wlet[0] : wlet[0]; } - for (j = k = 0; j < size; j++, k+=2) { + for (j = k = 0; j < size; j++, k += 2) { if (k == size) k = 1; - fimg[(i << (dim-sh))+(j << sh)] = temp[k]; + fimg[(i << (dim - sh)) + (j << sh)] = temp[k]; } } } @@ -1104,26 +1115,27 @@ DCRaw::_WaveletDenoise() for (size = 2; size <= (1 << dim); size <<= 1) { for (sh = dim; sh >= 0; sh -= dim) { for (i = 0; i < size; i++) { - for (j = k = 0; j < size; j++, k+=2) { + for (j = k = 0; j < size; j++, k += 2) { if (k == size) k = 1; - temp[k] = fimg[(i << (dim-sh))+(j << sh)]; + temp[k] = fimg[(i << (dim - sh)) + (j << sh)]; } for (m = 0; m < size; m++) { - temp[m] *= (m & 1) ? wlet[0] : 1/wlet[0]; + temp[m] *= (m & 1) ? wlet[0] : 1 / wlet[0]; } - for (k = 3; k > 0; k-=2) { + for (k = 3; k > 0; k -= 2) { temp[-1] = temp[1]; for (m = 0; m < size; m += 2) { - temp[m] -= wlet[k+1] * (temp[m-1] + temp[m+1]); + temp[m] -= wlet[k + 1] + * (temp[m - 1] + temp[m + 1]); } temp[size] = temp[size - 2]; for (m = 1; m < size; m += 2) { - temp[m] -= wlet[k] * (temp[m-1] + temp[m+1]); + temp[m] -= wlet[k] * (temp[m - 1] + temp[m + 1]); } } for (j = 0; j < size; j++) { - fimg[(i << (dim-sh))+(j << sh)] = temp[j]; + fimg[(i << (dim - sh)) + (j << sh)] = temp[j]; } } } @@ -1144,22 +1156,25 @@ DCRaw::_WaveletDenoise() / fMeta.pre_multipliers[FC(row, 0) | 1]; } for (i = 0; i < 4; i++) { - window[i] = (ushort *) fimg + fInputWidth * i; + window[i] = (ushort *)fimg + fInputWidth * i; } for (wlast = -1, row = 1; row < (int32)fInputHeight - 1; row++) { while (wlast < (int32)row + 1) { - for (wlast++, i=0; i < 4; i++) { - window[(i+3) & 3] = window[i]; + for (wlast++, i = 0; i < 4; i++) { + window[(i + 3) & 3] = window[i]; } - for (col = FC(wlast,1) & 1; col < (int32)fInputWidth; col += 2) { + for (col = FC(wlast, 1) & 1; col < (int32)fInputWidth; + col += 2) { window[2][col] = _Bayer(col, wlast); } } - for (col = (FC(row, 0) & 1)+1; col < (int32)fInputWidth - 1; col += 2) { + for (col = (FC(row, 0) & 1) + 1; col < (int32)fInputWidth - 1; + col += 2) { avg = ( window[0][col - 1] + window[0][col + 1] + window[2][col - 1] + window[2][col + 1] - fMeta.black * 4) - * mul[row & 1] + (window[1][col] - fMeta.black) * 0.5 + fMeta.black; + * mul[row & 1] + (window[1][col] - fMeta.black) * 0.5 + + fMeta.black; diff = _Bayer(col, row) - avg; if (diff < -fThreshold / M_SQRT2) @@ -1198,7 +1213,8 @@ DCRaw::_PreInterpolate() for (row = 0; row < fInputHeight; row++) { for (col = 0; col < fInputWidth; col++) { - data[row * fInputWidth + col][FC(row, col)] = _Bayer(col, row); + data[row * fInputWidth + col][FC(row, col)] + = _Bayer(col, row); } } @@ -1213,7 +1229,7 @@ DCRaw::_PreInterpolate() // fColors++; // else { - for (row = FC(1,0) >> 1; row < fInputHeight; row += 2) { + for (row = FC(1, 0) >> 1; row < fInputHeight; row += 2) { for (col = FC(row, 1) & 1; col < fInputWidth; col += 2) { fImageData[row * fInputWidth + col][1] = fImageData[row * fInputWidth + col][3]; @@ -1237,7 +1253,8 @@ DCRaw::_CameraToCIELab(ushort cam[4], float lab[3]) for (uint32 j = 0; j < fColors; j++) { xyz_cam[i][j] = 0; for (uint32 k = 0; k < 3; k++) { - xyz_cam[i][j] += xyz_rgb[i][k] * fMeta.rgb_camera[k][j] / d65_white[i]; + xyz_cam[i][j] += xyz_rgb[i][k] * fMeta.rgb_camera[k][j] + / kD65White[i]; } } } @@ -1260,7 +1277,7 @@ DCRaw::_CameraToCIELab(ushort cam[4], float lab[3]) void -DCRaw::_CameraXYZCoefficients(double cam_xyz[4][3]) +DCRaw::_CameraXYZCoefficients(double cameraXYZ[4][3]) { double cam_rgb[4][3], inverse[4][3], num; uint32 i, j, k; @@ -1269,7 +1286,7 @@ DCRaw::_CameraXYZCoefficients(double cam_xyz[4][3]) for (i = 0; i < fColors; i++) { for (j = 0; j < 3; j++) { for (cam_rgb[i][j] = k = 0; k < 3; k++) { - cam_rgb[i][j] += cam_xyz[i][k] * xyz_rgb[k][j]; + cam_rgb[i][j] += cameraXYZ[i][k] * xyz_rgb[k][j]; } } } @@ -1296,8 +1313,7 @@ DCRaw::_CameraXYZCoefficients(double cam_xyz[4][3]) } -/*! - Thanks to Adobe for providing these excellent CAM -> XYZ matrices! +/*! Thanks to Adobe for providing these excellent CAM -> XYZ matrices! */ void DCRaw::_AdobeCoefficients(char *make, char *model) @@ -1307,316 +1323,316 @@ DCRaw::_AdobeCoefficients(char *make, char *model) short black, trans[12]; } table[] = { { "Canon EOS D2000", 0, - { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } }, + { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 }}, { "Canon EOS D6000", 0, - { 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 } }, + { 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 }}, { "Canon EOS D30", 0, - { 9805,-2689,-1312,-5803,13064,3068,-2438,3075,8775 } }, + { 9805,-2689,-1312,-5803,13064,3068,-2438,3075,8775 }}, { "Canon EOS D60", 0, - { 6188,-1341,-890,-7168,14489,2937,-2640,3228,8483 } }, + { 6188,-1341,-890,-7168,14489,2937,-2640,3228,8483 }}, { "Canon EOS 5D", 0, - { 6347,-479,-972,-8297,15954,2480,-1968,2131,7649 } }, + { 6347,-479,-972,-8297,15954,2480,-1968,2131,7649 }}, { "Canon EOS 20Da", 0, - { 14155,-5065,-1382,-6550,14633,2039,-1623,1824,6561 } }, + { 14155,-5065,-1382,-6550,14633,2039,-1623,1824,6561 }}, { "Canon EOS 20D", 0, - { 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 } }, + { 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 }}, { "Canon EOS 30D", 0, - { 6257,-303,-1000,-7880,15621,2396,-1714,1904,7046 } }, + { 6257,-303,-1000,-7880,15621,2396,-1714,1904,7046 }}, { "Canon EOS 350D", 0, - { 6018,-617,-965,-8645,15881,2975,-1530,1719,7642 } }, + { 6018,-617,-965,-8645,15881,2975,-1530,1719,7642 }}, { "Canon EOS 400D", 0, - { 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 } }, + { 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 }}, { "Canon EOS-1Ds Mark II", 0, - { 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 } }, + { 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 }}, { "Canon EOS-1D Mark II N", 0, - { 6240,-466,-822,-8180,15825,2500,-1801,1938,8042 } }, + { 6240,-466,-822,-8180,15825,2500,-1801,1938,8042 }}, { "Canon EOS-1D Mark II", 0, - { 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 } }, + { 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 }}, { "Canon EOS-1DS", 0, - { 4374,3631,-1743,-7520,15212,2472,-2892,3632,8161 } }, + { 4374,3631,-1743,-7520,15212,2472,-2892,3632,8161 }}, { "Canon EOS-1D", 0, - { 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 } }, + { 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 }}, { "Canon EOS", 0, - { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } }, + { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 }}, { "Canon PowerShot A50", 0, - { -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 } }, + { -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 }}, { "Canon PowerShot A5", 0, - { -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547 } }, + { -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547 }}, { "Canon PowerShot G1", 0, - { -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557 } }, + { -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557 }}, { "Canon PowerShot G2", 0, - { 9087,-2693,-1049,-6715,14382,2537,-2291,2819,7790 } }, + { 9087,-2693,-1049,-6715,14382,2537,-2291,2819,7790 }}, { "Canon PowerShot G3", 0, - { 9212,-2781,-1073,-6573,14189,2605,-2300,2844,7664 } }, + { 9212,-2781,-1073,-6573,14189,2605,-2300,2844,7664 }}, { "Canon PowerShot G5", 0, - { 9757,-2872,-933,-5972,13861,2301,-1622,2328,7212 } }, + { 9757,-2872,-933,-5972,13861,2301,-1622,2328,7212 }}, { "Canon PowerShot G6", 0, - { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } }, + { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 }}, { "Canon PowerShot Pro1", 0, - { 10062,-3522,-999,-7643,15117,2730,-765,817,7323 } }, + { 10062,-3522,-999,-7643,15117,2730,-765,817,7323 }}, { "Canon PowerShot Pro70", 34, - { -4155,9818,1529,3939,-25,4522,-5521,9870,6610,-2238,10873,1342 } }, + { -4155,9818,1529,3939,-25,4522,-5521,9870,6610,-2238,10873,1342 }}, { "Canon PowerShot Pro90", 0, - { -4963,9896,2235,4642,-987,4294,-5162,10011,5859,-1770,11230,577 } }, + { -4963,9896,2235,4642,-987,4294,-5162,10011,5859,-1770,11230,577 }}, { "Canon PowerShot S30", 0, - { 10566,-3652,-1129,-6552,14662,2006,-2197,2581,7670 } }, + { 10566,-3652,-1129,-6552,14662,2006,-2197,2581,7670 }}, { "Canon PowerShot S40", 0, - { 8510,-2487,-940,-6869,14231,2900,-2318,2829,9013 } }, + { 8510,-2487,-940,-6869,14231,2900,-2318,2829,9013 }}, { "Canon PowerShot S45", 0, - { 8163,-2333,-955,-6682,14174,2751,-2077,2597,8041 } }, + { 8163,-2333,-955,-6682,14174,2751,-2077,2597,8041 }}, { "Canon PowerShot S50", 0, - { 8882,-2571,-863,-6348,14234,2288,-1516,2172,6569 } }, + { 8882,-2571,-863,-6348,14234,2288,-1516,2172,6569 }}, { "Canon PowerShot S60", 0, - { 8795,-2482,-797,-7804,15403,2573,-1422,1996,7082 } }, + { 8795,-2482,-797,-7804,15403,2573,-1422,1996,7082 }}, { "Canon PowerShot S70", 0, - { 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } }, + { 9976,-3810,-832,-7115,14463,2906,-901,989,7889 }}, { "Canon PowerShot A610", 0, /* DJC */ - { 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 } }, + { 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 }}, { "Canon PowerShot A620", 0, /* DJC */ - { 15265,-6193,-1558,-4125,12116,2010,-888,1639,5220 } }, + { 15265,-6193,-1558,-4125,12116,2010,-888,1639,5220 }}, { "Canon PowerShot S3 IS", 0, /* DJC */ - { 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 } }, + { 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 }}, { "Contax N Digital", 0, - { 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 } }, + { 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 }}, { "EPSON R-D1", 0, - { 6827,-1878,-732,-8429,16012,2564,-704,592,7145 } }, + { 6827,-1878,-732,-8429,16012,2564,-704,592,7145 }}, { "FUJIFILM FinePix E550", 0, - { 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 } }, + { 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 }}, { "FUJIFILM FinePix E900", 0, - { 9183,-2526,-1078,-7461,15071,2574,-2022,2440,8639 } }, + { 9183,-2526,-1078,-7461,15071,2574,-2022,2440,8639 }}, { "FUJIFILM FinePix F8", 0, - { 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 } }, + { 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 }}, { "FUJIFILM FinePix F7", 0, - { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, + { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 }}, { "FUJIFILM FinePix S20Pro", 0, - { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, + { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 }}, { "FUJIFILM FinePix S2Pro", 128, - { 12492,-4690,-1402,-7033,15423,1647,-1507,2111,7697 } }, + { 12492,-4690,-1402,-7033,15423,1647,-1507,2111,7697 }}, { "FUJIFILM FinePix S3Pro", 0, - { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } }, + { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 }}, { "FUJIFILM FinePix S5000", 0, - { 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 } }, + { 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 }}, { "FUJIFILM FinePix S5100", 0, - { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } }, + { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 }}, { "FUJIFILM FinePix S5500", 0, - { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } }, + { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 }}, { "FUJIFILM FinePix S5200", 0, - { 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 } }, + { 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 }}, { "FUJIFILM FinePix S5600", 0, - { 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 } }, + { 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 }}, { "FUJIFILM FinePix S6", 0, - { 12628,-4887,-1401,-6861,14996,1962,-2198,2782,7091 } }, + { 12628,-4887,-1401,-6861,14996,1962,-2198,2782,7091 }}, { "FUJIFILM FinePix S7000", 0, - { 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 } }, + { 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 }}, { "FUJIFILM FinePix S9000", 0, - { 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 } }, + { 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 }}, { "FUJIFILM FinePix S9500", 0, - { 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 } }, + { 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 }}, { "FUJIFILM FinePix S9100", 0, - { 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 } }, + { 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 }}, { "FUJIFILM FinePix S9600", 0, - { 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 } }, + { 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 }}, { "Imacon Ixpress", 0, /* DJC */ - { 7025,-1415,-704,-5188,13765,1424,-1248,2742,6038 } }, + { 7025,-1415,-704,-5188,13765,1424,-1248,2742,6038 }}, { "KODAK NC2000", 0, /* DJC */ - { 16475,-6903,-1218,-851,10375,477,2505,-7,1020 } }, + { 16475,-6903,-1218,-851,10375,477,2505,-7,1020 }}, { "Kodak DCS315C", 8, - { 17523,-4827,-2510,756,8546,-137,6113,1649,2250 } }, + { 17523,-4827,-2510,756,8546,-137,6113,1649,2250 }}, { "Kodak DCS330C", 8, - { 20620,-7572,-2801,-103,10073,-396,3551,-233,2220 } }, + { 20620,-7572,-2801,-103,10073,-396,3551,-233,2220 }}, { "KODAK DCS420", 0, - { 10868,-1852,-644,-1537,11083,484,2343,628,2216 } }, + { 10868,-1852,-644,-1537,11083,484,2343,628,2216 }}, { "KODAK DCS460", 0, - { 10592,-2206,-967,-1944,11685,230,2206,670,1273 } }, + { 10592,-2206,-967,-1944,11685,230,2206,670,1273 }}, { "KODAK EOSDCS1", 0, - { 10592,-2206,-967,-1944,11685,230,2206,670,1273 } }, + { 10592,-2206,-967,-1944,11685,230,2206,670,1273 }}, { "KODAK EOSDCS3B", 0, - { 9898,-2700,-940,-2478,12219,206,1985,634,1031 } }, + { 9898,-2700,-940,-2478,12219,206,1985,634,1031 }}, { "Kodak DCS520C", 180, - { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } }, + { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 }}, { "Kodak DCS560C", 188, - { 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 } }, + { 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 }}, { "Kodak DCS620C", 180, - { 23617,-10175,-3149,-2054,11749,-272,2586,-489,3453 } }, + { 23617,-10175,-3149,-2054,11749,-272,2586,-489,3453 }}, { "Kodak DCS620X", 185, - { 13095,-6231,154,12221,-21,-2137,895,4602,2258 } }, + { 13095,-6231,154,12221,-21,-2137,895,4602,2258 }}, { "Kodak DCS660C", 214, - { 18244,-6351,-2739,-791,11193,-521,3711,-129,2802 } }, + { 18244,-6351,-2739,-791,11193,-521,3711,-129,2802 }}, { "Kodak DCS720X", 0, - { 11775,-5884,950,9556,1846,-1286,-1019,6221,2728 } }, + { 11775,-5884,950,9556,1846,-1286,-1019,6221,2728 }}, { "Kodak DCS760C", 0, - { 16623,-6309,-1411,-4344,13923,323,2285,274,2926 } }, + { 16623,-6309,-1411,-4344,13923,323,2285,274,2926 }}, { "Kodak DCS Pro SLR", 0, - { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } }, + { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 }}, { "Kodak DCS Pro 14nx", 0, - { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } }, + { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 }}, { "Kodak DCS Pro 14", 0, - { 7791,3128,-776,-8588,16458,2039,-2455,4006,6198 } }, + { 7791,3128,-776,-8588,16458,2039,-2455,4006,6198 }}, { "Kodak ProBack645", 0, - { 16414,-6060,-1470,-3555,13037,473,2545,122,4948 } }, + { 16414,-6060,-1470,-3555,13037,473,2545,122,4948 }}, { "Kodak ProBack", 0, - { 21179,-8316,-2918,-915,11019,-165,3477,-180,4210 } }, + { 21179,-8316,-2918,-915,11019,-165,3477,-180,4210 }}, { "KODAK P712", 0, - { 9658,-3314,-823,-5163,12695,2768,-1342,1843,6044 } }, + { 9658,-3314,-823,-5163,12695,2768,-1342,1843,6044 }}, { "KODAK P850", 0, - { 10511,-3836,-1102,-6946,14587,2558,-1481,1792,6246 } }, + { 10511,-3836,-1102,-6946,14587,2558,-1481,1792,6246 }}, { "KODAK P880", 0, - { 12805,-4662,-1376,-7480,15267,2360,-1626,2194,7904 } }, + { 12805,-4662,-1376,-7480,15267,2360,-1626,2194,7904 }}, { "Leaf CMost", 0, - { 3952,2189,449,-6701,14585,2275,-4536,7349,6536 } }, + { 3952,2189,449,-6701,14585,2275,-4536,7349,6536 }}, { "Leaf Valeo 6", 0, - { 3952,2189,449,-6701,14585,2275,-4536,7349,6536 } }, + { 3952,2189,449,-6701,14585,2275,-4536,7349,6536 }}, { "Leaf Aptus 65", 0, - { 7914,1414,-1190,-8777,16582,2280,-2811,4605,5562 } }, + { 7914,1414,-1190,-8777,16582,2280,-2811,4605,5562 }}, { "Leaf Aptus 75", 0, - { 7914,1414,-1190,-8777,16582,2280,-2811,4605,5562 } }, + { 7914,1414,-1190,-8777,16582,2280,-2811,4605,5562 }}, { "Leaf", 0, - { 8236,1746,-1314,-8251,15953,2428,-3673,5786,5771 } }, + { 8236,1746,-1314,-8251,15953,2428,-3673,5786,5771 }}, { "Micron 2010", 110, /* DJC */ - { 16695,-3761,-2151,155,9682,163,3433,951,4904 } }, + { 16695,-3761,-2151,155,9682,163,3433,951,4904 }}, { "Minolta DiMAGE 5", 0, - { 8983,-2942,-963,-6556,14476,2237,-2426,2887,8014 } }, + { 8983,-2942,-963,-6556,14476,2237,-2426,2887,8014 }}, { "Minolta DiMAGE 7Hi", 0, - { 11368,-3894,-1242,-6521,14358,2339,-2475,3056,7285 } }, + { 11368,-3894,-1242,-6521,14358,2339,-2475,3056,7285 }}, { "Minolta DiMAGE 7", 0, - { 9144,-2777,-998,-6676,14556,2281,-2470,3019,7744 } }, + { 9144,-2777,-998,-6676,14556,2281,-2470,3019,7744 }}, { "Minolta DiMAGE A1", 0, - { 9274,-2547,-1167,-8220,16323,1943,-2273,2720,8340 } }, + { 9274,-2547,-1167,-8220,16323,1943,-2273,2720,8340 }}, { "MINOLTA DiMAGE A200", 0, - { 8560,-2487,-986,-8112,15535,2771,-1209,1324,7743 } }, + { 8560,-2487,-986,-8112,15535,2771,-1209,1324,7743 }}, { "Minolta DiMAGE A2", 0, - { 9097,-2726,-1053,-8073,15506,2762,-966,981,7763 } }, + { 9097,-2726,-1053,-8073,15506,2762,-966,981,7763 }}, { "Minolta DiMAGE Z2", 0, /* DJC */ - { 11280,-3564,-1370,-4655,12374,2282,-1423,2168,5396 } }, + { 11280,-3564,-1370,-4655,12374,2282,-1423,2168,5396 }}, { "MINOLTA DYNAX 5", 0, - { 10284,-3283,-1086,-7957,15762,2316,-829,882,6644 } }, + { 10284,-3283,-1086,-7957,15762,2316,-829,882,6644 }}, { "MINOLTA DYNAX 7", 0, - { 10239,-3104,-1099,-8037,15727,2451,-927,925,6871 } }, + { 10239,-3104,-1099,-8037,15727,2451,-927,925,6871 }}, { "NIKON D100", 0, - { 5902,-933,-782,-8983,16719,2354,-1402,1455,6464 } }, + { 5902,-933,-782,-8983,16719,2354,-1402,1455,6464 }}, { "NIKON D1H", 0, - { 7577,-2166,-926,-7454,15592,1934,-2377,2808,8606 } }, + { 7577,-2166,-926,-7454,15592,1934,-2377,2808,8606 }}, { "NIKON D1X", 0, - { 7702,-2245,-975,-9114,17242,1875,-2679,3055,8521 } }, + { 7702,-2245,-975,-9114,17242,1875,-2679,3055,8521 }}, { "NIKON D1", 0, /* multiplied by 2.218750, 1.0, 1.148438 */ - { 16772,-4726,-2141,-7611,15713,1972,-2846,3494,9521 } }, + { 16772,-4726,-2141,-7611,15713,1972,-2846,3494,9521 }}, { "NIKON D2H", 0, - { 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 } }, + { 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 }}, { "NIKON D2X", 0, - { 10231,-2769,-1255,-8301,15900,2552,-797,680,7148 } }, + { 10231,-2769,-1255,-8301,15900,2552,-797,680,7148 }}, { "NIKON D40", 0, - { 6992,-1668,-806,-8138,15748,2543,-874,850,7897 } }, + { 6992,-1668,-806,-8138,15748,2543,-874,850,7897 }}, { "NIKON D50", 0, - { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } }, + { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 }}, { "NIKON D70", 0, - { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } }, + { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 }}, { "NIKON D80", 0, - { 8629,-2410,-883,-9055,16940,2171,-1490,1363,8520 } }, + { 8629,-2410,-883,-9055,16940,2171,-1490,1363,8520 }}, { "NIKON D200", 0, - { 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 } }, + { 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 }}, { "NIKON E950", 0, /* DJC */ - { -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 } }, + { -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 }}, { "NIKON E995", 0, /* copied from E5000 */ - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 }}, { "NIKON E2500", 0, - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 }}, { "NIKON E4300", 0, /* copied from Minolta DiMAGE Z2 */ - { 11280,-3564,-1370,-4655,12374,2282,-1423,2168,5396 } }, + { 11280,-3564,-1370,-4655,12374,2282,-1423,2168,5396 }}, { "NIKON E4500", 0, - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 }}, { "NIKON E5000", 0, - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 }}, { "NIKON E5400", 0, - { 9349,-2987,-1001,-7919,15766,2266,-2098,2680,6839 } }, + { 9349,-2987,-1001,-7919,15766,2266,-2098,2680,6839 }}, { "NIKON E5700", 0, - { -5368,11478,2368,5537,-113,3148,-4969,10021,5782,778,9028,211 } }, + { -5368,11478,2368,5537,-113,3148,-4969,10021,5782,778,9028,211 }}, { "NIKON E8400", 0, - { 7842,-2320,-992,-8154,15718,2599,-1098,1342,7560 } }, + { 7842,-2320,-992,-8154,15718,2599,-1098,1342,7560 }}, { "NIKON E8700", 0, - { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, + { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 }}, { "NIKON E8800", 0, - { 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 } }, + { 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 }}, { "OLYMPUS C5050", 0, - { 10508,-3124,-1273,-6079,14294,1901,-1653,2306,6237 } }, + { 10508,-3124,-1273,-6079,14294,1901,-1653,2306,6237 }}, { "OLYMPUS C5060", 0, - { 10445,-3362,-1307,-7662,15690,2058,-1135,1176,7602 } }, + { 10445,-3362,-1307,-7662,15690,2058,-1135,1176,7602 }}, { "OLYMPUS C7070", 0, - { 10252,-3531,-1095,-7114,14850,2436,-1451,1723,6365 } }, + { 10252,-3531,-1095,-7114,14850,2436,-1451,1723,6365 }}, { "OLYMPUS C70", 0, - { 10793,-3791,-1146,-7498,15177,2488,-1390,1577,7321 } }, + { 10793,-3791,-1146,-7498,15177,2488,-1390,1577,7321 }}, { "OLYMPUS C80", 0, - { 8606,-2509,-1014,-8238,15714,2703,-942,979,7760 } }, + { 8606,-2509,-1014,-8238,15714,2703,-942,979,7760 }}, { "OLYMPUS E-10", 0, - { 12745,-4500,-1416,-6062,14542,1580,-1934,2256,6603 } }, + { 12745,-4500,-1416,-6062,14542,1580,-1934,2256,6603 }}, { "OLYMPUS E-1", 0, - { 11846,-4767,-945,-7027,15878,1089,-2699,4122,8311 } }, + { 11846,-4767,-945,-7027,15878,1089,-2699,4122,8311 }}, { "OLYMPUS E-20", 0, - { 13173,-4732,-1499,-5807,14036,1895,-2045,2452,7142 } }, + { 13173,-4732,-1499,-5807,14036,1895,-2045,2452,7142 }}, { "OLYMPUS E-300", 0, - { 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 } }, + { 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 }}, { "OLYMPUS E-330", 0, - { 8961,-2473,-1084,-7979,15990,2067,-2319,3035,8249 } }, + { 8961,-2473,-1084,-7979,15990,2067,-2319,3035,8249 }}, { "OLYMPUS E-400", 0, - { 6169,-1483,-21,-7107,14761,2536,-2904,3580,8568 } }, + { 6169,-1483,-21,-7107,14761,2536,-2904,3580,8568 }}, { "OLYMPUS E-500", 0, - { 8136,-1968,-299,-5481,13742,1871,-2556,4205,6630 } }, + { 8136,-1968,-299,-5481,13742,1871,-2556,4205,6630 }}, { "OLYMPUS SP350", 0, - { 12078,-4836,-1069,-6671,14306,2578,-786,939,7418 } }, + { 12078,-4836,-1069,-6671,14306,2578,-786,939,7418 }}, { "OLYMPUS SP3", 0, - { 11766,-4445,-1067,-6901,14421,2707,-1029,1217,7572 } }, + { 11766,-4445,-1067,-6901,14421,2707,-1029,1217,7572 }}, { "OLYMPUS SP500UZ", 0, - { 9493,-3415,-666,-5211,12334,3260,-1548,2262,6482 } }, + { 9493,-3415,-666,-5211,12334,3260,-1548,2262,6482 }}, { "OLYMPUS SP510UZ", 0, - { 10593,-3607,-1010,-5881,13127,3084,-1200,1805,6721 } }, + { 10593,-3607,-1010,-5881,13127,3084,-1200,1805,6721 }}, { "PENTAX *ist DL2", 0, - { 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 } }, + { 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 }}, { "PENTAX *ist DL", 0, - { 10829,-2838,-1115,-8339,15817,2696,-837,680,11939 } }, + { 10829,-2838,-1115,-8339,15817,2696,-837,680,11939 }}, { "PENTAX *ist DS2", 0, - { 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 } }, + { 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 }}, { "PENTAX *ist DS", 0, - { 10371,-2333,-1206,-8688,16231,2602,-1230,1116,11282 } }, + { 10371,-2333,-1206,-8688,16231,2602,-1230,1116,11282 }}, { "PENTAX *ist D", 0, - { 9651,-2059,-1189,-8881,16512,2487,-1460,1345,10687 } }, + { 9651,-2059,-1189,-8881,16512,2487,-1460,1345,10687 }}, { "PENTAX K10D", 0, - { 9566,-2863,-803,-7170,15172,2112,-818,803,9705 } }, + { 9566,-2863,-803,-7170,15172,2112,-818,803,9705 }}, { "PENTAX K1", 0, - { 11095,-3157,-1324,-8377,15834,2720,-1108,947,11688 } }, + { 11095,-3157,-1324,-8377,15834,2720,-1108,947,11688 }}, { "Panasonic DMC-FZ30", 0, - { 10976,-4029,-1141,-7918,15491,2600,-1670,2071,8246 } }, + { 10976,-4029,-1141,-7918,15491,2600,-1670,2071,8246 }}, { "Panasonic DMC-FZ50", 0, /* aka "LEICA V-LUX1" */ - { 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } }, + { 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 }}, { "Panasonic DMC-L1", 0, /* aka "LEICA DIGILUX 3" */ - { 8054,-1885,-1025,-8349,16367,2040,-2805,3542,7629 } }, + { 8054,-1885,-1025,-8349,16367,2040,-2805,3542,7629 }}, { "Panasonic DMC-LC1", 0, /* aka "LEICA DIGILUX 2" */ - { 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } }, + { 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 }}, { "Panasonic DMC-LX1", 0, /* aka "LEICA D-LUX2" */ - { 10704,-4187,-1230,-8314,15952,2501,-920,945,8927 } }, + { 10704,-4187,-1230,-8314,15952,2501,-920,945,8927 }}, { "Panasonic DMC-LX2", 0, /* aka "LEICA D-LUX3" */ - { 8048,-2810,-623,-6450,13519,3272,-1700,2146,7049 } }, + { 8048,-2810,-623,-6450,13519,3272,-1700,2146,7049 }}, { "SAMSUNG GX-1", 0, - { 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 } }, + { 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 }}, { "Sinar", 0, /* DJC */ - { 16442,-2956,-2422,-2877,12128,750,-1136,6066,4559 } }, + { 16442,-2956,-2422,-2877,12128,750,-1136,6066,4559 }}, { "SONY DSC-F828", 491, - { 7924,-1910,-777,-8226,15459,2998,-1517,2199,6818,-7242,11401,3481 } }, + { 7924,-1910,-777,-8226,15459,2998,-1517,2199,6818,-7242,11401,3481 }}, { "SONY DSC-R1", 512, - { 8512,-2641,-694,-8042,15670,2526,-1821,2117,7414 } }, + { 8512,-2641,-694,-8042,15670,2526,-1821,2117,7414 }}, { "SONY DSC-V3", 0, - { 7511,-2571,-692,-7894,15088,3060,-948,1111,8128 } }, + { 7511,-2571,-692,-7894,15088,3060,-948,1111,8128 }}, { "SONY DSLR-A100", 0, - { 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } } + { 9437,-2811,-774,-8405,16215,2290,-710,596,7181 }} }; - double cam_xyz[4][3]; + double cameraXYZ[4][3]; for (uint32 i = 0; i < sizeof table / sizeof *table; i++) { if (!strncasecmp(model, table[i].prefix, strlen(table[i].prefix))) { if (table[i].black) fMeta.black = table[i].black; for (uint32 j = 0; j < 12; j++) { - cam_xyz[0][j] = table[i].trans[j] / 10000.0; + cameraXYZ[0][j] = table[i].trans[j] / 10000.0; } - _CameraXYZCoefficients(cam_xyz); + _CameraXYZCoefficients(cameraXYZ); break; } } @@ -1648,17 +1664,18 @@ DCRaw::_BorderInterpolate(uint32 border) f = _FilterCoefficient(col, row); for (c = 0; c < fColors; c++) { - if (c != f && sum[c + 4]) - fImageData[row * fInputWidth + col][c] = sum[c] / sum[c+4]; + if (c != f && sum[c + 4]) { + fImageData[row * fInputWidth + col][c] + = sum[c] / sum[c + 4]; + } } } } } -/*! - Adaptive Homogeneity-Directed interpolation is based on - the work of Keigo Hirakawa, Thomas Parks, and Paul Lee. +/*! Adaptive Homogeneity-Directed interpolation is based on + the work of Keigo Hirakawa, Thomas Parks, and Paul Lee. */ void DCRaw::_AHDInterpolate() @@ -1679,13 +1696,13 @@ DCRaw::_AHDInterpolate() char (*homo)[TS][TS], *buffer; _BorderInterpolate(3); - buffer = (char *) malloc(26*TS*TS); /* 1664 kB */ + buffer = (char *)malloc(26 * TS * TS); /* 1664 kB */ if (buffer == NULL) throw (status_t)B_NO_MEMORY; rgb = (ushort(*)[TS][TS][3])buffer; - lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS); - homo = (char (*)[TS][TS])(buffer + 24*TS*TS); + lab = (short (*)[TS][TS][3])(buffer + 12 * TS * TS); + homo = (char (*)[TS][TS])(buffer + 24 * TS * TS); float percentage = 20; float percentageStep = 70.0f / (fInputHeight / (TS - 6)); @@ -1699,17 +1716,22 @@ DCRaw::_AHDInterpolate() memset(rgb, 0, 12 * TS * TS); /* Interpolate green horizontally and vertically: */ - for (row = top < 2 ? 2 : top; row < top + TS && row < fInputHeight - 2; row++) { + for (row = top < 2 ? 2 : top; row < top + TS + && row < fInputHeight - 2; row++) { col = left + (FC(row, left) == 1); if (col < 2) col += 2; - for (fc = FC(row, col); col < left + TS && col < fInputWidth - 2; col += 2) { + for (fc = FC(row, col); col < left + TS + && col < fInputWidth - 2; col += 2) { pix = fImageData + row * fInputWidth + col; val = ((pix[-1][1] + pix[0][fc] + pix[1][1]) * 2 - pix[-2][fc] - pix[2][fc]) >> 2; - rgb[0][row - top][col - left][1] = ULIM(val, pix[-1][1], pix[1][1]); - val = ((pix[-fInputWidth][1] + pix[0][fc] + pix[fInputWidth][1]) * 2 - - pix[-2 * fInputWidth][fc] - pix[2 * fInputWidth][fc]) >> 2; + rgb[0][row - top][col - left][1] + = ULIM(val, pix[-1][1], pix[1][1]); + val = ((pix[-fInputWidth][1] + pix[0][fc] + + pix[fInputWidth][1]) * 2 + - pix[-2 * fInputWidth][fc] - pix[2 * fInputWidth][fc]) + >> 2; rgb[1][row - top][col - left][1] = ULIM(val, pix[-fInputWidth][1], pix[fInputWidth][1]); } @@ -1717,8 +1739,10 @@ DCRaw::_AHDInterpolate() /* Interpolate red and blue, and convert to CIELab: */ for (d = 0; d < 2; d++) { - for (row = top + 1; row < top + TS - 1 && row < fInputHeight - 1; row++) { - for (col = left + 1; col < left + TS - 1 && col < fInputWidth - 1; col++) { + for (row = top + 1; row < top + TS - 1 + && row < fInputHeight - 1; row++) { + for (col = left + 1; col < left + TS - 1 + && col < fInputWidth - 1; col++) { pix = fImageData + row * fInputWidth + col; rix = &rgb[d][row - top][col - left]; if ((c = 2 - FC(row, col)) == 1) { @@ -1732,7 +1756,8 @@ DCRaw::_AHDInterpolate() } else { val = rix[0][1] + ((pix[-fInputWidth - 1][c] + pix[-fInputWidth + 1][c] - + pix[fInputWidth - 1][c] + pix[fInputWidth + 1][c] + + pix[fInputWidth - 1][c] + + pix[fInputWidth + 1][c] - rix[-TS - 1][1] - rix[-TS + 1][1] - rix[TS - 1][1] - rix[TS + 1][1] + 1) >> 2); } @@ -1741,7 +1766,8 @@ DCRaw::_AHDInterpolate() rix[0][c] = pix[0][c]; _CameraToCIELab(rix[0], flab); for (c = 0; c < 3; c++) { - lab[d][row - top][col - left][c] = int16(64 * flab[c]); + lab[d][row - top][col - left][c] + = int16(64 * flab[c]); } } } @@ -1751,11 +1777,13 @@ DCRaw::_AHDInterpolate() memset(homo, 0, 2 * TS * TS); for (row = top + 2; row < top+TS-2 && row < fInputHeight; row++) { tr = row - top; - for (col = left + 2; col < left + TS - 2 && col < fInputWidth; col++) { + for (col = left + 2; col < left + TS - 2 + && col < fInputWidth; col++) { tc = col - left; for (d = 0; d < 2; d++) { for (i = 0; i < 4; i++) { - ldiff[d][i] = ABS(lab[d][tr][tc][0]-lab[d][tr][tc+dir[i]][0]); + ldiff[d][i] = ABS(lab[d][tr][tc][0] + - lab[d][tr][tc+dir[i]][0]); } } @@ -1765,8 +1793,10 @@ DCRaw::_AHDInterpolate() for (d = 0; d < 2; d++) { for (i = 0; i < 4; i++) { if (i >> 1 == d || ldiff[d][i] <= leps) { - abdiff[d][i] = square(lab[d][tr][tc][1]-lab[d][tr][tc+dir[i]][1]) - + square(lab[d][tr][tc][2]-lab[d][tr][tc+dir[i]][2]); + abdiff[d][i] = square(lab[d][tr][tc][1] + - lab[d][tr][tc+dir[i]][1]) + + square(lab[d][tr][tc][2] + - lab[d][tr][tc+dir[i]][2]); } } } @@ -1784,10 +1814,12 @@ DCRaw::_AHDInterpolate() } /* Combine the most homogenous pixels for the final result: */ - for (row = top + 3; row < top + TS - 3 && row < fInputHeight - 3; row++) { + for (row = top + 3; row < top + TS - 3 && row < fInputHeight - 3; + row++) { tr = row - top; - for (col = left + 3; col < left + TS - 3 && col < fInputWidth - 3; col++) { - tc = col-left; + for (col = left + 3; col < left + TS - 3 + && col < fInputWidth - 3; col++) { + tc = col - left; for (d = 0; d < 2; d++) { for (hm[d] = 0, i = tr - 1; i <= tr + 1; i++) { for (j = tc - 1; j <= tc + 1; j++) { @@ -1868,33 +1900,33 @@ DCRaw::_ConvertToRGB() uint32 row, col, c, i, j, k; float out[3], out_cam[3][4]; double num, inverse[3][3]; - static const double xyzd50_srgb[3][3] = - { { 0.436083, 0.385083, 0.143055 }, + static const double xyzd50_srgb[3][3] = { + { 0.436083, 0.385083, 0.143055 }, { 0.222507, 0.716888, 0.060608 }, - { 0.013930, 0.097097, 0.714022 } }; - static const double rgb_rgb[3][3] = - { { 1,0,0 }, { 0,1,0 }, { 0,0,1 } }; - static const double adobe_rgb[3][3] = - { { 0.715146, 0.284856, 0.000000 }, + { 0.013930, 0.097097, 0.714022 }}; + static const double rgb_rgb[3][3] = { + { 1,0,0 }, { 0,1,0 }, { 0,0,1 }}; + static const double adobe_rgb[3][3] = { + { 0.715146, 0.284856, 0.000000 }, { 0.000000, 1.000000, 0.000000 }, - { 0.000000, 0.041166, 0.958839 } }; - static const double wide_rgb[3][3] = - { { 0.593087, 0.404710, 0.002206 }, + { 0.000000, 0.041166, 0.958839 }}; + static const double wide_rgb[3][3] = { + { 0.593087, 0.404710, 0.002206 }, { 0.095413, 0.843149, 0.061439 }, - { 0.011621, 0.069091, 0.919288 } }; - static const double prophoto_rgb[3][3] = - { { 0.529317, 0.330092, 0.140588 }, + { 0.011621, 0.069091, 0.919288 }}; + static const double prophoto_rgb[3][3] = { + { 0.529317, 0.330092, 0.140588 }, { 0.098368, 0.873465, 0.028169 }, - { 0.016879, 0.117663, 0.865457 } }; - static const double (*out_rgb[])[3] = - { rgb_rgb, adobe_rgb, wide_rgb, prophoto_rgb, xyz_rgb }; - static const char *name[] = - { "sRGB", "Adobe RGB (1998)", "WideGamut D65", "ProPhoto D65", "XYZ" }; - static const unsigned phead[] = - { 1024, 0, 0x2100000, 0x6d6e7472, 0x52474220, 0x58595a20, 0, 0, 0, - 0x61637370, 0, 0, 0x6e6f6e65, 0, 0, 0, 0, 0xf6d6, 0x10000, 0xd32d }; - unsigned pbody[] = - { 10, 0x63707274, 0, 36, /* cprt */ + { 0.016879, 0.117663, 0.865457 }}; + static const double (*out_rgb[])[3] + = { rgb_rgb, adobe_rgb, wide_rgb, prophoto_rgb, xyz_rgb }; + static const char *name[] = { "sRGB", "Adobe RGB (1998)", "WideGamut D65", + "ProPhoto D65", "XYZ" }; + static const unsigned phead[] = { 1024, 0, 0x2100000, 0x6d6e7472, + 0x52474220, 0x58595a20, 0, 0, 0, 0x61637370, 0, 0, 0x6e6f6e65, + 0, 0, 0, 0, 0xf6d6, 0x10000, 0xd32d }; + unsigned pbody[] = { 10, + 0x63707274, 0, 36, /* cprt */ 0x64657363, 0, 40, /* desc */ 0x77747074, 0, 20, /* wtpt */ 0x626b7074, 0, 20, /* bkpt */ @@ -1921,7 +1953,8 @@ DCRaw::_ConvertToRGB() fOutputProfile[0] = 132 + 12 * pbody[0]; for (i = 0; i < pbody[0]; i++) { - fOutputProfile[fOutputProfile[0]/4] = i ? (i > 1 ? 0x58595a20 : 0x64657363) : 0x74657874; + fOutputProfile[fOutputProfile[0] / 4] + = i ? (i > 1 ? 0x58595a20 : 0x64657363) : 0x74657874; pbody[i*3+2] = fOutputProfile[0]; fOutputProfile[0] += (pbody[i*3+3] + 3) & -4; } @@ -1938,7 +1971,8 @@ DCRaw::_ConvertToRGB() } for (i = 4; i < 7; i++) { - memcpy((char *)fOutputProfile + pbody[i*3+2], pcurve, sizeof(pcurve)); + memcpy((char *)fOutputProfile + pbody[i * 3 + 2], pcurve, + sizeof(pcurve)); } _PseudoInverse((double (*)[3])out_rgb[fOutputColor - 1], inverse, 3); @@ -1948,19 +1982,22 @@ DCRaw::_ConvertToRGB() for (num = k=0; k < 3; k++) { num += xyzd50_srgb[i][k] * inverse[j][k]; } - fOutputProfile[pbody[j * 3 + 23] / 4 + i + 2] = uint32(num * 0x10000 + 0.5); + fOutputProfile[pbody[j * 3 + 23] / 4 + i + 2] + = uint32(num * 0x10000 + 0.5); } } for (i = 0; i < phead[0]/4; i++) { fOutputProfile[i] = htonl(fOutputProfile[i]); } - strcpy((char *)fOutputProfile + pbody[2] + 8, "auto-generated by dcraw"); + strcpy((char *)fOutputProfile + pbody[2] + 8, + "auto-generated by dcraw"); strcpy((char *)fOutputProfile + pbody[5] + 12, name[fOutputColor - 1]); for (i = 0; i < 3; i++) { for (j = 0; j < fColors; j++) { for (out_cam[i][j] = k = 0; k < 3; k++) { - out_cam[i][j] += out_rgb[fOutputColor-1][i][k] * fMeta.rgb_camera[k][j]; + out_cam[i][j] += out_rgb[fOutputColor-1][i][k] + * fMeta.rgb_camera[k][j]; } } } @@ -2052,8 +2089,7 @@ DCRaw::_InitDecoder() } -/*! - Construct a decode tree according the specification in *source. +/*! Construct a decode tree according the specification in *source. The first 16 bytes specify how many codes should be 1-bit, 2-bit 3-bit, etc. Bytes after that are the leaf values. @@ -2077,14 +2113,15 @@ DCRaw::_InitDecoder() 111110 0x0a 1111110 0x0b 1111111 0xff - */ +*/ uchar * DCRaw::_MakeDecoder(const uchar* source, int level) { if (level == 0) fDecodeLeaf = 0; - if ((uint8*)fFreeDecode > (uint8*)fDecodeBuffer + sizeof(decode) * kDecodeBufferCount) { + if ((uint8*)fFreeDecode > (uint8*)fDecodeBuffer + + sizeof(decode) * kDecodeBufferCount) { fprintf(stderr, "decoder table overflow\n"); throw (status_t)B_ERROR; } @@ -2110,12 +2147,9 @@ DCRaw::_MakeDecoder(const uchar* source, int level) } -/* - Not a full implementation of Lossless JPEG, just - enough to decode Canon, Kodak and Adobe DNG images. - */ - - +/*! Not a full implementation of Lossless JPEG, just + enough to decode Canon, Kodak and Adobe DNG images. +*/ void DCRaw::_InitDecodeBits() { @@ -2124,9 +2158,8 @@ DCRaw::_InitDecodeBits() } -/*! - _GetDecodeBits(n) where 0 <= n <= 25 returns an n-bit integer - */ +/*! _GetDecodeBits(n) where 0 <= n <= 25 returns an n-bit integer +*/ uint32 DCRaw::_GetDecodeBits(uint32 numBits) { @@ -2135,7 +2168,8 @@ DCRaw::_GetDecodeBits(uint32 numBits) while (fDecodeBitsRead < numBits) { uint8 c = fRead.Next(); - if ((fDecodeBitsReset = fDecodeBitsZeroAfterMax && c == 0xff && fRead.Next())) + if ((fDecodeBitsReset = fDecodeBitsZeroAfterMax + && c == 0xff && fRead.Next())) return 0; fDecodeBits = (fDecodeBits << 8) + c; fDecodeBitsRead += 8; @@ -2259,8 +2293,7 @@ DCRaw::_LosslessJPEGRow(struct jhead *jh, int jrow) // #pragma mark - RAW loaders -/*! - This is, for example, used in PENTAX RAW images +/*! This is, for example, used in PENTAX RAW images */ void DCRaw::_LoadRAWPacked12(const image_data_info& image) @@ -2353,12 +2386,11 @@ DCRaw::_MakeCanonDecoder(uint32 table) } -/*! - Return 0 if the image starts with compressed data, +/*! Return 0 if the image starts with compressed data, 1 if it starts with uncompressed low-order bits. In Canon compressed data, 0xff is always followed by 0x00. - */ +*/ bool DCRaw::_CanonHasLowBits() { @@ -2557,7 +2589,8 @@ DCRaw::_LoadRAW(const image_data_info& image) break; default: - fprintf(stderr, "DCRaw: unknown compression: %ld\n", image.compression); + fprintf(stderr, "DCRaw: unknown compression: %ld\n", + image.compression); throw (status_t)B_NO_TRANSLATOR; break; } @@ -2688,8 +2721,7 @@ DCRaw::_ParseTIFFTimestamp(bool reversed) } -/*! - Reads a TIFF tag and positions the file stream to its data section +/*! Reads a TIFF tag and positions the file stream to its data section */ void DCRaw::_ParseTIFFTag(off_t baseOffset, tiff_tag& tag, off_t& offset) @@ -2739,7 +2771,7 @@ DCRaw::_ParseTIFFImageFileDirectory(off_t baseOffset, uint32 offset) double analogBalance[] = {1, 1, 1, 1}; double xyz[] = {1, 1, 1, 1}; bool useColorMatrix = false; - double cameraCalibration[4][4], colorMatrix[4][3], cam_xyz[4][3]; + double cameraCalibration[4][4], colorMatrix[4][3], cameraXYZ[4][3]; for (int32 j = 0; j < 4; j++) { for (int32 i = 0; i < 4; i++) { @@ -2771,8 +2803,10 @@ DCRaw::_ParseTIFFImageFileDirectory(off_t baseOffset, uint32 offset) case 17: case 18: - if (tag.type == 3 && tag.length == 1) - fMeta.camera_multipliers[(tag.tag - 17) * 2] = fRead.Next() / 256.0; + if (tag.type == 3 && tag.length == 1) { + fMeta.camera_multipliers[(tag.tag - 17) * 2] + = fRead.Next() / 256.0; + } break; case 23: // ISO speed @@ -3143,7 +3177,7 @@ DCRaw::_ParseTIFFImageFileDirectory(off_t baseOffset, uint32 offset) xyz[0] = getrat(); xyz[1] = getrat(); xyz[2] = 1 - xyz[0] - xyz[1]; - FORC3 xyz[c] /= d65_white[c]; + FORC3 xyz[c] /= kD65White[c]; break; case 50740: /* DNGPrivateData */ if (dng_version) break; @@ -3204,14 +3238,14 @@ DCRaw::_ParseTIFFImageFileDirectory(off_t baseOffset, uint32 offset) if (useColorMatrix) { for (uint32 c = 0; c < fColors; c++) { for (uint32 i = 0; i < 3; i++) { - cam_xyz[c][i] = 0; + cameraXYZ[c][i] = 0; for (uint32 j = 0; j < fColors; j++) { - cam_xyz[c][i] += cameraCalibration[c][j] + cameraXYZ[c][i] += cameraCalibration[c][j] * colorMatrix[j][i] * xyz[i]; } } } - _CameraXYZCoefficients(cam_xyz); + _CameraXYZCoefficients(cameraXYZ); } #if 0 @@ -3302,7 +3336,8 @@ DCRaw::_ParseTIFF(off_t baseOffset) } } - if (fRawIndex < 0 || (!fDNGVersion && _Raw().samples == 3 && _Raw().bits_per_sample == 8)) + if (fRawIndex < 0 + || (!fDNGVersion && _Raw().samples == 3 && _Raw().bits_per_sample == 8)) throw (status_t)B_NO_TRANSLATOR; if (fRawIndex >= 0) { @@ -3417,7 +3452,8 @@ DCRaw::Identify() int32 rawCount = 0; for (int32 i = 0; i < (int32)fNumImages; i++) { - if (fImages[i].width == 0 || fImages[i].height == 0 || fImages[i].data_offset == 0) { + if (fImages[i].width == 0 || fImages[i].height == 0 + || fImages[i].data_offset == 0) { fNumImages--; if (i == fRawIndex) fRawIndex = -1; @@ -3433,7 +3469,7 @@ DCRaw::Identify() sizeof(image_data_info) * (fNumImages - i)); } i--; - } else if (fImages[i].is_raw && fImages[i].compression == COMPRESSION_PACKBITS) + } else if (fImages[i].is_raw) rawCount++; } diff --git a/src/add-ons/translators/raw/RAW.h b/src/add-ons/translators/raw/RAW.h index 183048ab22..fe84ec5e29 100644 --- a/src/add-ons/translators/raw/RAW.h +++ b/src/add-ons/translators/raw/RAW.h @@ -8,11 +8,10 @@ #include "ReadHelper.h" + struct jhead; struct tiff_tag; -#define COMPRESSION_PACKBITS 32773 - struct image_meta_info { char manufacturer[64]; @@ -52,6 +51,10 @@ struct image_data_info { bool is_raw; }; +#define COMPRESSION_PACKBITS 32773 + /* Macintosh RLE */ + + typedef void (*monitor_hook)(const char* message, float percentage, void* data); class DCRaw {