Line data Source code
1 : /*
2 : * Copyright (c) 1988-1997 Sam Leffler
3 : * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4 : *
5 : * Permission to use, copy, modify, distribute, and sell this software and
6 : * its documentation for any purpose is hereby granted without fee, provided
7 : * that (i) the above copyright notices and this permission notice appear in
8 : * all copies of the software and related documentation, and (ii) the names of
9 : * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 : * publicity relating to the software without the specific, prior written
11 : * permission of Sam Leffler and Silicon Graphics.
12 : *
13 : * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 : * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 : * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16 : *
17 : * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 : * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 : * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 : * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 : * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 : * OF THIS SOFTWARE.
23 : */
24 :
25 : /*
26 : * TIFF Library.
27 : *
28 : * Core Directory Tag Support.
29 : */
30 : #include "tiffiop.h"
31 : #include <stdlib.h>
32 :
33 : /*
34 : * NOTE: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG.
35 : *
36 : * NOTE: The second field (field_readcount) and third field (field_writecount)
37 : * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3)
38 : * and TIFF_SPP (-2). The macros should be used but would throw off
39 : * the formatting of the code, so please interpret the -1, -2 and -3
40 : * values accordingly.
41 : */
42 :
43 : /* const object should be initialized */
44 : #ifdef _MSC_VER
45 : #pragma warning(push)
46 : #pragma warning(disable : 4132)
47 : #endif
48 : static const TIFFFieldArray tiffFieldArray;
49 : static const TIFFFieldArray exifFieldArray;
50 : static const TIFFFieldArray gpsFieldArray;
51 : #ifdef _MSC_VER
52 : #pragma warning(pop)
53 : #endif
54 : /*--: Rational2Double: --
55 : * The Rational2Double upgraded libtiff functionality allows the definition and
56 : * achievement of true double-precision accuracy for TIFF tags of RATIONAL type
57 : * and field_bit=FIELD_CUSTOM using the set_field_type = TIFF_SETGET_DOUBLE.
58 : * Unfortunately, that changes the old implemented interface for TIFFGetField().
59 : * In order to keep the old TIFFGetField() interface behavior those tags have to
60 : * be redefined with set_field_type = TIFF_SETGET_FLOAT!
61 : *
62 : * Rational custom arrays are already defined as _Cxx_FLOAT, thus can stay.
63 : *
64 : */
65 :
66 : /* clang-format off */ /* for better readability of tag comments */
67 : static const TIFFField tiffFields[] = {
68 : {TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL},
69 : {TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "OldSubfileType", NULL},
70 : {TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL},
71 : {TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL},
72 : {TIFFTAG_BITSPERSAMPLE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL},
73 : {TIFFTAG_COMPRESSION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL},
74 : {TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL},
75 : {TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL},
76 : {TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellWidth", NULL},
77 : {TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellLength", NULL},
78 : {TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL},
79 : {TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL},
80 : {TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL},
81 : {TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL},
82 : {TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL},
83 : {TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL},
84 : {TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL},
85 : {TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL},
86 : {TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL},
87 : {TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL},
88 : {TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL},
89 : {TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL},
90 : {TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL},
91 : {TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL},
92 : {TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL},
93 : {TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL},
94 : {TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL},
95 : {TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL},
96 : {TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL},
97 : {TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL},
98 : {TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL},
99 : {TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL},
100 : {TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL},
101 : {TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL},
102 : {TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL},
103 : {TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL},
104 : {TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL},
105 : {TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL},
106 : {TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL},
107 : {TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL},
108 : {TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL},
109 : {TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL},
110 : {TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL},
111 : {TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL},
112 : {TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL},
113 : {TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL},
114 : {TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL},
115 : {TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL},
116 : {TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", (TIFFFieldArray *)&tiffFieldArray},
117 : {TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL},
118 : {TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL},
119 : {TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_NUMBEROFINKS, 1, 0, "NumberOfInks", NULL},
120 : {TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL},
121 : {TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL},
122 : {TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL},
123 : {TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL},
124 : {TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL},
125 : {TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL},
126 : {TIFFTAG_CLIPPATH, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL},
127 : {TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL},
128 : {TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL},
129 : {TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL},
130 : {TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL},
131 : {TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL},
132 : {TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL},
133 : {TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "XMLPacket", NULL},
134 : /* begin SGI tags */
135 : {TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL},
136 : {TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL},
137 : {TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL},
138 : {TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL},
139 : /* end SGI tags */
140 : /* begin Pixar tags */
141 : {TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL},
142 : {TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL},
143 : {TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL},
144 : {TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL},
145 : {TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL},
146 : {TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL},
147 : {TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL},
148 : {TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL},
149 : /* end Pixar tags */
150 : {TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "RichTIFFIPTC", NULL},
151 : {TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Photoshop", NULL},
152 : /*--: EXIFIFD and GPSIFD specified as TIFF_LONG by Aware-Systems and not TIFF_IFD8 as in original LibTiff. However, for IFD-like tags,
153 : * libtiff uses the data type TIFF_IFD8 in tiffFields[]-tag definition combined with a special handling procedure in order to write either
154 : * a 32-bit value and the TIFF_IFD type-id into ClassicTIFF files or a 64-bit value and the TIFF_IFD8 type-id into BigTIFF files. */
155 : {TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EXIFIFDOffset", (TIFFFieldArray *)&exifFieldArray},
156 : {TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ICC Profile", NULL},
157 : {TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GPSIFDOffset", (TIFFFieldArray *)&gpsFieldArray},
158 : {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL},
159 : {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL},
160 : {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL},
161 : {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL},
162 : {TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL},
163 : {TIFFTAG_IMAGESOURCEDATA, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Adobe Photoshop Document Data Block", NULL},
164 : {TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL},
165 : /* begin DNG tags */
166 : {TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DNGVersion", NULL},
167 : {TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DNGBackwardVersion", NULL},
168 : {TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL},
169 : {TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL},
170 : {TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPlaneColor", NULL},
171 : {TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CFALayout", NULL},
172 : {TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LinearizationTable", NULL},
173 : {TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BlackLevelRepeatDim", NULL},
174 : {TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevel", NULL},
175 : {TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaH", NULL},
176 : {TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaV", NULL},
177 : {TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "WhiteLevel", NULL},
178 : {TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultScale", NULL},
179 : {TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BestQualityScale", NULL},
180 : {TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultCropOrigin", NULL},
181 : {TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultCropSize", NULL},
182 : {TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix1", NULL},
183 : {TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix2", NULL},
184 : {TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration1", NULL},
185 : {TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration2", NULL},
186 : {TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix1", NULL},
187 : {TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix2", NULL},
188 : {TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AnalogBalance", NULL},
189 : {TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotNeutral", NULL},
190 : {TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AsShotWhiteXY", NULL},
191 : {TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineExposure", NULL},
192 : {TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineNoise", NULL},
193 : {TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineSharpness", NULL},
194 : {TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BayerGreenSplit", NULL},
195 : {TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LinearResponseLimit", NULL},
196 : {TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL},
197 : {TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensInfo", NULL},
198 : {TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ChromaBlurRadius", NULL},
199 : {TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AntiAliasStrength", NULL},
200 : {TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShadowScale", NULL},
201 : {TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DNGPrivateData", NULL},
202 : {TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MakerNoteSafety", NULL},
203 : {TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant1", NULL},
204 : {TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant2", NULL},
205 : {TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawDataUniqueID", NULL},
206 : {TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL},
207 : {TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileData", NULL},
208 : {TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ActiveArea", NULL},
209 : {TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MaskedAreas", NULL},
210 : {TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotICCProfile", NULL},
211 : {TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotPreProfileMatrix", NULL},
212 : {TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentICCProfile", NULL},
213 : {TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentPreProfileMatrix", NULL},
214 : {TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
215 : #if 0
216 : /* begin DNG 1.2.0.0 tags */
217 : {TIFFTAG_COLORIMETRICREFERENCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorimetricReference", NULL},
218 : {TIFFTAG_CAMERACALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibrationSignature", NULL},
219 : {TIFFTAG_PROFILECALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileCalibrationSignature", NULL},
220 : {TIFFTAG_EXTRACAMERAPROFILES, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ExtraCameraProfiles", NULL},
221 : {TIFFTAG_ASSHOTPROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotProfileName", NULL},
222 : {TIFFTAG_NOISEREDUCTIONAPPLIED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NoiseReductionApplied", NULL},
223 : {TIFFTAG_PROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileName", NULL},
224 : {TIFFTAG_PROFILEHUESATMAPDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapDims", NULL},
225 : {TIFFTAG_PROFILEHUESATMAPDATA1, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData1", NULL},
226 : {TIFFTAG_PROFILEHUESATMAPDATA2, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData2", NULL},
227 : {TIFFTAG_PROFILETONECURVE, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileToneCurve", NULL},
228 : {TIFFTAG_PROFILEEMBEDPOLICY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileEmbedPolicy", NULL},
229 : {TIFFTAG_PROFILECOPYRIGHT, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileCopyright", NULL},
230 : {TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix1", NULL},
231 : {TIFFTAG_FORWARDMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix2", NULL},
232 : {TIFFTAG_PREVIEWAPPLICATIONNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewApplicationName", NULL},
233 : {TIFFTAG_PREVIEWAPPLICATIONVERSION, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewApplicationVersion", NULL},
234 : {TIFFTAG_PREVIEWSETTINGSNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewSettingsName", NULL},
235 : {TIFFTAG_PREVIEWSETTINGSDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewSettingsDigest", NULL},
236 : {TIFFTAG_PREVIEWCOLORSPACE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewColorSpace", NULL},
237 : {TIFFTAG_PREVIEWDATETIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewDateTime", NULL},
238 : {TIFFTAG_RAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawImageDigest", NULL},
239 : {TIFFTAG_ORIGINALRAWFILEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalRawFileDigest", NULL},
240 : {TIFFTAG_SUBTILEBLOCKSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubTileBlockSize", NULL},
241 : {TIFFTAG_ROWINTERLEAVEFACTOR, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RowInterleaveFactor", NULL},
242 : {TIFFTAG_PROFILELOOKTABLEDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileLookTableDims", NULL},
243 : {TIFFTAG_PROFILELOOKTABLEDATA, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileLookTableData", NULL},
244 : /* begin DNG 1.3.0.0 tags */
245 : {TIFFTAG_OPCODELIST1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList1", NULL},
246 : {TIFFTAG_OPCODELIST2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList2", NULL},
247 : {TIFFTAG_OPCODELIST3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList3", NULL},
248 : {TIFFTAG_NOISEPROFILE, -1, -1, TIFF_DOUBLE, 0, TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "NoiseProfile", NULL},
249 : /* begin DNG 1.4.0.0 tags */
250 : {TIFFTAG_DEFAULTUSERCROP, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultUserCrop", NULL},
251 : {TIFFTAG_DEFAULTBLACKRENDER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultBlackRender", NULL},
252 : {TIFFTAG_BASELINEEXPOSUREOFFSET, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineExposureOffset", NULL},
253 : {TIFFTAG_PROFILELOOKTABLEENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileLookTableEncoding", NULL},
254 : {TIFFTAG_PROFILEHUESATMAPENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapEncoding", NULL},
255 : {TIFFTAG_ORIGINALDEFAULTFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalDefaultFinalSize", NULL},
256 : {TIFFTAG_ORIGINALBESTQUALITYFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalBestQualityFinalSize", NULL},
257 : {TIFFTAG_ORIGINALDEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalDefaultCropSize", NULL}, /* could also be rational */
258 : {TIFFTAG_NEWRAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NewRawImageDigest", NULL},
259 : {TIFFTAG_RAWTOPREVIEWGAIN, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawToPreviewGain", NULL},
260 : /* begin DNG 1.5.0.0 tags */
261 : {TIFFTAG_DEPTHFORMAT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthFormat", NULL},
262 : {TIFFTAG_DEPTHNEAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthNear", NULL},
263 : {TIFFTAG_DEPTHFAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthFar", NULL},
264 : {TIFFTAG_DEPTHUNITS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthUnits", NULL},
265 : {TIFFTAG_DEPTHMEASURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthMeasureType", NULL},
266 : {TIFFTAG_ENHANCEPARAMS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EnhanceParams", NULL},
267 : /* begin DNG 1.6.0.0 tags */
268 : {TIFFTAG_PROFILEGAINTABLEMAP, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileGainTableMap", NULL},
269 : {TIFFTAG_SEMANTICNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SemanticName", NULL},
270 : {TIFFTAG_SEMANTICINSTANCEID, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SemanticInstanceID", NULL},
271 : {TIFFTAG_MASKSUBAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaskSubArea", NULL},
272 : {TIFFTAG_RGBTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "RGBTables", NULL},
273 : {TIFFTAG_CALIBRATIONILLUMINANT3, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant3", NULL},
274 : {TIFFTAG_COLORMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix3", NULL},
275 : {TIFFTAG_CAMERACALIBRATION3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration3", NULL},
276 : {TIFFTAG_REDUCTIONMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix3", NULL},
277 : {TIFFTAG_PROFILEHUESATMAPDATA3, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData3", NULL},
278 : {TIFFTAG_FORWARDMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix3", NULL},
279 : {TIFFTAG_ILLUMINANTDATA1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData1", NULL},
280 : {TIFFTAG_ILLUMINANTDATA2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData2", NULL},
281 : {TIFFTAG_ILLUMINANTDATA3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData3", NULL},
282 : /* end DNG tags */
283 : #endif
284 : /* begin TIFF/EP tags */
285 : {TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP CFARepeatPatternDim", NULL},
286 : {TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP CFAPattern", NULL},
287 : #if 0
288 : /* TIFFTAG_EP_BATTERYLEVEL can be RATIONAL or ASCII.
289 : * LibTiff defines it as ASCII and converts RATIONAL to an ASCII string. */
290 : {TIFFTAG_EP_BATTERYLEVEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP BatteryLevel", NULL},
291 : {TIFFTAG_EP_INTERLACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP Interlace", NULL},
292 : /* TIFFTAG_EP_IPTC_NAA and TIFFTAG_RICHTIFFIPTC share the same tag number (33723)
293 : * LibTIFF type is UNDEFINED or BYTE, but often times incorrectly specified as LONG, because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII. */
294 : {TIFFTAG_EP_TIMEZONEOFFSET, -1, -1, TIFF_SSHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP TimeZoneOffset", NULL},
295 : {TIFFTAG_EP_SELFTIMERMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SelfTimerMode", NULL},
296 : {TIFFTAG_EP_FLASHENERGY, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FlashEnergy", NULL},
297 : {TIFFTAG_EP_SPATIALFREQUENCYRESPONSE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SpatialFrequencyResponse", NULL},
298 : {TIFFTAG_EP_NOISE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP Noise", NULL},
299 : {TIFFTAG_EP_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneXResolution", NULL},
300 : {TIFFTAG_EP_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneYResolution", NULL},
301 : {TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneResolutionUnit", NULL},
302 : {TIFFTAG_EP_IMAGENUMBER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ImageNumber", NULL}, /* or SHORT */
303 : {TIFFTAG_EP_SECURITYCLASSIFICATION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SecurityClassification", NULL},
304 : {TIFFTAG_EP_IMAGEHISTORY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ImageHistory", NULL},
305 : {TIFFTAG_EP_EXPOSUREINDEX, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureIndex", NULL},
306 : {TIFFTAG_EP_STANDARDID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP StandardId", NULL},
307 : {TIFFTAG_EP_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SensingMethod", NULL},
308 : /* TIFF/EP tags equivalent to EXIF tags, sometimes defined differently. */
309 : {TIFFTAG_EP_EXPOSURETIME, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureTime", NULL}, /*N=1 or 2 */
310 : {TIFFTAG_EP_FNUMBER, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FNumber", NULL},
311 : {TIFFTAG_EP_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ExposureProgram", NULL},
312 : {TIFFTAG_EP_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SpectralSensitivity", NULL},
313 : {TIFFTAG_EP_ISOSPEEDRATINGS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ISOSpeedRatings", NULL},
314 : {TIFFTAG_EP_OECF, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP OptoelectricConversionFactor", NULL},
315 : {TIFFTAG_EP_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP DateTimeOriginal", NULL},
316 : {TIFFTAG_EP_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP CompressedBitsPerPixel", NULL},
317 : {TIFFTAG_EP_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ShutterSpeedValue", NULL},
318 : {TIFFTAG_EP_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ApertureValue", NULL},
319 : {TIFFTAG_EP_BRIGHTNESSVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP BrightnessValue", NULL},
320 : {TIFFTAG_EP_EXPOSUREBIASVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureBiasValue", NULL}, /*N=1 or 2 */
321 : {TIFFTAG_EP_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP MaxApertureValue", NULL},
322 : {TIFFTAG_EP_SUBJECTDISTANCE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectDistance", NULL},
323 : {TIFFTAG_EP_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP MeteringMode", NULL},
324 : {TIFFTAG_EP_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP LightSource", NULL},
325 : {TIFFTAG_EP_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP Flash", NULL},
326 : {TIFFTAG_EP_FOCALLENGTH, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FocalLength", NULL},
327 : {TIFFTAG_EP_SUBJECTLOCATION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectLocation", NULL},
328 : /* end TIFF/EP tags */
329 : #endif
330 : /* begin TIFF/FX tags */
331 : {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Indexed", NULL},
332 : {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GlobalParametersIFD", NULL},
333 : {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileType", NULL},
334 : {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FaxProfile", NULL},
335 : {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CodingMethods", NULL},
336 : {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "VersionYear", NULL},
337 : {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ModeNumber", NULL},
338 : {TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Decode", NULL},
339 : {TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ImageBaseColor", NULL},
340 : {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "T82Options", NULL},
341 : {TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "StripRowCounts", NULL},
342 : {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageLayer", NULL},
343 : /* end TIFF/FX tags */
344 : /* begin pseudo tags */
345 : };
346 :
347 : /*
348 : * EXIF tags (Version 2.31, July 2016 plus version 2.32 May 2019)
349 : */
350 : static const TIFFField exifFields[] = {
351 : {EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL},
352 : {EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL},
353 : {EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL},
354 : {EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL},
355 : /* After EXIF 2.2.1 ISOSpeedRatings is named PhotographicSensitivity. In addition, while "Count=Any", only 1 count should be used. */
356 : {EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL},
357 : {EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL},
358 : {EXIFTAG_SENSITIVITYTYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensitivityType", NULL},
359 : {EXIFTAG_STANDARDOUTPUTSENSITIVITY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "StandardOutputSensitivity", NULL},
360 : {EXIFTAG_RECOMMENDEDEXPOSUREINDEX, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RecommendedExposureIndex", NULL},
361 : {EXIFTAG_ISOSPEED, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeed", NULL},
362 : {EXIFTAG_ISOSPEEDLATITUDEYYY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudeyyy", NULL},
363 : {EXIFTAG_ISOSPEEDLATITUDEZZZ, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudezzz", NULL},
364 : {EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL},
365 : {EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL},
366 : {EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL},
367 : {EXIFTAG_OFFSETTIME, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTime", NULL},
368 : {EXIFTAG_OFFSETTIMEORIGINAL, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeOriginal", NULL},
369 : {EXIFTAG_OFFSETTIMEDIGITIZED, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeDigitized", NULL},
370 : {EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL},
371 : {EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL},
372 : {EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL},
373 : {EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL},
374 : {EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL},
375 : {EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL},
376 : {EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL},
377 : /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
378 : * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values,
379 : * which are not treated within LibTiff!! */
380 : {EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL},
381 : {EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL},
382 : {EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL},
383 : {EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL},
384 : {EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL},
385 : {EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL},
386 : {EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL},
387 : {EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL},
388 : {EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL},
389 : {EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL},
390 : {EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL},
391 : {EXIFTAG_TEMPERATURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Temperature", NULL},
392 : {EXIFTAG_HUMIDITY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Humidity", NULL},
393 : {EXIFTAG_PRESSURE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Pressure", NULL},
394 : {EXIFTAG_WATERDEPTH, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WaterDepth", NULL},
395 : {EXIFTAG_ACCELERATION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Acceleration", NULL},
396 : {EXIFTAG_CAMERAELEVATIONANGLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraElevationAngle", NULL},
397 : {EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL},
398 : {EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL},
399 : {EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL},
400 : {EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL},
401 : {EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL},
402 : {EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL},
403 : {EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL},
404 : {EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL},
405 : {EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL},
406 : {EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL},
407 : {EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL},
408 : {EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL},
409 : {EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL},
410 : {EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL},
411 : {EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL},
412 : {EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL},
413 : {EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL},
414 : {EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL},
415 : {EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL},
416 : {EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL},
417 : {EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL},
418 : {EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL},
419 : {EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL},
420 : {EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL},
421 : {EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL},
422 : {EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL},
423 : {EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL},
424 : {EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL},
425 : {EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL},
426 : {EXIFTAG_CAMERAOWNERNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraOwnerName", NULL},
427 : {EXIFTAG_BODYSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BodySerialNumber", NULL},
428 : {EXIFTAG_LENSSPECIFICATION, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSpecification", NULL},
429 : {EXIFTAG_LENSMAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensMake", NULL},
430 : {EXIFTAG_LENSMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensModel", NULL},
431 : {EXIFTAG_LENSSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSerialNumber", NULL},
432 : {EXIFTAG_GAMMA, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Gamma", NULL},
433 : {EXIFTAG_COMPOSITEIMAGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompositeImage", NULL},
434 : {EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SourceImageNumberOfCompositeImage", NULL},
435 : {EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1,
436 : "SourceExposureTimesOfCompositeImage", NULL}};
437 : /*
438 : * EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May
439 : * 2019)
440 : */
441 :
442 : static const TIFFField gpsFields[] = {
443 : /* For the GPS tag definitions in gpsFields[] the standard definition for Rationals is TIFF_SETGET_DOUBLE and TIFF_SETGET_C0_FLOAT.
444 : *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values can now be written and also read in double precision!
445 : * In order to achieve double precision for GPS tags: Standard definitions for GPSTAG is kept to TIFF_SETGET_DOUBLE
446 : * and TIFF_SETGET_C0_FLOAT is changed to TIFF_SETGET_C0_DOUBLE.
447 : */
448 : {GPSTAG_VERSIONID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "VersionID", NULL},
449 : {GPSTAG_LATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LatitudeRef", NULL},
450 : {GPSTAG_LATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Latitude", NULL},
451 : {GPSTAG_LONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LongitudeRef", NULL},
452 : {GPSTAG_LONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Longitude", NULL},
453 : {GPSTAG_ALTITUDEREF, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AltitudeRef", NULL},
454 : {GPSTAG_ALTITUDE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Altitude", NULL},
455 : {GPSTAG_TIMESTAMP, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TimeStamp", NULL},
456 : {GPSTAG_SATELLITES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Satellites", NULL},
457 : {GPSTAG_STATUS, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Status", NULL},
458 : {GPSTAG_MEASUREMODE, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeasureMode", NULL},
459 : {GPSTAG_DOP, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DOP", NULL},
460 : {GPSTAG_SPEEDREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpeedRef", NULL},
461 : {GPSTAG_SPEED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Speed", NULL},
462 : {GPSTAG_TRACKREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TrackRef", NULL},
463 : {GPSTAG_TRACK, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Track", NULL},
464 : {GPSTAG_IMGDIRECTIONREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImgDirectionRef", NULL},
465 : {GPSTAG_IMGDIRECTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImgDirection", NULL},
466 : {GPSTAG_MAPDATUM, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MapDatum", NULL},
467 : {GPSTAG_DESTLATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLatitudeRef", NULL},
468 : {GPSTAG_DESTLATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLatitude", NULL},
469 : {GPSTAG_DESTLONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLongitudeRef", NULL},
470 : {GPSTAG_DESTLONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLongitude", NULL},
471 : {GPSTAG_DESTBEARINGREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestBearingRef", NULL},
472 : {GPSTAG_DESTBEARING, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestBearing", NULL},
473 : {GPSTAG_DESTDISTANCEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestDistanceRef", NULL},
474 : {GPSTAG_DESTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestDistance", NULL},
475 : {GPSTAG_PROCESSINGMETHOD, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProcessingMethod", NULL},
476 : {GPSTAG_AREAINFORMATION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AreaInformation", NULL},
477 : {GPSTAG_DATESTAMP, 11, 11, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateStamp", NULL},
478 : {GPSTAG_DIFFERENTIAL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Differential", NULL},
479 : {GPSTAG_GPSHPOSITIONINGERROR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HorizontalPositioningError", NULL}};
480 : /* clang-format on */ /* was off for better readability of tag comments */
481 :
482 : static const TIFFFieldArray tiffFieldArray = {
483 : tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField *)tiffFields};
484 : static const TIFFFieldArray exifFieldArray = {
485 : tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField *)exifFields};
486 : static const TIFFFieldArray gpsFieldArray = {
487 : tfiatGps, 0, TIFFArrayCount(gpsFields), (TIFFField *)gpsFields};
488 :
489 : /*
490 : * We have our own local lfind() equivalent to avoid subtle differences
491 : * in types passed to lfind() on different systems.
492 : */
493 :
494 0 : static void *td_lfind(const void *key, const void *base, size_t *nmemb,
495 : size_t size, int (*compar)(const void *, const void *))
496 : {
497 : char *element, *end;
498 :
499 0 : end = (char *)base + *nmemb * size;
500 0 : for (element = (char *)base; element < end; element += size)
501 0 : if (!compar(key, element)) /* key found */
502 0 : return element;
503 :
504 0 : return NULL;
505 : }
506 :
507 118433 : const TIFFFieldArray *_TIFFGetFields(void) { return (&tiffFieldArray); }
508 :
509 0 : const TIFFFieldArray *_TIFFGetExifFields(void) { return (&exifFieldArray); }
510 :
511 0 : const TIFFFieldArray *_TIFFGetGpsFields(void) { return (&gpsFieldArray); }
512 :
513 118428 : void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
514 : {
515 118428 : if (tif->tif_fields && tif->tif_nfields > 0)
516 : {
517 : uint32_t i;
518 :
519 9433240 : for (i = 0; i < tif->tif_nfields; i++)
520 : {
521 9377230 : TIFFField *fld = tif->tif_fields[i];
522 9377230 : if (fld->field_name != NULL)
523 : {
524 9377130 : if (fld->field_bit == FIELD_CUSTOM && TIFFFieldIsAnonymous(fld))
525 : {
526 0 : _TIFFfreeExt(tif, fld->field_name);
527 : /* caution: tif_fields[i] must not be the beginning of a
528 : * fields-array. Otherwise the following tags are also freed
529 : * with the first free().
530 : */
531 0 : _TIFFfreeExt(tif, fld);
532 : }
533 : }
534 : }
535 :
536 56010 : _TIFFfreeExt(tif, tif->tif_fields);
537 56506 : tif->tif_fields = NULL;
538 56506 : tif->tif_nfields = 0;
539 : }
540 118431 : if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count))
541 : {
542 0 : TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed");
543 : }
544 118475 : }
545 :
546 352292000 : static int tagCompare(const void *a, const void *b)
547 : {
548 352292000 : const TIFFField *ta = *(const TIFFField **)a;
549 352292000 : const TIFFField *tb = *(const TIFFField **)b;
550 : /* NB: be careful of return values for 16-bit platforms */
551 352292000 : if (ta->field_tag != tb->field_tag)
552 351141000 : return (int)ta->field_tag - (int)tb->field_tag;
553 : else
554 1151050 : return (ta->field_type == TIFF_ANY)
555 : ? 0
556 1151050 : : ((int)tb->field_type - (int)ta->field_type);
557 : }
558 :
559 0 : static int tagNameCompare(const void *a, const void *b)
560 : {
561 0 : const TIFFField *ta = *(const TIFFField **)a;
562 0 : const TIFFField *tb = *(const TIFFField **)b;
563 0 : int ret = strcmp(ta->field_name, tb->field_name);
564 :
565 0 : if (ret)
566 0 : return ret;
567 : else
568 0 : return (ta->field_type == TIFF_ANY)
569 : ? 0
570 0 : : ((int)tb->field_type - (int)ta->field_type);
571 : }
572 :
573 397991 : int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
574 : {
575 : static const char module[] = "_TIFFMergeFields";
576 : static const char reason[] = "for fields array";
577 : /* TIFFField** tp; */
578 : uint32_t i;
579 :
580 397991 : tif->tif_foundfield = NULL;
581 :
582 397991 : if (tif->tif_fields && tif->tif_nfields > 0)
583 : {
584 279581 : tif->tif_fields = (TIFFField **)_TIFFCheckRealloc(
585 279505 : tif, tif->tif_fields, (tif->tif_nfields + n), sizeof(TIFFField *),
586 : reason);
587 : }
588 : else
589 : {
590 118472 : tif->tif_fields =
591 118486 : (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason);
592 : }
593 398053 : if (!tif->tif_fields)
594 : {
595 0 : TIFFErrorExtR(tif, module, "Failed to allocate fields array");
596 0 : return 0;
597 : }
598 :
599 : /* tp = tif->tif_fields + tif->tif_nfields; */
600 20002900 : for (i = 0; i < n; i++)
601 : {
602 19602600 : const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
603 :
604 : /* only add definitions that aren't already present */
605 19604900 : if (!fip)
606 : {
607 19604800 : tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i);
608 19604800 : tif->tif_nfields++;
609 : }
610 : }
611 :
612 : /* Sort the field info by tag number */
613 400345 : qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
614 :
615 398081 : return n;
616 : }
617 :
618 0 : void _TIFFPrintFieldInfo(TIFF *tif, FILE *fd)
619 : {
620 : uint32_t i;
621 :
622 0 : fprintf(fd, "%s: \n", tif->tif_name);
623 0 : for (i = 0; i < tif->tif_nfields; i++)
624 : {
625 0 : const TIFFField *fip = tif->tif_fields[i];
626 0 : fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n",
627 0 : (int)i, (unsigned long)fip->field_tag, fip->field_readcount,
628 0 : fip->field_writecount, fip->field_type, fip->field_bit,
629 0 : fip->field_oktochange ? "TRUE" : "FALSE",
630 0 : fip->field_passcount ? "TRUE" : "FALSE", fip->field_name);
631 : }
632 0 : }
633 :
634 : /*
635 : * Return size of TIFFDataType within TIFF-file in bytes
636 : */
637 621238 : int TIFFDataWidth(TIFFDataType type)
638 : {
639 621238 : switch (type)
640 : {
641 71283 : case 0: /* nothing */
642 : case TIFF_BYTE:
643 : case TIFF_ASCII:
644 : case TIFF_SBYTE:
645 : case TIFF_UNDEFINED:
646 71283 : return 1;
647 200489 : case TIFF_SHORT:
648 : case TIFF_SSHORT:
649 200489 : return 2;
650 206605 : case TIFF_LONG:
651 : case TIFF_SLONG:
652 : case TIFF_FLOAT:
653 : case TIFF_IFD:
654 206605 : return 4;
655 142518 : case TIFF_RATIONAL:
656 : case TIFF_SRATIONAL:
657 : case TIFF_DOUBLE:
658 : case TIFF_LONG8:
659 : case TIFF_SLONG8:
660 : case TIFF_IFD8:
661 142518 : return 8;
662 343 : default:
663 343 : return 0; /* will return 0 for unknown types */
664 : }
665 : }
666 :
667 : /*
668 : * Return internal storage size of TIFFSetGetFieldType in bytes.
669 : * TIFFSetField() and TIFFGetField() have to provide the parameter accordingly.
670 : * Replaces internal functions _TIFFDataSize() and _TIFFSetGetFieldSize()
671 : * with now extern available function TIFFFieldSetGetSize().
672 : */
673 136864 : int TIFFFieldSetGetSize(const TIFFField *fip)
674 : {
675 : /*
676 : * TIFFSetField() and TIFFGetField() must provide the parameter accordingly
677 : * to the definition of "set_field_type" of the tag definition in
678 : * dir_info.c. This function returns the data size for that purpose.
679 : *
680 : * Furthermore, this data size is also used for the internal storage,
681 : * even for TIFF_RATIONAL values for FIELD_CUSTOM, which are stored
682 : * internally as 4-byte float, but some of them should be stored internally
683 : * as 8-byte double, depending on the "set_field_type" _FLOAT_ or _DOUBLE_.
684 : */
685 136864 : if (fip == NULL)
686 0 : return 0;
687 :
688 136864 : switch (fip->set_field_type)
689 : {
690 36950 : case TIFF_SETGET_UNDEFINED:
691 : case TIFF_SETGET_ASCII:
692 : case TIFF_SETGET_C0_ASCII:
693 : case TIFF_SETGET_C16_ASCII:
694 : case TIFF_SETGET_C32_ASCII:
695 : case TIFF_SETGET_OTHER:
696 36950 : return 1;
697 105 : case TIFF_SETGET_UINT8:
698 : case TIFF_SETGET_SINT8:
699 : case TIFF_SETGET_C0_UINT8:
700 : case TIFF_SETGET_C0_SINT8:
701 : case TIFF_SETGET_C16_UINT8:
702 : case TIFF_SETGET_C16_SINT8:
703 : case TIFF_SETGET_C32_UINT8:
704 : case TIFF_SETGET_C32_SINT8:
705 105 : return 1;
706 27479 : case TIFF_SETGET_UINT16:
707 : case TIFF_SETGET_SINT16:
708 : case TIFF_SETGET_C0_UINT16:
709 : case TIFF_SETGET_C0_SINT16:
710 : case TIFF_SETGET_C16_UINT16:
711 : case TIFF_SETGET_C16_SINT16:
712 : case TIFF_SETGET_C32_UINT16:
713 : case TIFF_SETGET_C32_SINT16:
714 27479 : return 2;
715 2980 : case TIFF_SETGET_INT:
716 : case TIFF_SETGET_UINT32:
717 : case TIFF_SETGET_SINT32:
718 : case TIFF_SETGET_FLOAT:
719 : case TIFF_SETGET_UINT16_PAIR:
720 : case TIFF_SETGET_C0_UINT32:
721 : case TIFF_SETGET_C0_SINT32:
722 : case TIFF_SETGET_C0_FLOAT:
723 : case TIFF_SETGET_C16_UINT32:
724 : case TIFF_SETGET_C16_SINT32:
725 : case TIFF_SETGET_C16_FLOAT:
726 : case TIFF_SETGET_C32_UINT32:
727 : case TIFF_SETGET_C32_SINT32:
728 : case TIFF_SETGET_C32_FLOAT:
729 2980 : return 4;
730 69319 : case TIFF_SETGET_UINT64:
731 : case TIFF_SETGET_SINT64:
732 : case TIFF_SETGET_DOUBLE:
733 : case TIFF_SETGET_IFD8:
734 : case TIFF_SETGET_C0_UINT64:
735 : case TIFF_SETGET_C0_SINT64:
736 : case TIFF_SETGET_C0_DOUBLE:
737 : case TIFF_SETGET_C0_IFD8:
738 : case TIFF_SETGET_C16_UINT64:
739 : case TIFF_SETGET_C16_SINT64:
740 : case TIFF_SETGET_C16_DOUBLE:
741 : case TIFF_SETGET_C16_IFD8:
742 : case TIFF_SETGET_C32_UINT64:
743 : case TIFF_SETGET_C32_SINT64:
744 : case TIFF_SETGET_C32_DOUBLE:
745 : case TIFF_SETGET_C32_IFD8:
746 69319 : return 8;
747 31 : default:
748 31 : return 0;
749 : }
750 : } /*-- TIFFFieldSetGetSize() --- */
751 :
752 : /*
753 : * Return size of count parameter of TIFFSetField() and TIFFGetField()
754 : * and also if it is required: 0=none, 2=uint16_t, 4=uint32_t
755 : */
756 0 : int TIFFFieldSetGetCountSize(const TIFFField *fip)
757 : {
758 0 : if (fip == NULL)
759 0 : return 0;
760 :
761 0 : switch (fip->set_field_type)
762 : {
763 0 : case TIFF_SETGET_C16_ASCII:
764 : case TIFF_SETGET_C16_UINT8:
765 : case TIFF_SETGET_C16_SINT8:
766 : case TIFF_SETGET_C16_UINT16:
767 : case TIFF_SETGET_C16_SINT16:
768 : case TIFF_SETGET_C16_UINT32:
769 : case TIFF_SETGET_C16_SINT32:
770 : case TIFF_SETGET_C16_FLOAT:
771 : case TIFF_SETGET_C16_UINT64:
772 : case TIFF_SETGET_C16_SINT64:
773 : case TIFF_SETGET_C16_DOUBLE:
774 : case TIFF_SETGET_C16_IFD8:
775 0 : return 2;
776 0 : case TIFF_SETGET_C32_ASCII:
777 : case TIFF_SETGET_C32_UINT8:
778 : case TIFF_SETGET_C32_SINT8:
779 : case TIFF_SETGET_C32_UINT16:
780 : case TIFF_SETGET_C32_SINT16:
781 : case TIFF_SETGET_C32_UINT32:
782 : case TIFF_SETGET_C32_SINT32:
783 : case TIFF_SETGET_C32_FLOAT:
784 : case TIFF_SETGET_C32_UINT64:
785 : case TIFF_SETGET_C32_SINT64:
786 : case TIFF_SETGET_C32_DOUBLE:
787 : case TIFF_SETGET_C32_IFD8:
788 0 : return 4;
789 0 : default:
790 0 : return 0;
791 : }
792 : } /*-- TIFFFieldSetGetCountSize() --- */
793 :
794 26171600 : const TIFFField *TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt)
795 : {
796 26171600 : TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
797 26171600 : TIFFField *pkey = &key;
798 : const TIFFField **ret;
799 26171600 : if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
800 0 : (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
801 4307910 : return tif->tif_foundfield;
802 :
803 : /* If we are invoked with no field information, then just return. */
804 21863700 : if (!tif->tif_fields)
805 0 : return NULL;
806 :
807 : /* NB: use sorted search (e.g. binary search) */
808 :
809 21863700 : key.field_tag = tag;
810 21863700 : key.field_type = dt;
811 :
812 21863700 : ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields,
813 : sizeof(TIFFField *), tagCompare);
814 21859900 : return tif->tif_foundfield = (ret ? *ret : NULL);
815 : }
816 :
817 0 : static const TIFFField *_TIFFFindFieldByName(TIFF *tif, const char *field_name,
818 : TIFFDataType dt)
819 : {
820 0 : TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
821 0 : TIFFField *pkey = &key;
822 : const TIFFField **ret;
823 0 : if (tif->tif_foundfield &&
824 0 : streq(tif->tif_foundfield->field_name, field_name) &&
825 0 : (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
826 0 : return (tif->tif_foundfield);
827 :
828 : /* If we are invoked with no field information, then just return. */
829 0 : if (!tif->tif_fields)
830 0 : return NULL;
831 :
832 : /* NB: use linear search since list is sorted by key#, not name */
833 :
834 0 : key.field_name = (char *)field_name;
835 0 : key.field_type = dt;
836 :
837 : ret =
838 0 : (const TIFFField **)td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
839 : sizeof(TIFFField *), tagNameCompare);
840 :
841 0 : return tif->tif_foundfield = (ret ? *ret : NULL);
842 : }
843 :
844 1057750 : const TIFFField *TIFFFieldWithTag(TIFF *tif, uint32_t tag)
845 : {
846 1057750 : const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
847 1057740 : if (!fip)
848 : {
849 0 : TIFFWarningExtR(tif, "TIFFFieldWithTag", "Warning, unknown tag 0x%x",
850 : (unsigned int)tag);
851 : }
852 1057810 : return (fip);
853 : }
854 :
855 0 : const TIFFField *TIFFFieldWithName(TIFF *tif, const char *field_name)
856 : {
857 0 : const TIFFField *fip = _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
858 0 : if (!fip)
859 : {
860 0 : TIFFWarningExtR(tif, "TIFFFieldWithName", "Warning, unknown tag %s",
861 : field_name);
862 : }
863 0 : return (fip);
864 : }
865 :
866 0 : uint32_t TIFFFieldTag(const TIFFField *fip) { return fip->field_tag; }
867 :
868 0 : const char *TIFFFieldName(const TIFFField *fip) { return fip->field_name; }
869 :
870 0 : TIFFDataType TIFFFieldDataType(const TIFFField *fip) { return fip->field_type; }
871 :
872 0 : int TIFFFieldPassCount(const TIFFField *fip) { return fip->field_passcount; }
873 :
874 0 : int TIFFFieldReadCount(const TIFFField *fip) { return fip->field_readcount; }
875 :
876 0 : int TIFFFieldWriteCount(const TIFFField *fip) { return fip->field_writecount; }
877 :
878 13614800 : int TIFFFieldIsAnonymous(const TIFFField *fip) { return fip->field_anonymous; }
879 :
880 0 : const TIFFField *_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag,
881 : TIFFDataType dt)
882 :
883 : {
884 : const TIFFField *fld;
885 :
886 0 : fld = TIFFFindField(tif, tag, dt);
887 0 : if (fld == NULL)
888 : {
889 0 : fld = _TIFFCreateAnonField(tif, tag, dt);
890 0 : if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
891 0 : return NULL;
892 : }
893 :
894 0 : return fld;
895 : }
896 :
897 5 : TIFFField *_TIFFCreateAnonField(TIFF *tif, uint32_t tag,
898 : TIFFDataType field_type)
899 : {
900 : TIFFField *fld;
901 : (void)tif;
902 :
903 5 : fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField));
904 5 : if (fld == NULL)
905 0 : return NULL;
906 5 : _TIFFmemset(fld, 0, sizeof(TIFFField));
907 :
908 5 : fld->field_tag = tag;
909 5 : fld->field_readcount = TIFF_VARIABLE2;
910 5 : fld->field_writecount = TIFF_VARIABLE2;
911 5 : fld->field_type = field_type;
912 5 : fld->field_anonymous =
913 : 1; /* indicate that this is an anonymous / unknown tag */
914 5 : switch (field_type)
915 : {
916 0 : case TIFF_BYTE:
917 : case TIFF_UNDEFINED:
918 0 : fld->set_field_type = TIFF_SETGET_C32_UINT8;
919 0 : fld->get_field_type = TIFF_SETGET_C32_UINT8;
920 0 : break;
921 0 : case TIFF_ASCII:
922 0 : fld->set_field_type = TIFF_SETGET_C32_ASCII;
923 0 : fld->get_field_type = TIFF_SETGET_C32_ASCII;
924 0 : break;
925 0 : case TIFF_SHORT:
926 0 : fld->set_field_type = TIFF_SETGET_C32_UINT16;
927 0 : fld->get_field_type = TIFF_SETGET_C32_UINT16;
928 0 : break;
929 0 : case TIFF_LONG:
930 0 : fld->set_field_type = TIFF_SETGET_C32_UINT32;
931 0 : fld->get_field_type = TIFF_SETGET_C32_UINT32;
932 0 : break;
933 0 : case TIFF_RATIONAL:
934 : case TIFF_SRATIONAL:
935 : case TIFF_FLOAT:
936 0 : fld->set_field_type = TIFF_SETGET_C32_FLOAT;
937 0 : fld->get_field_type = TIFF_SETGET_C32_FLOAT;
938 0 : break;
939 0 : case TIFF_SBYTE:
940 0 : fld->set_field_type = TIFF_SETGET_C32_SINT8;
941 0 : fld->get_field_type = TIFF_SETGET_C32_SINT8;
942 0 : break;
943 0 : case TIFF_SSHORT:
944 0 : fld->set_field_type = TIFF_SETGET_C32_SINT16;
945 0 : fld->get_field_type = TIFF_SETGET_C32_SINT16;
946 0 : break;
947 0 : case TIFF_SLONG:
948 0 : fld->set_field_type = TIFF_SETGET_C32_SINT32;
949 0 : fld->get_field_type = TIFF_SETGET_C32_SINT32;
950 0 : break;
951 0 : case TIFF_DOUBLE:
952 0 : fld->set_field_type = TIFF_SETGET_C32_DOUBLE;
953 0 : fld->get_field_type = TIFF_SETGET_C32_DOUBLE;
954 0 : break;
955 0 : case TIFF_IFD:
956 : case TIFF_IFD8:
957 0 : fld->set_field_type = TIFF_SETGET_C32_IFD8;
958 0 : fld->get_field_type = TIFF_SETGET_C32_IFD8;
959 0 : break;
960 0 : case TIFF_LONG8:
961 0 : fld->set_field_type = TIFF_SETGET_C32_UINT64;
962 0 : fld->get_field_type = TIFF_SETGET_C32_UINT64;
963 0 : break;
964 0 : case TIFF_SLONG8:
965 0 : fld->set_field_type = TIFF_SETGET_C32_SINT64;
966 0 : fld->get_field_type = TIFF_SETGET_C32_SINT64;
967 0 : break;
968 5 : default:
969 5 : fld->set_field_type = TIFF_SETGET_UNDEFINED;
970 5 : fld->get_field_type = TIFF_SETGET_UNDEFINED;
971 5 : break;
972 : }
973 5 : fld->field_bit = FIELD_CUSTOM;
974 5 : fld->field_oktochange = TRUE;
975 5 : fld->field_passcount = TRUE;
976 5 : fld->field_name = (char *)_TIFFmallocExt(tif, 32);
977 5 : if (fld->field_name == NULL)
978 : {
979 0 : _TIFFfreeExt(tif, fld);
980 0 : return NULL;
981 : }
982 5 : fld->field_subfields = NULL;
983 :
984 : /*
985 : * note that this name is a special sign to TIFFClose() and
986 : * _TIFFSetupFields() to free the field
987 : * Update:
988 : * This special sign is replaced by fld->field_anonymous flag.
989 : */
990 5 : (void)snprintf(fld->field_name, 32, "Tag %d", (int)tag);
991 :
992 5 : return fld;
993 : }
994 :
995 : /****************************************************************************
996 : * O B S O L E T E D I N T E R F A C E S
997 : *
998 : * Don't use this stuff in your applications, it may be removed in the future
999 : * libtiff versions.
1000 : ****************************************************************************/
1001 :
1002 2842230 : static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count,
1003 : unsigned char passcount)
1004 : {
1005 2842230 : if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
1006 947607 : return TIFF_SETGET_ASCII;
1007 :
1008 1894620 : else if (count == 1 && passcount == 0)
1009 : {
1010 0 : switch (type)
1011 : {
1012 0 : case TIFF_BYTE:
1013 : case TIFF_UNDEFINED:
1014 0 : return TIFF_SETGET_UINT8;
1015 0 : case TIFF_ASCII:
1016 0 : return TIFF_SETGET_ASCII;
1017 0 : case TIFF_SHORT:
1018 0 : return TIFF_SETGET_UINT16;
1019 0 : case TIFF_LONG:
1020 0 : return TIFF_SETGET_UINT32;
1021 0 : case TIFF_RATIONAL:
1022 : case TIFF_SRATIONAL:
1023 : case TIFF_FLOAT:
1024 0 : return TIFF_SETGET_FLOAT;
1025 0 : case TIFF_SBYTE:
1026 0 : return TIFF_SETGET_SINT8;
1027 0 : case TIFF_SSHORT:
1028 0 : return TIFF_SETGET_SINT16;
1029 0 : case TIFF_SLONG:
1030 0 : return TIFF_SETGET_SINT32;
1031 0 : case TIFF_DOUBLE:
1032 0 : return TIFF_SETGET_DOUBLE;
1033 0 : case TIFF_IFD:
1034 : case TIFF_IFD8:
1035 0 : return TIFF_SETGET_IFD8;
1036 0 : case TIFF_LONG8:
1037 0 : return TIFF_SETGET_UINT64;
1038 0 : case TIFF_SLONG8:
1039 0 : return TIFF_SETGET_SINT64;
1040 0 : default:
1041 0 : return TIFF_SETGET_UNDEFINED;
1042 : }
1043 : }
1044 :
1045 1894620 : else if (count >= 1 && passcount == 0)
1046 : {
1047 0 : switch (type)
1048 : {
1049 0 : case TIFF_BYTE:
1050 : case TIFF_UNDEFINED:
1051 0 : return TIFF_SETGET_C0_UINT8;
1052 0 : case TIFF_ASCII:
1053 0 : return TIFF_SETGET_C0_ASCII;
1054 0 : case TIFF_SHORT:
1055 0 : return TIFF_SETGET_C0_UINT16;
1056 0 : case TIFF_LONG:
1057 0 : return TIFF_SETGET_C0_UINT32;
1058 0 : case TIFF_RATIONAL:
1059 : case TIFF_SRATIONAL:
1060 : case TIFF_FLOAT:
1061 0 : return TIFF_SETGET_C0_FLOAT;
1062 0 : case TIFF_SBYTE:
1063 0 : return TIFF_SETGET_C0_SINT8;
1064 0 : case TIFF_SSHORT:
1065 0 : return TIFF_SETGET_C0_SINT16;
1066 0 : case TIFF_SLONG:
1067 0 : return TIFF_SETGET_C0_SINT32;
1068 0 : case TIFF_DOUBLE:
1069 0 : return TIFF_SETGET_C0_DOUBLE;
1070 0 : case TIFF_IFD:
1071 : case TIFF_IFD8:
1072 0 : return TIFF_SETGET_C0_IFD8;
1073 0 : case TIFF_LONG8:
1074 0 : return TIFF_SETGET_C0_UINT64;
1075 0 : case TIFF_SLONG8:
1076 0 : return TIFF_SETGET_C0_SINT64;
1077 0 : default:
1078 0 : return TIFF_SETGET_UNDEFINED;
1079 : }
1080 : }
1081 :
1082 1894620 : else if (count == TIFF_VARIABLE && passcount == 1)
1083 : {
1084 1658070 : switch (type)
1085 : {
1086 0 : case TIFF_BYTE:
1087 : case TIFF_UNDEFINED:
1088 0 : return TIFF_SETGET_C16_UINT8;
1089 0 : case TIFF_ASCII:
1090 0 : return TIFF_SETGET_C16_ASCII;
1091 236844 : case TIFF_SHORT:
1092 236844 : return TIFF_SETGET_C16_UINT16;
1093 0 : case TIFF_LONG:
1094 0 : return TIFF_SETGET_C16_UINT32;
1095 0 : case TIFF_RATIONAL:
1096 : case TIFF_SRATIONAL:
1097 : case TIFF_FLOAT:
1098 0 : return TIFF_SETGET_C16_FLOAT;
1099 0 : case TIFF_SBYTE:
1100 0 : return TIFF_SETGET_C16_SINT8;
1101 0 : case TIFF_SSHORT:
1102 0 : return TIFF_SETGET_C16_SINT16;
1103 0 : case TIFF_SLONG:
1104 0 : return TIFF_SETGET_C16_SINT32;
1105 1421230 : case TIFF_DOUBLE:
1106 1421230 : return TIFF_SETGET_C16_DOUBLE;
1107 0 : case TIFF_IFD:
1108 : case TIFF_IFD8:
1109 0 : return TIFF_SETGET_C16_IFD8;
1110 0 : case TIFF_LONG8:
1111 0 : return TIFF_SETGET_C16_UINT64;
1112 0 : case TIFF_SLONG8:
1113 0 : return TIFF_SETGET_C16_SINT64;
1114 0 : default:
1115 0 : return TIFF_SETGET_UNDEFINED;
1116 : }
1117 : }
1118 :
1119 236551 : else if (count == TIFF_VARIABLE2 && passcount == 1)
1120 : {
1121 236937 : switch (type)
1122 : {
1123 236905 : case TIFF_BYTE:
1124 : case TIFF_UNDEFINED:
1125 236905 : return TIFF_SETGET_C32_UINT8;
1126 0 : case TIFF_ASCII:
1127 0 : return TIFF_SETGET_C32_ASCII;
1128 0 : case TIFF_SHORT:
1129 0 : return TIFF_SETGET_C32_UINT16;
1130 0 : case TIFF_LONG:
1131 0 : return TIFF_SETGET_C32_UINT32;
1132 0 : case TIFF_RATIONAL:
1133 : case TIFF_SRATIONAL:
1134 : case TIFF_FLOAT:
1135 0 : return TIFF_SETGET_C32_FLOAT;
1136 0 : case TIFF_SBYTE:
1137 0 : return TIFF_SETGET_C32_SINT8;
1138 0 : case TIFF_SSHORT:
1139 0 : return TIFF_SETGET_C32_SINT16;
1140 0 : case TIFF_SLONG:
1141 0 : return TIFF_SETGET_C32_SINT32;
1142 0 : case TIFF_DOUBLE:
1143 0 : return TIFF_SETGET_C32_DOUBLE;
1144 0 : case TIFF_IFD:
1145 : case TIFF_IFD8:
1146 0 : return TIFF_SETGET_C32_IFD8;
1147 0 : case TIFF_LONG8:
1148 0 : return TIFF_SETGET_C32_UINT64;
1149 0 : case TIFF_SLONG8:
1150 0 : return TIFF_SETGET_C32_SINT64;
1151 32 : default:
1152 32 : return TIFF_SETGET_UNDEFINED;
1153 : }
1154 : }
1155 :
1156 0 : return TIFF_SETGET_UNDEFINED;
1157 : }
1158 :
1159 236961 : int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldInfo info[], uint32_t n)
1160 : {
1161 : static const char module[] = "TIFFMergeFieldInfo";
1162 : static const char reason[] = "for fields array";
1163 : TIFFField *tp;
1164 : size_t nfields;
1165 : uint32_t i;
1166 :
1167 236961 : if (tif->tif_nfieldscompat > 0)
1168 : {
1169 118480 : tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckRealloc(
1170 118475 : tif, tif->tif_fieldscompat, tif->tif_nfieldscompat + 1,
1171 : sizeof(TIFFFieldArray), reason);
1172 : }
1173 : else
1174 : {
1175 118486 : tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckMalloc(
1176 : tif, 1, sizeof(TIFFFieldArray), reason);
1177 : }
1178 236937 : if (!tif->tif_fieldscompat)
1179 : {
1180 0 : TIFFErrorExtR(tif, module, "Failed to allocate fields array");
1181 0 : return -1;
1182 : }
1183 236937 : nfields = tif->tif_nfieldscompat++;
1184 :
1185 236937 : tif->tif_fieldscompat[nfields].type = tfiatOther;
1186 236937 : tif->tif_fieldscompat[nfields].allocated_size = n;
1187 236937 : tif->tif_fieldscompat[nfields].count = n;
1188 473884 : tif->tif_fieldscompat[nfields].fields =
1189 236937 : (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), reason);
1190 236947 : if (!tif->tif_fieldscompat[nfields].fields)
1191 : {
1192 16 : TIFFErrorExtR(tif, module, "Failed to allocate fields array");
1193 0 : return -1;
1194 : }
1195 :
1196 236931 : tp = tif->tif_fieldscompat[nfields].fields;
1197 1658220 : for (i = 0; i < n; i++)
1198 : {
1199 1421350 : tp->field_tag = info[i].field_tag;
1200 1421350 : if (info[i].field_readcount < TIFF_VARIABLE2 ||
1201 1421300 : info[i].field_writecount < TIFF_VARIABLE2)
1202 : {
1203 : /* The fields (field_readcount) and (field_writecount) may use the
1204 : * values TIFF_VARIABLE (-1), TIFF_SPP (-2), TIFF_VARIABLE2 (-3). */
1205 0 : TIFFErrorExtR(
1206 : tif, module,
1207 : "The value of field_readcount %d and field_writecount %d "
1208 : "must be greater than or equal to -3.",
1209 0 : info[i].field_readcount, info[i].field_writecount);
1210 0 : return -1;
1211 : }
1212 1421360 : if ((info[i].field_readcount == 0 || info[i].field_writecount == 0) &&
1213 78 : info[i].field_bit != FIELD_IGNORE)
1214 : {
1215 : /* The fields (field_readcount) and (field_writecount) may only
1216 : be zero for pseudo_tags or ignored tags. */
1217 0 : TIFFErrorExtR(
1218 : tif, module,
1219 : "The value of field_readcount %d and field_writecount %d "
1220 : "may only be zero for field_bit = 0 (i.e. ignored tags).",
1221 0 : info[i].field_readcount, info[i].field_writecount);
1222 0 : return -1;
1223 : }
1224 1421360 : tp->field_readcount = info[i].field_readcount;
1225 1421360 : tp->field_writecount = info[i].field_writecount;
1226 1421360 : tp->field_type = info[i].field_type;
1227 1421360 : tp->field_anonymous = 0;
1228 1421300 : tp->set_field_type =
1229 1421360 : _TIFFSetGetType(info[i].field_type, info[i].field_writecount,
1230 1421360 : info[i].field_passcount);
1231 1421290 : tp->get_field_type =
1232 1421300 : _TIFFSetGetType(info[i].field_type, info[i].field_readcount,
1233 1421300 : info[i].field_passcount);
1234 1421290 : tp->field_bit = info[i].field_bit;
1235 1421290 : tp->field_oktochange = info[i].field_oktochange;
1236 1421290 : tp->field_passcount = info[i].field_passcount;
1237 : /* Define an empty static string to be passed as field_name where a NULL
1238 : * pointer is passed in. Otherwise, this will lead to buffer overflow
1239 : * furtheron. */
1240 1421290 : if (info[i].field_name == NULL)
1241 : {
1242 : static const char *string_static_empty = "";
1243 0 : tp->field_name = (char *)string_static_empty;
1244 : }
1245 : else
1246 : {
1247 1421290 : tp->field_name = info[i].field_name;
1248 : }
1249 1421290 : tp->field_subfields = NULL;
1250 1421290 : tp++;
1251 : }
1252 :
1253 236867 : if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n))
1254 : {
1255 6 : TIFFErrorExtR(tif, module, "Setting up field info failed");
1256 0 : return -1;
1257 : }
1258 :
1259 236969 : return 0;
1260 : }
1261 :
1262 264426 : int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
1263 : {
1264 : /* Filter out non-codec specific tags */
1265 264426 : switch (tag)
1266 : {
1267 : /* Shared tags */
1268 7036 : case TIFFTAG_PREDICTOR:
1269 : /* JPEG tags */
1270 : case TIFFTAG_JPEGTABLES:
1271 : /* OJPEG tags */
1272 : case TIFFTAG_JPEGIFOFFSET:
1273 : case TIFFTAG_JPEGIFBYTECOUNT:
1274 : case TIFFTAG_JPEGQTABLES:
1275 : case TIFFTAG_JPEGDCTABLES:
1276 : case TIFFTAG_JPEGACTABLES:
1277 : case TIFFTAG_JPEGPROC:
1278 : case TIFFTAG_JPEGRESTARTINTERVAL:
1279 : /* CCITT* */
1280 : case TIFFTAG_BADFAXLINES:
1281 : case TIFFTAG_CLEANFAXDATA:
1282 : case TIFFTAG_CONSECUTIVEBADFAXLINES:
1283 : case TIFFTAG_GROUP3OPTIONS:
1284 : case TIFFTAG_GROUP4OPTIONS:
1285 : /* LERC */
1286 : case TIFFTAG_LERC_PARAMETERS:
1287 7036 : break;
1288 257390 : default:
1289 257390 : return 1;
1290 : }
1291 7036 : if (!TIFFIsCODECConfigured(tif->tif_dir.td_compression))
1292 : {
1293 0 : return 0;
1294 : }
1295 : /* Check if codec specific tags are allowed for the current
1296 : * compression scheme (codec) */
1297 7036 : switch (tif->tif_dir.td_compression)
1298 : {
1299 2055 : case COMPRESSION_LZW:
1300 2055 : if (tag == TIFFTAG_PREDICTOR)
1301 2055 : return 1;
1302 0 : break;
1303 0 : case COMPRESSION_PACKBITS:
1304 : /* No codec-specific tags */
1305 0 : break;
1306 0 : case COMPRESSION_THUNDERSCAN:
1307 : /* No codec-specific tags */
1308 0 : break;
1309 0 : case COMPRESSION_NEXT:
1310 : /* No codec-specific tags */
1311 0 : break;
1312 2014 : case COMPRESSION_JPEG:
1313 2014 : if (tag == TIFFTAG_JPEGTABLES)
1314 2014 : return 1;
1315 0 : break;
1316 8 : case COMPRESSION_OJPEG:
1317 : switch (tag)
1318 : {
1319 8 : case TIFFTAG_JPEGIFOFFSET:
1320 : case TIFFTAG_JPEGIFBYTECOUNT:
1321 : case TIFFTAG_JPEGQTABLES:
1322 : case TIFFTAG_JPEGDCTABLES:
1323 : case TIFFTAG_JPEGACTABLES:
1324 : case TIFFTAG_JPEGPROC:
1325 : case TIFFTAG_JPEGRESTARTINTERVAL:
1326 8 : return 1;
1327 : }
1328 0 : break;
1329 1 : case COMPRESSION_CCITTRLE:
1330 : case COMPRESSION_CCITTRLEW:
1331 : case COMPRESSION_CCITTFAX3:
1332 : case COMPRESSION_CCITTFAX4:
1333 : switch (tag)
1334 : {
1335 0 : case TIFFTAG_BADFAXLINES:
1336 : case TIFFTAG_CLEANFAXDATA:
1337 : case TIFFTAG_CONSECUTIVEBADFAXLINES:
1338 0 : return 1;
1339 1 : case TIFFTAG_GROUP3OPTIONS:
1340 1 : if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
1341 1 : return 1;
1342 0 : break;
1343 0 : case TIFFTAG_GROUP4OPTIONS:
1344 0 : if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
1345 0 : return 1;
1346 0 : break;
1347 : }
1348 0 : break;
1349 0 : case COMPRESSION_JBIG:
1350 : /* No codec-specific tags */
1351 0 : break;
1352 1502 : case COMPRESSION_DEFLATE:
1353 : case COMPRESSION_ADOBE_DEFLATE:
1354 1502 : if (tag == TIFFTAG_PREDICTOR)
1355 1502 : return 1;
1356 0 : break;
1357 0 : case COMPRESSION_PIXARLOG:
1358 0 : if (tag == TIFFTAG_PREDICTOR)
1359 0 : return 1;
1360 0 : break;
1361 0 : case COMPRESSION_SGILOG:
1362 : case COMPRESSION_SGILOG24:
1363 : /* No codec-specific tags */
1364 0 : break;
1365 0 : case COMPRESSION_LZMA:
1366 0 : if (tag == TIFFTAG_PREDICTOR)
1367 0 : return 1;
1368 0 : break;
1369 667 : case COMPRESSION_ZSTD:
1370 667 : if (tag == TIFFTAG_PREDICTOR)
1371 667 : return 1;
1372 0 : break;
1373 789 : case COMPRESSION_LERC:
1374 789 : if (tag == TIFFTAG_LERC_PARAMETERS)
1375 789 : return 1;
1376 0 : break;
1377 : }
1378 0 : return 0;
1379 : }
|