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_get_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_get_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, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL},
69 : {TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "OldSubfileType", NULL},
70 : {TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL},
71 : {TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL},
72 : {TIFFTAG_BITSPERSAMPLE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL},
73 : {TIFFTAG_COMPRESSION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_COMPRESSION, 0, 0, "Compression", NULL},
74 : {TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL},
75 : {TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL},
76 : {TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CellWidth", NULL},
77 : {TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CellLength", NULL},
78 : {TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_FILLORDER, 0, 0, "FillOrder", NULL},
79 : {TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DocumentName", NULL},
80 : {TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL},
81 : {TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Make", NULL},
82 : {TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Model", NULL},
83 : {TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL},
84 : {TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_ORIENTATION, 0, 0, "Orientation", NULL},
85 : {TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL},
86 : {TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL},
87 : {TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL},
88 : {TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL},
89 : {TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL},
90 : {TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_RESOLUTION, 1, 0, "XResolution", NULL},
91 : {TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_RESOLUTION, 1, 0, "YResolution", NULL},
92 : {TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL},
93 : {TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "PageName", NULL},
94 : {TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_POSITION, 1, 0, "XPosition", NULL},
95 : {TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_POSITION, 1, 0, "YPosition", NULL},
96 : {TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL},
97 : {TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL},
98 : {TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL},
99 : {TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL},
100 : {TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL},
101 : {TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL},
102 : {TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL},
103 : {TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL},
104 : {TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Software", NULL},
105 : {TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DateTime", NULL},
106 : {TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Artist", NULL},
107 : {TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "HostComputer", NULL},
108 : {TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL},
109 : {TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL},
110 : {TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, FIELD_COLORMAP, 1, 0, "ColorMap", NULL},
111 : {TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL},
112 : {TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL},
113 : {TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL},
114 : {TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL},
115 : {TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL},
116 : {TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, FIELD_SUBIFD, 1, 1, "SubIFD", (TIFFFieldArray *)&tiffFieldArray},
117 : {TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 0, 0, "InkSet", NULL},
118 : {TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, FIELD_INKNAMES, 1, 1, "InkNames", NULL},
119 : {TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_NUMBEROFINKS, 1, 0, "NumberOfInks", NULL},
120 : {TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, FIELD_CUSTOM, 0, 0, "DotRange", NULL},
121 : {TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL},
122 : {TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL},
123 : {TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL},
124 : {TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL},
125 : {TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL},
126 : {TIFFTAG_CLIPPATH, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 0, 1, "ClipPath", NULL},
127 : {TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL},
128 : {TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL},
129 : {TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL},
130 : {TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL},
131 : {TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL},
132 : {TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL},
133 : {TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "XMLPacket", NULL},
134 : /* begin SGI tags */
135 : {TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL},
136 : {TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL},
137 : {TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL},
138 : {TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, 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, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL},
142 : {TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL},
143 : {TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL},
144 : {TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL},
145 : {TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL},
146 : {TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL},
147 : {TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL},
148 : {TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Copyright", NULL},
149 : /* end Pixar tags */
150 : {TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "RichTIFFIPTC", NULL},
151 : {TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, 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, FIELD_CUSTOM, 1, 0, "EXIFIFDOffset", (TIFFFieldArray *)&exifFieldArray},
156 : {TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "ICC Profile", NULL},
157 : {TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, FIELD_CUSTOM, 1, 0, "GPSIFDOffset", (TIFFFieldArray *)&gpsFieldArray},
158 : {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL},
159 : {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL},
160 : {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL},
161 : {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL},
162 : {TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 0, 0, "StoNits", NULL},
163 : {TIFFTAG_IMAGESOURCEDATA, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "Adobe Photoshop Document Data Block", NULL},
164 : {TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL},
165 : /* begin DNG tags */
166 : {TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "DNGVersion", NULL},
167 : {TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "DNGBackwardVersion", NULL},
168 : {TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL},
169 : {TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL},
170 : {TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "CFAPlaneColor", NULL},
171 : {TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CFALayout", NULL},
172 : {TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, FIELD_CUSTOM, 1, 1, "LinearizationTable", NULL},
173 : {TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, FIELD_CUSTOM, 1, 0, "BlackLevelRepeatDim", NULL},
174 : {TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "BlackLevel", NULL},
175 : {TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaH", NULL},
176 : {TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaV", NULL},
177 : {TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, FIELD_CUSTOM, 1, 1, "WhiteLevel", NULL},
178 : {TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "DefaultScale", NULL},
179 : {TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "BestQualityScale", NULL},
180 : {TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "DefaultCropOrigin", NULL},
181 : {TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "DefaultCropSize", NULL},
182 : {TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ColorMatrix1", NULL},
183 : {TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ColorMatrix2", NULL},
184 : {TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "CameraCalibration1", NULL},
185 : {TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "CameraCalibration2", NULL},
186 : {TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ReductionMatrix1", NULL},
187 : {TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ReductionMatrix2", NULL},
188 : {TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "AnalogBalance", NULL},
189 : {TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "AsShotNeutral", NULL},
190 : {TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "AsShotWhiteXY", NULL},
191 : {TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "BaselineExposure", NULL},
192 : {TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "BaselineNoise", NULL},
193 : {TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "BaselineSharpness", NULL},
194 : {TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "BayerGreenSplit", NULL},
195 : {TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "LinearResponseLimit", NULL},
196 : {TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL},
197 : {TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "LensInfo", NULL},
198 : {TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "ChromaBlurRadius", NULL},
199 : {TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "AntiAliasStrength", NULL},
200 : {TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "ShadowScale", NULL},
201 : {TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "DNGPrivateData", NULL},
202 : {TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "MakerNoteSafety", NULL},
203 : {TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant1", NULL},
204 : {TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant2", NULL},
205 : {TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "RawDataUniqueID", NULL},
206 : {TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL},
207 : {TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "OriginalRawFileData", NULL},
208 : {TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "ActiveArea", NULL},
209 : {TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, FIELD_CUSTOM, 1, 1, "MaskedAreas", NULL},
210 : {TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "AsShotICCProfile", NULL},
211 : {TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "AsShotPreProfileMatrix", NULL},
212 : {TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "CurrentICCProfile", NULL},
213 : {TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "CurrentPreProfileMatrix", NULL},
214 : {TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, 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, FIELD_CUSTOM, 1, 0, "ColorimetricReference", NULL},
218 : {TIFFTAG_CAMERACALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "CameraCalibrationSignature", NULL},
219 : {TIFFTAG_PROFILECALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "ProfileCalibrationSignature", NULL},
220 : {TIFFTAG_EXTRACAMERAPROFILES, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, FIELD_CUSTOM, 1, 1, "ExtraCameraProfiles", NULL},
221 : {TIFFTAG_ASSHOTPROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "AsShotProfileName", NULL},
222 : {TIFFTAG_NOISEREDUCTIONAPPLIED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "NoiseReductionApplied", NULL},
223 : {TIFFTAG_PROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "ProfileName", NULL},
224 : {TIFFTAG_PROFILEHUESATMAPDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapDims", NULL},
225 : {TIFFTAG_PROFILEHUESATMAPDATA1, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData1", NULL},
226 : {TIFFTAG_PROFILEHUESATMAPDATA2, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData2", NULL},
227 : {TIFFTAG_PROFILETONECURVE, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ProfileToneCurve", NULL},
228 : {TIFFTAG_PROFILEEMBEDPOLICY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ProfileEmbedPolicy", NULL},
229 : {TIFFTAG_PROFILECOPYRIGHT, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "ProfileCopyright", NULL},
230 : {TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ForwardMatrix1", NULL},
231 : {TIFFTAG_FORWARDMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ForwardMatrix2", NULL},
232 : {TIFFTAG_PREVIEWAPPLICATIONNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "PreviewApplicationName", NULL},
233 : {TIFFTAG_PREVIEWAPPLICATIONVERSION, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "PreviewApplicationVersion", NULL},
234 : {TIFFTAG_PREVIEWSETTINGSNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "PreviewSettingsName", NULL},
235 : {TIFFTAG_PREVIEWSETTINGSDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "PreviewSettingsDigest", NULL},
236 : {TIFFTAG_PREVIEWCOLORSPACE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "PreviewColorSpace", NULL},
237 : {TIFFTAG_PREVIEWDATETIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "PreviewDateTime", NULL},
238 : {TIFFTAG_RAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "RawImageDigest", NULL},
239 : {TIFFTAG_ORIGINALRAWFILEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "OriginalRawFileDigest", NULL},
240 : {TIFFTAG_SUBTILEBLOCKSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "SubTileBlockSize", NULL},
241 : {TIFFTAG_ROWINTERLEAVEFACTOR, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "RowInterleaveFactor", NULL},
242 : {TIFFTAG_PROFILELOOKTABLEDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "ProfileLookTableDims", NULL},
243 : {TIFFTAG_PROFILELOOKTABLEDATA, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, 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, FIELD_CUSTOM, 1, 1, "OpcodeList1", NULL},
246 : {TIFFTAG_OPCODELIST2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "OpcodeList2", NULL},
247 : {TIFFTAG_OPCODELIST3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "OpcodeList3", NULL},
248 : {TIFFTAG_NOISEPROFILE, -1, -1, TIFF_DOUBLE, 0, TIFF_SETGET_C16_DOUBLE, 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, FIELD_CUSTOM, 1, 0, "DefaultUserCrop", NULL},
251 : {TIFFTAG_DEFAULTBLACKRENDER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "DefaultBlackRender", NULL},
252 : {TIFFTAG_BASELINEEXPOSUREOFFSET, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "BaselineExposureOffset", NULL},
253 : {TIFFTAG_PROFILELOOKTABLEENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ProfileLookTableEncoding", NULL},
254 : {TIFFTAG_PROFILEHUESATMAPENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapEncoding", NULL},
255 : {TIFFTAG_ORIGINALDEFAULTFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "OriginalDefaultFinalSize", NULL},
256 : {TIFFTAG_ORIGINALBESTQUALITYFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "OriginalBestQualityFinalSize", NULL},
257 : {TIFFTAG_ORIGINALDEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "OriginalDefaultCropSize", NULL}, /* could also be rational */
258 : {TIFFTAG_NEWRAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "NewRawImageDigest", NULL},
259 : {TIFFTAG_RAWTOPREVIEWGAIN, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, 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, FIELD_CUSTOM, 1, 0, "DepthFormat", NULL},
262 : {TIFFTAG_DEPTHNEAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "DepthNear", NULL},
263 : {TIFFTAG_DEPTHFAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "DepthFar", NULL},
264 : {TIFFTAG_DEPTHUNITS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "DepthUnits", NULL},
265 : {TIFFTAG_DEPTHMEASURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "DepthMeasureType", NULL},
266 : {TIFFTAG_ENHANCEPARAMS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, 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, FIELD_CUSTOM, 1, 1, "ProfileGainTableMap", NULL},
269 : {TIFFTAG_SEMANTICNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "SemanticName", NULL},
270 : {TIFFTAG_SEMANTICINSTANCEID, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "SemanticInstanceID", NULL},
271 : {TIFFTAG_MASKSUBAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, FIELD_CUSTOM, 1, 0, "MaskSubArea", NULL},
272 : {TIFFTAG_RGBTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "RGBTables", NULL},
273 : {TIFFTAG_CALIBRATIONILLUMINANT3, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant3", NULL},
274 : {TIFFTAG_COLORMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ColorMatrix3", NULL},
275 : {TIFFTAG_CAMERACALIBRATION3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "CameraCalibration3", NULL},
276 : {TIFFTAG_REDUCTIONMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ReductionMatrix3", NULL},
277 : {TIFFTAG_PROFILEHUESATMAPDATA3, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData3", NULL},
278 : {TIFFTAG_FORWARDMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "ForwardMatrix3", NULL},
279 : {TIFFTAG_ILLUMINANTDATA1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "IlluminantData1", NULL},
280 : {TIFFTAG_ILLUMINANTDATA2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "IlluminantData2", NULL},
281 : {TIFFTAG_ILLUMINANTDATA3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, 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, FIELD_CUSTOM, 1, 0, "EP CFARepeatPatternDim", NULL},
286 : {TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, 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, FIELD_CUSTOM, 1, 0, "EP BatteryLevel", NULL},
291 : {TIFFTAG_EP_INTERLACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, 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, FIELD_CUSTOM, 1, 1, "EP TimeZoneOffset", NULL},
295 : {TIFFTAG_EP_SELFTIMERMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP SelfTimerMode", NULL},
296 : {TIFFTAG_EP_FLASHENERGY, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP FlashEnergy", NULL},
297 : {TIFFTAG_EP_SPATIALFREQUENCYRESPONSE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "EP SpatialFrequencyResponse", NULL},
298 : {TIFFTAG_EP_NOISE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "EP Noise", NULL},
299 : {TIFFTAG_EP_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "EP FocalPlaneXResolution", NULL},
300 : {TIFFTAG_EP_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "EP FocalPlaneYResolution", NULL},
301 : {TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP FocalPlaneResolutionUnit", NULL},
302 : {TIFFTAG_EP_IMAGENUMBER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "EP ImageNumber", NULL}, /* or SHORT */
303 : {TIFFTAG_EP_SECURITYCLASSIFICATION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "EP SecurityClassification", NULL},
304 : {TIFFTAG_EP_IMAGEHISTORY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "EP ImageHistory", NULL},
305 : {TIFFTAG_EP_EXPOSUREINDEX, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP ExposureIndex", NULL},
306 : {TIFFTAG_EP_STANDARDID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "EP StandardId", NULL},
307 : {TIFFTAG_EP_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, 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, FIELD_CUSTOM, 1, 1, "EP ExposureTime", NULL}, /*N=1 or 2 */
310 : {TIFFTAG_EP_FNUMBER, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP FNumber", NULL},
311 : {TIFFTAG_EP_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP ExposureProgram", NULL},
312 : {TIFFTAG_EP_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "EP SpectralSensitivity", NULL},
313 : {TIFFTAG_EP_ISOSPEEDRATINGS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP ISOSpeedRatings", NULL},
314 : {TIFFTAG_EP_OECF, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, FIELD_CUSTOM, 1, 1, "EP OptoelectricConversionFactor", NULL},
315 : {TIFFTAG_EP_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "EP DateTimeOriginal", NULL},
316 : {TIFFTAG_EP_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "EP CompressedBitsPerPixel", NULL},
317 : {TIFFTAG_EP_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "EP ShutterSpeedValue", NULL},
318 : {TIFFTAG_EP_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "EP ApertureValue", NULL},
319 : {TIFFTAG_EP_BRIGHTNESSVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP BrightnessValue", NULL},
320 : {TIFFTAG_EP_EXPOSUREBIASVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP ExposureBiasValue", NULL}, /*N=1 or 2 */
321 : {TIFFTAG_EP_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "EP MaxApertureValue", NULL},
322 : {TIFFTAG_EP_SUBJECTDISTANCE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP SubjectDistance", NULL},
323 : {TIFFTAG_EP_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP MeteringMode", NULL},
324 : {TIFFTAG_EP_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP LightSource", NULL},
325 : {TIFFTAG_EP_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "EP Flash", NULL},
326 : {TIFFTAG_EP_FOCALLENGTH, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "EP FocalLength", NULL},
327 : {TIFFTAG_EP_SUBJECTLOCATION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, 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, FIELD_CUSTOM, 1, 0, "Indexed", NULL},
332 : {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, FIELD_CUSTOM, 1, 0, "GlobalParametersIFD", NULL},
333 : {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ProfileType", NULL},
334 : {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "FaxProfile", NULL},
335 : {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "CodingMethods", NULL},
336 : {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "VersionYear", NULL},
337 : {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "ModeNumber", NULL},
338 : {TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, FIELD_CUSTOM, 1, 1, "Decode", NULL},
339 : {TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, FIELD_CUSTOM, 1, 1, "ImageBaseColor", NULL},
340 : {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "T82Options", NULL},
341 : {TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, FIELD_CUSTOM, 1, 1, "StripRowCounts", NULL},
342 : {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, 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, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL},
352 : {EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "FNumber", NULL},
353 : {EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL},
354 : {EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, 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, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL},
357 : {EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL},
358 : {EXIFTAG_SENSITIVITYTYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "SensitivityType", NULL},
359 : {EXIFTAG_STANDARDOUTPUTSENSITIVITY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "StandardOutputSensitivity", NULL},
360 : {EXIFTAG_RECOMMENDEDEXPOSUREINDEX, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "RecommendedExposureIndex", NULL},
361 : {EXIFTAG_ISOSPEED, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ISOSpeed", NULL},
362 : {EXIFTAG_ISOSPEEDLATITUDEYYY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudeyyy", NULL},
363 : {EXIFTAG_ISOSPEEDLATITUDEZZZ, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudezzz", NULL},
364 : {EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL},
365 : {EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL},
366 : {EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL},
367 : {EXIFTAG_OFFSETTIME, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "OffsetTime", NULL},
368 : {EXIFTAG_OFFSETTIMEORIGINAL, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "OffsetTimeOriginal", NULL},
369 : {EXIFTAG_OFFSETTIMEDIGITIZED, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "OffsetTimeDigitized", NULL},
370 : {EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL},
371 : {EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL},
372 : {EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL},
373 : {EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL},
374 : {EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL},
375 : {EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL},
376 : {EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, 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, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL},
381 : {EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL},
382 : {EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "LightSource", NULL},
383 : {EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "Flash", NULL},
384 : {EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "FocalLength", NULL},
385 : {EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL},
386 : {EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "MakerNote", NULL},
387 : {EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "UserComment", NULL},
388 : {EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL},
389 : {EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL},
390 : {EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL},
391 : {EXIFTAG_TEMPERATURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "Temperature", NULL},
392 : {EXIFTAG_HUMIDITY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "Humidity", NULL},
393 : {EXIFTAG_PRESSURE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "Pressure", NULL},
394 : {EXIFTAG_WATERDEPTH, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "WaterDepth", NULL},
395 : {EXIFTAG_ACCELERATION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "Acceleration", NULL},
396 : {EXIFTAG_CAMERAELEVATIONANGLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "CameraElevationAngle", NULL},
397 : {EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL},
398 : {EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL},
399 : {EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL},
400 : {EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL},
401 : {EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL},
402 : {EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL},
403 : {EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL},
404 : {EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL},
405 : {EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL},
406 : {EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL},
407 : {EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL},
408 : {EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL},
409 : {EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL},
410 : {EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "FileSource", NULL},
411 : {EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "SceneType", NULL},
412 : {EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL},
413 : {EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL},
414 : {EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL},
415 : {EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL},
416 : {EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL},
417 : {EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL},
418 : {EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL},
419 : {EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "GainControl", NULL},
420 : {EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "Contrast", NULL},
421 : {EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "Saturation", NULL},
422 : {EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "Sharpness", NULL},
423 : {EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL},
424 : {EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL},
425 : {EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL},
426 : {EXIFTAG_CAMERAOWNERNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "CameraOwnerName", NULL},
427 : {EXIFTAG_BODYSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "BodySerialNumber", NULL},
428 : {EXIFTAG_LENSSPECIFICATION, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, FIELD_CUSTOM, 1, 0, "LensSpecification", NULL},
429 : {EXIFTAG_LENSMAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "LensMake", NULL},
430 : {EXIFTAG_LENSMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "LensModel", NULL},
431 : {EXIFTAG_LENSSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "LensSerialNumber", NULL},
432 : {EXIFTAG_GAMMA, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, FIELD_CUSTOM, 1, 0, "Gamma", NULL},
433 : {EXIFTAG_COMPOSITEIMAGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "CompositeImage", NULL},
434 : {EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, FIELD_CUSTOM, 1, 0, "SourceImageNumberOfCompositeImage", NULL},
435 : {EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, 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, FIELD_CUSTOM, 1, 0, "VersionID", NULL},
449 : {GPSTAG_LATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "LatitudeRef", NULL},
450 : {GPSTAG_LATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, FIELD_CUSTOM, 1, 0, "Latitude", NULL},
451 : {GPSTAG_LONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "LongitudeRef", NULL},
452 : {GPSTAG_LONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, FIELD_CUSTOM, 1, 0, "Longitude", NULL},
453 : {GPSTAG_ALTITUDEREF, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "AltitudeRef", NULL},
454 : {GPSTAG_ALTITUDE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "Altitude", NULL},
455 : {GPSTAG_TIMESTAMP, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, FIELD_CUSTOM, 1, 0, "TimeStamp", NULL},
456 : {GPSTAG_SATELLITES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Satellites", NULL},
457 : {GPSTAG_STATUS, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "Status", NULL},
458 : {GPSTAG_MEASUREMODE, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "MeasureMode", NULL},
459 : {GPSTAG_DOP, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "DOP", NULL},
460 : {GPSTAG_SPEEDREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "SpeedRef", NULL},
461 : {GPSTAG_SPEED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "Speed", NULL},
462 : {GPSTAG_TRACKREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "TrackRef", NULL},
463 : {GPSTAG_TRACK, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "Track", NULL},
464 : {GPSTAG_IMGDIRECTIONREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "ImgDirectionRef", NULL},
465 : {GPSTAG_IMGDIRECTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "ImgDirection", NULL},
466 : {GPSTAG_MAPDATUM, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "MapDatum", NULL},
467 : {GPSTAG_DESTLATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DestLatitudeRef", NULL},
468 : {GPSTAG_DESTLATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, FIELD_CUSTOM, 1, 0, "DestLatitude", NULL},
469 : {GPSTAG_DESTLONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DestLongitudeRef", NULL},
470 : {GPSTAG_DESTLONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, FIELD_CUSTOM, 1, 0, "DestLongitude", NULL},
471 : {GPSTAG_DESTBEARINGREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DestBearingRef", NULL},
472 : {GPSTAG_DESTBEARING, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "DestBearing", NULL},
473 : {GPSTAG_DESTDISTANCEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DestDistanceRef", NULL},
474 : {GPSTAG_DESTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, FIELD_CUSTOM, 1, 0, "DestDistance", NULL},
475 : {GPSTAG_PROCESSINGMETHOD, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "ProcessingMethod", NULL},
476 : {GPSTAG_AREAINFORMATION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, FIELD_CUSTOM, 1, 1, "AreaInformation", NULL},
477 : {GPSTAG_DATESTAMP, 11, 11, TIFF_ASCII, 0, TIFF_SETGET_ASCII, FIELD_CUSTOM, 1, 0, "DateStamp", NULL},
478 : {GPSTAG_DIFFERENTIAL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, FIELD_CUSTOM, 1, 0, "Differential", NULL},
479 : {GPSTAG_GPSHPOSITIONINGERROR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, 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 119713 : 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 119709 : void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
514 : {
515 119709 : if (tif->tif_fields && tif->tif_nfields > 0)
516 : {
517 : uint32_t i;
518 :
519 9551100 : for (i = 0; i < tif->tif_nfields; i++)
520 : {
521 9494120 : TIFFField *fld = tif->tif_fields[i];
522 9494120 : if (fld->field_name != NULL)
523 : {
524 9494060 : 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 56986 : _TIFFfreeExt(tif, tif->tif_fields);
537 57217 : tif->tif_fields = NULL;
538 57217 : tif->tif_nfields = 0;
539 : }
540 119718 : if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count))
541 : {
542 0 : TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed");
543 : }
544 119723 : }
545 :
546 357865000 : static int tagCompare(const void *a, const void *b)
547 : {
548 357865000 : const TIFFField *ta = *(const TIFFField **)a;
549 357865000 : const TIFFField *tb = *(const TIFFField **)b;
550 : /* NB: be careful of return values for 16-bit platforms */
551 357865000 : if (ta->field_tag != tb->field_tag)
552 356338000 : return (int)ta->field_tag - (int)tb->field_tag;
553 : else
554 1526970 : return (ta->field_type == TIFF_ANY)
555 : ? 0
556 1526970 : : ((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 402126 : 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 402126 : tif->tif_foundfield = NULL;
581 :
582 402126 : if (tif->tif_fields && tif->tif_nfields > 0)
583 : {
584 282407 : tif->tif_fields = (TIFFField **)_TIFFCheckRealloc(
585 282324 : tif, tif->tif_fields, (tif->tif_nfields + n), sizeof(TIFFField *),
586 : reason);
587 : }
588 : else
589 : {
590 119740 : tif->tif_fields =
591 119802 : (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason);
592 : }
593 402147 : 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 20222700 : for (i = 0; i < n; i++)
601 : {
602 19821800 : const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
603 :
604 : /* only add definitions that aren't already present */
605 19820600 : if (!fip)
606 : {
607 19821400 : tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i);
608 19821400 : tif->tif_nfields++;
609 : }
610 : }
611 :
612 : /* Sort the field info by tag number */
613 400961 : qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
614 :
615 402140 : 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 633473 : int TIFFDataWidth(TIFFDataType type)
638 : {
639 633473 : switch (type)
640 : {
641 72683 : case 0: /* nothing */
642 : case TIFF_BYTE:
643 : case TIFF_ASCII:
644 : case TIFF_SBYTE:
645 : case TIFF_UNDEFINED:
646 72683 : return 1;
647 204257 : case TIFF_SHORT:
648 : case TIFF_SSHORT:
649 204257 : return 2;
650 211023 : case TIFF_LONG:
651 : case TIFF_SLONG:
652 : case TIFF_FLOAT:
653 : case TIFF_IFD:
654 211023 : return 4;
655 145215 : case TIFF_RATIONAL:
656 : case TIFF_SRATIONAL:
657 : case TIFF_DOUBLE:
658 : case TIFF_LONG8:
659 : case TIFF_SLONG8:
660 : case TIFF_IFD8:
661 145215 : return 8;
662 295 : default:
663 295 : 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 139542 : int TIFFFieldSetGetSize(const TIFFField *fip)
674 : {
675 : /*
676 : * TIFFSetField() and TIFFGetField() must provide the parameter accordingly
677 : * to the definition of "set_get_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_get_field_type" _FLOAT_ or
684 : * _DOUBLE_.
685 : */
686 139542 : if (fip == NULL)
687 0 : return 0;
688 :
689 139542 : switch (fip->set_get_field_type)
690 : {
691 37703 : case TIFF_SETGET_UNDEFINED:
692 : case TIFF_SETGET_ASCII:
693 : case TIFF_SETGET_C0_ASCII:
694 : case TIFF_SETGET_C16_ASCII:
695 : case TIFF_SETGET_C32_ASCII:
696 : case TIFF_SETGET_OTHER:
697 37703 : return 1;
698 105 : case TIFF_SETGET_UINT8:
699 : case TIFF_SETGET_SINT8:
700 : case TIFF_SETGET_C0_UINT8:
701 : case TIFF_SETGET_C0_SINT8:
702 : case TIFF_SETGET_C16_UINT8:
703 : case TIFF_SETGET_C16_SINT8:
704 : case TIFF_SETGET_C32_UINT8:
705 : case TIFF_SETGET_C32_SINT8:
706 105 : return 1;
707 27955 : case TIFF_SETGET_UINT16:
708 : case TIFF_SETGET_SINT16:
709 : case TIFF_SETGET_C0_UINT16:
710 : case TIFF_SETGET_C0_SINT16:
711 : case TIFF_SETGET_C16_UINT16:
712 : case TIFF_SETGET_C16_SINT16:
713 : case TIFF_SETGET_C32_UINT16:
714 : case TIFF_SETGET_C32_SINT16:
715 27955 : return 2;
716 2980 : case TIFF_SETGET_INT:
717 : case TIFF_SETGET_UINT32:
718 : case TIFF_SETGET_SINT32:
719 : case TIFF_SETGET_FLOAT:
720 : case TIFF_SETGET_UINT16_PAIR:
721 : case TIFF_SETGET_C0_UINT32:
722 : case TIFF_SETGET_C0_SINT32:
723 : case TIFF_SETGET_C0_FLOAT:
724 : case TIFF_SETGET_C16_UINT32:
725 : case TIFF_SETGET_C16_SINT32:
726 : case TIFF_SETGET_C16_FLOAT:
727 : case TIFF_SETGET_C32_UINT32:
728 : case TIFF_SETGET_C32_SINT32:
729 : case TIFF_SETGET_C32_FLOAT:
730 2980 : return 4;
731 70741 : case TIFF_SETGET_UINT64:
732 : case TIFF_SETGET_SINT64:
733 : case TIFF_SETGET_DOUBLE:
734 : case TIFF_SETGET_IFD8:
735 : case TIFF_SETGET_C0_UINT64:
736 : case TIFF_SETGET_C0_SINT64:
737 : case TIFF_SETGET_C0_DOUBLE:
738 : case TIFF_SETGET_C0_IFD8:
739 : case TIFF_SETGET_C16_UINT64:
740 : case TIFF_SETGET_C16_SINT64:
741 : case TIFF_SETGET_C16_DOUBLE:
742 : case TIFF_SETGET_C16_IFD8:
743 : case TIFF_SETGET_C32_UINT64:
744 : case TIFF_SETGET_C32_SINT64:
745 : case TIFF_SETGET_C32_DOUBLE:
746 : case TIFF_SETGET_C32_IFD8:
747 70741 : return 8;
748 58 : default:
749 58 : return 0;
750 : }
751 : } /*-- TIFFFieldSetGetSize() --- */
752 :
753 : /*
754 : * Return size of count parameter of TIFFSetField() and TIFFGetField()
755 : * and also if it is required: 0=none, 2=uint16_t, 4=uint32_t
756 : */
757 0 : int TIFFFieldSetGetCountSize(const TIFFField *fip)
758 : {
759 0 : if (fip == NULL)
760 0 : return 0;
761 :
762 0 : switch (fip->set_get_field_type)
763 : {
764 0 : case TIFF_SETGET_C16_ASCII:
765 : case TIFF_SETGET_C16_UINT8:
766 : case TIFF_SETGET_C16_SINT8:
767 : case TIFF_SETGET_C16_UINT16:
768 : case TIFF_SETGET_C16_SINT16:
769 : case TIFF_SETGET_C16_UINT32:
770 : case TIFF_SETGET_C16_SINT32:
771 : case TIFF_SETGET_C16_FLOAT:
772 : case TIFF_SETGET_C16_UINT64:
773 : case TIFF_SETGET_C16_SINT64:
774 : case TIFF_SETGET_C16_DOUBLE:
775 : case TIFF_SETGET_C16_IFD8:
776 0 : return 2;
777 0 : case TIFF_SETGET_C32_ASCII:
778 : case TIFF_SETGET_C32_UINT8:
779 : case TIFF_SETGET_C32_SINT8:
780 : case TIFF_SETGET_C32_UINT16:
781 : case TIFF_SETGET_C32_SINT16:
782 : case TIFF_SETGET_C32_UINT32:
783 : case TIFF_SETGET_C32_SINT32:
784 : case TIFF_SETGET_C32_FLOAT:
785 : case TIFF_SETGET_C32_UINT64:
786 : case TIFF_SETGET_C32_SINT64:
787 : case TIFF_SETGET_C32_DOUBLE:
788 : case TIFF_SETGET_C32_IFD8:
789 0 : return 4;
790 0 : default:
791 0 : return 0;
792 : }
793 : } /*-- TIFFFieldSetGetCountSize() --- */
794 :
795 26491100 : const TIFFField *TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt)
796 : {
797 26491100 : TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, NULL, NULL};
798 26491100 : TIFFField *pkey = &key;
799 : const TIFFField **ret;
800 26491100 : if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
801 0 : (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
802 4372260 : return tif->tif_foundfield;
803 :
804 : /* If we are invoked with no field information, then just return. */
805 22118900 : if (!tif->tif_fields)
806 0 : return NULL;
807 :
808 : /* NB: use sorted search (e.g. binary search) */
809 :
810 22118900 : key.field_tag = tag;
811 22118900 : key.field_type = dt;
812 :
813 22118900 : ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields,
814 : sizeof(TIFFField *), tagCompare);
815 22119600 : return tif->tif_foundfield = (ret ? *ret : NULL);
816 : }
817 :
818 0 : static const TIFFField *_TIFFFindFieldByName(TIFF *tif, const char *field_name,
819 : TIFFDataType dt)
820 : {
821 0 : TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, NULL, NULL};
822 0 : TIFFField *pkey = &key;
823 : const TIFFField **ret;
824 0 : if (tif->tif_foundfield &&
825 0 : streq(tif->tif_foundfield->field_name, field_name) &&
826 0 : (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
827 0 : return (tif->tif_foundfield);
828 :
829 : /* If we are invoked with no field information, then just return. */
830 0 : if (!tif->tif_fields)
831 0 : return NULL;
832 :
833 : /* NB: use linear search since list is sorted by key#, not name */
834 :
835 0 : key.field_name = (char *)field_name;
836 0 : key.field_type = dt;
837 :
838 : ret =
839 0 : (const TIFFField **)td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
840 : sizeof(TIFFField *), tagNameCompare);
841 :
842 0 : return tif->tif_foundfield = (ret ? *ret : NULL);
843 : }
844 :
845 1073210 : const TIFFField *TIFFFieldWithTag(TIFF *tif, uint32_t tag)
846 : {
847 1073210 : const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
848 1073240 : if (!fip)
849 : {
850 0 : TIFFWarningExtR(tif, "TIFFFieldWithTag", "Warning, unknown tag 0x%x",
851 : (unsigned int)tag);
852 : }
853 1073310 : return (fip);
854 : }
855 :
856 0 : const TIFFField *TIFFFieldWithName(TIFF *tif, const char *field_name)
857 : {
858 0 : const TIFFField *fip = _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
859 0 : if (!fip)
860 : {
861 0 : TIFFWarningExtR(tif, "TIFFFieldWithName", "Warning, unknown tag %s",
862 : field_name);
863 : }
864 0 : return (fip);
865 : }
866 :
867 0 : uint32_t TIFFFieldTag(const TIFFField *fip) { return fip->field_tag; }
868 :
869 0 : const char *TIFFFieldName(const TIFFField *fip) { return fip->field_name; }
870 :
871 0 : TIFFDataType TIFFFieldDataType(const TIFFField *fip) { return fip->field_type; }
872 :
873 0 : int TIFFFieldPassCount(const TIFFField *fip) { return fip->field_passcount; }
874 :
875 0 : int TIFFFieldReadCount(const TIFFField *fip) { return fip->field_readcount; }
876 :
877 0 : int TIFFFieldWriteCount(const TIFFField *fip) { return fip->field_writecount; }
878 :
879 13762700 : int TIFFFieldIsAnonymous(const TIFFField *fip) { return fip->field_anonymous; }
880 :
881 0 : const TIFFField *_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag,
882 : TIFFDataType dt)
883 :
884 : {
885 : const TIFFField *fld;
886 :
887 0 : fld = TIFFFindField(tif, tag, dt);
888 0 : if (fld == NULL)
889 : {
890 0 : fld = _TIFFCreateAnonField(tif, tag, dt);
891 0 : if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
892 0 : return NULL;
893 : }
894 :
895 0 : return fld;
896 : }
897 :
898 5 : TIFFField *_TIFFCreateAnonField(TIFF *tif, uint32_t tag,
899 : TIFFDataType field_type)
900 : {
901 : TIFFField *fld;
902 : (void)tif;
903 :
904 5 : fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField));
905 5 : if (fld == NULL)
906 0 : return NULL;
907 5 : _TIFFmemset(fld, 0, sizeof(TIFFField));
908 :
909 5 : fld->field_tag = tag;
910 5 : fld->field_readcount = TIFF_VARIABLE2;
911 5 : fld->field_writecount = TIFF_VARIABLE2;
912 5 : fld->field_type = field_type;
913 5 : fld->field_anonymous =
914 : 1; /* indicate that this is an anonymous / unknown tag */
915 5 : switch (field_type)
916 : {
917 0 : case TIFF_BYTE:
918 : case TIFF_UNDEFINED:
919 0 : fld->set_get_field_type = TIFF_SETGET_C32_UINT8;
920 0 : break;
921 0 : case TIFF_ASCII:
922 0 : fld->set_get_field_type = TIFF_SETGET_C32_ASCII;
923 0 : break;
924 0 : case TIFF_SHORT:
925 0 : fld->set_get_field_type = TIFF_SETGET_C32_UINT16;
926 0 : break;
927 0 : case TIFF_LONG:
928 0 : fld->set_get_field_type = TIFF_SETGET_C32_UINT32;
929 0 : break;
930 0 : case TIFF_RATIONAL:
931 : case TIFF_SRATIONAL:
932 : case TIFF_FLOAT:
933 0 : fld->set_get_field_type = TIFF_SETGET_C32_FLOAT;
934 0 : break;
935 0 : case TIFF_SBYTE:
936 0 : fld->set_get_field_type = TIFF_SETGET_C32_SINT8;
937 0 : break;
938 0 : case TIFF_SSHORT:
939 0 : fld->set_get_field_type = TIFF_SETGET_C32_SINT16;
940 0 : break;
941 0 : case TIFF_SLONG:
942 0 : fld->set_get_field_type = TIFF_SETGET_C32_SINT32;
943 0 : break;
944 0 : case TIFF_DOUBLE:
945 0 : fld->set_get_field_type = TIFF_SETGET_C32_DOUBLE;
946 0 : break;
947 0 : case TIFF_IFD:
948 : case TIFF_IFD8:
949 0 : fld->set_get_field_type = TIFF_SETGET_C32_IFD8;
950 0 : break;
951 0 : case TIFF_LONG8:
952 0 : fld->set_get_field_type = TIFF_SETGET_C32_UINT64;
953 0 : break;
954 0 : case TIFF_SLONG8:
955 0 : fld->set_get_field_type = TIFF_SETGET_C32_SINT64;
956 0 : break;
957 5 : default:
958 5 : fld->set_get_field_type = TIFF_SETGET_UNDEFINED;
959 5 : break;
960 : }
961 5 : fld->field_bit = FIELD_CUSTOM;
962 5 : fld->field_oktochange = TRUE;
963 5 : fld->field_passcount = TRUE;
964 5 : fld->field_name = (char *)_TIFFmallocExt(tif, 32);
965 5 : if (fld->field_name == NULL)
966 : {
967 0 : _TIFFfreeExt(tif, fld);
968 0 : return NULL;
969 : }
970 5 : fld->field_subfields = NULL;
971 :
972 : /*
973 : * note that this name is a special sign to TIFFClose() and
974 : * _TIFFSetupFields() to free the field
975 : * Update:
976 : * This special sign is replaced by fld->field_anonymous flag.
977 : */
978 5 : (void)snprintf(fld->field_name, 32, "Tag %d", (int)tag);
979 :
980 5 : return fld;
981 : }
982 :
983 : /****************************************************************************
984 : * O B S O L E T E D I N T E R F A C E S
985 : *
986 : * Don't use this stuff in your applications, it may be removed in the future
987 : * libtiff versions.
988 : ****************************************************************************/
989 :
990 1436560 : static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count,
991 : unsigned char passcount)
992 : {
993 1436560 : if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
994 478892 : return TIFF_SETGET_ASCII;
995 :
996 957664 : else if (count == 1 && passcount == 0)
997 : {
998 0 : switch (type)
999 : {
1000 0 : case TIFF_BYTE:
1001 : case TIFF_UNDEFINED:
1002 0 : return TIFF_SETGET_UINT8;
1003 0 : case TIFF_ASCII:
1004 0 : return TIFF_SETGET_ASCII;
1005 0 : case TIFF_SHORT:
1006 0 : return TIFF_SETGET_UINT16;
1007 0 : case TIFF_LONG:
1008 0 : return TIFF_SETGET_UINT32;
1009 0 : case TIFF_RATIONAL:
1010 : case TIFF_SRATIONAL:
1011 : case TIFF_FLOAT:
1012 0 : return TIFF_SETGET_FLOAT;
1013 0 : case TIFF_SBYTE:
1014 0 : return TIFF_SETGET_SINT8;
1015 0 : case TIFF_SSHORT:
1016 0 : return TIFF_SETGET_SINT16;
1017 0 : case TIFF_SLONG:
1018 0 : return TIFF_SETGET_SINT32;
1019 0 : case TIFF_DOUBLE:
1020 0 : return TIFF_SETGET_DOUBLE;
1021 0 : case TIFF_IFD:
1022 : case TIFF_IFD8:
1023 0 : return TIFF_SETGET_IFD8;
1024 0 : case TIFF_LONG8:
1025 0 : return TIFF_SETGET_UINT64;
1026 0 : case TIFF_SLONG8:
1027 0 : return TIFF_SETGET_SINT64;
1028 0 : default:
1029 0 : return TIFF_SETGET_UNDEFINED;
1030 : }
1031 : }
1032 :
1033 957664 : else if (count >= 1 && passcount == 0)
1034 : {
1035 0 : switch (type)
1036 : {
1037 0 : case TIFF_BYTE:
1038 : case TIFF_UNDEFINED:
1039 0 : return TIFF_SETGET_C0_UINT8;
1040 0 : case TIFF_ASCII:
1041 0 : return TIFF_SETGET_C0_ASCII;
1042 0 : case TIFF_SHORT:
1043 0 : return TIFF_SETGET_C0_UINT16;
1044 0 : case TIFF_LONG:
1045 0 : return TIFF_SETGET_C0_UINT32;
1046 0 : case TIFF_RATIONAL:
1047 : case TIFF_SRATIONAL:
1048 : case TIFF_FLOAT:
1049 0 : return TIFF_SETGET_C0_FLOAT;
1050 0 : case TIFF_SBYTE:
1051 0 : return TIFF_SETGET_C0_SINT8;
1052 0 : case TIFF_SSHORT:
1053 0 : return TIFF_SETGET_C0_SINT16;
1054 0 : case TIFF_SLONG:
1055 0 : return TIFF_SETGET_C0_SINT32;
1056 0 : case TIFF_DOUBLE:
1057 0 : return TIFF_SETGET_C0_DOUBLE;
1058 0 : case TIFF_IFD:
1059 : case TIFF_IFD8:
1060 0 : return TIFF_SETGET_C0_IFD8;
1061 0 : case TIFF_LONG8:
1062 0 : return TIFF_SETGET_C0_UINT64;
1063 0 : case TIFF_SLONG8:
1064 0 : return TIFF_SETGET_C0_SINT64;
1065 0 : default:
1066 0 : return TIFF_SETGET_UNDEFINED;
1067 : }
1068 : }
1069 :
1070 957664 : else if (count == TIFF_VARIABLE && passcount == 1)
1071 : {
1072 837955 : switch (type)
1073 : {
1074 0 : case TIFF_BYTE:
1075 : case TIFF_UNDEFINED:
1076 0 : return TIFF_SETGET_C16_UINT8;
1077 0 : case TIFF_ASCII:
1078 0 : return TIFF_SETGET_C16_ASCII;
1079 119726 : case TIFF_SHORT:
1080 119726 : return TIFF_SETGET_C16_UINT16;
1081 0 : case TIFF_LONG:
1082 0 : return TIFF_SETGET_C16_UINT32;
1083 0 : case TIFF_RATIONAL:
1084 : case TIFF_SRATIONAL:
1085 : case TIFF_FLOAT:
1086 0 : return TIFF_SETGET_C16_FLOAT;
1087 0 : case TIFF_SBYTE:
1088 0 : return TIFF_SETGET_C16_SINT8;
1089 0 : case TIFF_SSHORT:
1090 0 : return TIFF_SETGET_C16_SINT16;
1091 0 : case TIFF_SLONG:
1092 0 : return TIFF_SETGET_C16_SINT32;
1093 718246 : case TIFF_DOUBLE:
1094 718246 : return TIFF_SETGET_C16_DOUBLE;
1095 0 : case TIFF_IFD:
1096 : case TIFF_IFD8:
1097 0 : return TIFF_SETGET_C16_IFD8;
1098 0 : case TIFF_LONG8:
1099 0 : return TIFF_SETGET_C16_UINT64;
1100 0 : case TIFF_SLONG8:
1101 0 : return TIFF_SETGET_C16_SINT64;
1102 0 : default:
1103 0 : return TIFF_SETGET_UNDEFINED;
1104 : }
1105 : }
1106 :
1107 119709 : else if (count == TIFF_VARIABLE2 && passcount == 1)
1108 : {
1109 119738 : switch (type)
1110 : {
1111 119735 : case TIFF_BYTE:
1112 : case TIFF_UNDEFINED:
1113 119735 : return TIFF_SETGET_C32_UINT8;
1114 0 : case TIFF_ASCII:
1115 0 : return TIFF_SETGET_C32_ASCII;
1116 0 : case TIFF_SHORT:
1117 0 : return TIFF_SETGET_C32_UINT16;
1118 0 : case TIFF_LONG:
1119 0 : return TIFF_SETGET_C32_UINT32;
1120 0 : case TIFF_RATIONAL:
1121 : case TIFF_SRATIONAL:
1122 : case TIFF_FLOAT:
1123 0 : return TIFF_SETGET_C32_FLOAT;
1124 0 : case TIFF_SBYTE:
1125 0 : return TIFF_SETGET_C32_SINT8;
1126 0 : case TIFF_SSHORT:
1127 0 : return TIFF_SETGET_C32_SINT16;
1128 0 : case TIFF_SLONG:
1129 0 : return TIFF_SETGET_C32_SINT32;
1130 0 : case TIFF_DOUBLE:
1131 0 : return TIFF_SETGET_C32_DOUBLE;
1132 0 : case TIFF_IFD:
1133 : case TIFF_IFD8:
1134 0 : return TIFF_SETGET_C32_IFD8;
1135 0 : case TIFF_LONG8:
1136 0 : return TIFF_SETGET_C32_UINT64;
1137 0 : case TIFF_SLONG8:
1138 0 : return TIFF_SETGET_C32_SINT64;
1139 3 : default:
1140 3 : return TIFF_SETGET_UNDEFINED;
1141 : }
1142 : }
1143 :
1144 0 : return TIFF_SETGET_UNDEFINED;
1145 : }
1146 :
1147 239486 : int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldInfo info[], uint32_t n)
1148 : {
1149 : static const char module[] = "TIFFMergeFieldInfo";
1150 : static const char reason[] = "for fields array";
1151 : TIFFField *tp;
1152 : size_t nfields;
1153 : uint32_t i;
1154 :
1155 239486 : if (tif->tif_nfieldscompat > 0)
1156 : {
1157 119734 : tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckRealloc(
1158 119727 : tif, tif->tif_fieldscompat, tif->tif_nfieldscompat + 1,
1159 : sizeof(TIFFFieldArray), reason);
1160 : }
1161 : else
1162 : {
1163 119759 : tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckMalloc(
1164 : tif, 1, sizeof(TIFFFieldArray), reason);
1165 : }
1166 239457 : if (!tif->tif_fieldscompat)
1167 : {
1168 0 : TIFFErrorExtR(tif, module, "Failed to allocate fields array");
1169 0 : return -1;
1170 : }
1171 239457 : nfields = tif->tif_nfieldscompat++;
1172 :
1173 239457 : tif->tif_fieldscompat[nfields].type = tfiatOther;
1174 239457 : tif->tif_fieldscompat[nfields].allocated_size = n;
1175 239457 : tif->tif_fieldscompat[nfields].count = n;
1176 478925 : tif->tif_fieldscompat[nfields].fields =
1177 239457 : (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), reason);
1178 239468 : if (!tif->tif_fieldscompat[nfields].fields)
1179 : {
1180 2 : TIFFErrorExtR(tif, module, "Failed to allocate fields array");
1181 0 : return -1;
1182 : }
1183 :
1184 239466 : tp = tif->tif_fieldscompat[nfields].fields;
1185 1675960 : for (i = 0; i < n; i++)
1186 : {
1187 1436360 : tp->field_tag = info[i].field_tag;
1188 1436360 : if (info[i].field_readcount < TIFF_VARIABLE2 ||
1189 1436350 : info[i].field_writecount < TIFF_VARIABLE2)
1190 : {
1191 : /* The fields (field_readcount) and (field_writecount) may use the
1192 : * values TIFF_VARIABLE (-1), TIFF_SPP (-2), TIFF_VARIABLE2 (-3). */
1193 0 : TIFFErrorExtR(
1194 : tif, module,
1195 : "The value of field_readcount %d and field_writecount %d "
1196 : "must be greater than or equal to -3.",
1197 0 : info[i].field_readcount, info[i].field_writecount);
1198 0 : return -1;
1199 : }
1200 1436430 : if ((info[i].field_readcount == 0 || info[i].field_writecount == 0) &&
1201 74 : info[i].field_bit != FIELD_IGNORE)
1202 : {
1203 : /* The fields (field_readcount) and (field_writecount) may only
1204 : be zero for pseudo_tags or ignored tags. */
1205 0 : TIFFErrorExtR(
1206 : tif, module,
1207 : "The value of field_readcount %d and field_writecount %d "
1208 : "may only be zero for field_bit = 0 (i.e. ignored tags).",
1209 0 : info[i].field_readcount, info[i].field_writecount);
1210 0 : return -1;
1211 : }
1212 1436430 : tp->field_readcount = info[i].field_readcount;
1213 1436430 : tp->field_writecount = info[i].field_writecount;
1214 1436430 : tp->field_type = info[i].field_type;
1215 1436430 : tp->field_anonymous = 0;
1216 1436490 : tp->set_get_field_type =
1217 1436430 : _TIFFSetGetType(info[i].field_type, info[i].field_writecount,
1218 1436430 : info[i].field_passcount);
1219 1436490 : tp->field_bit = info[i].field_bit;
1220 1436490 : tp->field_oktochange = info[i].field_oktochange;
1221 1436490 : tp->field_passcount = info[i].field_passcount;
1222 : /* Define an empty static string to be passed as field_name where a NULL
1223 : * pointer is passed in. Otherwise, this will lead to buffer overflow
1224 : * furtheron. */
1225 1436490 : if (info[i].field_name == NULL)
1226 : {
1227 : static const char *string_static_empty = "";
1228 0 : tp->field_name = (char *)string_static_empty;
1229 : }
1230 : else
1231 : {
1232 1436490 : tp->field_name = info[i].field_name;
1233 : }
1234 1436490 : tp->field_subfields = NULL;
1235 1436490 : tp++;
1236 : }
1237 :
1238 239602 : if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n))
1239 : {
1240 2 : TIFFErrorExtR(tif, module, "Setting up field info failed");
1241 0 : return -1;
1242 : }
1243 :
1244 239496 : return 0;
1245 : }
1246 :
1247 270052 : int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
1248 : {
1249 : /* Filter out non-codec specific tags */
1250 270052 : switch (tag)
1251 : {
1252 : /* Shared tags */
1253 7206 : case TIFFTAG_PREDICTOR:
1254 : /* JPEG tags */
1255 : case TIFFTAG_JPEGTABLES:
1256 : /* OJPEG tags */
1257 : case TIFFTAG_JPEGIFOFFSET:
1258 : case TIFFTAG_JPEGIFBYTECOUNT:
1259 : case TIFFTAG_JPEGQTABLES:
1260 : case TIFFTAG_JPEGDCTABLES:
1261 : case TIFFTAG_JPEGACTABLES:
1262 : case TIFFTAG_JPEGPROC:
1263 : case TIFFTAG_JPEGRESTARTINTERVAL:
1264 : /* CCITT* */
1265 : case TIFFTAG_BADFAXLINES:
1266 : case TIFFTAG_CLEANFAXDATA:
1267 : case TIFFTAG_CONSECUTIVEBADFAXLINES:
1268 : case TIFFTAG_GROUP3OPTIONS:
1269 : case TIFFTAG_GROUP4OPTIONS:
1270 : /* LERC */
1271 : case TIFFTAG_LERC_PARAMETERS:
1272 7206 : break;
1273 262846 : default:
1274 262846 : return 1;
1275 : }
1276 7206 : if (!TIFFIsCODECConfigured(tif->tif_dir.td_compression))
1277 : {
1278 0 : return 0;
1279 : }
1280 : /* Check if codec specific tags are allowed for the current
1281 : * compression scheme (codec) */
1282 7206 : switch (tif->tif_dir.td_compression)
1283 : {
1284 2094 : case COMPRESSION_LZW:
1285 2094 : if (tag == TIFFTAG_PREDICTOR)
1286 2094 : return 1;
1287 0 : break;
1288 0 : case COMPRESSION_PACKBITS:
1289 : /* No codec-specific tags */
1290 0 : break;
1291 0 : case COMPRESSION_THUNDERSCAN:
1292 : /* No codec-specific tags */
1293 0 : break;
1294 0 : case COMPRESSION_NEXT:
1295 : /* No codec-specific tags */
1296 0 : break;
1297 2043 : case COMPRESSION_JPEG:
1298 2043 : if (tag == TIFFTAG_JPEGTABLES)
1299 2043 : return 1;
1300 0 : break;
1301 8 : case COMPRESSION_OJPEG:
1302 : switch (tag)
1303 : {
1304 8 : case TIFFTAG_JPEGIFOFFSET:
1305 : case TIFFTAG_JPEGIFBYTECOUNT:
1306 : case TIFFTAG_JPEGQTABLES:
1307 : case TIFFTAG_JPEGDCTABLES:
1308 : case TIFFTAG_JPEGACTABLES:
1309 : case TIFFTAG_JPEGPROC:
1310 : case TIFFTAG_JPEGRESTARTINTERVAL:
1311 8 : return 1;
1312 : }
1313 0 : break;
1314 1 : case COMPRESSION_CCITTRLE:
1315 : case COMPRESSION_CCITTRLEW:
1316 : case COMPRESSION_CCITTFAX3:
1317 : case COMPRESSION_CCITTFAX4:
1318 : switch (tag)
1319 : {
1320 0 : case TIFFTAG_BADFAXLINES:
1321 : case TIFFTAG_CLEANFAXDATA:
1322 : case TIFFTAG_CONSECUTIVEBADFAXLINES:
1323 0 : return 1;
1324 1 : case TIFFTAG_GROUP3OPTIONS:
1325 1 : if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
1326 1 : return 1;
1327 0 : break;
1328 0 : case TIFFTAG_GROUP4OPTIONS:
1329 0 : if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4)
1330 0 : return 1;
1331 0 : break;
1332 : }
1333 0 : break;
1334 0 : case COMPRESSION_JBIG:
1335 : /* No codec-specific tags */
1336 0 : break;
1337 1602 : case COMPRESSION_DEFLATE:
1338 : case COMPRESSION_ADOBE_DEFLATE:
1339 1602 : if (tag == TIFFTAG_PREDICTOR)
1340 1602 : return 1;
1341 0 : break;
1342 0 : case COMPRESSION_PIXARLOG:
1343 0 : if (tag == TIFFTAG_PREDICTOR)
1344 0 : return 1;
1345 0 : break;
1346 0 : case COMPRESSION_SGILOG:
1347 : case COMPRESSION_SGILOG24:
1348 : /* No codec-specific tags */
1349 0 : break;
1350 0 : case COMPRESSION_LZMA:
1351 0 : if (tag == TIFFTAG_PREDICTOR)
1352 0 : return 1;
1353 0 : break;
1354 669 : case COMPRESSION_ZSTD:
1355 669 : if (tag == TIFFTAG_PREDICTOR)
1356 669 : return 1;
1357 0 : break;
1358 789 : case COMPRESSION_LERC:
1359 789 : if (tag == TIFFTAG_LERC_PARAMETERS)
1360 789 : return 1;
1361 0 : break;
1362 : }
1363 0 : return 0;
1364 : }
|