File: | libs/tiff-4.0.2/tools/raw2tiff.c |
Location: | line 255, column 4 |
Description: | Value stored to 'photometric' is never read |
1 | /* $Id: raw2tiff.c,v 1.25 2010-03-10 18:56:49 bfriesen Exp $ |
2 | * |
3 | * Project: libtiff tools |
4 | * Purpose: Convert raw byte sequences in TIFF images |
5 | * Author: Andrey Kiselev, dron@ak4719.spb.edu |
6 | * |
7 | ****************************************************************************** |
8 | * Copyright (c) 2002, Andrey Kiselev <dron@ak4719.spb.edu> |
9 | * |
10 | * Permission to use, copy, modify, distribute, and sell this software and |
11 | * its documentation for any purpose is hereby granted without fee, provided |
12 | * that (i) the above copyright notices and this permission notice appear in |
13 | * all copies of the software and related documentation, and (ii) the names of |
14 | * Sam Leffler and Silicon Graphics may not be used in any advertising or |
15 | * publicity relating to the software without the specific, prior written |
16 | * permission of Sam Leffler and Silicon Graphics. |
17 | * |
18 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, |
19 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY |
20 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
21 | * |
22 | * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR |
23 | * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, |
24 | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
25 | * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF |
26 | * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
27 | * OF THIS SOFTWARE. |
28 | */ |
29 | |
30 | #include "tif_config.h" |
31 | |
32 | #include <stdio.h> |
33 | #include <stdlib.h> |
34 | #include <string.h> |
35 | #include <sys/stat.h> |
36 | #include <sys/types.h> |
37 | #include <math.h> |
38 | #include <ctype.h> |
39 | |
40 | #ifdef HAVE_UNISTD_H1 |
41 | # include <unistd.h> |
42 | #endif |
43 | |
44 | #if HAVE_FCNTL_H1 |
45 | # include <fcntl.h> |
46 | #endif |
47 | |
48 | #if HAVE_SYS_TYPES_H1 |
49 | # include <sys/types.h> |
50 | #endif |
51 | |
52 | #if HAVE_IO_H |
53 | # include <io.h> |
54 | #endif |
55 | |
56 | #ifdef NEED_LIBPORT |
57 | # include "libport.h" |
58 | #endif |
59 | |
60 | #include "tiffio.h" |
61 | |
62 | #ifndef HAVE_GETOPT1 |
63 | extern int getopt(int, char**, char*); |
64 | #endif |
65 | |
66 | #ifndef O_BINARY0 |
67 | # define O_BINARY0 0 |
68 | #endif |
69 | |
70 | typedef enum { |
71 | PIXEL, |
72 | BAND |
73 | } InterleavingType; |
74 | |
75 | static uint16 compression = (uint16) -1; |
76 | static int jpegcolormode = JPEGCOLORMODE_RGB0x0001; |
77 | static int quality = 75; /* JPEG quality */ |
78 | static uint16 predictor = 0; |
79 | |
80 | static void swapBytesInScanline(void *, uint32, TIFFDataType); |
81 | static int guessSize(int, TIFFDataType, off_t, uint32, int, |
82 | uint32 *, uint32 *); |
83 | static double correlation(void *, void *, uint32, TIFFDataType); |
84 | static void usage(void); |
85 | static int processCompressOptions(char*); |
86 | |
87 | int |
88 | main(int argc, char* argv[]) |
89 | { |
90 | uint32 width = 0, length = 0, linebytes, bufsize; |
91 | uint32 nbands = 1; /* number of bands in input image*/ |
92 | off_t hdr_size = 0; /* size of the header to skip */ |
93 | TIFFDataType dtype = TIFF_BYTE; |
94 | int16 depth = 1; /* bytes per pixel in input image */ |
95 | int swab = 0; /* byte swapping flag */ |
96 | InterleavingType interleaving = 0; /* interleaving type flag */ |
97 | uint32 rowsperstrip = (uint32) -1; |
98 | uint16 photometric = PHOTOMETRIC_MINISBLACK1; |
99 | uint16 config = PLANARCONFIG_CONTIG1; |
100 | uint16 fillorder = FILLORDER_LSB2MSB2; |
101 | int fd; |
102 | char *outfilename = NULL((void*)0); |
103 | TIFF *out; |
104 | |
105 | uint32 row, col, band; |
106 | int c; |
107 | unsigned char *buf = NULL((void*)0), *buf1 = NULL((void*)0); |
108 | extern int optind; |
109 | extern char* optarg; |
110 | |
111 | while ((c = getopt(argc, argv, "c:r:H:w:l:b:d:LMp:si:o:h")) != -1) { |
112 | switch (c) { |
113 | case 'c': /* compression scheme */ |
114 | if (!processCompressOptions(optarg)) |
115 | usage(); |
116 | break; |
117 | case 'r': /* rows/strip */ |
118 | rowsperstrip = atoi(optarg); |
119 | break; |
120 | case 'H': /* size of input image file header */ |
121 | hdr_size = atoi(optarg); |
122 | break; |
123 | case 'w': /* input image width */ |
124 | width = atoi(optarg); |
125 | break; |
126 | case 'l': /* input image length */ |
127 | length = atoi(optarg); |
128 | break; |
129 | case 'b': /* number of bands in input image */ |
130 | nbands = atoi(optarg); |
131 | break; |
132 | case 'd': /* type of samples in input image */ |
133 | if (strncmp(optarg, "byte", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (4))) || ( __builtin_constant_p ("byte") && strlen ("byte") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("byte") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("byte"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("byte") + 1) - (size_t )(const void *)("byte") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "byte") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("byte") && ((size_t)(const void *)(("byte") + 1) - (size_t)(const void * )("byte") == 1) ? __builtin_strcmp (optarg, "byte") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("byte"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("byte") && ((size_t)(const void *)(("byte") + 1) - ( size_t)(const void *)("byte") == 1) && (__s2_len = __builtin_strlen ("byte"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) ? __builtin_strcmp (optarg, "byte") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("byte"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("byte"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("byte"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("byte"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "byte")))); }) : strncmp (optarg, "byte", 4))) == 0) |
134 | dtype = TIFF_BYTE; |
135 | else if (strncmp(optarg, "short", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (5))) || ( __builtin_constant_p ("short") && strlen ("short") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("short") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("short"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("short") + 1) - (size_t )(const void *)("short") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "short") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("short") && ((size_t)(const void *)(("short") + 1) - (size_t)(const void *)("short") == 1) ? __builtin_strcmp (optarg, "short") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("short"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("short") && ((size_t)(const void *)(("short") + 1) - (size_t)(const void *)("short") == 1) && (__s2_len = __builtin_strlen ("short"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg , "short") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) (const char *) ("short"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("short"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("short"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("short"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (optarg, "short" )))); }) : strncmp (optarg, "short", 5))) == 0) |
136 | dtype = TIFF_SHORT; |
137 | else if (strncmp(optarg, "long", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (4))) || ( __builtin_constant_p ("long") && strlen ("long") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("long") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("long"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("long") + 1) - (size_t )(const void *)("long") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "long") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("long") && ((size_t)(const void *)(("long") + 1) - (size_t)(const void * )("long") == 1) ? __builtin_strcmp (optarg, "long") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("long"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("long") && ((size_t)(const void *)(("long") + 1) - ( size_t)(const void *)("long") == 1) && (__s2_len = __builtin_strlen ("long"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) ? __builtin_strcmp (optarg, "long") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("long"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("long"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("long"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("long"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "long")))); }) : strncmp (optarg, "long", 4))) == 0) |
138 | dtype = TIFF_LONG; |
139 | else if (strncmp(optarg, "sbyte", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (5))) || ( __builtin_constant_p ("sbyte") && strlen ("sbyte") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("sbyte") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("sbyte"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("sbyte") + 1) - (size_t )(const void *)("sbyte") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "sbyte") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("sbyte") && ((size_t)(const void *)(("sbyte") + 1) - (size_t)(const void *)("sbyte") == 1) ? __builtin_strcmp (optarg, "sbyte") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sbyte"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("sbyte") && ((size_t)(const void *)(("sbyte") + 1) - (size_t)(const void *)("sbyte") == 1) && (__s2_len = __builtin_strlen ("sbyte"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg , "sbyte") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) (const char *) ("sbyte"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sbyte"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sbyte"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("sbyte"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (optarg, "sbyte" )))); }) : strncmp (optarg, "sbyte", 5))) == 0) |
140 | dtype = TIFF_SBYTE; |
141 | else if (strncmp(optarg, "sshort", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (6))) || ( __builtin_constant_p ("sshort") && strlen ("sshort") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("sshort") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("sshort"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("sshort") + 1 ) - (size_t)(const void *)("sshort") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (optarg, "sshort") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("sshort" ) && ((size_t)(const void *)(("sshort") + 1) - (size_t )(const void *)("sshort") == 1) ? __builtin_strcmp (optarg, "sshort" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("sshort"); int __result = (((const unsigned char *) (const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("sshort") && ((size_t )(const void *)(("sshort") + 1) - (size_t)(const void *)("sshort" ) == 1) && (__s2_len = __builtin_strlen ("sshort"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t )(const void *)((optarg) + 1) - (size_t)(const void *)(optarg ) == 1) ? __builtin_strcmp (optarg, "sshort") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("sshort"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sshort"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("sshort"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("sshort"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "sshort")))); }) : strncmp (optarg, "sshort", 6))) == 0) |
142 | dtype = TIFF_SSHORT; |
143 | else if (strncmp(optarg, "slong", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (5))) || ( __builtin_constant_p ("slong") && strlen ("slong") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("slong") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("slong"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("slong") + 1) - (size_t )(const void *)("slong") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "slong") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("slong") && ((size_t)(const void *)(("slong") + 1) - (size_t)(const void *)("slong") == 1) ? __builtin_strcmp (optarg, "slong") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("slong"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("slong") && ((size_t)(const void *)(("slong") + 1) - (size_t)(const void *)("slong") == 1) && (__s2_len = __builtin_strlen ("slong"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg , "slong") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) (const char *) ("slong"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("slong"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("slong"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("slong"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (optarg, "slong" )))); }) : strncmp (optarg, "slong", 5))) == 0) |
144 | dtype = TIFF_SLONG; |
145 | else if (strncmp(optarg, "float", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (5))) || ( __builtin_constant_p ("float") && strlen ("float") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("float") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("float"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("float") + 1) - (size_t )(const void *)("float") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "float") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("float") && ((size_t)(const void *)(("float") + 1) - (size_t)(const void *)("float") == 1) ? __builtin_strcmp (optarg, "float") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("float"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("float") && ((size_t)(const void *)(("float") + 1) - (size_t)(const void *)("float") == 1) && (__s2_len = __builtin_strlen ("float"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg , "float") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) (const char *) ("float"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("float"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("float"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("float"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (optarg, "float" )))); }) : strncmp (optarg, "float", 5))) == 0) |
146 | dtype = TIFF_FLOAT; |
147 | else if (strncmp(optarg, "double", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (6))) || ( __builtin_constant_p ("double") && strlen ("double") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("double") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("double"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("double") + 1 ) - (size_t)(const void *)("double") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (optarg, "double") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("double" ) && ((size_t)(const void *)(("double") + 1) - (size_t )(const void *)("double") == 1) ? __builtin_strcmp (optarg, "double" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("double"); int __result = (((const unsigned char *) (const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("double") && ((size_t )(const void *)(("double") + 1) - (size_t)(const void *)("double" ) == 1) && (__s2_len = __builtin_strlen ("double"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t )(const void *)((optarg) + 1) - (size_t)(const void *)(optarg ) == 1) ? __builtin_strcmp (optarg, "double") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("double"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("double"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("double"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("double"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "double")))); }) : strncmp (optarg, "double", 6))) == 0) |
148 | dtype = TIFF_DOUBLE; |
149 | else |
150 | dtype = TIFF_BYTE; |
151 | depth = TIFFDataWidth(dtype); |
152 | break; |
153 | case 'L': /* input has lsb-to-msb fillorder */ |
154 | fillorder = FILLORDER_LSB2MSB2; |
155 | break; |
156 | case 'M': /* input has msb-to-lsb fillorder */ |
157 | fillorder = FILLORDER_MSB2LSB1; |
158 | break; |
159 | case 'p': /* photometric interpretation */ |
160 | if (strncmp(optarg, "miniswhite", 10)(__extension__ (__builtin_constant_p (10) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (10))) || (__builtin_constant_p ("miniswhite") && strlen ("miniswhite" ) < ((size_t) (10)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("miniswhite") && (__s1_len = __builtin_strlen (optarg ), __s2_len = __builtin_strlen ("miniswhite"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("miniswhite" ) + 1) - (size_t)(const void *)("miniswhite") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "miniswhite") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("miniswhite" ) && ((size_t)(const void *)(("miniswhite") + 1) - (size_t )(const void *)("miniswhite") == 1) ? __builtin_strcmp (optarg , "miniswhite") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("miniswhite"); int __result = (((const unsigned char *) (const char *) (optarg) )[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (optarg ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (optarg ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (optarg ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "miniswhite") && ((size_t)(const void *)(("miniswhite" ) + 1) - (size_t)(const void *)("miniswhite") == 1) && (__s2_len = __builtin_strlen ("miniswhite"), __s2_len < 4 ) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg, "miniswhite") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("miniswhite"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("miniswhite"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("miniswhite"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("miniswhite"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (optarg, "miniswhite")))); }) : strncmp (optarg, "miniswhite", 10))) == 0) |
161 | photometric = PHOTOMETRIC_MINISWHITE0; |
162 | else if (strncmp(optarg, "minisblack", 10)(__extension__ (__builtin_constant_p (10) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (10))) || (__builtin_constant_p ("minisblack") && strlen ("minisblack" ) < ((size_t) (10)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("minisblack") && (__s1_len = __builtin_strlen (optarg ), __s2_len = __builtin_strlen ("minisblack"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("minisblack" ) + 1) - (size_t)(const void *)("minisblack") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "minisblack") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("minisblack" ) && ((size_t)(const void *)(("minisblack") + 1) - (size_t )(const void *)("minisblack") == 1) ? __builtin_strcmp (optarg , "minisblack") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("minisblack"); int __result = (((const unsigned char *) (const char *) (optarg) )[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (optarg ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (optarg ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (optarg ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "minisblack") && ((size_t)(const void *)(("minisblack" ) + 1) - (size_t)(const void *)("minisblack") == 1) && (__s2_len = __builtin_strlen ("minisblack"), __s2_len < 4 ) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg, "minisblack") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("minisblack"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("minisblack"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("minisblack"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("minisblack"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (optarg, "minisblack")))); }) : strncmp (optarg, "minisblack", 10))) == 0) |
163 | photometric = PHOTOMETRIC_MINISBLACK1; |
164 | else if (strncmp(optarg, "rgb", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (3))) || ( __builtin_constant_p ("rgb") && strlen ("rgb") < ( (size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (optarg) && __builtin_constant_p ("rgb") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("rgb"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("rgb") + 1) - (size_t )(const void *)("rgb") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "rgb") : (__builtin_constant_p (optarg) && ( (size_t)(const void *)((optarg) + 1) - (size_t)(const void *) (optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("rgb") && ((size_t)(const void *)(("rgb") + 1) - (size_t)(const void * )("rgb") == 1) ? __builtin_strcmp (optarg, "rgb") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("rgb"); int __result = (((const unsigned char *) (const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("rgb") && ((size_t)(const void *)(("rgb") + 1) - (size_t )(const void *)("rgb") == 1) && (__s2_len = __builtin_strlen ("rgb"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) ? __builtin_strcmp (optarg, "rgb") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("rgb"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("rgb"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("rgb"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("rgb"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "rgb")))); }) : strncmp (optarg, "rgb", 3))) == 0) |
165 | photometric = PHOTOMETRIC_RGB2; |
166 | else if (strncmp(optarg, "cmyk", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (4))) || ( __builtin_constant_p ("cmyk") && strlen ("cmyk") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("cmyk") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("cmyk"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("cmyk") + 1) - (size_t )(const void *)("cmyk") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "cmyk") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("cmyk") && ((size_t)(const void *)(("cmyk") + 1) - (size_t)(const void * )("cmyk") == 1) ? __builtin_strcmp (optarg, "cmyk") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cmyk"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("cmyk") && ((size_t)(const void *)(("cmyk") + 1) - ( size_t)(const void *)("cmyk") == 1) && (__s2_len = __builtin_strlen ("cmyk"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) ? __builtin_strcmp (optarg, "cmyk") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("cmyk"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cmyk"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cmyk"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cmyk"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "cmyk")))); }) : strncmp (optarg, "cmyk", 4))) == 0) |
167 | photometric = PHOTOMETRIC_SEPARATED5; |
168 | else if (strncmp(optarg, "ycbcr", 5)(__extension__ (__builtin_constant_p (5) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (5))) || ( __builtin_constant_p ("ycbcr") && strlen ("ycbcr") < ((size_t) (5)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("ycbcr") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("ycbcr"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("ycbcr") + 1) - (size_t )(const void *)("ycbcr") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "ycbcr") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("ycbcr") && ((size_t)(const void *)(("ycbcr") + 1) - (size_t)(const void *)("ycbcr") == 1) ? __builtin_strcmp (optarg, "ycbcr") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ycbcr"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("ycbcr") && ((size_t)(const void *)(("ycbcr") + 1) - (size_t)(const void *)("ycbcr") == 1) && (__s2_len = __builtin_strlen ("ycbcr"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg , "ycbcr") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) (const char *) ("ycbcr"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ycbcr"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ycbcr"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("ycbcr"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (optarg, "ycbcr" )))); }) : strncmp (optarg, "ycbcr", 5))) == 0) |
169 | photometric = PHOTOMETRIC_YCBCR6; |
170 | else if (strncmp(optarg, "cielab", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (6))) || ( __builtin_constant_p ("cielab") && strlen ("cielab") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("cielab") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("cielab"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("cielab") + 1 ) - (size_t)(const void *)("cielab") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (optarg, "cielab") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("cielab" ) && ((size_t)(const void *)(("cielab") + 1) - (size_t )(const void *)("cielab") == 1) ? __builtin_strcmp (optarg, "cielab" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("cielab"); int __result = (((const unsigned char *) (const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("cielab") && ((size_t )(const void *)(("cielab") + 1) - (size_t)(const void *)("cielab" ) == 1) && (__s2_len = __builtin_strlen ("cielab"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t )(const void *)((optarg) + 1) - (size_t)(const void *)(optarg ) == 1) ? __builtin_strcmp (optarg, "cielab") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("cielab"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cielab"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("cielab"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("cielab"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "cielab")))); }) : strncmp (optarg, "cielab", 6))) == 0) |
171 | photometric = PHOTOMETRIC_CIELAB8; |
172 | else if (strncmp(optarg, "icclab", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (6))) || ( __builtin_constant_p ("icclab") && strlen ("icclab") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("icclab") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("icclab"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("icclab") + 1 ) - (size_t)(const void *)("icclab") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (optarg, "icclab") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("icclab" ) && ((size_t)(const void *)(("icclab") + 1) - (size_t )(const void *)("icclab") == 1) ? __builtin_strcmp (optarg, "icclab" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("icclab"); int __result = (((const unsigned char *) (const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("icclab") && ((size_t )(const void *)(("icclab") + 1) - (size_t)(const void *)("icclab" ) == 1) && (__s2_len = __builtin_strlen ("icclab"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t )(const void *)((optarg) + 1) - (size_t)(const void *)(optarg ) == 1) ? __builtin_strcmp (optarg, "icclab") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("icclab"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("icclab"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("icclab"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("icclab"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "icclab")))); }) : strncmp (optarg, "icclab", 6))) == 0) |
173 | photometric = PHOTOMETRIC_ICCLAB9; |
174 | else if (strncmp(optarg, "itulab", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (6))) || ( __builtin_constant_p ("itulab") && strlen ("itulab") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("itulab") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("itulab"), (!((size_t)(const void *)((optarg) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("itulab") + 1 ) - (size_t)(const void *)("itulab") == 1) || __s2_len >= 4 )) ? __builtin_strcmp (optarg, "itulab") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) && (__s1_len = __builtin_strlen (optarg), __s1_len < 4) ? (__builtin_constant_p ("itulab" ) && ((size_t)(const void *)(("itulab") + 1) - (size_t )(const void *)("itulab") == 1) ? __builtin_strcmp (optarg, "itulab" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("itulab"); int __result = (((const unsigned char *) (const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p ("itulab") && ((size_t )(const void *)(("itulab") + 1) - (size_t)(const void *)("itulab" ) == 1) && (__s2_len = __builtin_strlen ("itulab"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t )(const void *)((optarg) + 1) - (size_t)(const void *)(optarg ) == 1) ? __builtin_strcmp (optarg, "itulab") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("itulab"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("itulab"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("itulab"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("itulab"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "itulab")))); }) : strncmp (optarg, "itulab", 6))) == 0) |
175 | photometric = PHOTOMETRIC_ITULAB10; |
176 | else |
177 | photometric = PHOTOMETRIC_MINISBLACK1; |
178 | break; |
179 | case 's': /* do we need to swap bytes? */ |
180 | swab = 1; |
181 | break; |
182 | case 'i': /* type of interleaving */ |
183 | if (strncmp(optarg, "pixel", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (4))) || ( __builtin_constant_p ("pixel") && strlen ("pixel") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("pixel") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("pixel"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("pixel") + 1) - (size_t )(const void *)("pixel") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "pixel") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("pixel") && ((size_t)(const void *)(("pixel") + 1) - (size_t)(const void *)("pixel") == 1) ? __builtin_strcmp (optarg, "pixel") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("pixel"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("pixel") && ((size_t)(const void *)(("pixel") + 1) - (size_t)(const void *)("pixel") == 1) && (__s2_len = __builtin_strlen ("pixel"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - ( size_t)(const void *)(optarg) == 1) ? __builtin_strcmp (optarg , "pixel") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) (const char *) ("pixel"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("pixel"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("pixel"))[2] - __s2 [2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("pixel"))[3] - __s2 [3]); } } __result; })))) : __builtin_strcmp (optarg, "pixel" )))); }) : strncmp (optarg, "pixel", 4))) == 0) |
184 | interleaving = PIXEL; |
185 | else if (strncmp(optarg, "band", 6)(__extension__ (__builtin_constant_p (6) && ((__builtin_constant_p (optarg) && strlen (optarg) < ((size_t) (6))) || ( __builtin_constant_p ("band") && strlen ("band") < ((size_t) (6)))) ? __extension__ ({ size_t __s1_len, __s2_len ; (__builtin_constant_p (optarg) && __builtin_constant_p ("band") && (__s1_len = __builtin_strlen (optarg), __s2_len = __builtin_strlen ("band"), (!((size_t)(const void *)((optarg ) + 1) - (size_t)(const void *)(optarg) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("band") + 1) - (size_t )(const void *)("band") == 1) || __s2_len >= 4)) ? __builtin_strcmp (optarg, "band") : (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) && (__s1_len = __builtin_strlen (optarg ), __s1_len < 4) ? (__builtin_constant_p ("band") && ((size_t)(const void *)(("band") + 1) - (size_t)(const void * )("band") == 1) ? __builtin_strcmp (optarg, "band") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("band"); int __result = (((const unsigned char *) ( const char *) (optarg))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (optarg))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (optarg))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("band") && ((size_t)(const void *)(("band") + 1) - ( size_t)(const void *)("band") == 1) && (__s2_len = __builtin_strlen ("band"), __s2_len < 4) ? (__builtin_constant_p (optarg) && ((size_t)(const void *)((optarg) + 1) - (size_t)(const void * )(optarg) == 1) ? __builtin_strcmp (optarg, "band") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (optarg); int __result = (((const unsigned char *) ( const char *) ("band"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("band"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("band"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("band"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (optarg, "band")))); }) : strncmp (optarg, "band", 6))) == 0) |
186 | interleaving = BAND; |
187 | else |
188 | interleaving = 0; |
189 | break; |
190 | case 'o': |
191 | outfilename = optarg; |
192 | break; |
193 | case 'h': |
194 | usage(); |
195 | default: |
196 | break; |
197 | } |
198 | } |
199 | |
200 | if (argc - optind < 2) |
201 | usage(); |
202 | |
203 | fd = open(argv[optind], O_RDONLY00|O_BINARY0, 0); |
204 | if (fd < 0) { |
205 | fprintf(stderrstderr, "%s: %s: Cannot open input file.\n", |
206 | argv[0], argv[optind]); |
207 | return (-1); |
208 | } |
209 | |
210 | if (guessSize(fd, dtype, hdr_size, nbands, swab, &width, &length) < 0) |
211 | return 1; |
212 | |
213 | if (outfilename == NULL((void*)0)) |
214 | outfilename = argv[optind+1]; |
215 | out = TIFFOpen(outfilename, "w"); |
216 | if (out == NULL((void*)0)) { |
217 | fprintf(stderrstderr, "%s: %s: Cannot open file for output.\n", |
218 | argv[0], outfilename); |
219 | return (-1); |
220 | } |
221 | TIFFSetField(out, TIFFTAG_IMAGEWIDTH256, width); |
222 | TIFFSetField(out, TIFFTAG_IMAGELENGTH257, length); |
223 | TIFFSetField(out, TIFFTAG_ORIENTATION274, ORIENTATION_TOPLEFT1); |
224 | TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL277, nbands); |
225 | TIFFSetField(out, TIFFTAG_BITSPERSAMPLE258, depth * 8); |
226 | TIFFSetField(out, TIFFTAG_FILLORDER266, fillorder); |
227 | TIFFSetField(out, TIFFTAG_PLANARCONFIG284, config); |
228 | TIFFSetField(out, TIFFTAG_PHOTOMETRIC262, photometric); |
229 | switch (dtype) { |
230 | case TIFF_BYTE: |
231 | case TIFF_SHORT: |
232 | case TIFF_LONG: |
233 | TIFFSetField(out, TIFFTAG_SAMPLEFORMAT339, SAMPLEFORMAT_UINT1); |
234 | break; |
235 | case TIFF_SBYTE: |
236 | case TIFF_SSHORT: |
237 | case TIFF_SLONG: |
238 | TIFFSetField(out, TIFFTAG_SAMPLEFORMAT339, SAMPLEFORMAT_INT2); |
239 | break; |
240 | case TIFF_FLOAT: |
241 | case TIFF_DOUBLE: |
242 | TIFFSetField(out, TIFFTAG_SAMPLEFORMAT339, SAMPLEFORMAT_IEEEFP3); |
243 | break; |
244 | default: |
245 | TIFFSetField(out, TIFFTAG_SAMPLEFORMAT339, SAMPLEFORMAT_VOID4); |
246 | break; |
247 | } |
248 | if (compression == (uint16) -1) |
249 | compression = COMPRESSION_PACKBITS32773; |
250 | TIFFSetField(out, TIFFTAG_COMPRESSION259, compression); |
251 | switch (compression) { |
252 | case COMPRESSION_JPEG7: |
253 | if (photometric == PHOTOMETRIC_RGB2 |
254 | && jpegcolormode == JPEGCOLORMODE_RGB0x0001) |
255 | photometric = PHOTOMETRIC_YCBCR6; |
Value stored to 'photometric' is never read | |
256 | TIFFSetField(out, TIFFTAG_JPEGQUALITY65537, quality); |
257 | TIFFSetField(out, TIFFTAG_JPEGCOLORMODE65538, jpegcolormode); |
258 | break; |
259 | case COMPRESSION_LZW5: |
260 | case COMPRESSION_DEFLATE32946: |
261 | if (predictor != 0) |
262 | TIFFSetField(out, TIFFTAG_PREDICTOR317, predictor); |
263 | break; |
264 | } |
265 | switch(interleaving) { |
266 | case BAND: /* band interleaved data */ |
267 | linebytes = width * depth; |
268 | buf = (unsigned char *)_TIFFmalloc(linebytes); |
269 | break; |
270 | case PIXEL: /* pixel interleaved data */ |
271 | default: |
272 | linebytes = width * nbands * depth; |
273 | break; |
274 | } |
275 | bufsize = width * nbands * depth; |
276 | buf1 = (unsigned char *)_TIFFmalloc(bufsize); |
277 | |
278 | rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); |
279 | if (rowsperstrip > length) { |
280 | rowsperstrip = length; |
281 | } |
282 | TIFFSetField(out, TIFFTAG_ROWSPERSTRIP278, rowsperstrip ); |
283 | |
284 | lseek(fd, hdr_size, SEEK_SET0); /* Skip the file header */ |
285 | for (row = 0; row < length; row++) { |
286 | switch(interleaving) { |
287 | case BAND: /* band interleaved data */ |
288 | for (band = 0; band < nbands; band++) { |
289 | lseek(fd, |
290 | hdr_size + (length*band+row)*linebytes, |
291 | SEEK_SET0); |
292 | if (read(fd, buf, linebytes) < 0) { |
293 | fprintf(stderrstderr, |
294 | "%s: %s: scanline %lu: Read error.\n", |
295 | argv[0], argv[optind], |
296 | (unsigned long) row); |
297 | break; |
298 | } |
299 | if (swab) /* Swap bytes if needed */ |
300 | swapBytesInScanline(buf, width, dtype); |
301 | for (col = 0; col < width; col++) |
302 | memcpy(buf1 + (col*nbands+band)*depth, |
303 | buf + col * depth, depth); |
304 | } |
305 | break; |
306 | case PIXEL: /* pixel interleaved data */ |
307 | default: |
308 | if (read(fd, buf1, bufsize) < 0) { |
309 | fprintf(stderrstderr, |
310 | "%s: %s: scanline %lu: Read error.\n", |
311 | argv[0], argv[optind], |
312 | (unsigned long) row); |
313 | break; |
314 | } |
315 | if (swab) /* Swap bytes if needed */ |
316 | swapBytesInScanline(buf1, width, dtype); |
317 | break; |
318 | } |
319 | |
320 | if (TIFFWriteScanline(out, buf1, row, 0) < 0) { |
321 | fprintf(stderrstderr, "%s: %s: scanline %lu: Write error.\n", |
322 | argv[0], outfilename, (unsigned long) row); |
323 | break; |
324 | } |
325 | } |
326 | if (buf) |
327 | _TIFFfree(buf); |
328 | if (buf1) |
329 | _TIFFfree(buf1); |
330 | TIFFClose(out); |
331 | return (0); |
332 | } |
333 | |
334 | static void |
335 | swapBytesInScanline(void *buf, uint32 width, TIFFDataType dtype) |
336 | { |
337 | switch (dtype) { |
338 | case TIFF_SHORT: |
339 | case TIFF_SSHORT: |
340 | TIFFSwabArrayOfShort((uint16*)buf, |
341 | (unsigned long)width); |
342 | break; |
343 | case TIFF_LONG: |
344 | case TIFF_SLONG: |
345 | TIFFSwabArrayOfLong((uint32*)buf, |
346 | (unsigned long)width); |
347 | break; |
348 | /* case TIFF_FLOAT: */ /* FIXME */ |
349 | case TIFF_DOUBLE: |
350 | TIFFSwabArrayOfDouble((double*)buf, |
351 | (unsigned long)width); |
352 | break; |
353 | default: |
354 | break; |
355 | } |
356 | } |
357 | |
358 | static int |
359 | guessSize(int fd, TIFFDataType dtype, off_t hdr_size, uint32 nbands, |
360 | int swab, uint32 *width, uint32 *length) |
361 | { |
362 | const float longt = 40.0; /* maximum possible height/width ratio */ |
363 | char *buf1, *buf2; |
364 | struct stat filestat; |
365 | uint32 w, h, scanlinesize, imagesize; |
366 | uint32 depth = TIFFDataWidth(dtype); |
367 | float cor_coef = 0, tmp; |
368 | |
369 | fstat(fd, &filestat); |
370 | |
371 | if (filestat.st_size < hdr_size) { |
372 | fprintf(stderrstderr, "Too large header size specified.\n"); |
373 | return -1; |
374 | } |
375 | |
376 | imagesize = (filestat.st_size - hdr_size) / nbands / depth; |
377 | |
378 | if (*width != 0 && *length == 0) { |
379 | fprintf(stderrstderr, "Image height is not specified.\n"); |
380 | |
381 | *length = imagesize / *width; |
382 | |
383 | fprintf(stderrstderr, "Height is guessed as %lu.\n", |
384 | (unsigned long)*length); |
385 | |
386 | return 1; |
387 | } else if (*width == 0 && *length != 0) { |
388 | fprintf(stderrstderr, "Image width is not specified.\n"); |
389 | |
390 | *width = imagesize / *length; |
391 | |
392 | fprintf(stderrstderr, "Width is guessed as %lu.\n", |
393 | (unsigned long)*width); |
394 | |
395 | return 1; |
396 | } else if (*width == 0 && *length == 0) { |
397 | fprintf(stderrstderr, "Image width and height are not specified.\n"); |
398 | |
399 | for (w = (uint32) sqrt(imagesize / longt); |
400 | w < sqrt(imagesize * longt); |
401 | w++) { |
402 | if (imagesize % w == 0) { |
403 | scanlinesize = w * depth; |
404 | buf1 = _TIFFmalloc(scanlinesize); |
405 | buf2 = _TIFFmalloc(scanlinesize); |
406 | h = imagesize / w; |
407 | lseek(fd, hdr_size + (int)(h/2)*scanlinesize, |
408 | SEEK_SET0); |
409 | read(fd, buf1, scanlinesize); |
410 | read(fd, buf2, scanlinesize); |
411 | if (swab) { |
412 | swapBytesInScanline(buf1, w, dtype); |
413 | swapBytesInScanline(buf2, w, dtype); |
414 | } |
415 | tmp = (float) fabs(correlation(buf1, buf2, |
416 | w, dtype)); |
417 | if (tmp > cor_coef) { |
418 | cor_coef = tmp; |
419 | *width = w, *length = h; |
420 | } |
421 | |
422 | _TIFFfree(buf1); |
423 | _TIFFfree(buf2); |
424 | } |
425 | } |
426 | |
427 | fprintf(stderrstderr, |
428 | "Width is guessed as %lu, height is guessed as %lu.\n", |
429 | (unsigned long)*width, (unsigned long)*length); |
430 | |
431 | return 1; |
432 | } else { |
433 | if (filestat.st_size<(off_t)(hdr_size+(*width)*(*length)*nbands*depth)) { |
434 | fprintf(stderrstderr, "Input file too small.\n"); |
435 | return -1; |
436 | } |
437 | } |
438 | |
439 | return 1; |
440 | } |
441 | |
442 | /* Calculate correlation coefficient between two numeric vectors */ |
443 | static double |
444 | correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) |
445 | { |
446 | double X, Y, M1 = 0.0, M2 = 0.0, D1 = 0.0, D2 = 0.0, K = 0.0; |
447 | uint32 i; |
448 | |
449 | switch (dtype) { |
450 | case TIFF_BYTE: |
451 | default: |
452 | for (i = 0; i < n_elem; i++) { |
453 | X = ((unsigned char *)buf1)[i]; |
454 | Y = ((unsigned char *)buf2)[i]; |
455 | M1 += X, M2 += Y; |
456 | D1 += X * X, D2 += Y * Y; |
457 | K += X * Y; |
458 | } |
459 | break; |
460 | case TIFF_SBYTE: |
461 | for (i = 0; i < n_elem; i++) { |
462 | X = ((signed char *)buf1)[i]; |
463 | Y = ((signed char *)buf2)[i]; |
464 | M1 += X, M2 += Y; |
465 | D1 += X * X, D2 += Y * Y; |
466 | K += X * Y; |
467 | } |
468 | break; |
469 | case TIFF_SHORT: |
470 | for (i = 0; i < n_elem; i++) { |
471 | X = ((uint16 *)buf1)[i]; |
472 | Y = ((uint16 *)buf2)[i]; |
473 | M1 += X, M2 += Y; |
474 | D1 += X * X, D2 += Y * Y; |
475 | K += X * Y; |
476 | } |
477 | break; |
478 | case TIFF_SSHORT: |
479 | for (i = 0; i < n_elem; i++) { |
480 | X = ((int16 *)buf1)[i]; |
481 | Y = ((int16 *)buf2)[i]; |
482 | M1 += X, M2 += Y; |
483 | D1 += X * X, D2 += Y * Y; |
484 | K += X * Y; |
485 | } |
486 | break; |
487 | case TIFF_LONG: |
488 | for (i = 0; i < n_elem; i++) { |
489 | X = ((uint32 *)buf1)[i]; |
490 | Y = ((uint32 *)buf2)[i]; |
491 | M1 += X, M2 += Y; |
492 | D1 += X * X, D2 += Y * Y; |
493 | K += X * Y; |
494 | } |
495 | break; |
496 | case TIFF_SLONG: |
497 | for (i = 0; i < n_elem; i++) { |
498 | X = ((int32 *)buf1)[i]; |
499 | Y = ((int32 *)buf2)[i]; |
500 | M1 += X, M2 += Y; |
501 | D1 += X * X, D2 += Y * Y; |
502 | K += X * Y; |
503 | } |
504 | break; |
505 | case TIFF_FLOAT: |
506 | for (i = 0; i < n_elem; i++) { |
507 | X = ((float *)buf1)[i]; |
508 | Y = ((float *)buf2)[i]; |
509 | M1 += X, M2 += Y; |
510 | D1 += X * X, D2 += Y * Y; |
511 | K += X * Y; |
512 | } |
513 | break; |
514 | case TIFF_DOUBLE: |
515 | for (i = 0; i < n_elem; i++) { |
516 | X = ((double *)buf1)[i]; |
517 | Y = ((double *)buf2)[i]; |
518 | M1 += X, M2 += Y; |
519 | D1 += X * X, D2 += Y * Y; |
520 | K += X * Y; |
521 | } |
522 | break; |
523 | } |
524 | |
525 | M1 /= n_elem; |
526 | M2 /= n_elem; |
527 | D1 -= M1 * M1 * n_elem; |
528 | D2 -= M2 * M2 * n_elem; |
529 | K = (K - M1 * M2 * n_elem) / sqrt(D1 * D2); |
530 | |
531 | return K; |
532 | } |
533 | |
534 | static int |
535 | processCompressOptions(char* opt) |
536 | { |
537 | if (strcmp(opt, "none")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (opt) && __builtin_constant_p ("none") && (__s1_len = __builtin_strlen (opt), __s2_len = __builtin_strlen ("none" ), (!((size_t)(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("none") + 1) - (size_t)(const void *)("none") == 1) || __s2_len >= 4)) ? __builtin_strcmp (opt, "none") : (__builtin_constant_p (opt) && ((size_t)(const void *)((opt) + 1) - (size_t )(const void *)(opt) == 1) && (__s1_len = __builtin_strlen (opt), __s1_len < 4) ? (__builtin_constant_p ("none") && ((size_t)(const void *)(("none") + 1) - (size_t)(const void * )("none") == 1) ? __builtin_strcmp (opt, "none") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("none"); int __result = (((const unsigned char *) ( const char *) (opt))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (opt))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (opt))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (opt))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("none") && ((size_t)(const void *)(("none") + 1) - ( size_t)(const void *)("none") == 1) && (__s2_len = __builtin_strlen ("none"), __s2_len < 4) ? (__builtin_constant_p (opt) && ((size_t)(const void *)((opt) + 1) - (size_t)(const void *)( opt) == 1) ? __builtin_strcmp (opt, "none") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (opt); int __result = (((const unsigned char *) (const char *) ("none"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("none"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("none"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("none"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (opt, "none")))); }) == 0) |
538 | compression = COMPRESSION_NONE1; |
539 | else if (strcmp(opt, "packbits")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (opt) && __builtin_constant_p ("packbits") && (__s1_len = __builtin_strlen (opt), __s2_len = __builtin_strlen ("packbits"), (!((size_t)(const void *)((opt) + 1) - (size_t )(const void *)(opt) == 1) || __s1_len >= 4) && (! ((size_t)(const void *)(("packbits") + 1) - (size_t)(const void *)("packbits") == 1) || __s2_len >= 4)) ? __builtin_strcmp (opt, "packbits") : (__builtin_constant_p (opt) && ( (size_t)(const void *)((opt) + 1) - (size_t)(const void *)(opt ) == 1) && (__s1_len = __builtin_strlen (opt), __s1_len < 4) ? (__builtin_constant_p ("packbits") && ((size_t )(const void *)(("packbits") + 1) - (size_t)(const void *)("packbits" ) == 1) ? __builtin_strcmp (opt, "packbits") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("packbits"); int __result = (((const unsigned char * ) (const char *) (opt))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (opt))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (opt))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (opt))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("packbits") && ((size_t)(const void *)(("packbits") + 1) - (size_t)(const void *)("packbits") == 1) && ( __s2_len = __builtin_strlen ("packbits"), __s2_len < 4) ? ( __builtin_constant_p (opt) && ((size_t)(const void *) ((opt) + 1) - (size_t)(const void *)(opt) == 1) ? __builtin_strcmp (opt, "packbits") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (opt); int __result = (((const unsigned char *) (const char *) ("packbits"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("packbits"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("packbits"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("packbits"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (opt, "packbits" )))); }) == 0) |
540 | compression = COMPRESSION_PACKBITS32773; |
541 | else if (strncmp(opt, "jpeg", 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p (opt) && strlen (opt) < ((size_t) (4))) || (__builtin_constant_p ("jpeg") && strlen ("jpeg") < ((size_t) (4)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (opt) && __builtin_constant_p ("jpeg") && (__s1_len = __builtin_strlen (opt), __s2_len = __builtin_strlen ("jpeg"), (!((size_t)(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("jpeg") + 1) - (size_t)(const void *)("jpeg") == 1) || __s2_len >= 4)) ? __builtin_strcmp (opt, "jpeg") : (__builtin_constant_p (opt) && ((size_t)(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1) && (__s1_len = __builtin_strlen ( opt), __s1_len < 4) ? (__builtin_constant_p ("jpeg") && ((size_t)(const void *)(("jpeg") + 1) - (size_t)(const void * )("jpeg") == 1) ? __builtin_strcmp (opt, "jpeg") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("jpeg"); int __result = (((const unsigned char *) ( const char *) (opt))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (opt))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (opt))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (opt))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("jpeg") && ((size_t)(const void *)(("jpeg") + 1) - ( size_t)(const void *)("jpeg") == 1) && (__s2_len = __builtin_strlen ("jpeg"), __s2_len < 4) ? (__builtin_constant_p (opt) && ((size_t)(const void *)((opt) + 1) - (size_t)(const void *)( opt) == 1) ? __builtin_strcmp (opt, "jpeg") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (opt); int __result = (((const unsigned char *) (const char *) ("jpeg"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("jpeg"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("jpeg"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("jpeg"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (opt, "jpeg")))); }) : strncmp (opt, "jpeg", 4))) == 0) { |
542 | char* cp = strchr(opt, ':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (opt) && (':') == '\0' ? (char *) __rawmemchr (opt, ':' ) : __builtin_strchr (opt, ':'))); |
543 | |
544 | compression = COMPRESSION_JPEG7; |
545 | while( cp ) |
546 | { |
547 | if (isdigit((int)cp[1])((*__ctype_b_loc ())[(int) (((int)cp[1]))] & (unsigned short int) _ISdigit)) |
548 | quality = atoi(cp+1); |
549 | else if (cp[1] == 'r' ) |
550 | jpegcolormode = JPEGCOLORMODE_RAW0x0000; |
551 | else |
552 | usage(); |
553 | |
554 | cp = strchr(cp+1,':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (cp+1) && (':') == '\0' ? (char *) __rawmemchr (cp+1 , ':') : __builtin_strchr (cp+1, ':'))); |
555 | } |
556 | } else if (strncmp(opt, "lzw", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (opt) && strlen (opt) < ((size_t) (3))) || (__builtin_constant_p ("lzw") && strlen ("lzw") < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (opt) && __builtin_constant_p ("lzw") && (__s1_len = __builtin_strlen (opt), __s2_len = __builtin_strlen ("lzw"), (!((size_t)(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("lzw") + 1) - (size_t)(const void *)("lzw") == 1) || __s2_len >= 4)) ? __builtin_strcmp (opt, "lzw") : (__builtin_constant_p (opt) && ((size_t )(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1 ) && (__s1_len = __builtin_strlen (opt), __s1_len < 4) ? (__builtin_constant_p ("lzw") && ((size_t)(const void *)(("lzw") + 1) - (size_t)(const void *)("lzw") == 1) ? __builtin_strcmp (opt, "lzw") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("lzw"); int __result = (((const unsigned char *) (const char *) (opt ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (opt) )[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (opt) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (opt))[ 3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("lzw" ) && ((size_t)(const void *)(("lzw") + 1) - (size_t)( const void *)("lzw") == 1) && (__s2_len = __builtin_strlen ("lzw"), __s2_len < 4) ? (__builtin_constant_p (opt) && ((size_t)(const void *)((opt) + 1) - (size_t)(const void *)( opt) == 1) ? __builtin_strcmp (opt, "lzw") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (opt); int __result = (((const unsigned char *) (const char *) ("lzw"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lzw"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("lzw"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("lzw"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (opt, "lzw")))); }) : strncmp (opt, "lzw", 3))) == 0) { |
557 | char* cp = strchr(opt, ':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (opt) && (':') == '\0' ? (char *) __rawmemchr (opt, ':' ) : __builtin_strchr (opt, ':'))); |
558 | if (cp) |
559 | predictor = atoi(cp+1); |
560 | compression = COMPRESSION_LZW5; |
561 | } else if (strncmp(opt, "zip", 3)(__extension__ (__builtin_constant_p (3) && ((__builtin_constant_p (opt) && strlen (opt) < ((size_t) (3))) || (__builtin_constant_p ("zip") && strlen ("zip") < ((size_t) (3)))) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (opt) && __builtin_constant_p ("zip") && (__s1_len = __builtin_strlen (opt), __s2_len = __builtin_strlen ("zip"), (!((size_t)(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("zip") + 1) - (size_t)(const void *)("zip") == 1) || __s2_len >= 4)) ? __builtin_strcmp (opt, "zip") : (__builtin_constant_p (opt) && ((size_t )(const void *)((opt) + 1) - (size_t)(const void *)(opt) == 1 ) && (__s1_len = __builtin_strlen (opt), __s1_len < 4) ? (__builtin_constant_p ("zip") && ((size_t)(const void *)(("zip") + 1) - (size_t)(const void *)("zip") == 1) ? __builtin_strcmp (opt, "zip") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("zip"); int __result = (((const unsigned char *) (const char *) (opt ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (opt) )[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (opt) )[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (opt))[ 3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("zip" ) && ((size_t)(const void *)(("zip") + 1) - (size_t)( const void *)("zip") == 1) && (__s2_len = __builtin_strlen ("zip"), __s2_len < 4) ? (__builtin_constant_p (opt) && ((size_t)(const void *)((opt) + 1) - (size_t)(const void *)( opt) == 1) ? __builtin_strcmp (opt, "zip") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (opt); int __result = (((const unsigned char *) (const char *) ("zip"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("zip"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("zip"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("zip"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (opt, "zip")))); }) : strncmp (opt, "zip", 3))) == 0) { |
562 | char* cp = strchr(opt, ':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (opt) && (':') == '\0' ? (char *) __rawmemchr (opt, ':' ) : __builtin_strchr (opt, ':'))); |
563 | if (cp) |
564 | predictor = atoi(cp+1); |
565 | compression = COMPRESSION_DEFLATE32946; |
566 | } else |
567 | return (0); |
568 | return (1); |
569 | } |
570 | |
571 | static char* stuff[] = { |
572 | "raw2tiff --- tool for converting raw byte sequences in TIFF images", |
573 | "usage: raw2tiff [options] input.raw output.tif", |
574 | "where options are:", |
575 | " -L input data has LSB2MSB bit order (default)", |
576 | " -M input data has MSB2LSB bit order", |
577 | " -r # make each strip have no more than # rows", |
578 | " -H # size of input image file header in bytes (0 by default)", |
579 | " -w # width of input image in pixels", |
580 | " -l # length of input image in lines", |
581 | " -b # number of bands in input image (1 by default)", |
582 | "", |
583 | " -d data_type type of samples in input image", |
584 | "where data_type may be:", |
585 | " byte 8-bit unsigned integer (default)", |
586 | " short 16-bit unsigned integer", |
587 | " long 32-bit unsigned integer", |
588 | " sbyte 8-bit signed integer", |
589 | " sshort 16-bit signed integer", |
590 | " slong 32-bit signed integer", |
591 | " float 32-bit IEEE floating point", |
592 | " double 64-bit IEEE floating point", |
593 | "", |
594 | " -p photo photometric interpretation (color space) of the input image", |
595 | "where photo may be:", |
596 | " miniswhite white color represented with 0 value", |
597 | " minisblack black color represented with 0 value (default)", |
598 | " rgb image has RGB color model", |
599 | " cmyk image has CMYK (separated) color model", |
600 | " ycbcr image has YCbCr color model", |
601 | " cielab image has CIE L*a*b color model", |
602 | " icclab image has ICC L*a*b color model", |
603 | " itulab image has ITU L*a*b color model", |
604 | "", |
605 | " -s swap bytes fetched from input file", |
606 | "", |
607 | " -i config type of samples interleaving in input image", |
608 | "where config may be:", |
609 | " pixel pixel interleaved data (default)", |
610 | " band band interleaved data", |
611 | "", |
612 | " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", |
613 | " -c zip[:opts] compress output with deflate encoding", |
614 | " -c jpeg[:opts] compress output with JPEG encoding", |
615 | " -c packbits compress output with packbits encoding", |
616 | " -c none use no compression algorithm on output", |
617 | "", |
618 | "JPEG options:", |
619 | " # set compression quality level (0-100, default 75)", |
620 | " r output color image as RGB rather than YCbCr", |
621 | "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", |
622 | "", |
623 | "LZW and deflate options:", |
624 | " # set predictor value", |
625 | "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", |
626 | " -o out.tif write output to out.tif", |
627 | " -h this help message", |
628 | NULL((void*)0) |
629 | }; |
630 | |
631 | static void |
632 | usage(void) |
633 | { |
634 | char buf[BUFSIZ8192]; |
635 | int i; |
636 | |
637 | setbuf(stderrstderr, buf); |
638 | fprintf(stderrstderr, "%s\n\n", TIFFGetVersion()); |
639 | for (i = 0; stuff[i] != NULL((void*)0); i++) |
640 | fprintf(stderrstderr, "%s\n", stuff[i]); |
641 | exit(-1); |
642 | } |
643 | |
644 | /* vim: set ts=8 sts=8 sw=8 noet: */ |
645 | /* |
646 | * Local Variables: |
647 | * mode: c |
648 | * c-basic-offset: 8 |
649 | * fill-column: 78 |
650 | * End: |
651 | */ |