diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2010-04-10 16:07:24 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2010-04-10 16:07:24 +0000 |
commit | 7d714381d1af9f51ae0094df79e1fe8d28c46b84 (patch) | |
tree | cf576cb526aa84b025b3bb599062e1849a55a3b0 | |
parent | 73225706f044df73549d0982e782b41ff94e117f (diff) | |
download | netpbm-mirror-7d714381d1af9f51ae0094df79e1fe8d28c46b84.tar.gz netpbm-mirror-7d714381d1af9f51ae0094df79e1fe8d28c46b84.tar.xz netpbm-mirror-7d714381d1af9f51ae0094df79e1fe8d28c46b84.zip |
Fix compiler warnings
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1185 9d0c8265-081b-0410-96cb-a4ca84ce46f8
38 files changed, 1528 insertions, 1483 deletions
diff --git a/analyzer/pnmhistmap.c b/analyzer/pnmhistmap.c index c45ab0c6..d83765f5 100644 --- a/analyzer/pnmhistmap.c +++ b/analyzer/pnmhistmap.c @@ -117,7 +117,7 @@ parseCommandLine(int argc, const char ** argv, cmdlineP->inputFilespec = "-"; else if (argc-1 != 1) pm_error("Program takes zero or one argument (filename). You " - "specified %d", argc-1); + "specified %u", argc-1); else cmdlineP->inputFilespec = argv[1]; } @@ -205,11 +205,11 @@ pgmHist(FILE * const ifP, MALLOCARRAY(ghist, histWidth); if (ghist == NULL) - pm_error("Not enough memory for histogram array (%d bytes)", - histWidth * sizeof(int)); + pm_error("Not enough memory for histogram array (%u bytes)", + histWidth * (unsigned)sizeof(int)); bits = pbm_allocarray(histWidth, histHeight); if (bits == NULL) - pm_error("no space for output array (%d bits)", + pm_error("no space for output array (%u bits)", histWidth * histHeight); memset(ghist, 0, histWidth * sizeof(ghist[0])); @@ -299,8 +299,8 @@ createHist(bool const colorWanted[3], unsigned int i; MALLOCARRAY(hist, histWidth); if (hist == NULL) - pm_error ("Not enough memory for histogram arrays (%u bytes)", - histWidth * sizeof(hist[0]) * 3); + pm_error("Not enough memory for histogram arrays (%u bytes)", + histWidth * (unsigned)sizeof(hist[0]) * 3); for (i = 0; i < histWidth; ++i) hist[i] = 0; diff --git a/converter/other/cameratopam/camera.c b/converter/other/cameratopam/camera.c index 98d6d37a..ea5eec39 100644 --- a/converter/other/cameratopam/camera.c +++ b/converter/other/cameratopam/camera.c @@ -12,6 +12,7 @@ #include <jpeglib.h> #endif +#include "pm_config.h" #include "pm.h" #include "mallocvar.h" @@ -686,67 +687,71 @@ static int radc_token (int tree) void kodak_radc_load_raw() { - int row, col, tree, nreps, rep, step, i, c, s, r, x, y, val; - short last[3] = { 16,16,16 }, mul[3], buf[3][3][386]; + int row, col, tree, nreps, rep, step, i, c, s, r, x, y, val; + short last[3] = { 16,16,16 }, mul[3], buf[3][3][386]; - init_decoder(); - getbits(ifp, -1); - for (i=0; i < sizeof(buf)/sizeof(short); i++) - buf[0][0][i] = 2048; - for (row=0; row < height; row+=4) { - for (i=0; i < 3; i++) - mul[i] = getbits(ifp, 6); - FORC3 { - val = ((0x1000000/last[c] + 0x7ff) >> 12) * mul[c]; - s = val > 65564 ? 10:12; - x = ~(-1 << (s-1)); - val <<= 12-s; - for (i=0; i < sizeof(buf[0])/sizeof(short); i++) - buf[c][0][i] = (buf[c][0][i] * val + x) >> s; - last[c] = mul[c]; - for (r=0; r <= !c; r++) { - buf[c][1][width/2] = buf[c][2][width/2] = mul[c] << 7; - for (tree=1, col=width/2; col > 0; ) { - if ((tree = radc_token(tree))) { - col -= 2; - if (tree == 8) - FORYX buf[c][y][x] = radc_token(tree+10) * mul[c]; - else - FORYX buf[c][y][x] = radc_token(tree+10) * 16 + PREDICTOR; - } else - do { - nreps = (col > 2) ? radc_token(9) + 1 : 1; - for (rep=0; rep < 8 && rep < nreps && col > 0; rep++) { - col -= 2; - FORYX buf[c][y][x] = PREDICTOR; - if (rep & 1) { - step = radc_token(10) << 4; - FORYX buf[c][y][x] += step; + init_decoder(); + getbits(ifp, -1); + for (i=0; i < sizeof(buf)/sizeof(short); i++) + buf[0][0][i] = 2048; + for (row=0; row < height; row+=4) { + for (i=0; i < 3; i++) + mul[i] = getbits(ifp, 6); + FORC3 { + val = ((0x1000000/last[c] + 0x7ff) >> 12) * mul[c]; + s = val > 65564 ? 10:12; + x = ~(-1 << (s-1)); + val <<= 12-s; + for (i=0; i < ARRAY_SIZE(buf[c][0]); i++) + buf[c][0][i] = (buf[c][0][i] * val + x) >> s; + last[c] = mul[c]; + for (r=0; r <= !c; r++) { + buf[c][1][width/2] = buf[c][2][width/2] = mul[c] << 7; + for (tree=1, col=width/2; col > 0; ) { + if ((tree = radc_token(tree))) { + col -= 2; + if (tree == 8) + FORYX buf[c][y][x] = + radc_token(tree+10) * mul[c]; + else + FORYX buf[c][y][x] = + radc_token(tree+10) * 16 + PREDICTOR; + } else + do { + nreps = (col > 2) ? radc_token(9) + 1 : 1; + for (rep=0; + rep < 8 && rep < nreps && col > 0; + rep++) { + col -= 2; + FORYX buf[c][y][x] = PREDICTOR; + if (rep & 1) { + step = radc_token(10) << 4; + FORYX buf[c][y][x] += step; + } + } + } while (nreps == 9); + } + for (y=0; y < 2; y++) + for (x=0; x < width/2; x++) { + val = (buf[c][y+1][x] << 4) / mul[c]; + if (val < 0) val = 0; + if (c) + BAYER(row+y*2+c-1,x*2+2-c) = val; + else + BAYER(row+r*2+y,x*2+y) = val; + } + memcpy (buf[c][0]+!c, buf[c][2], sizeof buf[c][0]-2*!c); + } } - } - } while (nreps == 9); - } - for (y=0; y < 2; y++) - for (x=0; x < width/2; x++) { - val = (buf[c][y+1][x] << 4) / mul[c]; - if (val < 0) val = 0; - if (c) - BAYER(row+y*2+c-1,x*2+2-c) = val; - else - BAYER(row+r*2+y,x*2+y) = val; - } - memcpy (buf[c][0]+!c, buf[c][2], sizeof buf[c][0]-2*!c); - } - } - for (y=row; y < row+4; y++) - for (x=0; x < width; x++) - if ((x+y) & 1) { - val = (BAYER(y,x)-2048)*2 + (BAYER(y,x-1)+BAYER(y,x+1))/2; - if (val < 0) val = 0; - BAYER(y,x) = val; - } - } - maximum = 0x1fff; /* wild guess */ + for (y=row; y < row+4; y++) + for (x=0; x < width; x++) + if ((x+y) & 1) { + val = (BAYER(y,x)-2048)*2 + (BAYER(y,x-1)+BAYER(y,x+1))/2; + if (val < 0) val = 0; + BAYER(y,x) = val; + } + } + maximum = 0x1fff; /* wild guess */ } #undef FORYX diff --git a/converter/other/cameratopam/identify.c b/converter/other/cameratopam/identify.c index a101c8ad..b99496b7 100644 --- a/converter/other/cameratopam/identify.c +++ b/converter/other/cameratopam/identify.c @@ -15,9 +15,9 @@ #if HAVE_INT64 - static bool const have64BitArithmetic = true; +static bool const have64BitArithmetic = true; #else - static bool const have64BitArithmetic = false; +static bool const have64BitArithmetic = false; #endif @@ -25,225 +25,237 @@ static loadRawFn load_raw; /* This does the same as the function of the same name in the GNU C library */ static const char *memmem_internal (const char *haystack, size_t haystacklen, - const char *needle, size_t needlelen) + const char *needle, size_t needlelen) { - const char *c; - for (c = haystack; c <= haystack + haystacklen - needlelen; c++) - if (!memcmp (c, needle, needlelen)) - return c; - return NULL; + const char *c; + for (c = haystack; c <= haystack + haystacklen - needlelen; c++) + if (!memcmp (c, needle, needlelen)) + return c; + return NULL; } /* - Thanks to Adobe for providing these excellent CAM -> XYZ matrices! - */ + Thanks to Adobe for providing these excellent CAM -> XYZ matrices! +*/ static void adobe_coeff() { - static const struct { - const char *prefix; - short trans[12]; - } table[] = { - { "Canon EOS D2000C", - { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } }, - { "Canon EOS D30", - { 9805,-2689,-1312,-5803,13064,3068,-2438,3075,8775 } }, - { "Canon EOS D60", - { 6188,-1341,-890,-7168,14489,2937,-2640,3228,8483 } }, - { "Canon EOS 10D", - { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } }, - { "Canon EOS 20D", - { 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 } }, - { "Canon EOS-1Ds Mark II", - { 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 } }, - { "Canon EOS-1D Mark II", - { 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 } }, - { "Canon EOS-1DS", - { 4374,3631,-1743,-7520,15212,2472,-2892,3632,8161 } }, - { "Canon EOS-1D", - { 6906,-278,-1017,-6649,15074,1621,-2848,3897,7611 } }, - { "Canon EOS", - { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } }, - { "Canon PowerShot 600", - { -3822,10019,1311,4085,-157,3386,-5341,10829,4812,-1969,10969,1126 } }, - { "Canon PowerShot A50", - { -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 } }, - { "Canon PowerShot A5", - { -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547 } }, - { "Canon PowerShot G1", - { -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557 } }, - { "Canon PowerShot G2", - { 9087,-2693,-1049,-6715,14382,2537,-2291,2819,7790 } }, - { "Canon PowerShot G3", - { 9212,-2781,-1073,-6573,14189,2605,-2300,2844,7664 } }, - { "Canon PowerShot G5", - { 9757,-2872,-933,-5972,13861,2301,-1622,2328,7212 } }, - { "Canon PowerShot G6", - { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } }, - { "Canon PowerShot Pro1", - { 10062,-3522,-999,-7643,15117,2730,-765,817,7323 } }, - { "Canon PowerShot Pro70", - { -4155,9818,1529,3939,-25,4522,-5521,9870,6610,-2238,10873,1342 } }, - { "Canon PowerShot Pro90", - { -4963,9896,2235,4642,-987,4294,-5162,10011,5859,-1770,11230,577 } }, - { "Canon PowerShot S30", - { 10566,-3652,-1129,-6552,14662,2006,-2197,2581,7670 } }, - { "Canon PowerShot S40", - { 8510,-2487,-940,-6869,14231,2900,-2318,2829,9013 } }, - { "Canon PowerShot S45", - { 8163,-2333,-955,-6682,14174,2751,-2077,2597,8041 } }, - { "Canon PowerShot S50", - { 8882,-2571,-863,-6348,14234,2288,-1516,2172,6569 } }, - { "Canon PowerShot S70", - { 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } }, - { "Contax N Digital", - { 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 } }, - { "EPSON R-D1", - { 6827,-1878,-732,-8429,16012,2564,-704,592,7145 } }, - { "FUJIFILM FinePix E550", - { 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 } }, - { "FUJIFILM FinePix F700", - { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, - { "FUJIFILM FinePix S20Pro", - { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, - { "FUJIFILM FinePix S2Pro", - { 12492,-4690,-1402,-7033,15423,1647,-1507,2111,7697 } }, - { "FUJIFILM FinePix S3Pro", - { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } }, - { "FUJIFILM FinePix S5000", - { 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 } }, - { "FUJIFILM FinePix S5100", - { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } }, - { "FUJIFILM FinePix S7000", - { 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 } }, - { "Kodak DCS315C", - { 17523,-4827,-2510,756,8546,-137,6113,1649,2250 } }, - { "Kodak DCS330C", - { 20620,-7572,-2801,-103,10073,-396,3551,-233,2220 } }, - { "KODAK DCS420", - { 10868,-1852,-644,-1537,11083,484,2343,628,2216 } }, - { "KODAK DCS460", - { 10592,-2206,-967,-1944,11685,230,2206,670,1273 } }, - { "KODAK EOSDCS1", - { 10592,-2206,-967,-1944,11685,230,2206,670,1273 } }, - { "KODAK EOSDCS3B", - { 9898,-2700,-940,-2478,12219,206,1985,634,1031 } }, - { "Kodak DCS520C", - { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } }, - { "Kodak DCS560C", - { 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 } }, - { "Kodak DCS620C", - { 23617,-10175,-3149,-2054,11749,-272,2586,-489,3453 } }, - { "Kodak DCS620X", - { 13095,-6231,154,12221,-21,-2137,895,4602,2258 } }, - { "Kodak DCS660C", - { 18244,-6351,-2739,-791,11193,-521,3711,-129,2802 } }, - { "Kodak DCS720X", - { 11775,-5884,950,9556,1846,-1286,-1019,6221,2728 } }, - { "Kodak DCS760C", - { 16623,-6309,-1411,-4344,13923,323,2285,274,2926 } }, - { "Kodak DCS Pro SLR", - { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } }, - { "Kodak DCS Pro 14nx", - { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } }, - { "Kodak DCS Pro 14", - { 7791,3128,-776,-8588,16458,2039,-2455,4006,6198 } }, - { "Kodak ProBack645", - { 16414,-6060,-1470,-3555,13037,473,2545,122,4948 } }, - { "Kodak ProBack", - { 21179,-8316,-2918,-915,11019,-165,3477,-180,4210 } }, - { "LEICA DIGILUX 2", - { 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } }, - { "Leaf Valeo", - { 8236,1746,-1314,-8251,15953,2428,-3673,5786,5771 } }, - { "Minolta DiMAGE 5", - { 8983,-2942,-963,-6556,14476,2237,-2426,2887,8014 } }, - { "Minolta DiMAGE 7", - { 9144,-2777,-998,-6676,14556,2281,-2470,3019,7744 } }, - { "Minolta DiMAGE A1", - { 9274,-2547,-1167,-8220,16323,1943,-2273,2720,8340 } }, - { "MINOLTA DiMAGE A200", - { 8560,-2487,-986,-8112,15535,2771,-1209,1324,7743 } }, - { "Minolta DiMAGE A2", - { 9097,-2726,-1053,-8073,15506,2762,-966,981,7763 } }, - { "MINOLTA DYNAX 7D", - { 10239,-3104,-1099,-8037,15727,2451,-927,925,6871 } }, - { "NIKON D100", - { 5915,-949,-778,-7516,15364,2282,-1228,1337,6404 } }, - { "NIKON D1H", - { 7577,-2166,-926,-7454,15592,1934,-2377,2808,8606 } }, - { "NIKON D1X", - { 7620,-2173,-966,-7604,15843,1805,-2356,2811,8439 } }, - { "NIKON D1", - { 7559,-2130,-965,-7611,15713,1972,-2478,3042,8290 } }, - { "NIKON D2H", - { 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 } }, - { "NIKON D70", - { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } }, - { "NIKON E995", /* copied from E5000 */ - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, - { "NIKON E2500", - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, - { "NIKON E4500", - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, - { "NIKON E5000", - { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, - { "NIKON E5400", - { 9349,-2987,-1001,-7919,15766,2266,-2098,2680,6839 } }, - { "NIKON E5700", - { -5368,11478,2368,5537,-113,3148,-4969,10021,5782,778,9028,211 } }, - { "NIKON E8400", - { 7842,-2320,-992,-8154,15718,2599,-1098,1342,7560 } }, - { "NIKON E8700", - { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, - { "NIKON E8800", - { 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 } }, - { "OLYMPUS C5050", - { 10508,-3124,-1273,-6079,14294,1901,-1653,2306,6237 } }, - { "OLYMPUS C5060", - { 10445,-3362,-1307,-7662,15690,2058,-1135,1176,7602 } }, - { "OLYMPUS C70", - { 10793,-3791,-1146,-7498,15177,2488,-1390,1577,7321 } }, - { "OLYMPUS C80", - { 8606,-2509,-1014,-8238,15714,2703,-942,979,7760 } }, - { "OLYMPUS E-10", - { 12745,-4500,-1416,-6062,14542,1580,-1934,2256,6603 } }, - { "OLYMPUS E-1", - { 11846,-4767,-945,-7027,15878,1089,-2699,4122,8311 } }, - { "OLYMPUS E-20", - { 13173,-4732,-1499,-5807,14036,1895,-2045,2452,7142 } }, - { "OLYMPUS E-300", - { 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 } }, - { "PENTAX *ist D", - { 9651,-2059,-1189,-8881,16512,2487,-1460,1345,10687 } }, - { "Panasonic DMC-LC1", - { 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } }, - { "SONY DSC-F828", - { 7924,-1910,-777,-8226,15459,2998,-1517,2199,6818,-7242,11401,3481 } }, - { "SONY DSC-V3", - { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } } - }; - double cc[4][4], cm[4][3], xyz[] = { 1,1,1 }; - char name[130]; - int i, j; + static const struct { + const char *prefix; + short trans[12]; + } table[] = { + { "Canon EOS D2000C", + { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } }, + { "Canon EOS D30", + { 9805,-2689,-1312,-5803,13064,3068,-2438,3075,8775 } }, + { "Canon EOS D60", + { 6188,-1341,-890,-7168,14489,2937,-2640,3228,8483 } }, + { "Canon EOS 10D", + { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } }, + { "Canon EOS 20D", + { 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 } }, + { "Canon EOS-1Ds Mark II", + { 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 } }, + { "Canon EOS-1D Mark II", + { 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 } }, + { "Canon EOS-1DS", + { 4374,3631,-1743,-7520,15212,2472,-2892,3632,8161 } }, + { "Canon EOS-1D", + { 6906,-278,-1017,-6649,15074,1621,-2848,3897,7611 } }, + { "Canon EOS", + { 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } }, + { "Canon PowerShot 600", + { -3822,10019,1311,4085,-157,3386,-5341,10829,4812,-1969,10969, + 1126} }, + { "Canon PowerShot A50", + { -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 } }, + { "Canon PowerShot A5", + { -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547} }, + { "Canon PowerShot G1", + { -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557} }, + { "Canon PowerShot G2", + { 9087,-2693,-1049,-6715,14382,2537,-2291,2819,7790 } }, + { "Canon PowerShot G3", + { 9212,-2781,-1073,-6573,14189,2605,-2300,2844,7664 } }, + { "Canon PowerShot G5", + { 9757,-2872,-933,-5972,13861,2301,-1622,2328,7212 } }, + { "Canon PowerShot G6", + { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } }, + { "Canon PowerShot Pro1", + { 10062,-3522,-999,-7643,15117,2730,-765,817,7323 } }, + { "Canon PowerShot Pro70", + { -4155,9818,1529,3939,-25,4522,-5521,9870,6610,-2238,10873,1342 } }, + { "Canon PowerShot Pro90", + { -4963,9896,2235,4642,-987,4294,-5162,10011,5859,-1770,11230,577} }, + { "Canon PowerShot S30", + { 10566,-3652,-1129,-6552,14662,2006,-2197,2581,7670 } }, + { "Canon PowerShot S40", + { 8510,-2487,-940,-6869,14231,2900,-2318,2829,9013 } }, + { "Canon PowerShot S45", + { 8163,-2333,-955,-6682,14174,2751,-2077,2597,8041 } }, + { "Canon PowerShot S50", + { 8882,-2571,-863,-6348,14234,2288,-1516,2172,6569 } }, + { "Canon PowerShot S70", + { 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } }, + { "Contax N Digital", + { 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 } }, + { "EPSON R-D1", + { 6827,-1878,-732,-8429,16012,2564,-704,592,7145 } }, + { "FUJIFILM FinePix E550", + { 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 } }, + { "FUJIFILM FinePix F700", + { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, + { "FUJIFILM FinePix S20Pro", + { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, + { "FUJIFILM FinePix S2Pro", + { 12492,-4690,-1402,-7033,15423,1647,-1507,2111,7697 } }, + { "FUJIFILM FinePix S3Pro", + { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } }, + { "FUJIFILM FinePix S5000", + { 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 } }, + { "FUJIFILM FinePix S5100", + { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } }, + { "FUJIFILM FinePix S7000", + { 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 } }, + { "Kodak DCS315C", + { 17523,-4827,-2510,756,8546,-137,6113,1649,2250 } }, + { "Kodak DCS330C", + { 20620,-7572,-2801,-103,10073,-396,3551,-233,2220 } }, + { "KODAK DCS420", + { 10868,-1852,-644,-1537,11083,484,2343,628,2216 } }, + { "KODAK DCS460", + { 10592,-2206,-967,-1944,11685,230,2206,670,1273 } }, + { "KODAK EOSDCS1", + { 10592,-2206,-967,-1944,11685,230,2206,670,1273 } }, + { "KODAK EOSDCS3B", + { 9898,-2700,-940,-2478,12219,206,1985,634,1031 } }, + { "Kodak DCS520C", + { 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } }, + { "Kodak DCS560C", + { 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 } }, + { "Kodak DCS620C", + { 23617,-10175,-3149,-2054,11749,-272,2586,-489,3453 } }, + { "Kodak DCS620X", + { 13095,-6231,154,12221,-21,-2137,895,4602,2258 } }, + { "Kodak DCS660C", + { 18244,-6351,-2739,-791,11193,-521,3711,-129,2802 } }, + { "Kodak DCS720X", + { 11775,-5884,950,9556,1846,-1286,-1019,6221,2728 } }, + { "Kodak DCS760C", + { 16623,-6309,-1411,-4344,13923,323,2285,274,2926 } }, + { "Kodak DCS Pro SLR", + { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } }, + { "Kodak DCS Pro 14nx", + { 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } }, + { "Kodak DCS Pro 14", + { 7791,3128,-776,-8588,16458,2039,-2455,4006,6198 } }, + { "Kodak ProBack645", + { 16414,-6060,-1470,-3555,13037,473,2545,122,4948 } }, + { "Kodak ProBack", + { 21179,-8316,-2918,-915,11019,-165,3477,-180,4210 } }, + { "LEICA DIGILUX 2", + { 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } }, + { "Leaf Valeo", + { 8236,1746,-1314,-8251,15953,2428,-3673,5786,5771 } }, + { "Minolta DiMAGE 5", + { 8983,-2942,-963,-6556,14476,2237,-2426,2887,8014 } }, + { "Minolta DiMAGE 7", + { 9144,-2777,-998,-6676,14556,2281,-2470,3019,7744 } }, + { "Minolta DiMAGE A1", + { 9274,-2547,-1167,-8220,16323,1943,-2273,2720,8340 } }, + { "MINOLTA DiMAGE A200", + { 8560,-2487,-986,-8112,15535,2771,-1209,1324,7743 } }, + { "Minolta DiMAGE A2", + { 9097,-2726,-1053,-8073,15506,2762,-966,981,7763 } }, + { "MINOLTA DYNAX 7D", + { 10239,-3104,-1099,-8037,15727,2451,-927,925,6871 } }, + { "NIKON D100", + { 5915,-949,-778,-7516,15364,2282,-1228,1337,6404 } }, + { "NIKON D1H", + { 7577,-2166,-926,-7454,15592,1934,-2377,2808,8606 } }, + { "NIKON D1X", + { 7620,-2173,-966,-7604,15843,1805,-2356,2811,8439 } }, + { "NIKON D1", + { 7559,-2130,-965,-7611,15713,1972,-2478,3042,8290 } }, + { "NIKON D2H", + { 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 } }, + { "NIKON D70", + { 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } }, + { "NIKON E995", /* copied from E5000 */ + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { "NIKON E2500", + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { "NIKON E4500", + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { "NIKON E5000", + { -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } }, + { "NIKON E5400", + { 9349,-2987,-1001,-7919,15766,2266,-2098,2680,6839 } }, + { "NIKON E5700", + { -5368,11478,2368,5537,-113,3148,-4969,10021,5782,778,9028,211 } }, + { "NIKON E8400", + { 7842,-2320,-992,-8154,15718,2599,-1098,1342,7560 } }, + { "NIKON E8700", + { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, + { "NIKON E8800", + { 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 } }, + { "OLYMPUS C5050", + { 10508,-3124,-1273,-6079,14294,1901,-1653,2306,6237 } }, + { "OLYMPUS C5060", + { 10445,-3362,-1307,-7662,15690,2058,-1135,1176,7602 } }, + { "OLYMPUS C70", + { 10793,-3791,-1146,-7498,15177,2488,-1390,1577,7321 } }, + { "OLYMPUS C80", + { 8606,-2509,-1014,-8238,15714,2703,-942,979,7760 } }, + { "OLYMPUS E-10", + { 12745,-4500,-1416,-6062,14542,1580,-1934,2256,6603 } }, + { "OLYMPUS E-1", + { 11846,-4767,-945,-7027,15878,1089,-2699,4122,8311 } }, + { "OLYMPUS E-20", + { 13173,-4732,-1499,-5807,14036,1895,-2045,2452,7142 } }, + { "OLYMPUS E-300", + { 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 } }, + { "PENTAX *ist D", + { 9651,-2059,-1189,-8881,16512,2487,-1460,1345,10687 } }, + { "Panasonic DMC-LC1", + { 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } }, + { "SONY DSC-F828", + { 7924,-1910,-777,-8226,15459,2998,-1517,2199,6818,-7242,11401, + 3481} }, + { "SONY DSC-V3", + { 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } } + }; + double cc[4][4]; + double cm[4][3]; + double xyz[] = { 1,1,1 }; + char name[130]; + int i, j; - for (i=0; i < 4; i++) - for (j=0; j < 4; j++) - cc[i][j] = i == j; - sprintf (name, "%s %s", make, model); - for (i=0; i < sizeof table / sizeof *table; i++) - if (!strncmp (name, table[i].prefix, strlen(table[i].prefix))) { - for (j=0; j < 12; j++) - cm[0][j] = table[i].trans[j]; - dng_coeff (cc, cm, xyz); - break; - } + for (i=0; i < 4; i++) + for (j=0; j < 4; j++) + cc[i][j] = i == j; + sprintf (name, "%s %s", make, model); + for (i=0; i < sizeof table / sizeof *table; i++) + if (!strncmp (name, table[i].prefix, strlen(table[i].prefix))) { + unsigned int j; + /* I have no idea what this code is supposed to do, but the way I + found it, it was setting the first 12 elements, instead of 4, + of cm[0]. But cm[0] has only 3 elements! So I just changed it + to use the first 3 "trans" values and ignore the rest. I + don't know if that produces useful results, but at least it + cures the array bounds violation. -Bryan 2010.04.09. + */ + for (j=0; j < 3; j++) + cm[0][j] = table[i].trans[j]; + dng_coeff (cc, cm, xyz); + break; + } } /* - Identify which camera created this file, and set global variables - accordingly. Return nonzero if the file cannot be decoded. - */ + Identify which camera created this file, and set global variables + accordingly. Return nonzero if the file cannot be decoded. +*/ int identify(FILE * const ifp, bool const use_secondary, @@ -254,930 +266,930 @@ identify(FILE * const ifp, const char * const inputFileName, loadRawFn * const loadRawFnP) { - char head[32]; - char * c; - unsigned hlen, fsize, i; - static const struct { - int fsize; - char make[12], model[15], withjpeg; - } table[] = { - { 62464, "Kodak", "DC20" ,0 }, - { 124928, "Kodak", "DC20" ,0 }, - { 311696, "ST Micro", "STV680 VGA" ,0 }, /* SPYz */ - { 787456, "Creative", "PC-CAM 600" ,0 }, - { 2465792, "NIKON", "E950" ,1 }, /* or E800,E700 */ - { 2940928, "NIKON", "E2100" ,1 }, /* or E2500 */ - { 4771840, "NIKON", "E990" ,1 }, /* or E995 */ - { 4775936, "NIKON", "E3700" ,1 }, /* or Optio 33WR */ - { 5869568, "NIKON", "E4300" ,1 }, /* or DiMAGE Z2 */ - { 5865472, "NIKON", "E4500" ,0 }, - { 1976352, "CASIO", "QV-2000UX" ,0 }, - { 3217760, "CASIO", "QV-3*00EX" ,0 }, - { 6218368, "CASIO", "QV-5700" ,0 }, - { 7530816, "CASIO", "QV-R51" ,1 }, - { 7684000, "CASIO", "QV-4000" ,0 }, - { 7753344, "CASIO", "EX-Z55" ,1 }, - { 9313536, "CASIO", "EX-P600" ,1 }, - { 10979200, "CASIO", "EX-P700" ,1 }, - { 3178560, "PENTAX", "Optio S" ,1 }, /* 8-bit */ - { 4841984, "PENTAX", "Optio S" ,1 }, /* 12-bit */ - { 6114240, "PENTAX", "Optio S4" ,1 }, /* or S4i */ - { 12582980, "Sinar", "" ,0 } }; - static const char *corp[] = - { "Canon", "NIKON", "EPSON", "Kodak", "OLYMPUS", "PENTAX", - "MINOLTA", "Minolta", "Konica", "CASIO" }; - float tmp; + char head[32]; + char * c; + unsigned hlen, fsize, i; + static const struct { + int fsize; + char make[12], model[15], withjpeg; + } table[] = { + { 62464, "Kodak", "DC20" ,0 }, + { 124928, "Kodak", "DC20" ,0 }, + { 311696, "ST Micro", "STV680 VGA" ,0 }, /* SPYz */ + { 787456, "Creative", "PC-CAM 600" ,0 }, + { 2465792, "NIKON", "E950" ,1 }, /* or E800,E700 */ + { 2940928, "NIKON", "E2100" ,1 }, /* or E2500 */ + { 4771840, "NIKON", "E990" ,1 }, /* or E995 */ + { 4775936, "NIKON", "E3700" ,1 }, /* or Optio 33WR */ + { 5869568, "NIKON", "E4300" ,1 }, /* or DiMAGE Z2 */ + { 5865472, "NIKON", "E4500" ,0 }, + { 1976352, "CASIO", "QV-2000UX" ,0 }, + { 3217760, "CASIO", "QV-3*00EX" ,0 }, + { 6218368, "CASIO", "QV-5700" ,0 }, + { 7530816, "CASIO", "QV-R51" ,1 }, + { 7684000, "CASIO", "QV-4000" ,0 }, + { 7753344, "CASIO", "EX-Z55" ,1 }, + { 9313536, "CASIO", "EX-P600" ,1 }, + { 10979200, "CASIO", "EX-P700" ,1 }, + { 3178560, "PENTAX", "Optio S" ,1 }, /* 8-bit */ + { 4841984, "PENTAX", "Optio S" ,1 }, /* 12-bit */ + { 6114240, "PENTAX", "Optio S4" ,1 }, /* or S4i */ + { 12582980, "Sinar", "" ,0 } }; + static const char *corp[] = + { "Canon", "NIKON", "EPSON", "Kodak", "OLYMPUS", "PENTAX", + "MINOLTA", "Minolta", "Konica", "CASIO" }; + float tmp; - /* What format is this file? Set make[] if we recognize it. */ + /* What format is this file? Set make[] if we recognize it. */ - raw_height = raw_width = fuji_width = flip = 0; - make[0] = model[0] = model2[0] = 0; - memset (white, 0, sizeof white); - timestamp = tiff_samples = 0; - data_offset = meta_length = tiff_data_compression = 0; - zero_after_ff = is_dng = fuji_secondary = filters = 0; - black = is_foveon = use_coeff = 0; - use_gamma = xmag = ymag = 1; - for (i=0; i < 4; i++) { - cam_mul[i] = 1 & i; - pre_mul[i] = 1; - } - colors = 3; - for (i=0; i < 0x1000; i++) curve[i] = i; - maximum = 0xfff; + raw_height = raw_width = fuji_width = flip = 0; + make[0] = model[0] = model2[0] = 0; + memset (white, 0, sizeof white); + timestamp = tiff_samples = 0; + data_offset = meta_length = tiff_data_compression = 0; + zero_after_ff = is_dng = fuji_secondary = filters = 0; + black = is_foveon = use_coeff = 0; + use_gamma = xmag = ymag = 1; + for (i=0; i < 4; i++) { + cam_mul[i] = 1 & i; + pre_mul[i] = 1; + } + colors = 3; + for (i=0; i < 0x1000; i++) curve[i] = i; + maximum = 0xfff; #ifdef USE_LCMS - profile_length = 0; + profile_length = 0; #endif - order = get2(ifp); - hlen = get4(ifp); - fseek (ifp, 0, SEEK_SET); - fread (head, 1, 32, ifp); - fseek (ifp, 0, SEEK_END); - fsize = ftell(ifp); - if ((c = (char*)memmem_internal(head, 32, "MMMMRawT", 8))) { - strcpy (make, "Phase One"); - data_offset = c - head; - fseek (ifp, data_offset + 8, SEEK_SET); - fseek (ifp, get4(ifp) + 136, SEEK_CUR); - raw_width = get4(ifp); - fseek (ifp, 12, SEEK_CUR); - raw_height = get4(ifp); - } else if (order == 0x4949 || order == 0x4d4d) { - if (!memcmp (head+6, "HEAPCCDR", 8)) { - data_offset = hlen; - parse_ciff(ifp, hlen, fsize - hlen); - } else { - parse_tiff(ifp, 0); - if (!strncmp(make,"NIKON",5) && filters == 0) - make[0] = 0; - } - } else if (!memcmp (head, "\0MRM", 4)) - parse_minolta(ifp); + order = get2(ifp); + hlen = get4(ifp); + fseek (ifp, 0, SEEK_SET); + fread (head, 1, 32, ifp); + fseek (ifp, 0, SEEK_END); + fsize = ftell(ifp); + if ((c = (char*)memmem_internal(head, 32, "MMMMRawT", 8))) { + strcpy (make, "Phase One"); + data_offset = c - head; + fseek (ifp, data_offset + 8, SEEK_SET); + fseek (ifp, get4(ifp) + 136, SEEK_CUR); + raw_width = get4(ifp); + fseek (ifp, 12, SEEK_CUR); + raw_height = get4(ifp); + } else if (order == 0x4949 || order == 0x4d4d) { + if (!memcmp (head+6, "HEAPCCDR", 8)) { + data_offset = hlen; + parse_ciff(ifp, hlen, fsize - hlen); + } else { + parse_tiff(ifp, 0); + if (!strncmp(make,"NIKON",5) && filters == 0) + make[0] = 0; + } + } else if (!memcmp (head, "\0MRM", 4)) + parse_minolta(ifp); else if (!memcmp (head, "\xff\xd8\xff\xe1", 4) && - !memcmp (head+6, "Exif", 4)) { - fseek (ifp, 4, SEEK_SET); - fseek (ifp, 4 + get2(ifp), SEEK_SET); - if (fgetc(ifp) != 0xff) - parse_tiff(ifp, 12); - } else if (!memcmp (head, "BM", 2)) { - data_offset = 0x1000; - order = 0x4949; - fseek (ifp, 38, SEEK_SET); - if (get4(ifp) == 2834 && get4(ifp) == 2834) { - strcpy (model, "BMQ"); - flip = 3; - goto nucore; - } - } else if (!memcmp (head, "BR", 2)) { - strcpy (model, "RAW"); -nucore: - strcpy (make, "Nucore"); - order = 0x4949; - fseek (ifp, 10, SEEK_SET); - data_offset += get4(ifp); - get4(ifp); - raw_width = get4(ifp); - raw_height = get4(ifp); - if (model[0] == 'B' && raw_width == 2597) { - raw_width++; - data_offset -= 0x1000; - } - } else if (!memcmp (head+25, "ARECOYK", 7)) { - strcpy (make, "Contax"); - strcpy (model,"N Digital"); - fseek (ifp, 60, SEEK_SET); - camera_red = get4(ifp); - camera_red /= get4(ifp); - camera_blue = get4(ifp); - camera_blue = get4(ifp) / camera_blue; - } else if (!memcmp (head, "FUJIFILM", 8)) { - long data_offset_long; - fseek (ifp, 84, SEEK_SET); - parse_tiff(ifp, get4(ifp)+12); - fseek (ifp, 100, SEEK_SET); - pm_readbiglong(ifp, &data_offset_long); - data_offset = data_offset_long; - } else if (!memcmp (head, "DSC-Image", 9)) - parse_rollei(ifp); - else if (!memcmp (head, "FOVb", 4)) - parse_foveon(ifp); - else - for (i=0; i < sizeof table / sizeof *table; i++) - if (fsize == table[i].fsize) { - strcpy (make, table[i].make ); - strcpy (model, table[i].model); - if (table[i].withjpeg) - parse_external_jpeg(inputFileName); - } - parse_mos(ifp, 8); - parse_mos(ifp, 3472); + !memcmp (head+6, "Exif", 4)) { + fseek (ifp, 4, SEEK_SET); + fseek (ifp, 4 + get2(ifp), SEEK_SET); + if (fgetc(ifp) != 0xff) + parse_tiff(ifp, 12); + } else if (!memcmp (head, "BM", 2)) { + data_offset = 0x1000; + order = 0x4949; + fseek (ifp, 38, SEEK_SET); + if (get4(ifp) == 2834 && get4(ifp) == 2834) { + strcpy (model, "BMQ"); + flip = 3; + goto nucore; + } + } else if (!memcmp (head, "BR", 2)) { + strcpy (model, "RAW"); + nucore: + strcpy (make, "Nucore"); + order = 0x4949; + fseek (ifp, 10, SEEK_SET); + data_offset += get4(ifp); + get4(ifp); + raw_width = get4(ifp); + raw_height = get4(ifp); + if (model[0] == 'B' && raw_width == 2597) { + raw_width++; + data_offset -= 0x1000; + } + } else if (!memcmp (head+25, "ARECOYK", 7)) { + strcpy (make, "Contax"); + strcpy (model,"N Digital"); + fseek (ifp, 60, SEEK_SET); + camera_red = get4(ifp); + camera_red /= get4(ifp); + camera_blue = get4(ifp); + camera_blue = get4(ifp) / camera_blue; + } else if (!memcmp (head, "FUJIFILM", 8)) { + long data_offset_long; + fseek (ifp, 84, SEEK_SET); + parse_tiff(ifp, get4(ifp)+12); + fseek (ifp, 100, SEEK_SET); + pm_readbiglong(ifp, &data_offset_long); + data_offset = data_offset_long; + } else if (!memcmp (head, "DSC-Image", 9)) + parse_rollei(ifp); + else if (!memcmp (head, "FOVb", 4)) + parse_foveon(ifp); + else + for (i=0; i < sizeof table / sizeof *table; i++) + if (fsize == table[i].fsize) { + strcpy (make, table[i].make ); + strcpy (model, table[i].model); + if (table[i].withjpeg) + parse_external_jpeg(inputFileName); + } + parse_mos(ifp, 8); + parse_mos(ifp, 3472); - for (i=0; i < sizeof corp / sizeof *corp; i++) - if (strstr (make, corp[i])) /* Simplify company names */ - strcpy (make, corp[i]); - if (!strncmp (make, "KODAK", 5)) - make[16] = model[16] = 0; - c = make + strlen(make); /* Remove trailing spaces */ - while (*--c == ' ') *c = 0; - c = model + strlen(model); - while (*--c == ' ') *c = 0; - i = strlen(make); /* Remove make from model */ - if (!strncmp (model, make, i++)) - memmove (model, model+i, 64-i); - make[63] = model[63] = model2[63] = 0; + for (i=0; i < sizeof corp / sizeof *corp; i++) + if (strstr (make, corp[i])) /* Simplify company names */ + strcpy (make, corp[i]); + if (!strncmp (make, "KODAK", 5)) + make[16] = model[16] = 0; + c = make + strlen(make); /* Remove trailing spaces */ + while (*--c == ' ') *c = 0; + c = model + strlen(model); + while (*--c == ' ') *c = 0; + i = strlen(make); /* Remove make from model */ + if (!strncmp (model, make, i++)) + memmove (model, model+i, 64-i); + make[63] = model[63] = model2[63] = 0; - if (make[0] == 0) { - pm_message ("unrecognized file format."); - return 1; - } + if (make[0] == 0) { + pm_message ("unrecognized file format."); + return 1; + } /* File format is OK. Do we know this camera? */ /* Start with some useful defaults: */ - top_margin = left_margin = 0; - if ((raw_height | raw_width) < 0) - raw_height = raw_width = 0; - height = raw_height; - width = raw_width; - if (fuji_width) { - width = height + fuji_width; - height = width - 1; - ymag = 1; - } - load_raw = NULL; - if (is_dng) { - strcat (model, " DNG"); - if (!filters) - colors = tiff_samples; - if (tiff_data_compression == 1) - load_raw = adobe_dng_load_raw_nc; - if (tiff_data_compression == 7) - load_raw = adobe_dng_load_raw_lj; - goto dng_skip; - } + top_margin = left_margin = 0; + if ((raw_height | raw_width) < 0) + raw_height = raw_width = 0; + height = raw_height; + width = raw_width; + if (fuji_width) { + width = height + fuji_width; + height = width - 1; + ymag = 1; + } + load_raw = NULL; + if (is_dng) { + strcat (model, " DNG"); + if (!filters) + colors = tiff_samples; + if (tiff_data_compression == 1) + load_raw = adobe_dng_load_raw_nc; + if (tiff_data_compression == 7) + load_raw = adobe_dng_load_raw_lj; + goto dng_skip; + } /* We'll try to decode anything from Canon or Nikon. */ - if (!filters) filters = 0x94949494; - if ((is_canon = !strcmp(make,"Canon"))) - load_raw = memcmp (head+6,"HEAPCCDR",8) ? - lossless_jpeg_load_raw : canon_compressed_load_raw; - if (!strcmp(make,"NIKON")) - load_raw = nikon_is_compressed() ? - nikon_compressed_load_raw : nikon_load_raw; + if (!filters) filters = 0x94949494; + if ((is_canon = !strcmp(make,"Canon"))) + load_raw = memcmp (head+6,"HEAPCCDR",8) ? + lossless_jpeg_load_raw : canon_compressed_load_raw; + if (!strcmp(make,"NIKON")) + load_raw = nikon_is_compressed() ? + nikon_compressed_load_raw : nikon_load_raw; /* Set parameters based on camera name (for non-DNG files). */ - if (is_foveon) { - if (!have64BitArithmetic) - pm_error("This program was built without 64 bit arithmetic " - "capability and the Foveon format requires it."); - if (height*2 < width) ymag = 2; - if (width < height) xmag = 2; - filters = 0; - load_raw = foveon_load_raw; - foveon_coeff(&use_coeff, coeff); - } else if (!strcmp(model,"PowerShot 600")) { - height = 613; - width = 854; - colors = 4; - filters = 0xe1e4e1e4; - load_raw = canon_600_load_raw; - } else if (!strcmp(model,"PowerShot A5") || - !strcmp(model,"PowerShot A5 Zoom")) { - height = 773; - width = 960; - raw_width = 992; - colors = 4; - filters = 0x1e4e1e4e; - load_raw = canon_a5_load_raw; - } else if (!strcmp(model,"PowerShot A50")) { - height = 968; - width = 1290; - raw_width = 1320; - colors = 4; - filters = 0x1b4e4b1e; - load_raw = canon_a5_load_raw; - } else if (!strcmp(model,"PowerShot Pro70")) { - height = 1024; - width = 1552; - colors = 4; - filters = 0x1e4b4e1b; - load_raw = canon_a5_load_raw; - black = 34; - } else if (!strcmp(model,"PowerShot Pro90 IS")) { - width = 1896; - colors = 4; - filters = 0xb4b4b4b4; - } else if (is_canon && raw_width == 2144) { - height = 1550; - width = 2088; - top_margin = 8; - left_margin = 4; - if (!strcmp(model,"PowerShot G1")) { - colors = 4; - filters = 0xb4b4b4b4; - } - } else if (is_canon && raw_width == 2224) { - height = 1448; - width = 2176; - top_margin = 6; - left_margin = 48; - } else if (is_canon && raw_width == 2376) { - height = 1720; - width = 2312; - top_margin = 6; - left_margin = 12; - } else if (is_canon && raw_width == 2672) { - height = 1960; - width = 2616; - top_margin = 6; - left_margin = 12; - } else if (is_canon && raw_width == 3152) { - height = 2056; - width = 3088; - top_margin = 12; - left_margin = 64; - maximum = 0xfa0; - } else if (is_canon && raw_width == 3160) { - height = 2328; - width = 3112; - top_margin = 12; - left_margin = 44; - } else if (is_canon && raw_width == 3344) { - height = 2472; - width = 3288; - top_margin = 6; - left_margin = 4; - } else if (!strcmp(model,"EOS D2000C")) { - filters = 0x61616161; - black = curve[200]; - } else if (!strcmp(model,"EOS-1D")) { - raw_height = height = 1662; - raw_width = width = 2496; - data_offset = 288912; - filters = 0x61616161; - } else if (!strcmp(model,"EOS-1DS")) { - raw_height = height = 2718; - raw_width = width = 4082; - data_offset = 289168; - filters = 0x61616161; - } else if (is_canon && raw_width == 3516) { - top_margin = 14; - left_margin = 42; - goto canon_cr2; - } else if (is_canon && raw_width == 3596) { - top_margin = 12; - left_margin = 74; - goto canon_cr2; - } else if (is_canon && raw_width == 5108) { - top_margin = 13; - left_margin = 98; - maximum = 0xe80; -canon_cr2: - height = raw_height - top_margin; - width = raw_width - left_margin; - } else if (!strcmp(model,"D1")) { - camera_red *= 256/527.0; - camera_blue *= 256/317.0; - } else if (!strcmp(model,"D1X")) { - width = 4024; - ymag = 2; - } else if (!strcmp(model,"D100")) { - if (tiff_data_compression == 34713 && load_raw == nikon_load_raw) - raw_width = (width += 3) + 3; - } else if (!strcmp(model,"D2H")) { - width = 2482; - left_margin = 6; - } else if (!strcmp(model,"D2X")) { - width = 4312; - pre_mul[0] = 1.514; - pre_mul[2] = 1.727; - } else if (fsize == 2465792) { - height = 1203; - width = 1616; - filters = 0x4b4b4b4b; - colors = 4; - load_raw = nikon_e950_load_raw; - nikon_e950_coeff(); - pre_mul[0] = 1.18193; - pre_mul[2] = 1.16452; - pre_mul[3] = 1.17250; - } else if (!strcmp(model,"E990")) { - if (!timestamp && !nikon_e990()) goto cp_e995; - height = 1540; - width = 2064; - colors = 4; - filters = 0xb4b4b4b4; - nikon_e950_coeff(); - pre_mul[0] = 1.196; - pre_mul[1] = 1.246; - pre_mul[2] = 1.018; - } else if (!strcmp(model,"E995")) { -cp_e995: - strcpy (model, "E995"); - height = 1540; - width = 2064; - colors = 4; - filters = 0xe1e1e1e1; - } else if (!strcmp(model,"E2100")) { - if (!timestamp && !nikon_e2100()) goto cp_e2500; - width = 1616; - height = 1206; - load_raw = nikon_e2100_load_raw; - pre_mul[0] = 1.945; - pre_mul[2] = 1.040; - } else if (!strcmp(model,"E2500")) { -cp_e2500: - strcpy (model, "E2500"); - width = 1616; - height = 1204; - colors = 4; - filters = 0x4b4b4b4b; - } else if (!strcmp(model,"E3700")) { - if (!timestamp && pentax_optio33()) goto optio_33wr; - height = 1542; - width = 2064; - load_raw = nikon_e2100_load_raw; - pre_mul[0] = 1.818; - pre_mul[2] = 1.618; - } else if (!strcmp(model,"Optio 33WR")) { -optio_33wr: - strcpy (make, "PENTAX"); - strcpy (model,"Optio 33WR"); - height = 1542; - width = 2064; - load_raw = nikon_e2100_load_raw; - flip = 1; - filters = 0x16161616; - pre_mul[0] = 1.331; - pre_mul[2] = 1.820; - } else if (!strcmp(model,"E4300")) { - if (!timestamp && minolta_z2()) goto dimage_z2; - height = 1710; - width = 2288; - filters = 0x16161616; - pre_mul[0] = 508; - pre_mul[1] = 256; - pre_mul[2] = 322; - } else if (!strcmp(model,"DiMAGE Z2")) { -dimage_z2: - strcpy (make, "MINOLTA"); - strcpy (model,"DiMAGE Z2"); - height = 1710; - width = 2288; - filters = 0x16161616; - load_raw = nikon_e2100_load_raw; - pre_mul[0] = 508; - pre_mul[1] = 256; - pre_mul[2] = 450; - } else if (!strcmp(model,"E4500")) { - height = 1708; - width = 2288; - colors = 4; - filters = 0xb4b4b4b4; - } else if (!strcmp(model,"R-D1")) { - tiff_data_compression = 34713; - load_raw = nikon_load_raw; - } else if (!strcmp(model,"FinePixS2Pro")) { - height = 3584; - width = 3583; - fuji_width = 2144; - filters = 0x61616161; - load_raw = fuji_s2_load_raw; - black = 128; - strcpy (model+7, " S2Pro"); - } else if (!strcmp(model,"FinePix S3Pro")) { - height = 3583; - width = 3584; - fuji_width = 2144; - if (fsize > 18000000 && use_secondary) - data_offset += 4352*2*1444; - filters = 0x49494949; - load_raw = fuji_s3_load_raw; - maximum = 0xffff; - } else if (!strcmp(model,"FinePix S5000")) { - height = 2499; - width = 2500; - fuji_width = 1423; - filters = 0x49494949; - load_raw = fuji_s5000_load_raw; - maximum = 0x3e00; - } else if (!strcmp(model,"FinePix S5100") || - !strcmp(model,"FinePix S5500")) { - height = 1735; - width = 2304; - data_offset += width*10; - filters = 0x49494949; - load_raw = unpacked_load_raw; - maximum = 0xffff; - } else if (!strcmp(model,"FinePix E550") || - !strcmp(model,"FinePix F810") || - !strcmp(model,"FinePix S7000")) { - height = 3587; - width = 3588; - fuji_width = 2047; - filters = 0x49494949; - load_raw = fuji_s7000_load_raw; - maximum = 0x3e00; - } else if (!strcmp(model,"FinePix F700") || - !strcmp(model,"FinePix S20Pro")) { - height = 2523; - width = 2524; - fuji_width = 1440; - filters = 0x49494949; - load_raw = fuji_f700_load_raw; - maximum = 0x3e00; - } else if (!strcmp(model,"Digital Camera KD-400Z")) { - height = 1712; - width = 2312; - raw_width = 2336; - data_offset = 4034; - fseek (ifp, 2032, SEEK_SET); - goto konica_400z; - } else if (!strcmp(model,"Digital Camera KD-510Z")) { - data_offset = 4032; - pre_mul[0] = 1.297; - pre_mul[2] = 1.438; - fseek (ifp, 2032, SEEK_SET); - goto konica_510z; - } else if (!strcasecmp(make,"MINOLTA")) { - load_raw = unpacked_load_raw; - maximum = 0xf7d; - if (!strncmp(model,"DiMAGE A",8)) { - if (!strcmp(model,"DiMAGE A200")) { - filters = 0x49494949; - tmp = camera_red; - camera_red = 1 / camera_blue; - camera_blue = 1 / tmp; - } - load_raw = packed_12_load_raw; - maximum = model[8] == '1' ? 0xf8b : 0xfff; - } else if (!strncmp(model,"ALPHA",5) || - !strncmp(model,"DYNAX",5) || - !strncmp(model,"MAXXUM",6)) { - load_raw = packed_12_load_raw; - maximum = 0xffb; - } else if (!strncmp(model,"DiMAGE G",8)) { - if (model[8] == '4') { - data_offset = 5056; - pre_mul[0] = 1.602; - pre_mul[2] = 1.441; - fseek (ifp, 2078, SEEK_SET); - height = 1716; - width = 2304; - } else if (model[8] == '5') { - data_offset = 4016; - fseek (ifp, 1936, SEEK_SET); -konica_510z: - height = 1956; - width = 2607; - raw_width = 2624; - } else if (model[8] == '6') { - data_offset = 4032; - fseek (ifp, 2030, SEEK_SET); - height = 2136; - width = 2848; - } - filters = 0x61616161; -konica_400z: - load_raw = unpacked_load_raw; - maximum = 0x3df; - order = 0x4d4d; - camera_red = get2(ifp); - camera_blue = get2(ifp); - camera_red /= get2(ifp); - camera_blue /= get2(ifp); - } - if (pre_mul[0] == 1 && pre_mul[2] == 1) { - pre_mul[0] = 1.42; - pre_mul[2] = 1.25; - } - } else if (!strcmp(model,"*ist D")) { - load_raw = unpacked_load_raw; - } else if (!strcmp(model,"*ist DS")) { - height--; - load_raw = packed_12_load_raw; - } else if (!strcmp(model,"Optio S")) { - if (fsize == 3178560) { - height = 1540; - width = 2064; - load_raw = eight_bit_load_raw; - camera_red *= 4; - camera_blue *= 4; - pre_mul[0] = 1.391; - pre_mul[2] = 1.188; - } else { - height = 1544; - width = 2068; - raw_width = 3136; - load_raw = packed_12_load_raw; - maximum = 0xf7c; - pre_mul[0] = 1.137; - pre_mul[2] = 1.453; - } - } else if (!strncmp(model,"Optio S4",8)) { - height = 1737; - width = 2324; - raw_width = 3520; - load_raw = packed_12_load_raw; - maximum = 0xf7a; - pre_mul[0] = 1.980; - pre_mul[2] = 1.570; - } else if (!strcmp(model,"STV680 VGA")) { - height = 484; - width = 644; - load_raw = eight_bit_load_raw; - flip = 2; - filters = 0x16161616; - black = 16; - pre_mul[0] = 1.097; - pre_mul[2] = 1.128; - } else if (!strcmp(make,"Phase One")) { - switch (raw_height) { - case 2060: - strcpy (model, "LightPhase"); - height = 2048; - width = 3080; - top_margin = 5; - left_margin = 22; - pre_mul[0] = 1.331; - pre_mul[2] = 1.154; - break; - case 2682: - strcpy (model, "H10"); - height = 2672; - width = 4012; - top_margin = 5; - left_margin = 26; - break; - case 4128: - strcpy (model, "H20"); - height = 4098; - width = 4098; - top_margin = 20; - left_margin = 26; - pre_mul[0] = 1.963; - pre_mul[2] = 1.430; - break; - case 5488: - strcpy (model, "H25"); - height = 5458; - width = 4098; - top_margin = 20; - left_margin = 26; - pre_mul[0] = 2.80; - pre_mul[2] = 1.20; - } - filters = top_margin & 1 ? 0x94949494 : 0x49494949; - load_raw = phase_one_load_raw; - maximum = 0xffff; - } else if (!strcmp(model,"Ixpress")) { - height = 4084; - width = 4080; - filters = 0x49494949; - load_raw = ixpress_load_raw; - maximum = 0xffff; - pre_mul[0] = 1.963; - pre_mul[2] = 1.430; - } else if (!strcmp(make,"Sinar") && !memcmp(head,"8BPS",4)) { - fseek (ifp, 14, SEEK_SET); - height = get4(ifp); - width = get4(ifp); - filters = 0x61616161; - data_offset = 68; - load_raw = unpacked_load_raw; - maximum = 0xffff; - } else if (!strcmp(make,"Leaf")) { - if (height > width) - filters = 0x16161616; - load_raw = unpacked_load_raw; - maximum = 0x3fff; - strcpy (model, "Valeo"); - if (raw_width == 2060) { - filters = 0; - load_raw = leaf_load_raw; - maximum = 0xffff; - strcpy (model, "Volare"); - } - } else if (!strcmp(model,"DIGILUX 2") || !strcmp(model,"DMC-LC1")) { - height = 1928; - width = 2568; - data_offset = 1024; - load_raw = unpacked_load_raw; - maximum = 0xfff0; - } else if (!strcmp(model,"E-1")) { - filters = 0x61616161; - load_raw = unpacked_load_raw; - maximum = 0xfff0; - black = 1024; - } else if (!strcmp(model,"E-10")) { - load_raw = unpacked_load_raw; - maximum = 0xfff0; - black = 2048; - } else if (!strncmp(model,"E-20",4)) { - load_raw = unpacked_load_raw; - maximum = 0xffc0; - black = 2560; - } else if (!strcmp(model,"E-300")) { - width -= 21; - load_raw = olympus_e300_load_raw; - if (fsize > 15728640) { - load_raw = unpacked_load_raw; - maximum = 0xfc30; - } else - black = 62; - } else if (!strcmp(make,"OLYMPUS")) { - load_raw = olympus_cseries_load_raw; - if (!strcmp(model,"C5050Z") || - !strcmp(model,"C8080WZ")) - filters = 0x16161616; - } else if (!strcmp(model,"N Digital")) { - height = 2047; - width = 3072; - filters = 0x61616161; - data_offset = 0x1a00; - load_raw = packed_12_load_raw; - maximum = 0xf1e; - } else if (!strcmp(model,"DSC-F828")) { - width = 3288; - left_margin = 5; - load_raw = sony_load_raw; - filters = 0x9c9c9c9c; - colors = 4; - black = 491; - } else if (!strcmp(model,"DSC-V3")) { - width = 3109; - left_margin = 59; - load_raw = sony_load_raw; - } else if (!strcasecmp(make,"KODAK")) { - filters = 0x61616161; - if (!strcmp(model,"NC2000F")) { - width -= 4; - left_margin = 1; - for (i=176; i < 0x1000; i++) - curve[i] = curve[i-1]; - pre_mul[0] = 1.509; - pre_mul[2] = 2.686; - } else if (!strcmp(model,"EOSDCS3B")) { - width -= 4; - left_margin = 2; - } else if (!strcmp(model,"EOSDCS1")) { - width -= 4; - left_margin = 2; - } else if (!strcmp(model,"DCS315C")) { - black = 8; - } else if (!strcmp(model,"DCS330C")) { - black = 8; - } else if (!strcmp(model,"DCS420")) { - width -= 4; - left_margin = 2; - } else if (!strcmp(model,"DCS460")) { - width -= 4; - left_margin = 2; - } else if (!strcmp(model,"DCS460A")) { - width -= 4; - left_margin = 2; - colors = 1; - filters = 0; - } else if (!strcmp(model,"DCS520C")) { - black = 180; - } else if (!strcmp(model,"DCS560C")) { - black = 188; - } else if (!strcmp(model,"DCS620C")) { - black = 180; - } else if (!strcmp(model,"DCS620X")) { - black = 185; - } else if (!strcmp(model,"DCS660C")) { - black = 214; - } else if (!strcmp(model,"DCS660M")) { - black = 214; - colors = 1; - filters = 0; - } else if (!strcmp(model,"DCS760M")) { - colors = 1; - filters = 0; - } - switch (tiff_data_compression) { - case 0: /* No compression */ - case 1: - load_raw = kodak_easy_load_raw; - break; - case 7: /* Lossless JPEG */ - load_raw = lossless_jpeg_load_raw; - case 32867: - break; - case 65000: /* Kodak DCR compression */ + if (is_foveon) { if (!have64BitArithmetic) pm_error("This program was built without 64 bit arithmetic " - "capability, and Kodak DCR compression requires it."); - if (kodak_data_compression == 32803) - load_raw = kodak_compressed_load_raw; - else { - load_raw = kodak_yuv_load_raw; - height = (height+1) & -2; - width = (width +1) & -2; + "capability and the Foveon format requires it."); + if (height*2 < width) ymag = 2; + if (width < height) xmag = 2; + filters = 0; + load_raw = foveon_load_raw; + foveon_coeff(&use_coeff, coeff); + } else if (!strcmp(model,"PowerShot 600")) { + height = 613; + width = 854; + colors = 4; + filters = 0xe1e4e1e4; + load_raw = canon_600_load_raw; + } else if (!strcmp(model,"PowerShot A5") || + !strcmp(model,"PowerShot A5 Zoom")) { + height = 773; + width = 960; + raw_width = 992; + colors = 4; + filters = 0x1e4e1e4e; + load_raw = canon_a5_load_raw; + } else if (!strcmp(model,"PowerShot A50")) { + height = 968; + width = 1290; + raw_width = 1320; + colors = 4; + filters = 0x1b4e4b1e; + load_raw = canon_a5_load_raw; + } else if (!strcmp(model,"PowerShot Pro70")) { + height = 1024; + width = 1552; + colors = 4; + filters = 0x1e4b4e1b; + load_raw = canon_a5_load_raw; + black = 34; + } else if (!strcmp(model,"PowerShot Pro90 IS")) { + width = 1896; + colors = 4; + filters = 0xb4b4b4b4; + } else if (is_canon && raw_width == 2144) { + height = 1550; + width = 2088; + top_margin = 8; + left_margin = 4; + if (!strcmp(model,"PowerShot G1")) { + colors = 4; + filters = 0xb4b4b4b4; + } + } else if (is_canon && raw_width == 2224) { + height = 1448; + width = 2176; + top_margin = 6; + left_margin = 48; + } else if (is_canon && raw_width == 2376) { + height = 1720; + width = 2312; + top_margin = 6; + left_margin = 12; + } else if (is_canon && raw_width == 2672) { + height = 1960; + width = 2616; + top_margin = 6; + left_margin = 12; + } else if (is_canon && raw_width == 3152) { + height = 2056; + width = 3088; + top_margin = 12; + left_margin = 64; + maximum = 0xfa0; + } else if (is_canon && raw_width == 3160) { + height = 2328; + width = 3112; + top_margin = 12; + left_margin = 44; + } else if (is_canon && raw_width == 3344) { + height = 2472; + width = 3288; + top_margin = 6; + left_margin = 4; + } else if (!strcmp(model,"EOS D2000C")) { + filters = 0x61616161; + black = curve[200]; + } else if (!strcmp(model,"EOS-1D")) { + raw_height = height = 1662; + raw_width = width = 2496; + data_offset = 288912; + filters = 0x61616161; + } else if (!strcmp(model,"EOS-1DS")) { + raw_height = height = 2718; + raw_width = width = 4082; + data_offset = 289168; + filters = 0x61616161; + } else if (is_canon && raw_width == 3516) { + top_margin = 14; + left_margin = 42; + goto canon_cr2; + } else if (is_canon && raw_width == 3596) { + top_margin = 12; + left_margin = 74; + goto canon_cr2; + } else if (is_canon && raw_width == 5108) { + top_margin = 13; + left_margin = 98; + maximum = 0xe80; + canon_cr2: + height = raw_height - top_margin; + width = raw_width - left_margin; + } else if (!strcmp(model,"D1")) { + camera_red *= 256/527.0; + camera_blue *= 256/317.0; + } else if (!strcmp(model,"D1X")) { + width = 4024; + ymag = 2; + } else if (!strcmp(model,"D100")) { + if (tiff_data_compression == 34713 && load_raw == nikon_load_raw) + raw_width = (width += 3) + 3; + } else if (!strcmp(model,"D2H")) { + width = 2482; + left_margin = 6; + } else if (!strcmp(model,"D2X")) { + width = 4312; + pre_mul[0] = 1.514; + pre_mul[2] = 1.727; + } else if (fsize == 2465792) { + height = 1203; + width = 1616; + filters = 0x4b4b4b4b; + colors = 4; + load_raw = nikon_e950_load_raw; + nikon_e950_coeff(); + pre_mul[0] = 1.18193; + pre_mul[2] = 1.16452; + pre_mul[3] = 1.17250; + } else if (!strcmp(model,"E990")) { + if (!timestamp && !nikon_e990()) goto cp_e995; + height = 1540; + width = 2064; + colors = 4; + filters = 0xb4b4b4b4; + nikon_e950_coeff(); + pre_mul[0] = 1.196; + pre_mul[1] = 1.246; + pre_mul[2] = 1.018; + } else if (!strcmp(model,"E995")) { + cp_e995: + strcpy (model, "E995"); + height = 1540; + width = 2064; + colors = 4; + filters = 0xe1e1e1e1; + } else if (!strcmp(model,"E2100")) { + if (!timestamp && !nikon_e2100()) goto cp_e2500; + width = 1616; + height = 1206; + load_raw = nikon_e2100_load_raw; + pre_mul[0] = 1.945; + pre_mul[2] = 1.040; + } else if (!strcmp(model,"E2500")) { + cp_e2500: + strcpy (model, "E2500"); + width = 1616; + height = 1204; + colors = 4; + filters = 0x4b4b4b4b; + } else if (!strcmp(model,"E3700")) { + if (!timestamp && pentax_optio33()) goto optio_33wr; + height = 1542; + width = 2064; + load_raw = nikon_e2100_load_raw; + pre_mul[0] = 1.818; + pre_mul[2] = 1.618; + } else if (!strcmp(model,"Optio 33WR")) { + optio_33wr: + strcpy (make, "PENTAX"); + strcpy (model,"Optio 33WR"); + height = 1542; + width = 2064; + load_raw = nikon_e2100_load_raw; + flip = 1; + filters = 0x16161616; + pre_mul[0] = 1.331; + pre_mul[2] = 1.820; + } else if (!strcmp(model,"E4300")) { + if (!timestamp && minolta_z2()) goto dimage_z2; + height = 1710; + width = 2288; + filters = 0x16161616; + pre_mul[0] = 508; + pre_mul[1] = 256; + pre_mul[2] = 322; + } else if (!strcmp(model,"DiMAGE Z2")) { + dimage_z2: + strcpy (make, "MINOLTA"); + strcpy (model,"DiMAGE Z2"); + height = 1710; + width = 2288; + filters = 0x16161616; + load_raw = nikon_e2100_load_raw; + pre_mul[0] = 508; + pre_mul[1] = 256; + pre_mul[2] = 450; + } else if (!strcmp(model,"E4500")) { + height = 1708; + width = 2288; + colors = 4; + filters = 0xb4b4b4b4; + } else if (!strcmp(model,"R-D1")) { + tiff_data_compression = 34713; + load_raw = nikon_load_raw; + } else if (!strcmp(model,"FinePixS2Pro")) { + height = 3584; + width = 3583; + fuji_width = 2144; + filters = 0x61616161; + load_raw = fuji_s2_load_raw; + black = 128; + strcpy (model+7, " S2Pro"); + } else if (!strcmp(model,"FinePix S3Pro")) { + height = 3583; + width = 3584; + fuji_width = 2144; + if (fsize > 18000000 && use_secondary) + data_offset += 4352*2*1444; + filters = 0x49494949; + load_raw = fuji_s3_load_raw; + maximum = 0xffff; + } else if (!strcmp(model,"FinePix S5000")) { + height = 2499; + width = 2500; + fuji_width = 1423; + filters = 0x49494949; + load_raw = fuji_s5000_load_raw; + maximum = 0x3e00; + } else if (!strcmp(model,"FinePix S5100") || + !strcmp(model,"FinePix S5500")) { + height = 1735; + width = 2304; + data_offset += width*10; + filters = 0x49494949; + load_raw = unpacked_load_raw; + maximum = 0xffff; + } else if (!strcmp(model,"FinePix E550") || + !strcmp(model,"FinePix F810") || + !strcmp(model,"FinePix S7000")) { + height = 3587; + width = 3588; + fuji_width = 2047; + filters = 0x49494949; + load_raw = fuji_s7000_load_raw; + maximum = 0x3e00; + } else if (!strcmp(model,"FinePix F700") || + !strcmp(model,"FinePix S20Pro")) { + height = 2523; + width = 2524; + fuji_width = 1440; + filters = 0x49494949; + load_raw = fuji_f700_load_raw; + maximum = 0x3e00; + } else if (!strcmp(model,"Digital Camera KD-400Z")) { + height = 1712; + width = 2312; + raw_width = 2336; + data_offset = 4034; + fseek (ifp, 2032, SEEK_SET); + goto konica_400z; + } else if (!strcmp(model,"Digital Camera KD-510Z")) { + data_offset = 4032; + pre_mul[0] = 1.297; + pre_mul[2] = 1.438; + fseek (ifp, 2032, SEEK_SET); + goto konica_510z; + } else if (!strcasecmp(make,"MINOLTA")) { + load_raw = unpacked_load_raw; + maximum = 0xf7d; + if (!strncmp(model,"DiMAGE A",8)) { + if (!strcmp(model,"DiMAGE A200")) { + filters = 0x49494949; + tmp = camera_red; + camera_red = 1 / camera_blue; + camera_blue = 1 / tmp; + } + load_raw = packed_12_load_raw; + maximum = model[8] == '1' ? 0xf8b : 0xfff; + } else if (!strncmp(model,"ALPHA",5) || + !strncmp(model,"DYNAX",5) || + !strncmp(model,"MAXXUM",6)) { + load_raw = packed_12_load_raw; + maximum = 0xffb; + } else if (!strncmp(model,"DiMAGE G",8)) { + if (model[8] == '4') { + data_offset = 5056; + pre_mul[0] = 1.602; + pre_mul[2] = 1.441; + fseek (ifp, 2078, SEEK_SET); + height = 1716; + width = 2304; + } else if (model[8] == '5') { + data_offset = 4016; + fseek (ifp, 1936, SEEK_SET); + konica_510z: + height = 1956; + width = 2607; + raw_width = 2624; + } else if (model[8] == '6') { + data_offset = 4032; + fseek (ifp, 2030, SEEK_SET); + height = 2136; + width = 2848; + } + filters = 0x61616161; + konica_400z: + load_raw = unpacked_load_raw; + maximum = 0x3df; + order = 0x4d4d; + camera_red = get2(ifp); + camera_blue = get2(ifp); + camera_red /= get2(ifp); + camera_blue /= get2(ifp); + } + if (pre_mul[0] == 1 && pre_mul[2] == 1) { + pre_mul[0] = 1.42; + pre_mul[2] = 1.25; + } + } else if (!strcmp(model,"*ist D")) { + load_raw = unpacked_load_raw; + } else if (!strcmp(model,"*ist DS")) { + height--; + load_raw = packed_12_load_raw; + } else if (!strcmp(model,"Optio S")) { + if (fsize == 3178560) { + height = 1540; + width = 2064; + load_raw = eight_bit_load_raw; + camera_red *= 4; + camera_blue *= 4; + pre_mul[0] = 1.391; + pre_mul[2] = 1.188; + } else { + height = 1544; + width = 2068; + raw_width = 3136; + load_raw = packed_12_load_raw; + maximum = 0xf7c; + pre_mul[0] = 1.137; + pre_mul[2] = 1.453; + } + } else if (!strncmp(model,"Optio S4",8)) { + height = 1737; + width = 2324; + raw_width = 3520; + load_raw = packed_12_load_raw; + maximum = 0xf7a; + pre_mul[0] = 1.980; + pre_mul[2] = 1.570; + } else if (!strcmp(model,"STV680 VGA")) { + height = 484; + width = 644; + load_raw = eight_bit_load_raw; + flip = 2; + filters = 0x16161616; + black = 16; + pre_mul[0] = 1.097; + pre_mul[2] = 1.128; + } else if (!strcmp(make,"Phase One")) { + switch (raw_height) { + case 2060: + strcpy (model, "LightPhase"); + height = 2048; + width = 3080; + top_margin = 5; + left_margin = 22; + pre_mul[0] = 1.331; + pre_mul[2] = 1.154; + break; + case 2682: + strcpy (model, "H10"); + height = 2672; + width = 4012; + top_margin = 5; + left_margin = 26; + break; + case 4128: + strcpy (model, "H20"); + height = 4098; + width = 4098; + top_margin = 20; + left_margin = 26; + pre_mul[0] = 1.963; + pre_mul[2] = 1.430; + break; + case 5488: + strcpy (model, "H25"); + height = 5458; + width = 4098; + top_margin = 20; + left_margin = 26; + pre_mul[0] = 2.80; + pre_mul[2] = 1.20; + } + filters = top_margin & 1 ? 0x94949494 : 0x49494949; + load_raw = phase_one_load_raw; + maximum = 0xffff; + } else if (!strcmp(model,"Ixpress")) { + height = 4084; + width = 4080; + filters = 0x49494949; + load_raw = ixpress_load_raw; + maximum = 0xffff; + pre_mul[0] = 1.963; + pre_mul[2] = 1.430; + } else if (!strcmp(make,"Sinar") && !memcmp(head,"8BPS",4)) { + fseek (ifp, 14, SEEK_SET); + height = get4(ifp); + width = get4(ifp); + filters = 0x61616161; + data_offset = 68; + load_raw = unpacked_load_raw; + maximum = 0xffff; + } else if (!strcmp(make,"Leaf")) { + if (height > width) + filters = 0x16161616; + load_raw = unpacked_load_raw; + maximum = 0x3fff; + strcpy (model, "Valeo"); + if (raw_width == 2060) { filters = 0; + load_raw = leaf_load_raw; + maximum = 0xffff; + strcpy (model, "Volare"); + } + } else if (!strcmp(model,"DIGILUX 2") || !strcmp(model,"DMC-LC1")) { + height = 1928; + width = 2568; + data_offset = 1024; + load_raw = unpacked_load_raw; + maximum = 0xfff0; + } else if (!strcmp(model,"E-1")) { + filters = 0x61616161; + load_raw = unpacked_load_raw; + maximum = 0xfff0; + black = 1024; + } else if (!strcmp(model,"E-10")) { + load_raw = unpacked_load_raw; + maximum = 0xfff0; + black = 2048; + } else if (!strncmp(model,"E-20",4)) { + load_raw = unpacked_load_raw; + maximum = 0xffc0; + black = 2560; + } else if (!strcmp(model,"E-300")) { + width -= 21; + load_raw = olympus_e300_load_raw; + if (fsize > 15728640) { + load_raw = unpacked_load_raw; + maximum = 0xfc30; + } else + black = 62; + } else if (!strcmp(make,"OLYMPUS")) { + load_raw = olympus_cseries_load_raw; + if (!strcmp(model,"C5050Z") || + !strcmp(model,"C8080WZ")) + filters = 0x16161616; + } else if (!strcmp(model,"N Digital")) { + height = 2047; + width = 3072; + filters = 0x61616161; + data_offset = 0x1a00; + load_raw = packed_12_load_raw; + maximum = 0xf1e; + } else if (!strcmp(model,"DSC-F828")) { + width = 3288; + left_margin = 5; + load_raw = sony_load_raw; + filters = 0x9c9c9c9c; + colors = 4; + black = 491; + } else if (!strcmp(model,"DSC-V3")) { + width = 3109; + left_margin = 59; + load_raw = sony_load_raw; + } else if (!strcasecmp(make,"KODAK")) { + filters = 0x61616161; + if (!strcmp(model,"NC2000F")) { + width -= 4; + left_margin = 1; + for (i=176; i < 0x1000; i++) + curve[i] = curve[i-1]; + pre_mul[0] = 1.509; + pre_mul[2] = 2.686; + } else if (!strcmp(model,"EOSDCS3B")) { + width -= 4; + left_margin = 2; + } else if (!strcmp(model,"EOSDCS1")) { + width -= 4; + left_margin = 2; + } else if (!strcmp(model,"DCS315C")) { + black = 8; + } else if (!strcmp(model,"DCS330C")) { + black = 8; + } else if (!strcmp(model,"DCS420")) { + width -= 4; + left_margin = 2; + } else if (!strcmp(model,"DCS460")) { + width -= 4; + left_margin = 2; + } else if (!strcmp(model,"DCS460A")) { + width -= 4; + left_margin = 2; + colors = 1; + filters = 0; + } else if (!strcmp(model,"DCS520C")) { + black = 180; + } else if (!strcmp(model,"DCS560C")) { + black = 188; + } else if (!strcmp(model,"DCS620C")) { + black = 180; + } else if (!strcmp(model,"DCS620X")) { + black = 185; + } else if (!strcmp(model,"DCS660C")) { + black = 214; + } else if (!strcmp(model,"DCS660M")) { + black = 214; + colors = 1; + filters = 0; + } else if (!strcmp(model,"DCS760M")) { + colors = 1; + filters = 0; + } + switch (tiff_data_compression) { + case 0: /* No compression */ + case 1: + load_raw = kodak_easy_load_raw; + break; + case 7: /* Lossless JPEG */ + load_raw = lossless_jpeg_load_raw; + case 32867: + break; + case 65000: /* Kodak DCR compression */ + if (!have64BitArithmetic) + pm_error("This program was built without 64 bit arithmetic " + "capability, and Kodak DCR compression requires it."); + if (kodak_data_compression == 32803) + load_raw = kodak_compressed_load_raw; + else { + load_raw = kodak_yuv_load_raw; + height = (height+1) & -2; + width = (width +1) & -2; + filters = 0; + } + break; + default: + pm_message ("%s %s uses unrecognized compression method %d.", + make, model, tiff_data_compression); + return 1; + } + if (!strcmp(model,"DC20")) { + height = 242; + if (fsize < 100000) { + width = 249; + raw_width = 256; + } else { + width = 501; + raw_width = 512; + } + data_offset = raw_width + 1; + colors = 4; + filters = 0x8d8d8d8d; + kodak_dc20_coeff (1.0); + pre_mul[1] = 1.179; + pre_mul[2] = 1.209; + pre_mul[3] = 1.036; + load_raw = kodak_easy_load_raw; + } else if (strstr(model,"DC25")) { + strcpy (model, "DC25"); + height = 242; + if (fsize < 100000) { + width = 249; + raw_width = 256; + data_offset = 15681; + } else { + width = 501; + raw_width = 512; + data_offset = 15937; + } + colors = 4; + filters = 0xb4b4b4b4; + load_raw = kodak_easy_load_raw; + } else if (!strcmp(model,"Digital Camera 40")) { + strcpy (model, "DC40"); + height = 512; + width = 768; + data_offset = 1152; + load_raw = kodak_radc_load_raw; + } else if (strstr(model,"DC50")) { + strcpy (model, "DC50"); + height = 512; + width = 768; + data_offset = 19712; + load_raw = kodak_radc_load_raw; + } else if (strstr(model,"DC120")) { + strcpy (model, "DC120"); + height = 976; + width = 848; + if (tiff_data_compression == 7) + load_raw = kodak_jpeg_load_raw; + else + load_raw = kodak_dc120_load_raw; + } + } else if (!strcmp(make,"Rollei")) { + switch (raw_width) { + case 1316: + height = 1030; + width = 1300; + top_margin = 1; + left_margin = 6; + break; + case 2568: + height = 1960; + width = 2560; + top_margin = 2; + left_margin = 8; + } + filters = 0x16161616; + load_raw = rollei_load_raw; + pre_mul[0] = 1.8; + pre_mul[2] = 1.3; + } else if (!strcmp(model,"PC-CAM 600")) { + height = 768; + data_offset = width = 1024; + filters = 0x49494949; + load_raw = eight_bit_load_raw; + pre_mul[0] = 1.14; + pre_mul[2] = 2.73; + } else if (!strcmp(model,"QV-2000UX")) { + height = 1208; + width = 1632; + data_offset = width * 2; + load_raw = eight_bit_load_raw; + } else if (!strcmp(model,"QV-3*00EX")) { + height = 1546; + width = 2070; + raw_width = 2080; + load_raw = eight_bit_load_raw; + } else if (!strcmp(model,"QV-4000")) { + height = 1700; + width = 2260; + load_raw = unpacked_load_raw; + maximum = 0xffff; + } else if (!strcmp(model,"QV-5700")) { + height = 1924; + width = 2576; + load_raw = casio_qv5700_load_raw; + } else if (!strcmp(model,"QV-R51")) { + height = 1926; + width = 2576; + raw_width = 3904; + load_raw = packed_12_load_raw; + pre_mul[0] = 1.340; + pre_mul[2] = 1.672; + } else if (!strcmp(model,"EX-Z55")) { + height = 1960; + width = 2570; + raw_width = 3904; + load_raw = packed_12_load_raw; + pre_mul[0] = 1.520; + pre_mul[2] = 1.316; + } else if (!strcmp(model,"EX-P600")) { + height = 2142; + width = 2844; + raw_width = 4288; + load_raw = packed_12_load_raw; + pre_mul[0] = 1.797; + pre_mul[2] = 1.219; + } else if (!strcmp(model,"EX-P700")) { + height = 2318; + width = 3082; + raw_width = 4672; + load_raw = packed_12_load_raw; + pre_mul[0] = 1.758; + pre_mul[2] = 1.504; + } else if (!strcmp(make,"Nucore")) { + filters = 0x61616161; + load_raw = unpacked_load_raw; + if (width == 2598) { + filters = 0x16161616; + load_raw = nucore_load_raw; + flip = 2; } - break; - default: - pm_message ("%s %s uses unrecognized compression method %d.", - make, model, tiff_data_compression); - return 1; - } - if (!strcmp(model,"DC20")) { - height = 242; - if (fsize < 100000) { - width = 249; - raw_width = 256; - } else { - width = 501; - raw_width = 512; - } - data_offset = raw_width + 1; - colors = 4; - filters = 0x8d8d8d8d; - kodak_dc20_coeff (1.0); - pre_mul[1] = 1.179; - pre_mul[2] = 1.209; - pre_mul[3] = 1.036; - load_raw = kodak_easy_load_raw; - } else if (strstr(model,"DC25")) { - strcpy (model, "DC25"); - height = 242; - if (fsize < 100000) { - width = 249; - raw_width = 256; - data_offset = 15681; - } else { - width = 501; - raw_width = 512; - data_offset = 15937; - } - colors = 4; - filters = 0xb4b4b4b4; - load_raw = kodak_easy_load_raw; - } else if (!strcmp(model,"Digital Camera 40")) { - strcpy (model, "DC40"); - height = 512; - width = 768; - data_offset = 1152; - load_raw = kodak_radc_load_raw; - } else if (strstr(model,"DC50")) { - strcpy (model, "DC50"); - height = 512; - width = 768; - data_offset = 19712; - load_raw = kodak_radc_load_raw; - } else if (strstr(model,"DC120")) { - strcpy (model, "DC120"); - height = 976; - width = 848; - if (tiff_data_compression == 7) - load_raw = kodak_jpeg_load_raw; - else - load_raw = kodak_dc120_load_raw; - } - } else if (!strcmp(make,"Rollei")) { - switch (raw_width) { - case 1316: - height = 1030; - width = 1300; - top_margin = 1; - left_margin = 6; - break; - case 2568: - height = 1960; - width = 2560; - top_margin = 2; - left_margin = 8; - } - filters = 0x16161616; - load_raw = rollei_load_raw; - pre_mul[0] = 1.8; - pre_mul[2] = 1.3; - } else if (!strcmp(model,"PC-CAM 600")) { - height = 768; - data_offset = width = 1024; - filters = 0x49494949; - load_raw = eight_bit_load_raw; - pre_mul[0] = 1.14; - pre_mul[2] = 2.73; - } else if (!strcmp(model,"QV-2000UX")) { - height = 1208; - width = 1632; - data_offset = width * 2; - load_raw = eight_bit_load_raw; - } else if (!strcmp(model,"QV-3*00EX")) { - height = 1546; - width = 2070; - raw_width = 2080; - load_raw = eight_bit_load_raw; - } else if (!strcmp(model,"QV-4000")) { - height = 1700; - width = 2260; - load_raw = unpacked_load_raw; - maximum = 0xffff; - } else if (!strcmp(model,"QV-5700")) { - height = 1924; - width = 2576; - load_raw = casio_qv5700_load_raw; - } else if (!strcmp(model,"QV-R51")) { - height = 1926; - width = 2576; - raw_width = 3904; - load_raw = packed_12_load_raw; - pre_mul[0] = 1.340; - pre_mul[2] = 1.672; - } else if (!strcmp(model,"EX-Z55")) { - height = 1960; - width = 2570; - raw_width = 3904; - load_raw = packed_12_load_raw; - pre_mul[0] = 1.520; - pre_mul[2] = 1.316; - } else if (!strcmp(model,"EX-P600")) { - height = 2142; - width = 2844; - raw_width = 4288; - load_raw = packed_12_load_raw; - pre_mul[0] = 1.797; - pre_mul[2] = 1.219; - } else if (!strcmp(model,"EX-P700")) { - height = 2318; - width = 3082; - raw_width = 4672; - load_raw = packed_12_load_raw; - pre_mul[0] = 1.758; - pre_mul[2] = 1.504; - } else if (!strcmp(make,"Nucore")) { - filters = 0x61616161; - load_raw = unpacked_load_raw; - if (width == 2598) { - filters = 0x16161616; - load_raw = nucore_load_raw; - flip = 2; } - } - if (!use_coeff) adobe_coeff(); + if (!use_coeff) adobe_coeff(); dng_skip: - if (!load_raw || !height) { - pm_message ("This program cannot handle data from %s %s.", - make, model); - return 1; - } + if (!load_raw || !height) { + pm_message ("This program cannot handle data from %s %s.", + make, model); + return 1; + } #ifdef NO_JPEG - if (load_raw == kodak_jpeg_load_raw) { - pm_message ("decoder was not linked with libjpeg."); - return 1; - } -#endif - if (!raw_height) raw_height = height; - if (!raw_width ) raw_width = width; - if (use_camera_rgb && colors == 3) - use_coeff = 0; - if (use_coeff) /* Apply user-selected color balance */ - for (i=0; i < colors; i++) { - coeff[0][i] *= red_scale; - coeff[2][i] *= blue_scale; + if (load_raw == kodak_jpeg_load_raw) { + pm_message ("decoder was not linked with libjpeg."); + return 1; } - if (four_color_rgb && filters && colors == 3) { - for (i=0; i < 32; i+=4) { - if ((filters >> i & 15) == 9) - filters |= 2 << i; - if ((filters >> i & 15) == 6) - filters |= 8 << i; +#endif + if (!raw_height) raw_height = height; + if (!raw_width ) raw_width = width; + if (use_camera_rgb && colors == 3) + use_coeff = 0; + if (use_coeff) /* Apply user-selected color balance */ + for (i=0; i < colors; i++) { + coeff[0][i] *= red_scale; + coeff[2][i] *= blue_scale; + } + if (four_color_rgb && filters && colors == 3) { + for (i=0; i < 32; i+=4) { + if ((filters >> i & 15) == 9) + filters |= 2 << i; + if ((filters >> i & 15) == 6) + filters |= 8 << i; + } + colors++; + pre_mul[3] = pre_mul[1]; + if (use_coeff) + for (i=0; i < 3; i++) + coeff[i][3] = coeff[i][1] /= 2; } - colors++; - pre_mul[3] = pre_mul[1]; - if (use_coeff) - for (i=0; i < 3; i++) - coeff[i][3] = coeff[i][1] /= 2; - } - fseek (ifp, data_offset, SEEK_SET); + fseek (ifp, data_offset, SEEK_SET); - *loadRawFnP = load_raw; + *loadRawFnP = load_raw; - return 0; + return 0; } diff --git a/converter/other/exif.c b/converter/other/exif.c index 19f108a7..fbfb0629 100644 --- a/converter/other/exif.c +++ b/converter/other/exif.c @@ -818,7 +818,7 @@ process_EXIF(unsigned char * const ExifData, if (ShowTags){ fprintf(stderr, - "Non-settings part of Exif header: %d bytes\n", + "Non-settings part of Exif header: %lu bytes\n", ExifData+length-LastExifRefd); } } diff --git a/converter/other/fiasco/lib/dither.c b/converter/other/fiasco/lib/dither.c index a39afa3c..a26e0541 100644 --- a/converter/other/fiasco/lib/dither.c +++ b/converter/other/fiasco/lib/dither.c @@ -65,19 +65,22 @@ static int display_16_bit (const struct fiasco_renderer *this, unsigned char *ximage, const fiasco_image_t *fiasco_image); + static int display_24_bit_bgr (const struct fiasco_renderer *this, unsigned char *ximage, const fiasco_image_t *fiasco_image); + static int display_24_bit_rgb (const struct fiasco_renderer *this, unsigned char *ximage, const fiasco_image_t *fiasco_image); + static int display_32_bit (const struct fiasco_renderer *this, unsigned char *ximage, const fiasco_image_t *fiasco_image); + static int free_bits_at_bottom (unsigned long a); -static int -free_bits_at_top (unsigned long a); + static int number_of_bits_set (unsigned long a); @@ -345,21 +348,6 @@ number_of_bits_set (unsigned long a) } static int -free_bits_at_top (unsigned long a) -/* - * How many 0 bits are there at most significant end of longword. - * Low performance, do not call often. - */ -{ - if(!a) /* assume char is 8 bits */ - return sizeof (unsigned long) * 8; - else if (((long) a) < 0l) /* assume twos complement */ - return 0; - else - return 1 + free_bits_at_top ( a << 1); -} - -static int free_bits_at_bottom (unsigned long a) /* * How many 0 bits are there at least significant end of longword. diff --git a/converter/other/fiasco/params.c b/converter/other/fiasco/params.c index 7a302b82..a5aefbd6 100644 --- a/converter/other/fiasco/params.c +++ b/converter/other/fiasco/params.c @@ -631,6 +631,8 @@ read_parameter_file (param_t *params, FILE *file) } } + + static void usage (const param_t *params, const char *progname, const char *synopsis, const char *comment, const char *non_opt_string, @@ -647,82 +649,84 @@ usage (const param_t *params, const char *progname, const char *synopsis, * No return value. */ { - int i; - size_t width = 0; + int i; + size_t width = 0; - fprintf (stderr, "Usage: %s [OPTION]...%s\n", progname, - non_opt_string ? non_opt_string : " "); - if (synopsis != NULL) - fprintf (stderr, synopsis); - fprintf (stderr, "\n\n"); - fprintf (stderr, "Mandatory or optional arguments to long options " - "are mandatory or optional\nfor short options too. " - "Default values are surrounded by {}.\n"); - for (i = 0; params [i].name != NULL; i++) - if (params [i].optchar != '\0' || show_all_options) - { - if (params [i].type == POSTR) - width = max (width, (strlen (params [i].name) - + strlen (params [i].argument_name) + 2)); - else if (params [i].type != PFLAG) - width = max (width, (strlen (params [i].name) - + strlen (params [i].argument_name))); - else - width = max (width, (strlen (params [i].name)) - 1); - } + fprintf (stderr, "Usage: %s [OPTION]...%s\n", progname, + non_opt_string ? non_opt_string : " "); + if (synopsis != NULL) + fprintf (stderr, synopsis); + fprintf (stderr, "\n\n"); + fprintf (stderr, "Mandatory or optional arguments to long options " + "are mandatory or optional\nfor short options too. " + "Default values are surrounded by {}.\n"); + for (i = 0; params [i].name != NULL; i++) + if (params [i].optchar != '\0' || show_all_options) + { + if (params [i].type == POSTR) + width = max (width, (strlen (params [i].name) + + strlen (params [i].argument_name) + 2)); + else if (params [i].type != PFLAG) + width = max (width, (strlen (params [i].name) + + strlen (params [i].argument_name))); + else + width = max (width, (strlen (params [i].name)) - 1); + } - for (i = 0; params [i].name != NULL; i++) - if (params [i].optchar != '\0' || show_all_options) - { - if (params [i].optchar != '\0') - fprintf (stderr, " -%c, --", params [i].optchar); - else - fprintf (stderr, " --"); + for (i = 0; params [i].name != NULL; i++) + if (params [i].optchar != '\0' || show_all_options) + { + if (params [i].optchar != '\0') + fprintf (stderr, " -%c, --", params [i].optchar); + else + fprintf (stderr, " --"); - if (params [i].type == POSTR) - fprintf (stderr, "%s=[%s]%-*s ", params [i].name, - params [i].argument_name, - max (0, (width - 2 - strlen (params [i].name) - - strlen (params [i].argument_name))), ""); - else if (params [i].type != PFLAG) - fprintf (stderr, "%s=%-*s ", params [i].name, - width - strlen (params [i].name), - params [i].argument_name); - else - fprintf (stderr, "%-*s ", width + 1, params [i].name); - - fprintf (stderr, params [i].use, params [i].argument_name); + if (params [i].type == POSTR) + fprintf (stderr, "%s=[%s]%-*s ", params [i].name, + params [i].argument_name, + (unsigned) + max(0, (width - 2 - strlen (params [i].name) + - strlen (params [i].argument_name))), ""); + else if (params [i].type != PFLAG) + fprintf (stderr, "%s=%-*s ", params [i].name, + (unsigned)(width - strlen (params [i].name)), + params [i].argument_name); + else + fprintf (stderr, "%-*s ", + (unsigned)(width + 1), params [i].name); + + fprintf (stderr, params [i].use, params [i].argument_name); - switch (params [i].type) - { - case PFLAG: - break; - case PINT: - fprintf (stderr, "{%d}", params [i].value.i); - break; - case PFLOAT: - fprintf (stderr, "{%.2f}", (double) params [i].value.f); - break; - case PSTR: - case POSTR: - if (params [i].value.s) - fprintf (stderr, "{%s}", params [i].value.s); - break; - default: - error ("type %d for %s invalid", - params [i].type, params [i].name); - } - fprintf (stderr, "\n"); - } - fprintf (stderr, "\n"); - fprintf (stderr, "Parameter initialization order:\n"); - fprintf (stderr, - "1.) %s\n2.) $HOME/%s\t 3.) command line\t 4.) --config=file", - sys_file_name, usr_file_name); - fprintf (stderr, "\n\n"); - if (comment != NULL) - fprintf (stderr, "%s\n", comment); - - exit (1); + switch (params [i].type) + { + case PFLAG: + break; + case PINT: + fprintf (stderr, "{%d}", params [i].value.i); + break; + case PFLOAT: + fprintf (stderr, "{%.2f}", (double) params [i].value.f); + break; + case PSTR: + case POSTR: + if (params [i].value.s) + fprintf (stderr, "{%s}", params [i].value.s); + break; + default: + error ("type %d for %s invalid", + params [i].type, params [i].name); + } + fprintf (stderr, "\n"); + } + fprintf (stderr, "\n"); + fprintf (stderr, "Parameter initialization order:\n"); + fprintf (stderr, + "1.) %s\n2.) $HOME/%s\t 3.) command line\t 4.) --config=file", + sys_file_name, usr_file_name); + fprintf (stderr, "\n\n"); + if (comment != NULL) + fprintf (stderr, "%s\n", comment); + + exit (1); } diff --git a/converter/other/infotopam.c b/converter/other/infotopam.c index 21fa8ee2..69080a35 100644 --- a/converter/other/infotopam.c +++ b/converter/other/infotopam.c @@ -233,33 +233,33 @@ getDiskObject( IconInfo * const infoP ) { /* Read the disk object header */ bytesRead = fread( &dobj, 1, sizeof(dobj), infoP->fp ); if (ferror(infoP->fp)) - pm_error( "Cannot read disk object header for file '%s'. " - "fread() errno = %d (%s)", - infoP->name, errno, strerror( errno ) ); - else if ( bytesRead != sizeof(dobj) ) - pm_error( "Cannot read entire disk object header for file '%s'. " - "Only read 0x%X of 0x%X bytes", - infoP->name, bytesRead, sizeof(dobj) ); + pm_error("Cannot read disk object header for file '%s'. " + "fread() errno = %d (%s)", + infoP->name, errno, strerror(errno)); + else if (bytesRead != sizeof(dobj)) + pm_error("Cannot read entire disk object header for file '%s'. " + "Only read 0x%X of 0x%X bytes", + infoP->name, (unsigned)bytesRead, (unsigned)sizeof(dobj)); /* Check magic number */ - if ( ( dobj.magic[0] != 0xE3 ) && ( dobj.magic[1] != 0x10 ) ) - pm_error( "Wrong magic number for file '%s'. " - "Expected 0xE310, but got 0x%X%X", - infoP->name, dobj.magic[0], dobj.magic[1] ); + if ((dobj.magic[0] != 0xE3) && (dobj.magic[1] != 0x10)) + pm_error("Wrong magic number for file '%s'. " + "Expected 0xE310, but got 0x%X%X", + infoP->name, dobj.magic[0], dobj.magic[1]); /* Set version info and have drawer data flag */ - infoP->version = ( dobj.version[0] << 8 ) + - ( dobj.version[1] ); - infoP->drawerData = ( dobj.pDrawerData[0] << 24 ) + - ( dobj.pDrawerData[1] << 16 ) + - ( dobj.pDrawerData[2] << 8 ) + - ( dobj.pDrawerData[3] ) ? TRUE : FALSE; + infoP->version = (dobj.version[0] << 8) + + (dobj.version[1] ); + infoP->drawerData = (dobj.pDrawerData[0] << 24) + + (dobj.pDrawerData[1] << 16) + + (dobj.pDrawerData[2] << 8) + + (dobj.pDrawerData[3] ) ? TRUE : FALSE; } static void -getIconHeader( IconInfo * const infoP ) { +getIconHeader(IconInfo * const infoP) { /*------------------------------------------------------------------------- * Get fields from icon header portion of info file *-------------------------------------------------------------------------*/ @@ -267,25 +267,25 @@ getIconHeader( IconInfo * const infoP ) { size_t bytesRead; /* Read icon header */ - bytesRead = fread( &ihead, 1, sizeof(ihead), infoP->fp ); - if ( ferror(infoP->fp ) ) - pm_error( "Cannot read icon header for file '%s'. " - "fread() errno = %d (%s)", - infoP->name, errno, strerror( errno ) ); - else if ( bytesRead != sizeof(ihead) ) - pm_error( "Cannot read the entire icon header for file '%s'. " - "Only read 0x%X of 0x%X bytes", - infoP->name, bytesRead, sizeof(ihead) ); + bytesRead = fread(&ihead, 1, sizeof(ihead), infoP->fp); + if (ferror(infoP->fp)) + pm_error("Cannot read icon header for file '%s'. " + "fread() errno = %d (%s)", + infoP->name, errno, strerror(errno)); + else if (bytesRead != sizeof(ihead)) + pm_error("Cannot read the entire icon header for file '%s'. " + "Only read 0x%X of 0x%X bytes", + infoP->name, (unsigned)bytesRead, (unsigned)sizeof(ihead)); /* Get icon width, heigh, and bitplanes */ - infoP->width = ( ihead.iconWidth[0] << 8 ) + ihead.iconWidth[1]; - infoP->height = ( ihead.iconHeight[0] << 8 ) + ihead.iconHeight[1]; - infoP->depth = ( ihead.bpp[0] << 8 ) + ihead.bpp[1]; + infoP->width = (ihead.iconWidth[0] << 8) + ihead.iconWidth[1]; + infoP->height = (ihead.iconHeight[0] << 8) + ihead.iconHeight[1]; + infoP->depth = (ihead.bpp[0] << 8) + ihead.bpp[1]; /* Check number of bit planes */ - if ( ( infoP->depth > 2 ) || ( infoP->depth < 1 ) ) - pm_error( "We don't know how to interpret %u bitplanes file '%s'. ", - infoP->depth, infoP->name ); + if ((infoP->depth > 2) || (infoP->depth < 1)) + pm_error("We don't know how to interpret %u bitplanes file '%s'. ", + infoP->depth, infoP->name); } diff --git a/converter/other/pamtosvg/bitmap.c b/converter/other/pamtosvg/bitmap.c index 1a00e748..84a8a8ae 100644 --- a/converter/other/pamtosvg/bitmap.c +++ b/converter/other/pamtosvg/bitmap.c @@ -59,8 +59,8 @@ at_bitmap_init(unsigned char * area, if (bitmap.bitmap == NULL) pm_error("Unable to allocate %u x %u x %u bitmap array", width, height, planes); - bzero(bitmap.bitmap, - width * height * planes * sizeof(unsigned char)); + memset(bitmap.bitmap, + 0, width * height * planes * sizeof(unsigned char)); } } diff --git a/converter/other/pamtosvg/image-proc.c b/converter/other/pamtosvg/image-proc.c index 287e6384..b044b547 100644 --- a/converter/other/pamtosvg/image-proc.c +++ b/converter/other/pamtosvg/image-proc.c @@ -52,7 +52,7 @@ new_distance_map(bitmap_type bitmap, unsigned char target_value, bool padded, at MALLOCARRAY(dist.d[y], w); if (dist.d[y] == NULL) pm_error("Unable to get memory for distance map"); - bzero(dist.d[y], w * sizeof(float)); + memset(dist.d[y], 0, w * sizeof(float)); MALLOCARRAY(dist.weight[y], w); if (dist.weight[y] == NULL) diff --git a/converter/other/pamtosvg/vector.c b/converter/other/pamtosvg/vector.c index 7678f73a..0a5ef3a9 100644 --- a/converter/other/pamtosvg/vector.c +++ b/converter/other/pamtosvg/vector.c @@ -1,5 +1,6 @@ /* vector.c: vector/point operations. */ +#define _XOPEN_SOURCE /* Make sure M_PI is in <math.h> */ #include <math.h> #include <errno.h> #include <assert.h> diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c index 198aa156..ef1df617 100644 --- a/converter/other/pnmtojpeg.c +++ b/converter/other/pnmtojpeg.c @@ -898,7 +898,7 @@ write_exif_header(struct jpeg_compress_struct * const cinfoP, pm_error("Invalid length %u at start of exif file", length); else { unsigned char * exif_data; - int rc; + size_t rc; size_t const data_length = length - 2; /* Subtract 2 byte length field*/ @@ -906,14 +906,15 @@ write_exif_header(struct jpeg_compress_struct * const cinfoP, exif_data = malloc(data_length); if (exif_data == NULL) - pm_error("Unable to allocate %d bytes for exif header buffer", - data_length); + pm_error("Unable to allocate %u bytes for exif header buffer", + (unsigned)data_length); rc = fread(exif_data, 1, data_length, exif_file); if (rc != data_length) pm_error("Premature end of file on exif header file. Should be " - "%d bytes of data, read only %d", data_length, rc); + "%u bytes of data, read only %u", + (unsigned)data_length, (unsigned)rc); jpeg_write_marker(cinfoP, JPEG_APP0+1, (const JOCTET *) exif_data, data_length); diff --git a/converter/other/svgtopam.c b/converter/other/svgtopam.c index c7eac8e6..0b28afb8 100644 --- a/converter/other/svgtopam.c +++ b/converter/other/svgtopam.c @@ -27,6 +27,7 @@ ============================================================================*/ #define _BSD_SOURCE /* Make sure strdup() is in <string.h> */ +#define _POSIX_SOURCE /* Make sure fileno() is in <stdio.h> */ #include <assert.h> #include <string.h> #include <stdio.h> diff --git a/converter/pbm/pbmto10x.c b/converter/pbm/pbmto10x.c index f8a38b5d..8a3edb36 100644 --- a/converter/pbm/pbmto10x.c +++ b/converter/pbm/pbmto10x.c @@ -60,7 +60,7 @@ res_60x72(void) { MALLOCARRAY(stripe, cols); if (stripe == NULL) pm_error("Unable to allocate %u bytes for a stripe buffer.", - cols * sizeof(stripe[0])); + (unsigned)(cols * sizeof(stripe[0]))); for (i = 0; i < LOW_RES_ROWS; ++i) bitrows[i] = pbm_allocrow(cols); printf("\033A\010"); /* '\n' = 8/72 */ @@ -95,7 +95,7 @@ res_120x144(void) { MALLOCARRAY(stripe, cols); if (stripe == NULL) pm_error("Unable to allocate %u bytes for a stripe buffer.", - cols * sizeof(stripe[0])); + (unsigned)(cols * sizeof(stripe[0]))); for (i = 0; i < HIGH_RES_ROWS; ++i) bitrows[i] = pbm_allocrow(cols); printf("\0333\001"); /* \n = 1/144" */ diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c index b8057393..dd64fc20 100644 --- a/converter/pbm/pbmtonokia.c +++ b/converter/pbm/pbmtonokia.c @@ -45,7 +45,7 @@ uppercase(const char * const subject) { if (buffer == NULL) pm_error("Out of memory allocating buffer for uppercasing a " - "%u-character string", strlen(subject)); + "%u-character string", (unsigned)strlen(subject)); else { unsigned int i; @@ -117,7 +117,7 @@ parseCommandLine(int argc, char ** argv, if (netSpec) { if (strlen(netOpt) != 6) pm_error("-net option must be 6 hex digits long. " - "You specified %u characters", strlen(netOpt)); + "You specified %u characters", (unsigned)strlen(netOpt)); else if (!strishex(netOpt)) pm_error("-net option must be hexadecimal. You specified '%s'", netOpt); @@ -131,7 +131,7 @@ parseCommandLine(int argc, char ** argv, else if (strlen(cmdlineP->txt) > 120) pm_error("Text message is longer (%u characters) than " "the 120 characters allowed by the format.", - strlen(cmdlineP->txt)); + (unsigned)strlen(cmdlineP->txt)); if (argc-1 == 0) cmdlineP->inputFileName = "-"; @@ -253,7 +253,7 @@ convertToHexNpm(bit ** const image, unsigned int it; - fprintf(ofP, "00%04X", len); + fprintf(ofP, "00%04X", (unsigned)len); for (it = 0; it < len; ++it) fprintf(ofP, "%02X", text[it]); diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c index 937e56c5..dd3dcc3b 100644 --- a/converter/pbm/pbmtoxbm.c +++ b/converter/pbm/pbmtoxbm.c @@ -83,7 +83,7 @@ parseCommandLine(int argc, cmdlineP->name = NULL; else if (strlen(cmdlineP->name) > 56) pm_error("Image name too long: %d chars. (max 56)", - strlen(cmdlineP->name)); + (unsigned)strlen(cmdlineP->name)); else if (!ISALPHA(cmdlineP->name[0]) && cmdlineP->name[0] !='_') pm_error("Image name '%s' starts with non-alphabet character.", cmdlineP->name); diff --git a/converter/pbm/thinkjettopbm.l b/converter/pbm/thinkjettopbm.l index 71501596..e9b44f23 100644 --- a/converter/pbm/thinkjettopbm.l +++ b/converter/pbm/thinkjettopbm.l @@ -49,6 +49,7 @@ uses a macro he failed to define). */ #define YY_NO_UNPUT +#define YY_NO_INPUT 1 #define YY_STACK_USED 0 #define YY_ALWAYS_INTERACTIVE 0 #define YY_NEVER_INTERACTIVE 0 @@ -200,6 +201,8 @@ main (int argc, char **argv) } debugFlag = cmdline.debug; yylex (); + if (0) + yyunput(0, NULL); /* defeat compiler warning about unused fn */ return 0; } diff --git a/converter/pbm/xbmtopbm.c b/converter/pbm/xbmtopbm.c index 135b79f1..2ac61ccf 100644 --- a/converter/pbm/xbmtopbm.c +++ b/converter/pbm/xbmtopbm.c @@ -170,7 +170,7 @@ getXbmHeader(FILE * const ifP, if (strlen(line) == MAX_LINE - 1) pm_error("A line in the input file is %u characters long. " "%u is the maximum we can handle", - strlen(line), MAX_LINE-1); + (unsigned)strlen(line), MAX_LINE-1); parseWidthHeightLine(line, &gotWidth, widthP, &gotHeight, heightP); diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c index 17e1e01e..ff009f00 100644 --- a/converter/pgm/sbigtopgm.c +++ b/converter/pgm/sbigtopgm.c @@ -30,39 +30,44 @@ #define SBIG_HEADER_LENGTH 2048 /* File header length */ /* looseCanon -- Canonicalize a line from the file header so - items more sloppily formatted than those - written by CCDOPS are still accepted. */ + items more sloppily formatted than those + written by CCDOPS are still accepted. +*/ + +static void +looseCanon(char * const cpArg) { -static void looseCanon(cp) - char *cp; -{ - char *op = cp; + char * cp; + char * op; char c; - + + cp = cpArg; /* initial value */ + op = cpArg; /* initial value */ + while ((c = *cp++) != 0) { - if (!ISSPACE(c)) { - if (ISUPPER(c)) { - c = tolower(c); - } - *op++ = c; - } + if (!ISSPACE(c)) { + if (ISUPPER(c)) + c = tolower(c); + *op++ = c; + } } - *op++ = 0; + *op++ = '\0'; } -int main(argc, argv) - int argc; - char* argv[]; -{ - FILE *ifp; - gray *grayrow; - register gray *gP; + + +int +main(int argc, char ** argv) { + + FILE * ifP; + gray * grayrow; + gray * gP; int argn, row; - register int col; + int col; int maxval; int comp, rows, cols; char header[SBIG_HEADER_LENGTH]; - char *hdr; + char * hdr; static char camera[80] = "ST-?"; pgm_init(&argc, argv); @@ -70,18 +75,16 @@ int main(argc, argv) argn = 1; if (argn < argc) { - ifp = pm_openr(argv[argn]); - argn++; - } else { - ifp = stdin; - } + ifP = pm_openr(argv[argn]); + argn++; + } else + ifP = stdin; if (argn != argc) pm_usage( "[sbigfile]" ); - if (fread(header, SBIG_HEADER_LENGTH, 1, ifp) < 1) { + if (fread(header, SBIG_HEADER_LENGTH, 1, ifP) < 1) pm_error("error reading SBIG file header"); - } /* Walk through the header and parse relevant parameters. */ @@ -91,25 +94,26 @@ int main(argc, argv) /* The SBIG header specification equivalent to maxval is "Sat_level", the saturation level of the image. This - specification is optional, and was not included in files - written by early versions of CCDOPS. It was introduced when it - became necessary to distinguish 14-bit images with a Sat_level - of 16383 from 16-bit images which saturate at 65535. In - addition, co-adding images or capturing with Track and - Accumulate can increase the saturation level. Since files + specification is optional, and was not included in files + written by early versions of CCDOPS. It was introduced when it + became necessary to distinguish 14-bit images with a Sat_level + of 16383 from 16-bit images which saturate at 65535. In + addition, co-adding images or capturing with Track and + Accumulate can increase the saturation level. Since files which don't have a Sat_level line in the header were most - probably written by early drivers for the ST-4 or ST-5, it - might seem reasonable to make the default for maxval 16383, - the correct value for those cameras. I chose instead to use - 65535 as the default because the overwhelming majority of + probably written by early drivers for the ST-4 or ST-5, it + might seem reasonable to make the default for maxval 16383, + the correct value for those cameras. I chose instead to use + 65535 as the default because the overwhelming majority of cameras in use today are 16 bit, and it's possible some non-SBIG software may omit the "optional" Sat_level - specification. Also, no harm is done if a larger maxval is - specified than appears in the image--a simple contrast stretch - will adjust pixels to use the full 0 to maxval range. The - converse, pixels having values greater than maxval, results in - an invalid file which may cause problems in programs which - attempt to process it. */ + specification. Also, no harm is done if a larger maxval is + specified than appears in the image--a simple contrast stretch + will adjust pixels to use the full 0 to maxval range. The + converse, pixels having values greater than maxval, results in + an invalid file which may cause problems in programs which + attempt to process it. + */ maxval = 65535; @@ -118,90 +122,90 @@ int main(argc, argv) for (;;) { char *cp = strchr(hdr, '\n'); - if (cp == NULL) { - pm_error("malformed SBIG file header at character %d", hdr - header); - } - *cp = 0; + if (cp == NULL) { + pm_error("malformed SBIG file header at character %lu", + hdr - header); + } + *cp = '\0'; if (strncmp(hdr, "ST-", 3) == 0) { - char *ep = strchr(hdr + 3, ' '); + char * const ep = strchr(hdr + 3, ' '); - if (ep != NULL) { - *ep = 0; - strcpy(camera, hdr); + if (ep != NULL) { + *ep = '\0'; + strcpy(camera, hdr); *ep = ' '; - } - } - looseCanon(hdr); + } + } + looseCanon(hdr); if (strncmp(hdr, "st-", 3) == 0) { comp = strstr(hdr, "compressed") != NULL; } else if (strncmp(hdr, "height=", 7) == 0) { - rows = atoi(hdr + 7); + rows = atoi(hdr + 7); } else if (strncmp(hdr, "width=", 6) == 0) { - cols = atoi(hdr + 6); + cols = atoi(hdr + 6); } else if (strncmp(hdr, "sat_level=", 10) == 0) { - maxval = atoi(hdr + 10); + maxval = atoi(hdr + 10); } else if (streq(hdr, "end")) { - break; - } - hdr = cp + 1; + break; + } + hdr = cp + 1; } - if ((comp == -1) || (rows == -1) || (cols == -1)) { + if (comp == -1 || rows == -1 || cols == -1) pm_error("required specification missing from SBIG file header"); - } - fprintf(stderr, "SBIG %s %dx%d %s image, saturation level = %d.\n", - camera, cols, rows, comp ? "compressed" : "uncompressed", maxval); + pm_message("SBIG %s %dx%d %s image, saturation level = %d", + camera, cols, rows, comp ? "compressed" : "uncompressed", + maxval); if (maxval > PGM_OVERALLMAXVAL) { - pm_error("Saturation level (%d levels) is too large.\n" + pm_error("Saturation level (%d levels) is too large" "This program's limit is %d.", maxval, PGM_OVERALLMAXVAL); } - pgm_writepgminit(stdout, cols, rows, (gray) maxval, 0); + pgm_writepgminit(stdout, cols, rows, maxval, 0); grayrow = pgm_allocrow(cols); #define DOSINT(fp) ((getc(fp) & 0xFF) | (getc(fp) << 8)) - for (row = 0; row < rows; row++) { - int compthis = comp; - - if (comp) { - int rowlen = DOSINT(ifp); /* Compressed row length */ - - /* If compression results in a row length >= the uncompressed - row length, that row is output uncompressed. We detect this - by observing that the compressed row length is equal to - that of an uncompressed row. */ - - if (rowlen == cols * 2) { - compthis = 0; - } - } - for (col = 0, gP = grayrow; col < cols; col++, gP++) { - gray g; - - if (compthis) { - - if (col == 0) { - g = DOSINT(ifp); - } else { - int delta = getc(ifp); - - if (delta == 0x80) { - g = DOSINT(ifp); - } else { - g += ((signed char) delta); - } - } - } else { - g = DOSINT(ifp); - } - *gP = g; - } - pgm_writepgmrow(stdout, grayrow, cols, (gray) maxval, 0); + for (row = 0; row < rows; ++row) { + int compthis; + + compthis = comp; /* initial value */ + + if (comp) { + int const rowlen = DOSINT(ifP); /* Compressed row length */ + + /* If compression results in a row length >= the uncompressed + row length, that row is output uncompressed. We detect this + by observing that the compressed row length is equal to + that of an uncompressed row. + */ + + if (rowlen == cols * 2) + compthis = 0; + } + for (col = 0, gP = grayrow; col < cols; ++col, ++gP) { + gray g; + + if (compthis) { + if (col == 0) { + g = DOSINT(ifP); + } else { + int delta = getc(ifP); + + if (delta == 0x80) + g = DOSINT(ifP); + else + g += ((signed char) delta); + } + } else + g = DOSINT(ifP); + *gP = g; + } + pgm_writepgmrow(stdout, grayrow, cols, (gray) maxval, 0); } - pm_close(ifp); + pm_close(ifP); pm_close(stdout); return 0; diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c index e13bf221..75d53858 100644 --- a/converter/ppm/ppmtompeg/parallel.c +++ b/converter/ppm/ppmtompeg/parallel.c @@ -1104,8 +1104,8 @@ GetRemoteFrame(MpegFrame * const frameP, if (numBytes > sizeof(buffer)) errorExit("Invalid message received: numBytes = %d, " - "which is greater than %d\n", - numBytes, sizeof(numBytes)); + "which is greater than %u", + numBytes, (unsigned)sizeof(numBytes)); ReadBytes(clientSocket, buffer, numBytes); fwrite(buffer, 1, numBytes, filePtr); diff --git a/converter/ppm/ppmtompeg/rgbtoycc.c b/converter/ppm/ppmtompeg/rgbtoycc.c index 766b8902..2dd1899a 100644 --- a/converter/ppm/ppmtompeg/rgbtoycc.c +++ b/converter/ppm/ppmtompeg/rgbtoycc.c @@ -84,11 +84,11 @@ compute_mult_tables(const pixval maxval) { if (mult299 == NULL || mult587 == NULL || mult114 == NULL || mult16874 == NULL || mult33126 == NULL || mult5 == NULL || mult41869 == NULL || mult08131 == NULL) - pm_error("Unable to allocate storage for arithmetic tables.\n" + pm_error("Unable to allocate storage for arithmetic tables. " "We need %d bytes, which is the maxval of the input " - "image, plus 1,\n" + "image, plus 1, " "times the storage size of a floating point value.", - 8 * (table_maxval+1)*sizeof(float)); + (unsigned)(8 * (table_maxval+1)*sizeof(float))); { int index; diff --git a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c index 18ea61a8..0f9d35a4 100644 --- a/converter/ppm/ppmtoxpm.c +++ b/converter/ppm/ppmtoxpm.c @@ -317,7 +317,7 @@ genCmap(colorhist_vector const chv, MALLOCARRAY(cmap, cmapSize); if (cmapP == NULL) pm_error("Out of memory allocating %u bytes for a color map.", - sizeof(cixel_map) * (ncolors+1)); + (unsigned)sizeof(cixel_map) * (ncolors+1)); xpmMaxval = xpmMaxvalFromMaxval(maxval); diff --git a/editor/pamflip.c b/editor/pamflip.c index 83f776af..b8b079f0 100644 --- a/editor/pamflip.c +++ b/editor/pamflip.c @@ -276,7 +276,7 @@ interpretMemorySize(unsigned int const memsizeSpec, if (memsizeOpt > sizeMax / Meg) pm_error("-memsize value too large: %u MiB. Maximum this program " "can handle is %u MiB", - memsizeOpt, sizeMax / Meg); + memsizeOpt, (unsigned)sizeMax / Meg); *availableMemoryP = memsizeOpt * Meg; } else *availableMemoryP = sizeMax; diff --git a/editor/pampaintspill.c b/editor/pampaintspill.c index b5f991d4..b9b783ef 100644 --- a/editor/pampaintspill.c +++ b/editor/pampaintspill.c @@ -24,6 +24,8 @@ * ---------------------------------------------------------------------- */ +#define _XOPEN_SOURCE 600 /* Make sure random(), srandom() are in <stdlib.h>*/ +#include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> diff --git a/editor/pamundice.c b/editor/pamundice.c index 89d8b6b5..0b092a3c 100644 --- a/editor/pamundice.c +++ b/editor/pamundice.c @@ -249,7 +249,7 @@ doSubstitution(const char * const pattern, pm_error("%s number %u is wider than " "the %u characters specified in the " "input file pattern", - desc, strlen(substString), precision); + desc, (unsigned)strlen(substString), precision); else buffer_addString(bufferP, substString); diff --git a/editor/ppmdither.c b/editor/ppmdither.c index 3b8d121b..09ed1187 100644 --- a/editor/ppmdither.c +++ b/editor/ppmdither.c @@ -20,7 +20,7 @@ We need 2*dith_power bits in an unsigned int. We also reserve one bit to give headroom to do calculations with these numbers. */ -#define MAX_DITH_POWER ((sizeof(unsigned int)*8 - 1) / 2) +#define MAX_DITH_POWER (((unsigned)sizeof(unsigned int)*8 - 1) / 2) struct colorResolution { diff --git a/editor/specialty/pnmindex.c b/editor/specialty/pnmindex.c index ca1da18c..3354bc35 100644 --- a/editor/specialty/pnmindex.c +++ b/editor/specialty/pnmindex.c @@ -72,7 +72,7 @@ systemf(const char * const fmt, shellCommand = malloc(allocSize); if (shellCommand == NULL) pm_error("Can't get storage for %u-character command", - allocSize); + (unsigned)allocSize); else { va_list varargs; size_t realLen; diff --git a/editor/specialty/pnmmercator.c b/editor/specialty/pnmmercator.c index 31ba3d82..af31d16d 100644 --- a/editor/specialty/pnmmercator.c +++ b/editor/specialty/pnmmercator.c @@ -16,6 +16,7 @@ ** */ +#define _XOPEN_SOURCE /* Make sure M_PI is in <math.h> */ #include <math.h> #include <string.h> diff --git a/generator/pamgauss.c b/generator/pamgauss.c index eb5fa3fe..ccbcc482 100644 --- a/generator/pamgauss.c +++ b/generator/pamgauss.c @@ -68,7 +68,8 @@ parseCommandLine(int argc, char ** argv, struct pam pam; if (strlen(cmdlineP->tupletype)+1 > sizeof(pam.tuple_type)) pm_error("The tuple type you specified is too long. " - "Maximum %d characters.", sizeof(pam.tuple_type)-1); + "Maximum %u characters.", + (unsigned)sizeof(pam.tuple_type)-1); } if (!sigmaSpec) diff --git a/generator/pamseq.c b/generator/pamseq.c index 98eac1cc..c923a061 100644 --- a/generator/pamseq.c +++ b/generator/pamseq.c @@ -59,7 +59,8 @@ parseCommandLine(int argc, char ** argv, struct pam pam; if (strlen(cmdlineP->tupletype)+1 > sizeof(pam.tuple_type)) pm_error("The tuple type you specified is too long. " - "Maximum %d characters.", sizeof(pam.tuple_type)-1); + "Maximum %u characters.", + (unsigned)sizeof(pam.tuple_type)-1); } if (argc-1 < 2) diff --git a/generator/pbmtext.c b/generator/pbmtext.c index 693c3f59..9a89f02f 100644 --- a/generator/pbmtext.c +++ b/generator/pbmtext.c @@ -236,7 +236,8 @@ fixControlChars(const char * const input, MALLOCARRAY(output, outputSize); if (output == NULL) - pm_error("Couldn't allocate %u bytes for a line of text.", outputSize); + pm_error("Couldn't allocate %u bytes for a line of text.", + (unsigned)outputSize); for (inCursor = 0, outCursor = 0; input[inCursor] != '\0'; ++inCursor) { if (outCursor + 1 + tabSize > outputSize) { @@ -244,7 +245,7 @@ fixControlChars(const char * const input, REALLOCARRAY(output, outputSize); if (output == NULL) pm_error("Couldn't allocate %u bytes for a line of text.", - outputSize); + (unsigned)outputSize); } if (input[inCursor] == '\n' && input[inCursor+1] == '\0') { /* This is a terminating newline. We don't do those. */ @@ -709,7 +710,7 @@ getText(const char cmdline_text[], while (fgets(buf, sizeof(buf), stdin) != NULL) { if (strlen(buf) + 1 >= sizeof(buf)) pm_error("A line of input text is longer than %u characters." - "Cannot process.", sizeof(buf)-1); + "Cannot process.", (unsigned)sizeof(buf)-1); if (lineCount >= maxlines) { maxlines *= 2; REALLOCARRAY(text_array, maxlines); diff --git a/lib/libpam.c b/lib/libpam.c index 9384e178..e00f00db 100644 --- a/lib/libpam.c +++ b/lib/libpam.c @@ -261,9 +261,9 @@ pnm_allocpamrow(const struct pam * const pamP) { tuple * const tuplerow = allocPamRow(pamP); if (tuplerow == NULL) - pm_error("Out of memory allocating space for a tuple row of\n" - "%d tuples by %d samples per tuple by %d bytes per sample.", - pamP->width, allocationDepth(pamP), sizeof(sample)); + pm_error("Out of memory allocating space for a tuple row of " + "%d tuples by %d samples per tuple by %u bytes per sample.", + pamP->width, allocationDepth(pamP), (unsigned)sizeof(sample)); return tuplerow; } @@ -400,7 +400,7 @@ pnm_setminallocationdepth(struct pam * const pamP, pm_error("Can't set minimum allocation depth in pam structure, " "because the structure is only %u bytes long, and to " "have an allocation_depth field, it must bea at least %u", - pamP->len, PAM_STRUCT_SIZE(allocation_depth)); + pamP->len, (unsigned)PAM_STRUCT_SIZE(allocation_depth)); pamP->allocation_depth = MAX(allocationDepth, pamP->depth); @@ -575,7 +575,7 @@ appendComment(char ** const commentsP, if (*commentsP == NULL) pm_error("Couldn't get storage for %u characters of comments from " - "the PAM header", commentLen); + "the PAM header", (unsigned)commentLen); strcat(*commentsP, commentLine); } diff --git a/lib/libpamn.c b/lib/libpamn.c index fe004e91..76a8bb6d 100644 --- a/lib/libpamn.c +++ b/lib/libpamn.c @@ -42,7 +42,7 @@ allocpamrown(const struct pam * const pamP, if (tuplerown == NULL) asprintfN(&error, "Out of memory allocating space for a tuple row of" "%u tuples by %u samples per tuple by %u bytes per sample.", - pamP->width, pamP->depth, sizeof(samplen)); + pamP->width, pamP->depth, (unsigned)sizeof(samplen)); else { /* Now we initialize the pointers to the individual tuples to make this a regulation C two dimensional array. diff --git a/lib/libpgm2.c b/lib/libpgm2.c index 650d2cb5..00929c5a 100644 --- a/lib/libpgm2.c +++ b/lib/libpgm2.c @@ -125,10 +125,12 @@ writepgmrowraw(FILE * const fileP, if (rc < 0) pm_error("Error writing row. fwrite() errno=%d (%s)", errno, strerror(errno)); - else if (rc != bytesPerRow) - pm_error("Error writing row. Short write of %u bytes " - "instead of %u", rc, bytesPerRow); - + else { + size_t const bytesWritten = rc; + if (bytesWritten != bytesPerRow) + pm_error("Error writing row. Short write of %u bytes " + "instead of %u", (unsigned)bytesWritten, bytesPerRow); + } free(rowBuffer); } diff --git a/lib/libppm1.c b/lib/libppm1.c index ea929908..7b92d3ee 100644 --- a/lib/libppm1.c +++ b/lib/libppm1.c @@ -184,6 +184,46 @@ readPpmRow(FILE * const fileP, static void +interpRasterRowRaw(const unsigned char * const rowBuffer, + pixel * const pixelrow, + unsigned int const cols, + unsigned int const bytesPerSample) { + + unsigned int bufferCursor; + + bufferCursor = 0; /* start at beginning of rowBuffer[] */ + + if (bytesPerSample == 1) { + unsigned int col; + for (col = 0; col < cols; ++col) { + pixval const r = rowBuffer[bufferCursor++]; + pixval const g = rowBuffer[bufferCursor++]; + pixval const b = rowBuffer[bufferCursor++]; + PPM_ASSIGN(pixelrow[col], r, g, b); + } + } else { + /* two byte samples */ + unsigned int col; + for (col = 0; col < cols; ++col) { + pixval r, g, b; + + r = rowBuffer[bufferCursor++] << 8; + r |= rowBuffer[bufferCursor++]; + + g = rowBuffer[bufferCursor++] << 8; + g |= rowBuffer[bufferCursor++]; + + b = rowBuffer[bufferCursor++] << 8; + b |= rowBuffer[bufferCursor++]; + + PPM_ASSIGN(pixelrow[col], r, g, b); + } + } +} + + + +static void readRppmRow(FILE * const fileP, pixel * const pixelrow, unsigned int const cols, @@ -211,41 +251,14 @@ readRppmRow(FILE * const fileP, else if (ferror(fileP)) asprintfN(&error, "Error reading row. fread() errno=%d (%s)", errno, strerror(errno)); - else if (rc != bytesPerRow) - asprintfN(&error, "Error reading row. Short read of %u bytes " - "instead of %u", rc, bytesPerRow); else { - unsigned int bufferCursor; - - error = NULL; - - bufferCursor = 0; /* start at beginning of rowBuffer[] */ - - if (bytesPerSample == 1) { - unsigned int col; - for (col = 0; col < cols; ++col) { - pixval const r = rowBuffer[bufferCursor++]; - pixval const g = rowBuffer[bufferCursor++]; - pixval const b = rowBuffer[bufferCursor++]; - PPM_ASSIGN(pixelrow[col], r, g, b); - } - } else { - /* two byte samples */ - unsigned int col; - for (col = 0; col < cols; ++col) { - pixval r, g, b; - - r = rowBuffer[bufferCursor++] << 8; - r |= rowBuffer[bufferCursor++]; - - g = rowBuffer[bufferCursor++] << 8; - g |= rowBuffer[bufferCursor++]; - - b = rowBuffer[bufferCursor++] << 8; - b |= rowBuffer[bufferCursor++]; - - PPM_ASSIGN(pixelrow[col], r, g, b); - } + size_t const bytesRead = rc; + if (bytesRead != bytesPerRow) + asprintfN(&error, "Error reading row. Short read of %u bytes " + "instead of %u", (unsigned)bytesRead, bytesPerRow); + else { + interpRasterRowRaw(rowBuffer, pixelrow, cols, bytesPerSample); + error = NULL; } } free(rowBuffer); diff --git a/lib/libppm2.c b/lib/libppm2.c index 3bf74bd4..9d877bd3 100644 --- a/lib/libppm2.c +++ b/lib/libppm2.c @@ -133,10 +133,13 @@ ppm_writeppmrowraw(FILE * const fileP, if (rc < 0) pm_error("Error writing row. fwrite() errno=%d (%s)", errno, strerror(errno)); - else if (rc != bytesPerRow) - pm_error("Error writing row. Short write of %u bytes " - "instead of %u", rc, bytesPerRow); + else { + size_t const bytesWritten = rc; + if (bytesWritten != bytesPerRow) + pm_error("Error writing row. Short write of %u bytes " + "instead of %u", (unsigned)bytesWritten, bytesPerRow); + } free(rowBuffer); } diff --git a/lib/util/floatcode.h b/lib/util/floatcode.h index 99aec256..8559ff79 100644 --- a/lib/util/floatcode.h +++ b/lib/util/floatcode.h @@ -124,7 +124,7 @@ pm_doubleFromBigendDouble(pm_bigendDouble const arg) { }; break; case LITTLE_ENDIAN: { union { - unsigned char bytes[4]; + unsigned char bytes[8]; double native; } converter; diff --git a/other/pamchannel.c b/other/pamchannel.c index 64ab728b..9ca2437f 100644 --- a/other/pamchannel.c +++ b/other/pamchannel.c @@ -74,7 +74,8 @@ parseCommandLine(int argc, char ** argv, else if (strlen(cmdlineP->tupletype)+1 > sizeof(pam.tuple_type)) pm_error("Tuple type name specified is too long. Maximum of " - "%u characters allowed.", sizeof(pam.tuple_type)); + "%u characters allowed.", + (unsigned)sizeof(pam.tuple_type)); cmdlineP->n_channel = 0; /* initial value */ { diff --git a/other/pamstack.c b/other/pamstack.c index d826cf1f..22526d2b 100644 --- a/other/pamstack.c +++ b/other/pamstack.c @@ -70,7 +70,8 @@ parseCommandLine(int argc, char ** argv, else if (strlen(cmdlineP->tupletype)+1 > sizeof(pam.tuple_type)) pm_error("Tuple type name specified is too long. Maximum of " - "%u characters allowed.", sizeof(pam.tuple_type)); + "%u characters allowed.", + (unsigned)sizeof(pam.tuple_type)); cmdlineP->nInput = 0; /* initial value */ { |