]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/tiff/libtiff/tif_dirinfo.c
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / src / tiff / libtiff / tif_dirinfo.c
... / ...
CommitLineData
1
2/*
3 * Copyright (c) 1988-1997 Sam Leffler
4 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that (i) the above copyright notices and this permission notice appear in
9 * all copies of the software and related documentation, and (ii) the names of
10 * Sam Leffler and Silicon Graphics may not be used in any advertising or
11 * publicity relating to the software without the specific, prior written
12 * permission of Sam Leffler and Silicon Graphics.
13 *
14 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 *
18 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 * OF THIS SOFTWARE.
24 */
25
26/*
27 * TIFF Library.
28 *
29 * Core Directory Tag Support.
30 */
31#include "tiffiop.h"
32#include <stdlib.h>
33
34/*
35 * NOTE: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG.
36 *
37 * NOTE: The second field (field_readcount) and third field (field_writecount)
38 * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3)
39 * and TIFF_SPP (-2). The macros should be used but would throw off
40 * the formatting of the code, so please interprete the -1, -2 and -3
41 * values accordingly.
42 */
43
44static TIFFFieldArray tiffFieldArray;
45static TIFFFieldArray exifFieldArray;
46
47static TIFFField
48tiffFields[] = {
49 { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL },
50 { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "OldSubfileType", NULL },
51 { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL },
52 { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL },
53 { TIFFTAG_BITSPERSAMPLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL },
54 { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL },
55 { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL },
56 { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL },
57 { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellWidth", NULL },
58 { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellLength", NULL },
59 { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL },
60 { TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL },
61 { TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL },
62 { TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL },
63 { TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL },
64 { TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL },
65 { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL },
66 { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL },
67 { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL },
68 { TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL },
69 { TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL },
70 { TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL },
71 { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL },
72 { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL },
73 { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL },
74 { TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL },
75 { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL },
76 { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL },
77 { TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL },
78 { TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL },
79 { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL },
80 { TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL },
81 { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL },
82 { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL },
83 { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL },
84 { TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL },
85 { TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL },
86 { TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL },
87 { TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL },
88 { TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL },
89 { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL },
90 { TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL },
91 { TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL },
92 { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL },
93 { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL },
94 { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL },
95 { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL },
96 { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL },
97 { TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", &tiffFieldArray },
98 { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL },
99 { TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL },
100 { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NumberOfInks", NULL },
101 { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL },
102 { TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL },
103 { TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL },
104 { TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL },
105 { TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL },
106 { TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL },
107 { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL },
108 { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
109 { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
110 { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL },
111 { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL },
112 { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL },
113 { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL },
114 { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL },
115 { TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "XMLPacket", NULL },
116 /* begin SGI tags */
117 { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL },
118 { TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL },
119 { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL },
120 { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL },
121 /* end SGI tags */
122 /* begin Pixar tags */
123 { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL },
124 { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL },
125 { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL },
126 { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL },
127 { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL },
128 { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL },
129 { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL },
130 { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
131 /* end Pixar tags */
132 { TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
133 { TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Photoshop", NULL },
134 { TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset", &exifFieldArray },
135 { TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile", NULL },
136 { TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GPSIFDOffset", NULL },
137 { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL },
138 { TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL },
139 { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL },
140 { TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL },
141 { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL },
142 { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL },
143 /* begin DNG tags */
144 { TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGVersion", NULL },
145 { TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGBackwardVersion", NULL },
146 { TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL },
147 { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL },
148 { TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CFAPlaneColor", NULL },
149 { TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFALayout", NULL },
150 { TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "LinearizationTable", NULL },
151 { TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BlackLevelRepeatDim", NULL },
152 { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevel", NULL },
153 { TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaH", NULL },
154 { TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaV", NULL },
155 { TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "WhiteLevel", NULL },
156 { TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultScale", NULL },
157 { TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BestQualityScale", NULL },
158 { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropOrigin", NULL },
159 { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropSize", NULL },
160 { TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix1", NULL },
161 { TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix2", NULL },
162 { TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration1", NULL },
163 { TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration2", NULL },
164 { TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix1", NULL },
165 { TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix2", NULL },
166 { TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AnalogBalance", NULL },
167 { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotNeutral", NULL },
168 { TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AsShotWhiteXY", NULL },
169 { TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineExposure", NULL },
170 { TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineNoise", NULL },
171 { TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineSharpness", NULL },
172 { TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BayerGreenSplit", NULL },
173 { TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LinearResponseLimit", NULL },
174 { TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL },
175 { TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LensInfo", NULL },
176 { TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ChromaBlurRadius", NULL },
177 { TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AntiAliasStrength", NULL },
178 { TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ShadowScale", NULL },
179 { TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "DNGPrivateData", NULL },
180 { TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "MakerNoteSafety", NULL },
181 { TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant1", NULL },
182 { TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant2", NULL },
183 { TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "RawDataUniqueID", NULL },
184 { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL },
185 { TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "OriginalRawFileData", NULL },
186 { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ActiveArea", NULL },
187 { TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "MaskedAreas", NULL },
188 { TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotICCProfile", NULL },
189 { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL },
190 { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL },
191 { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix", NULL },
192 { TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
193 /* end DNG tags */
194 /* begin TIFF/FX tags */
195 { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed" },
196 { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL },
197 { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL },
198 { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL },
199 { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL },
200 { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL },
201 { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL },
202 { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL },
203 { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL },
204 { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL },
205 { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL },
206 { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL },
207 /* end DNG tags */
208 /* begin pseudo tags */
209};
210
211static TIFFField
212exifFields[] = {
213 { EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL },
214 { EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL },
215 { EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL },
216 { EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL },
217 { EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL },
218 { EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL },
219 { EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL },
220 { EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL },
221 { EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL },
222 { EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL },
223 { EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL },
224 { EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL },
225 { EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL },
226 { EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL },
227 { EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL },
228 { EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL },
229 { EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL },
230 { EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL },
231 { EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL },
232 { EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL },
233 { EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL },
234 { EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL },
235 { EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL },
236 { EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL },
237 { EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL },
238 { EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL },
239 { EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL },
240 { EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL },
241 { EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL },
242 { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL },
243 { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL },
244 { EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL },
245 { EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL },
246 { EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL },
247 { EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL },
248 { EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL },
249 { EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL },
250 { EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL },
251 { EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL },
252 { EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL },
253 { EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL },
254 { EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL },
255 { EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL },
256 { EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL },
257 { EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL },
258 { EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL },
259 { EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL },
260 { EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL },
261 { EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL },
262 { EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL },
263 { EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL },
264 { EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL },
265 { EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL },
266 { EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL },
267 { EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL },
268 { EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL }
269};
270
271static TIFFFieldArray
272tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), tiffFields };
273static TIFFFieldArray
274exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), exifFields };
275
276/*
277 * We have our own local lfind() equivelent to avoid subtle differences
278 * in types passed to lfind() on different systems.
279 */
280
281static void *
282td_lfind(const void *key, const void *base, size_t *nmemb, size_t size,
283 int(*compar)(const void *, const void *))
284{
285 char *element, *end;
286
287 end = (char *)base + *nmemb * size;
288 for (element = (char *)base; element < end; element += size)
289 if (!compar(key, element)) /* key found */
290 return element;
291
292 return NULL;
293}
294
295const TIFFFieldArray*
296_TIFFGetFields(void)
297{
298 return(&tiffFieldArray);
299}
300
301const TIFFFieldArray*
302_TIFFGetExifFields(void)
303{
304 return(&exifFieldArray);
305}
306
307void
308_TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray)
309{
310 if (tif->tif_fields && tif->tif_nfields > 0) {
311 uint32 i;
312
313 for (i = 0; i < tif->tif_nfields; i++) {
314 TIFFField *fld = tif->tif_fields[i];
315 if (fld->field_bit == FIELD_CUSTOM &&
316 strncmp("Tag ", fld->field_name, 4) == 0) {
317 _TIFFfree(fld->field_name);
318 _TIFFfree(fld);
319 }
320 }
321
322 _TIFFfree(tif->tif_fields);
323 tif->tif_fields = NULL;
324 tif->tif_nfields = 0;
325 }
326 if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count)) {
327 TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFields",
328 "Setting up field info failed");
329 }
330}
331
332static int
333tagCompare(const void* a, const void* b)
334{
335 const TIFFField* ta = *(const TIFFField**) a;
336 const TIFFField* tb = *(const TIFFField**) b;
337 /* NB: be careful of return values for 16-bit platforms */
338 if (ta->field_tag != tb->field_tag)
339 return (int)ta->field_tag - (int)tb->field_tag;
340 else
341 return (ta->field_type == TIFF_ANY) ?
342 0 : ((int)tb->field_type - (int)ta->field_type);
343}
344
345static int
346tagNameCompare(const void* a, const void* b)
347{
348 const TIFFField* ta = *(const TIFFField**) a;
349 const TIFFField* tb = *(const TIFFField**) b;
350 int ret = strcmp(ta->field_name, tb->field_name);
351
352 if (ret)
353 return ret;
354 else
355 return (ta->field_type == TIFF_ANY) ?
356 0 : ((int)tb->field_type - (int)ta->field_type);
357}
358
359int
360_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n)
361{
362 static const char module[] = "_TIFFMergeFields";
363 static const char reason[] = "for fields array";
364 /* TIFFField** tp; */
365 uint32 i;
366
367 tif->tif_foundfield = NULL;
368
369 if (tif->tif_fields && tif->tif_nfields > 0) {
370 tif->tif_fields = (TIFFField**)
371 _TIFFCheckRealloc(tif, tif->tif_fields,
372 (tif->tif_nfields + n),
373 sizeof(TIFFField *), reason);
374 } else {
375 tif->tif_fields = (TIFFField **)
376 _TIFFCheckMalloc(tif, n, sizeof(TIFFField *),
377 reason);
378 }
379 if (!tif->tif_fields) {
380 TIFFErrorExt(tif->tif_clientdata, module,
381 "Failed to allocate fields array");
382 return 0;
383 }
384
385 /* tp = tif->tif_fields + tif->tif_nfields; */
386 for (i = 0; i < n; i++) {
387 const TIFFField *fip =
388 TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
389
390 /* only add definitions that aren't already present */
391 if (!fip) {
392 tif->tif_fields[tif->tif_nfields] = (TIFFField *) (info+i);
393 tif->tif_nfields++;
394 }
395 }
396
397 /* Sort the field info by tag number */
398 qsort(tif->tif_fields, tif->tif_nfields,
399 sizeof(TIFFField *), tagCompare);
400
401 return n;
402}
403
404void
405_TIFFPrintFieldInfo(TIFF* tif, FILE* fd)
406{
407 uint32 i;
408
409 fprintf(fd, "%s: \n", tif->tif_name);
410 for (i = 0; i < tif->tif_nfields; i++) {
411 const TIFFField* fip = tif->tif_fields[i];
412 fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n"
413 , (int)i
414 , (unsigned long) fip->field_tag
415 , fip->field_readcount, fip->field_writecount
416 , fip->field_type
417 , fip->field_bit
418 , fip->field_oktochange ? "TRUE" : "FALSE"
419 , fip->field_passcount ? "TRUE" : "FALSE"
420 , fip->field_name
421 );
422 }
423}
424
425/*
426 * Return size of TIFFDataType in bytes
427 */
428int
429TIFFDataWidth(TIFFDataType type)
430{
431 switch(type)
432 {
433 case 0: /* nothing */
434 case TIFF_BYTE:
435 case TIFF_ASCII:
436 case TIFF_SBYTE:
437 case TIFF_UNDEFINED:
438 return 1;
439 case TIFF_SHORT:
440 case TIFF_SSHORT:
441 return 2;
442 case TIFF_LONG:
443 case TIFF_SLONG:
444 case TIFF_FLOAT:
445 case TIFF_IFD:
446 return 4;
447 case TIFF_RATIONAL:
448 case TIFF_SRATIONAL:
449 case TIFF_DOUBLE:
450 case TIFF_LONG8:
451 case TIFF_SLONG8:
452 case TIFF_IFD8:
453 return 8;
454 default:
455 return 0; /* will return 0 for unknown types */
456 }
457}
458
459/*
460 * Return size of TIFFDataType in bytes.
461 *
462 * XXX: We need a separate function to determine the space needed
463 * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8,
464 * but we use 4-byte float to represent rationals.
465 */
466int
467_TIFFDataSize(TIFFDataType type)
468{
469 switch (type)
470 {
471 case TIFF_BYTE:
472 case TIFF_SBYTE:
473 case TIFF_ASCII:
474 case TIFF_UNDEFINED:
475 return 1;
476 case TIFF_SHORT:
477 case TIFF_SSHORT:
478 return 2;
479 case TIFF_LONG:
480 case TIFF_SLONG:
481 case TIFF_FLOAT:
482 case TIFF_IFD:
483 case TIFF_RATIONAL:
484 case TIFF_SRATIONAL:
485 return 4;
486 case TIFF_DOUBLE:
487 case TIFF_LONG8:
488 case TIFF_SLONG8:
489 case TIFF_IFD8:
490 return 8;
491 default:
492 return 0;
493 }
494}
495
496const TIFFField*
497TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt)
498{
499 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
500 TIFFField* pkey = &key;
501 const TIFFField **ret;
502 if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
503 (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
504 return tif->tif_foundfield;
505
506 /* If we are invoked with no field information, then just return. */
507 if (!tif->tif_fields)
508 return NULL;
509
510 /* NB: use sorted search (e.g. binary search) */
511
512 key.field_tag = tag;
513 key.field_type = dt;
514
515 ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields,
516 tif->tif_nfields,
517 sizeof(TIFFField *), tagCompare);
518 return tif->tif_foundfield = (ret ? *ret : NULL);
519}
520
521const TIFFField*
522_TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt)
523{
524 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
525 TIFFField* pkey = &key;
526 const TIFFField **ret;
527 if (tif->tif_foundfield
528 && streq(tif->tif_foundfield->field_name, field_name)
529 && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
530 return (tif->tif_foundfield);
531
532 /* If we are invoked with no field information, then just return. */
533 if (!tif->tif_fields)
534 return NULL;
535
536 /* NB: use linear search since list is sorted by key#, not name */
537
538 key.field_name = (char *)field_name;
539 key.field_type = dt;
540
541 ret = (const TIFFField **)
542 td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
543 sizeof(TIFFField *), tagNameCompare);
544
545 return tif->tif_foundfield = (ret ? *ret : NULL);
546}
547
548const TIFFField*
549TIFFFieldWithTag(TIFF* tif, uint32 tag)
550{
551 const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
552 if (!fip) {
553 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
554 "Internal error, unknown tag 0x%x",
555 (unsigned int) tag);
556 }
557 return (fip);
558}
559
560const TIFFField*
561TIFFFieldWithName(TIFF* tif, const char *field_name)
562{
563 const TIFFField* fip =
564 _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
565 if (!fip) {
566 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
567 "Internal error, unknown tag %s", field_name);
568 }
569 return (fip);
570}
571
572uint32
573TIFFFieldTag(const TIFFField* fip)
574{
575 return fip->field_tag;
576}
577
578const char *
579TIFFFieldName(const TIFFField* fip)
580{
581 return fip->field_name;
582}
583
584TIFFDataType
585TIFFFieldDataType(const TIFFField* fip)
586{
587 return fip->field_type;
588}
589
590int
591TIFFFieldPassCount(const TIFFField* fip)
592{
593 return fip->field_passcount;
594}
595
596int
597TIFFFieldReadCount(const TIFFField* fip)
598{
599 return fip->field_readcount;
600}
601
602int
603TIFFFieldWriteCount(const TIFFField* fip)
604{
605 return fip->field_writecount;
606}
607
608const TIFFField*
609_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt)
610
611{
612 const TIFFField *fld;
613
614 fld = TIFFFindField(tif, tag, dt);
615 if (fld == NULL) {
616 fld = _TIFFCreateAnonField(tif, tag, dt);
617 if (!_TIFFMergeFields(tif, fld, 1))
618 return NULL;
619 }
620
621 return fld;
622}
623
624TIFFField*
625_TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
626{
627 TIFFField *fld;
628 (void) tif;
629
630 fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField));
631 if (fld == NULL)
632 return NULL;
633 _TIFFmemset(fld, 0, sizeof(TIFFField));
634
635 fld->field_tag = tag;
636 fld->field_readcount = TIFF_VARIABLE2;
637 fld->field_writecount = TIFF_VARIABLE2;
638 fld->field_type = field_type;
639 fld->reserved = 0;
640 switch (field_type)
641 {
642 case TIFF_BYTE:
643 case TIFF_UNDEFINED:
644 fld->set_field_type = TIFF_SETGET_C32_UINT8;
645 fld->get_field_type = TIFF_SETGET_C32_UINT8;
646 break;
647 case TIFF_ASCII:
648 fld->set_field_type = TIFF_SETGET_C32_ASCII;
649 fld->get_field_type = TIFF_SETGET_C32_ASCII;
650 break;
651 case TIFF_SHORT:
652 fld->set_field_type = TIFF_SETGET_C32_UINT16;
653 fld->get_field_type = TIFF_SETGET_C32_UINT16;
654 break;
655 case TIFF_LONG:
656 fld->set_field_type = TIFF_SETGET_C32_UINT32;
657 fld->get_field_type = TIFF_SETGET_C32_UINT32;
658 break;
659 case TIFF_RATIONAL:
660 case TIFF_SRATIONAL:
661 case TIFF_FLOAT:
662 fld->set_field_type = TIFF_SETGET_C32_FLOAT;
663 fld->get_field_type = TIFF_SETGET_C32_FLOAT;
664 break;
665 case TIFF_SBYTE:
666 fld->set_field_type = TIFF_SETGET_C32_SINT8;
667 fld->get_field_type = TIFF_SETGET_C32_SINT8;
668 break;
669 case TIFF_SSHORT:
670 fld->set_field_type = TIFF_SETGET_C32_SINT16;
671 fld->get_field_type = TIFF_SETGET_C32_SINT16;
672 break;
673 case TIFF_SLONG:
674 fld->set_field_type = TIFF_SETGET_C32_SINT32;
675 fld->get_field_type = TIFF_SETGET_C32_SINT32;
676 break;
677 case TIFF_DOUBLE:
678 fld->set_field_type = TIFF_SETGET_C32_DOUBLE;
679 fld->get_field_type = TIFF_SETGET_C32_DOUBLE;
680 break;
681 case TIFF_IFD:
682 case TIFF_IFD8:
683 fld->set_field_type = TIFF_SETGET_C32_IFD8;
684 fld->get_field_type = TIFF_SETGET_C32_IFD8;
685 break;
686 case TIFF_LONG8:
687 fld->set_field_type = TIFF_SETGET_C32_UINT64;
688 fld->get_field_type = TIFF_SETGET_C32_UINT64;
689 break;
690 case TIFF_SLONG8:
691 fld->set_field_type = TIFF_SETGET_C32_SINT64;
692 fld->get_field_type = TIFF_SETGET_C32_SINT64;
693 break;
694 default:
695 fld->set_field_type = TIFF_SETGET_UNDEFINED;
696 fld->get_field_type = TIFF_SETGET_UNDEFINED;
697 break;
698 }
699 fld->field_bit = FIELD_CUSTOM;
700 fld->field_oktochange = TRUE;
701 fld->field_passcount = TRUE;
702 fld->field_name = (char *) _TIFFmalloc(32);
703 if (fld->field_name == NULL) {
704 _TIFFfree(fld);
705 return NULL;
706 }
707 fld->field_subfields = NULL;
708
709 /*
710 * note that this name is a special sign to TIFFClose() and
711 * _TIFFSetupFields() to free the field
712 */
713 sprintf(fld->field_name, "Tag %d", (int) tag);
714
715 return fld;
716}
717
718/****************************************************************************
719 * O B S O L E T E D I N T E R F A C E S
720 *
721 * Don't use this stuff in your applications, it may be removed in the future
722 * libtiff versions.
723 ****************************************************************************/
724
725static TIFFSetGetFieldType
726_TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount)
727{
728 if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
729 return TIFF_SETGET_ASCII;
730
731 else if (count == 1 && passcount == 0) {
732 switch (type)
733 {
734 case TIFF_BYTE:
735 case TIFF_UNDEFINED:
736 return TIFF_SETGET_UINT8;
737 case TIFF_ASCII:
738 return TIFF_SETGET_ASCII;
739 case TIFF_SHORT:
740 return TIFF_SETGET_UINT16;
741 case TIFF_LONG:
742 return TIFF_SETGET_UINT32;
743 case TIFF_RATIONAL:
744 case TIFF_SRATIONAL:
745 case TIFF_FLOAT:
746 return TIFF_SETGET_FLOAT;
747 case TIFF_SBYTE:
748 return TIFF_SETGET_SINT8;
749 case TIFF_SSHORT:
750 return TIFF_SETGET_SINT16;
751 case TIFF_SLONG:
752 return TIFF_SETGET_SINT32;
753 case TIFF_DOUBLE:
754 return TIFF_SETGET_DOUBLE;
755 case TIFF_IFD:
756 case TIFF_IFD8:
757 return TIFF_SETGET_IFD8;
758 case TIFF_LONG8:
759 return TIFF_SETGET_UINT64;
760 case TIFF_SLONG8:
761 return TIFF_SETGET_SINT64;
762 default:
763 return TIFF_SETGET_UNDEFINED;
764 }
765 }
766
767 else if (count >= 1 && passcount == 0) {
768 switch (type)
769 {
770 case TIFF_BYTE:
771 case TIFF_UNDEFINED:
772 return TIFF_SETGET_C0_UINT8;
773 case TIFF_ASCII:
774 return TIFF_SETGET_C0_ASCII;
775 case TIFF_SHORT:
776 return TIFF_SETGET_C0_UINT16;
777 case TIFF_LONG:
778 return TIFF_SETGET_C0_UINT32;
779 case TIFF_RATIONAL:
780 case TIFF_SRATIONAL:
781 case TIFF_FLOAT:
782 return TIFF_SETGET_C0_FLOAT;
783 case TIFF_SBYTE:
784 return TIFF_SETGET_C0_SINT8;
785 case TIFF_SSHORT:
786 return TIFF_SETGET_C0_SINT16;
787 case TIFF_SLONG:
788 return TIFF_SETGET_C0_SINT32;
789 case TIFF_DOUBLE:
790 return TIFF_SETGET_C0_DOUBLE;
791 case TIFF_IFD:
792 case TIFF_IFD8:
793 return TIFF_SETGET_C0_IFD8;
794 case TIFF_LONG8:
795 return TIFF_SETGET_C0_UINT64;
796 case TIFF_SLONG8:
797 return TIFF_SETGET_C0_SINT64;
798 default:
799 return TIFF_SETGET_UNDEFINED;
800 }
801 }
802
803 else if (count == TIFF_VARIABLE && passcount == 1) {
804 switch (type)
805 {
806 case TIFF_BYTE:
807 case TIFF_UNDEFINED:
808 return TIFF_SETGET_C16_UINT8;
809 case TIFF_ASCII:
810 return TIFF_SETGET_C16_ASCII;
811 case TIFF_SHORT:
812 return TIFF_SETGET_C16_UINT16;
813 case TIFF_LONG:
814 return TIFF_SETGET_C16_UINT32;
815 case TIFF_RATIONAL:
816 case TIFF_SRATIONAL:
817 case TIFF_FLOAT:
818 return TIFF_SETGET_C16_FLOAT;
819 case TIFF_SBYTE:
820 return TIFF_SETGET_C16_SINT8;
821 case TIFF_SSHORT:
822 return TIFF_SETGET_C16_SINT16;
823 case TIFF_SLONG:
824 return TIFF_SETGET_C16_SINT32;
825 case TIFF_DOUBLE:
826 return TIFF_SETGET_C16_DOUBLE;
827 case TIFF_IFD:
828 case TIFF_IFD8:
829 return TIFF_SETGET_C16_IFD8;
830 case TIFF_LONG8:
831 return TIFF_SETGET_C16_UINT64;
832 case TIFF_SLONG8:
833 return TIFF_SETGET_C16_SINT64;
834 default:
835 return TIFF_SETGET_UNDEFINED;
836 }
837 }
838
839 else if (count == TIFF_VARIABLE2 && passcount == 1) {
840 switch (type)
841 {
842 case TIFF_BYTE:
843 case TIFF_UNDEFINED:
844 return TIFF_SETGET_C32_UINT8;
845 case TIFF_ASCII:
846 return TIFF_SETGET_C32_ASCII;
847 case TIFF_SHORT:
848 return TIFF_SETGET_C32_UINT16;
849 case TIFF_LONG:
850 return TIFF_SETGET_C32_UINT32;
851 case TIFF_RATIONAL:
852 case TIFF_SRATIONAL:
853 case TIFF_FLOAT:
854 return TIFF_SETGET_C32_FLOAT;
855 case TIFF_SBYTE:
856 return TIFF_SETGET_C32_SINT8;
857 case TIFF_SSHORT:
858 return TIFF_SETGET_C32_SINT16;
859 case TIFF_SLONG:
860 return TIFF_SETGET_C32_SINT32;
861 case TIFF_DOUBLE:
862 return TIFF_SETGET_C32_DOUBLE;
863 case TIFF_IFD:
864 case TIFF_IFD8:
865 return TIFF_SETGET_C32_IFD8;
866 case TIFF_LONG8:
867 return TIFF_SETGET_C32_UINT64;
868 case TIFF_SLONG8:
869 return TIFF_SETGET_C32_SINT64;
870 default:
871 return TIFF_SETGET_UNDEFINED;
872 }
873 }
874
875 return TIFF_SETGET_UNDEFINED;
876}
877
878int
879TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
880{
881 static const char module[] = "TIFFMergeFieldInfo";
882 static const char reason[] = "for fields array";
883 TIFFField *tp;
884 size_t nfields;
885 uint32 i;
886
887 if (tif->tif_nfieldscompat > 0) {
888 tif->tif_fieldscompat = (TIFFFieldArray *)
889 _TIFFCheckRealloc(tif, tif->tif_fieldscompat,
890 tif->tif_nfieldscompat + 1,
891 sizeof(TIFFFieldArray), reason);
892 } else {
893 tif->tif_fieldscompat = (TIFFFieldArray *)
894 _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray),
895 reason);
896 }
897 if (!tif->tif_fieldscompat) {
898 TIFFErrorExt(tif->tif_clientdata, module,
899 "Failed to allocate fields array");
900 return -1;
901 }
902 nfields = tif->tif_nfieldscompat++;
903
904 tif->tif_fieldscompat[nfields].type = tfiatOther;
905 tif->tif_fieldscompat[nfields].allocated_size = n;
906 tif->tif_fieldscompat[nfields].count = n;
907 tif->tif_fieldscompat[nfields].fields =
908 (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField),
909 reason);
910 if (!tif->tif_fieldscompat[nfields].fields) {
911 TIFFErrorExt(tif->tif_clientdata, module,
912 "Failed to allocate fields array");
913 return -1;
914 }
915
916 tp = tif->tif_fieldscompat[nfields].fields;
917 for (i = 0; i < n; i++) {
918 tp->field_tag = info[i].field_tag;
919 tp->field_readcount = info[i].field_readcount;
920 tp->field_writecount = info[i].field_writecount;
921 tp->field_type = info[i].field_type;
922 tp->reserved = 0;
923 tp->set_field_type =
924 _TIFFSetGetType(info[i].field_type,
925 info[i].field_readcount,
926 info[i].field_passcount);
927 tp->get_field_type =
928 _TIFFSetGetType(info[i].field_type,
929 info[i].field_readcount,
930 info[i].field_passcount);
931 tp->field_bit = info[i].field_bit;
932 tp->field_oktochange = info[i].field_oktochange;
933 tp->field_passcount = info[i].field_passcount;
934 tp->field_name = info[i].field_name;
935 tp->field_subfields = NULL;
936 tp++;
937 }
938
939 if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) {
940 TIFFErrorExt(tif->tif_clientdata, module,
941 "Setting up field info failed");
942 return -1;
943 }
944
945 return 0;
946}
947
948/* vim: set ts=8 sts=8 sw=8 noet: */
949
950/*
951 * Local Variables:
952 * mode: c
953 * c-basic-offset: 8
954 * fill-column: 78
955 * End:
956 */