Bug Summary

File:libs/tiff-4.0.2/libtiff/tif_dirinfo.c
Location:line 386, column 2
Description:Value stored to 'tp' is never read

Annotated Source Code

1/* $Id: tif_dirinfo.c,v 1.114 2011-05-17 00:21:17 fwarmerdam Exp $ */
2
3/*
4 * Copyright (c) 1988-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 *
7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written
13 * permission of Sam Leffler and Silicon Graphics.
14 *
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 *
19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE.
25 */
26
27/*
28 * TIFF Library.
29 *
30 * Core Directory Tag Support.
31 */
32#include "tiffiop.h"
33#include <stdlib.h>
34
35/*
36 * NOTE: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG.
37 *
38 * NOTE: The second field (field_readcount) and third field (field_writecount)
39 * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3)
40 * and TIFF_SPP (-2). The macros should be used but would throw off
41 * the formatting of the code, so please interprete the -1, -2 and -3
42 * values accordingly.
43 */
44
45static TIFFFieldArray tiffFieldArray;
46static TIFFFieldArray exifFieldArray;
47
48static TIFFField
49tiffFields[] = {
50 { TIFFTAG_SUBFILETYPE254, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE5, 1, 0, "SubfileType", NULL((void*)0) },
51 { TIFFTAG_OSUBFILETYPE255, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE5, 1, 0, "OldSubfileType", NULL((void*)0) },
52 { TIFFTAG_IMAGEWIDTH256, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS1, 0, 0, "ImageWidth", NULL((void*)0) },
53 { TIFFTAG_IMAGELENGTH257, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS1, 1, 0, "ImageLength", NULL((void*)0) },
54 { TIFFTAG_BITSPERSAMPLE258, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE6, 0, 0, "BitsPerSample", NULL((void*)0) },
55 { TIFFTAG_COMPRESSION259, -1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION7, 0, 0, "Compression", NULL((void*)0) },
56 { TIFFTAG_PHOTOMETRIC262, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC8, 0, 0, "PhotometricInterpretation", NULL((void*)0) },
57 { TIFFTAG_THRESHHOLDING263, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING9, 1, 0, "Threshholding", NULL((void*)0) },
58 { TIFFTAG_CELLWIDTH264, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 1, 0, "CellWidth", NULL((void*)0) },
59 { TIFFTAG_CELLLENGTH265, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 1, 0, "CellLength", NULL((void*)0) },
60 { TIFFTAG_FILLORDER266, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER10, 0, 0, "FillOrder", NULL((void*)0) },
61 { TIFFTAG_DOCUMENTNAME269, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "DocumentName", NULL((void*)0) },
62 { TIFFTAG_IMAGEDESCRIPTION270, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ImageDescription", NULL((void*)0) },
63 { TIFFTAG_MAKE271, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Make", NULL((void*)0) },
64 { TIFFTAG_MODEL272, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Model", NULL((void*)0) },
65 { TIFFTAG_STRIPOFFSETS273, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS25, 0, 0, "StripOffsets", NULL((void*)0) },
66 { TIFFTAG_ORIENTATION274, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION15, 0, 0, "Orientation", NULL((void*)0) },
67 { TIFFTAG_SAMPLESPERPIXEL277, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL16, 0, 0, "SamplesPerPixel", NULL((void*)0) },
68 { TIFFTAG_ROWSPERSTRIP278, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP17, 0, 0, "RowsPerStrip", NULL((void*)0) },
69 { TIFFTAG_STRIPBYTECOUNTS279, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS24, 0, 0, "StripByteCounts", NULL((void*)0) },
70 { TIFFTAG_MINSAMPLEVALUE280, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE18, 1, 0, "MinSampleValue", NULL((void*)0) },
71 { TIFFTAG_MAXSAMPLEVALUE281, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE19, 1, 0, "MaxSampleValue", NULL((void*)0) },
72 { TIFFTAG_XRESOLUTION282, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION3, 1, 0, "XResolution", NULL((void*)0) },
73 { TIFFTAG_YRESOLUTION283, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION3, 1, 0, "YResolution", NULL((void*)0) },
74 { TIFFTAG_PLANARCONFIG284, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG20, 0, 0, "PlanarConfiguration", NULL((void*)0) },
75 { TIFFTAG_PAGENAME285, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "PageName", NULL((void*)0) },
76 { TIFFTAG_XPOSITION286, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION4, 1, 0, "XPosition", NULL((void*)0) },
77 { TIFFTAG_YPOSITION287, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_POSITION4, 1, 0, "YPosition", NULL((void*)0) },
78 { TIFFTAG_FREEOFFSETS288, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 0, 0, "FreeOffsets", NULL((void*)0) },
79 { TIFFTAG_FREEBYTECOUNTS289, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 0, 0, "FreeByteCounts", NULL((void*)0) },
80 { TIFFTAG_GRAYRESPONSEUNIT290, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 1, 0, "GrayResponseUnit", NULL((void*)0) },
81 { TIFFTAG_GRAYRESPONSECURVE291, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 1, 0, "GrayResponseCurve", NULL((void*)0) },
82 { TIFFTAG_RESOLUTIONUNIT296, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT22, 1, 0, "ResolutionUnit", NULL((void*)0) },
83 { TIFFTAG_PAGENUMBER297, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER23, 1, 0, "PageNumber", NULL((void*)0) },
84 { TIFFTAG_COLORRESPONSEUNIT300, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE0, 1, 0, "ColorResponseUnit", NULL((void*)0) },
85 { TIFFTAG_TRANSFERFUNCTION301, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION44, 1, 0, "TransferFunction", NULL((void*)0) },
86 { TIFFTAG_SOFTWARE305, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Software", NULL((void*)0) },
87 { TIFFTAG_DATETIME306, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "DateTime", NULL((void*)0) },
88 { TIFFTAG_ARTIST315, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Artist", NULL((void*)0) },
89 { TIFFTAG_HOSTCOMPUTER316, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "HostComputer", NULL((void*)0) },
90 { TIFFTAG_WHITEPOINT318, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "WhitePoint", NULL((void*)0) },
91 { TIFFTAG_PRIMARYCHROMATICITIES319, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "PrimaryChromaticities", NULL((void*)0) },
92 { TIFFTAG_COLORMAP320, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP26, 1, 0, "ColorMap", NULL((void*)0) },
93 { TIFFTAG_HALFTONEHINTS321, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS37, 1, 0, "HalftoneHints", NULL((void*)0) },
94 { TIFFTAG_TILEWIDTH322, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS2, 0, 0, "TileWidth", NULL((void*)0) },
95 { TIFFTAG_TILELENGTH323, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS2, 0, 0, "TileLength", NULL((void*)0) },
96 { TIFFTAG_TILEOFFSETS324, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS25, 0, 0, "TileOffsets", NULL((void*)0) },
97 { TIFFTAG_TILEBYTECOUNTS325, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS24, 0, 0, "TileByteCounts", NULL((void*)0) },
98 { TIFFTAG_SUBIFD330, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD49, 1, 1, "SubIFD", &tiffFieldArray },
99 { TIFFTAG_INKSET332, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "InkSet", NULL((void*)0) },
100 { TIFFTAG_INKNAMES333, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES46, 1, 1, "InkNames", NULL((void*)0) },
101 { TIFFTAG_NUMBEROFINKS334, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "NumberOfInks", NULL((void*)0) },
102 { TIFFTAG_DOTRANGE336, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "DotRange", NULL((void*)0) },
103 { TIFFTAG_TARGETPRINTER337, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "TargetPrinter", NULL((void*)0) },
104 { TIFFTAG_EXTRASAMPLES338, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES31, 0, 1, "ExtraSamples", NULL((void*)0) },
105 { TIFFTAG_SAMPLEFORMAT339, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT32, 0, 0, "SampleFormat", NULL((void*)0) },
106 { TIFFTAG_SMINSAMPLEVALUE340, -2, -1, TIFF_ANYTIFF_NOTYPE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE33, 1, 0, "SMinSampleValue", NULL((void*)0) },
107 { TIFFTAG_SMAXSAMPLEVALUE341, -2, -1, TIFF_ANYTIFF_NOTYPE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE34, 1, 0, "SMaxSampleValue", NULL((void*)0) },
108 { TIFFTAG_CLIPPATH343, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ClipPath", NULL((void*)0) },
109 { TIFFTAG_XCLIPPATHUNITS344, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "XClipPathUnits", NULL((void*)0) },
110 { TIFFTAG_XCLIPPATHUNITS344, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "XClipPathUnits", NULL((void*)0) },
111 { TIFFTAG_YCLIPPATHUNITS345, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "YClipPathUnits", NULL((void*)0) },
112 { TIFFTAG_YCBCRCOEFFICIENTS529, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "YCbCrCoefficients", NULL((void*)0) },
113 { TIFFTAG_YCBCRSUBSAMPLING530, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING39, 0, 0, "YCbCrSubsampling", NULL((void*)0) },
114 { TIFFTAG_YCBCRPOSITIONING531, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING40, 0, 0, "YCbCrPositioning", NULL((void*)0) },
115 { TIFFTAG_REFERENCEBLACKWHITE532, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE41, 1, 0, "ReferenceBlackWhite", NULL((void*)0) },
116 { TIFFTAG_XMLPACKET700, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "XMLPacket", NULL((void*)0) },
117 /* begin SGI tags */
118 { TIFFTAG_MATTEING32995, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES31, 0, 0, "Matteing", NULL((void*)0) },
119 { TIFFTAG_DATATYPE32996, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT32, 0, 0, "DataType", NULL((void*)0) },
120 { TIFFTAG_IMAGEDEPTH32997, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH35, 0, 0, "ImageDepth", NULL((void*)0) },
121 { TIFFTAG_TILEDEPTH32998, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH36, 0, 0, "TileDepth", NULL((void*)0) },
122 /* end SGI tags */
123 /* begin Pixar tags */
124 { TIFFTAG_PIXAR_IMAGEFULLWIDTH33300, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ImageFullWidth", NULL((void*)0) },
125 { TIFFTAG_PIXAR_IMAGEFULLLENGTH33301, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ImageFullLength", NULL((void*)0) },
126 { TIFFTAG_PIXAR_TEXTUREFORMAT33302, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "TextureFormat", NULL((void*)0) },
127 { TIFFTAG_PIXAR_WRAPMODES33303, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "TextureWrapModes", NULL((void*)0) },
128 { TIFFTAG_PIXAR_FOVCOT33304, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FieldOfViewCotangent", NULL((void*)0) },
129 { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN33305, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "MatrixWorldToScreen", NULL((void*)0) },
130 { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA33306, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "MatrixWorldToCamera", NULL((void*)0) },
131 { TIFFTAG_COPYRIGHT33432, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Copyright", NULL((void*)0) },
132 /* end Pixar tags */
133 { TIFFTAG_RICHTIFFIPTC33723, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "RichTIFFIPTC", NULL((void*)0) },
134 { TIFFTAG_PHOTOSHOP34377, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "Photoshop", NULL((void*)0) },
135 { TIFFTAG_EXIFIFD34665, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "EXIFIFDOffset", &exifFieldArray },
136 { TIFFTAG_ICCPROFILE34675, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ICC Profile", NULL((void*)0) },
137 { TIFFTAG_GPSIFD34853, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "GPSIFDOffset", NULL((void*)0) },
138 { TIFFTAG_FAXRECVPARAMS34908, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM65, TRUE1, FALSE0, "FaxRecvParams", NULL((void*)0) },
139 { TIFFTAG_FAXSUBADDRESS34909, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM65, TRUE1, FALSE0, "FaxSubAddress", NULL((void*)0) },
140 { TIFFTAG_FAXRECVTIME34910, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM65, TRUE1, FALSE0, "FaxRecvTime", NULL((void*)0) },
141 { TIFFTAG_FAXDCS34911, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM65, TRUE1, FALSE0, "FaxDcs", NULL((void*)0) },
142 { TIFFTAG_STONITS37439, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "StoNits", NULL((void*)0) },
143 { TIFFTAG_INTEROPERABILITYIFD40965, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "InteroperabilityIFDOffset", NULL((void*)0) },
144 /* begin DNG tags */
145 { TIFFTAG_DNGVERSION50706, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "DNGVersion", NULL((void*)0) },
146 { TIFFTAG_DNGBACKWARDVERSION50707, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "DNGBackwardVersion", NULL((void*)0) },
147 { TIFFTAG_UNIQUECAMERAMODEL50708, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "UniqueCameraModel", NULL((void*)0) },
148 { TIFFTAG_LOCALIZEDCAMERAMODEL50709, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "LocalizedCameraModel", NULL((void*)0) },
149 { TIFFTAG_CFAPLANECOLOR50710, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "CFAPlaneColor", NULL((void*)0) },
150 { TIFFTAG_CFALAYOUT50711, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "CFALayout", NULL((void*)0) },
151 { TIFFTAG_LINEARIZATIONTABLE50712, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "LinearizationTable", NULL((void*)0) },
152 { TIFFTAG_BLACKLEVELREPEATDIM50713, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "BlackLevelRepeatDim", NULL((void*)0) },
153 { TIFFTAG_BLACKLEVEL50714, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "BlackLevel", NULL((void*)0) },
154 { TIFFTAG_BLACKLEVELDELTAH50715, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "BlackLevelDeltaH", NULL((void*)0) },
155 { TIFFTAG_BLACKLEVELDELTAV50716, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "BlackLevelDeltaV", NULL((void*)0) },
156 { TIFFTAG_WHITELEVEL50717, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "WhiteLevel", NULL((void*)0) },
157 { TIFFTAG_DEFAULTSCALE50718, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "DefaultScale", NULL((void*)0) },
158 { TIFFTAG_BESTQUALITYSCALE50780, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "BestQualityScale", NULL((void*)0) },
159 { TIFFTAG_DEFAULTCROPORIGIN50719, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "DefaultCropOrigin", NULL((void*)0) },
160 { TIFFTAG_DEFAULTCROPSIZE50720, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "DefaultCropSize", NULL((void*)0) },
161 { TIFFTAG_COLORMATRIX150721, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ColorMatrix1", NULL((void*)0) },
162 { TIFFTAG_COLORMATRIX250722, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ColorMatrix2", NULL((void*)0) },
163 { TIFFTAG_CAMERACALIBRATION150723, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "CameraCalibration1", NULL((void*)0) },
164 { TIFFTAG_CAMERACALIBRATION250724, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "CameraCalibration2", NULL((void*)0) },
165 { TIFFTAG_REDUCTIONMATRIX150725, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ReductionMatrix1", NULL((void*)0) },
166 { TIFFTAG_REDUCTIONMATRIX250726, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ReductionMatrix2", NULL((void*)0) },
167 { TIFFTAG_ANALOGBALANCE50727, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "AnalogBalance", NULL((void*)0) },
168 { TIFFTAG_ASSHOTNEUTRAL50728, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "AsShotNeutral", NULL((void*)0) },
169 { TIFFTAG_ASSHOTWHITEXY50729, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "AsShotWhiteXY", NULL((void*)0) },
170 { TIFFTAG_BASELINEEXPOSURE50730, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "BaselineExposure", NULL((void*)0) },
171 { TIFFTAG_BASELINENOISE50731, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "BaselineNoise", NULL((void*)0) },
172 { TIFFTAG_BASELINESHARPNESS50732, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "BaselineSharpness", NULL((void*)0) },
173 { TIFFTAG_BAYERGREENSPLIT50733, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "BayerGreenSplit", NULL((void*)0) },
174 { TIFFTAG_LINEARRESPONSELIMIT50734, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "LinearResponseLimit", NULL((void*)0) },
175 { TIFFTAG_CAMERASERIALNUMBER50735, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "CameraSerialNumber", NULL((void*)0) },
176 { TIFFTAG_LENSINFO50736, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "LensInfo", NULL((void*)0) },
177 { TIFFTAG_CHROMABLURRADIUS50737, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "ChromaBlurRadius", NULL((void*)0) },
178 { TIFFTAG_ANTIALIASSTRENGTH50738, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "AntiAliasStrength", NULL((void*)0) },
179 { TIFFTAG_SHADOWSCALE50739, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "ShadowScale", NULL((void*)0) },
180 { TIFFTAG_DNGPRIVATEDATA50740, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "DNGPrivateData", NULL((void*)0) },
181 { TIFFTAG_MAKERNOTESAFETY50741, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "MakerNoteSafety", NULL((void*)0) },
182 { TIFFTAG_CALIBRATIONILLUMINANT150778, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "CalibrationIlluminant1", NULL((void*)0) },
183 { TIFFTAG_CALIBRATIONILLUMINANT250779, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "CalibrationIlluminant2", NULL((void*)0) },
184 { TIFFTAG_RAWDATAUNIQUEID50781, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "RawDataUniqueID", NULL((void*)0) },
185 { TIFFTAG_ORIGINALRAWFILENAME50827, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "OriginalRawFileName", NULL((void*)0) },
186 { TIFFTAG_ORIGINALRAWFILEDATA50828, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "OriginalRawFileData", NULL((void*)0) },
187 { TIFFTAG_ACTIVEAREA50829, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "ActiveArea", NULL((void*)0) },
188 { TIFFTAG_MASKEDAREAS50830, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "MaskedAreas", NULL((void*)0) },
189 { TIFFTAG_ASSHOTICCPROFILE50831, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "AsShotICCProfile", NULL((void*)0) },
190 { TIFFTAG_ASSHOTPREPROFILEMATRIX50832, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "AsShotPreProfileMatrix", NULL((void*)0) },
191 { TIFFTAG_CURRENTICCPROFILE50833, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "CurrentICCProfile", NULL((void*)0) },
192 { TIFFTAG_CURRENTPREPROFILEMATRIX50834, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "CurrentPreProfileMatrix", NULL((void*)0) },
193 /* end DNG tags */
194 /* begin TIFF/FX tags */
195 { TIFFTAG_INDEXED346, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "Indexed" },
196 { TIFFTAG_GLOBALPARAMETERSIFD400, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "GlobalParametersIFD", NULL((void*)0) },
197 { TIFFTAG_PROFILETYPE401, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "ProfileType", NULL((void*)0) },
198 { TIFFTAG_FAXPROFILE402, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "FaxProfile", NULL((void*)0) },
199 { TIFFTAG_CODINGMETHODS403, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "CodingMethods", NULL((void*)0) },
200 { TIFFTAG_VERSIONYEAR404, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "VersionYear", NULL((void*)0) },
201 { TIFFTAG_MODENUMBER405, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "ModeNumber", NULL((void*)0) },
202 { TIFFTAG_DECODE433, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "Decode", NULL((void*)0) },
203 { TIFFTAG_IMAGEBASECOLOR434, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "ImageBaseColor", NULL((void*)0) },
204 { TIFFTAG_T82OPTIONS435, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "T82Options", NULL((void*)0) },
205 { TIFFTAG_STRIPROWCOUNTS559, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 1, "StripRowCounts", NULL((void*)0) },
206 { TIFFTAG_IMAGELAYER34732, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 0, 0, "ImageLayer", NULL((void*)0) },
207 /* end TIFF/FX tags */
208 /* begin pseudo tags */
209 { TIFFTAG_PERSAMPLE65563, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO0, TRUE1, FALSE0, "PerSample", NULL((void*)0)},
210};
211
212static TIFFField
213exifFields[] = {
214 { EXIFTAG_EXPOSURETIME33434, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ExposureTime", NULL((void*)0) },
215 { EXIFTAG_FNUMBER33437, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FNumber", NULL((void*)0) },
216 { EXIFTAG_EXPOSUREPROGRAM34850, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ExposureProgram", NULL((void*)0) },
217 { EXIFTAG_SPECTRALSENSITIVITY34852, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SpectralSensitivity", NULL((void*)0) },
218 { EXIFTAG_ISOSPEEDRATINGS34855, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "ISOSpeedRatings", NULL((void*)0) },
219 { EXIFTAG_OECF34856, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "OptoelectricConversionFactor", NULL((void*)0) },
220 { EXIFTAG_EXIFVERSION36864, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ExifVersion", NULL((void*)0) },
221 { EXIFTAG_DATETIMEORIGINAL36867, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "DateTimeOriginal", NULL((void*)0) },
222 { EXIFTAG_DATETIMEDIGITIZED36868, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "DateTimeDigitized", NULL((void*)0) },
223 { EXIFTAG_COMPONENTSCONFIGURATION37121, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ComponentsConfiguration", NULL((void*)0) },
224 { EXIFTAG_COMPRESSEDBITSPERPIXEL37122, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "CompressedBitsPerPixel", NULL((void*)0) },
225 { EXIFTAG_SHUTTERSPEEDVALUE37377, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ShutterSpeedValue", NULL((void*)0) },
226 { EXIFTAG_APERTUREVALUE37378, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ApertureValue", NULL((void*)0) },
227 { EXIFTAG_BRIGHTNESSVALUE37379, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "BrightnessValue", NULL((void*)0) },
228 { EXIFTAG_EXPOSUREBIASVALUE37380, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ExposureBiasValue", NULL((void*)0) },
229 { EXIFTAG_MAXAPERTUREVALUE37381, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "MaxApertureValue", NULL((void*)0) },
230 { EXIFTAG_SUBJECTDISTANCE37382, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SubjectDistance", NULL((void*)0) },
231 { EXIFTAG_METERINGMODE37383, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "MeteringMode", NULL((void*)0) },
232 { EXIFTAG_LIGHTSOURCE37384, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "LightSource", NULL((void*)0) },
233 { EXIFTAG_FLASH37385, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Flash", NULL((void*)0) },
234 { EXIFTAG_FOCALLENGTH37386, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FocalLength", NULL((void*)0) },
235 { EXIFTAG_SUBJECTAREA37396, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "SubjectArea", NULL((void*)0) },
236 { EXIFTAG_MAKERNOTE37500, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "MakerNote", NULL((void*)0) },
237 { EXIFTAG_USERCOMMENT37510, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "UserComment", NULL((void*)0) },
238 { EXIFTAG_SUBSECTIME37520, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SubSecTime", NULL((void*)0) },
239 { EXIFTAG_SUBSECTIMEORIGINAL37521, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SubSecTimeOriginal", NULL((void*)0) },
240 { EXIFTAG_SUBSECTIMEDIGITIZED37522, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SubSecTimeDigitized", NULL((void*)0) },
241 { EXIFTAG_FLASHPIXVERSION40960, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FlashpixVersion", NULL((void*)0) },
242 { EXIFTAG_COLORSPACE40961, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ColorSpace", NULL((void*)0) },
243 { EXIFTAG_PIXELXDIMENSION40962, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "PixelXDimension", NULL((void*)0) },
244 { EXIFTAG_PIXELYDIMENSION40963, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "PixelYDimension", NULL((void*)0) },
245 { EXIFTAG_RELATEDSOUNDFILE40964, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "RelatedSoundFile", NULL((void*)0) },
246 { EXIFTAG_FLASHENERGY41483, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FlashEnergy", NULL((void*)0) },
247 { EXIFTAG_SPATIALFREQUENCYRESPONSE41484, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "SpatialFrequencyResponse", NULL((void*)0) },
248 { EXIFTAG_FOCALPLANEXRESOLUTION41486, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FocalPlaneXResolution", NULL((void*)0) },
249 { EXIFTAG_FOCALPLANEYRESOLUTION41487, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FocalPlaneYResolution", NULL((void*)0) },
250 { EXIFTAG_FOCALPLANERESOLUTIONUNIT41488, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FocalPlaneResolutionUnit", NULL((void*)0) },
251 { EXIFTAG_SUBJECTLOCATION41492, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SubjectLocation", NULL((void*)0) },
252 { EXIFTAG_EXPOSUREINDEX41493, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ExposureIndex", NULL((void*)0) },
253 { EXIFTAG_SENSINGMETHOD41495, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SensingMethod", NULL((void*)0) },
254 { EXIFTAG_FILESOURCE41728, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FileSource", NULL((void*)0) },
255 { EXIFTAG_SCENETYPE41729, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SceneType", NULL((void*)0) },
256 { EXIFTAG_CFAPATTERN41730, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "CFAPattern", NULL((void*)0) },
257 { EXIFTAG_CUSTOMRENDERED41985, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "CustomRendered", NULL((void*)0) },
258 { EXIFTAG_EXPOSUREMODE41986, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ExposureMode", NULL((void*)0) },
259 { EXIFTAG_WHITEBALANCE41987, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "WhiteBalance", NULL((void*)0) },
260 { EXIFTAG_DIGITALZOOMRATIO41988, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "DigitalZoomRatio", NULL((void*)0) },
261 { EXIFTAG_FOCALLENGTHIN35MMFILM41989, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "FocalLengthIn35mmFilm", NULL((void*)0) },
262 { EXIFTAG_SCENECAPTURETYPE41990, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SceneCaptureType", NULL((void*)0) },
263 { EXIFTAG_GAINCONTROL41991, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "GainControl", NULL((void*)0) },
264 { EXIFTAG_CONTRAST41992, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Contrast", NULL((void*)0) },
265 { EXIFTAG_SATURATION41993, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Saturation", NULL((void*)0) },
266 { EXIFTAG_SHARPNESS41994, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "Sharpness", NULL((void*)0) },
267 { EXIFTAG_DEVICESETTINGDESCRIPTION41995, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 1, "DeviceSettingDescription", NULL((void*)0) },
268 { EXIFTAG_SUBJECTDISTANCERANGE41996, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "SubjectDistanceRange", NULL((void*)0) },
269 { EXIFTAG_IMAGEUNIQUEID42016, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM65, 1, 0, "ImageUniqueID", NULL((void*)0) }
270};
271
272static TIFFFieldArray
273tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields)(sizeof (tiffFields) / sizeof ((tiffFields)[0])), tiffFields };
274static TIFFFieldArray
275exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields)(sizeof (exifFields) / sizeof ((exifFields)[0])), exifFields };
276
277/*
278 * We have our own local lfind() equivelent to avoid subtle differences
279 * in types passed to lfind() on different systems.
280 */
281
282static void *
283td_lfind(const void *key, const void *base, size_t *nmemb, size_t size,
284 int(*compar)(const void *, const void *))
285{
286 char *element, *end;
287
288 end = (char *)base + *nmemb * size;
289 for (element = (char *)base; element < end; element += size)
290 if (!compar(key, element)) /* key found */
291 return element;
292
293 return NULL((void*)0);
294}
295
296const TIFFFieldArray*
297_TIFFGetFields(void)
298{
299 return(&tiffFieldArray);
300}
301
302const TIFFFieldArray*
303_TIFFGetExifFields(void)
304{
305 return(&exifFieldArray);
306}
307
308void
309_TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray)
310{
311 if (tif->tif_fields && tif->tif_nfields > 0) {
312 uint32 i;
313
314 for (i = 0; i < tif->tif_nfields; i++) {
315 TIFFField *fld = tif->tif_fields[i];
316 if (fld->field_bit == FIELD_CUSTOM65 &&
317 strncmp("Tag ", fld->field_name, 4)(__extension__ (__builtin_constant_p (4) && ((__builtin_constant_p
("Tag ") && strlen ("Tag ") < ((size_t) (4))) || (
__builtin_constant_p (fld->field_name) && strlen (
fld->field_name) < ((size_t) (4)))) ? __extension__ ({ size_t
__s1_len, __s2_len; (__builtin_constant_p ("Tag ") &&
__builtin_constant_p (fld->field_name) && (__s1_len
= __builtin_strlen ("Tag "), __s2_len = __builtin_strlen (fld
->field_name), (!((size_t)(const void *)(("Tag ") + 1) - (
size_t)(const void *)("Tag ") == 1) || __s1_len >= 4) &&
(!((size_t)(const void *)((fld->field_name) + 1) - (size_t
)(const void *)(fld->field_name) == 1) || __s2_len >= 4
)) ? __builtin_strcmp ("Tag ", fld->field_name) : (__builtin_constant_p
("Tag ") && ((size_t)(const void *)(("Tag ") + 1) - (
size_t)(const void *)("Tag ") == 1) && (__s1_len = __builtin_strlen
("Tag "), __s1_len < 4) ? (__builtin_constant_p (fld->
field_name) && ((size_t)(const void *)((fld->field_name
) + 1) - (size_t)(const void *)(fld->field_name) == 1) ? __builtin_strcmp
("Tag ", fld->field_name) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (fld->
field_name); int __result = (((const unsigned char *) (const char
*) ("Tag "))[0] - __s2[0]); if (__s1_len > 0 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
"Tag "))[1] - __s2[1]); if (__s1_len > 1 && __result
== 0) { __result = (((const unsigned char *) (const char *) (
"Tag "))[2] - __s2[2]); if (__s1_len > 2 && __result
== 0) __result = (((const unsigned char *) (const char *) ("Tag "
))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (
fld->field_name) && ((size_t)(const void *)((fld->
field_name) + 1) - (size_t)(const void *)(fld->field_name)
== 1) && (__s2_len = __builtin_strlen (fld->field_name
), __s2_len < 4) ? (__builtin_constant_p ("Tag ") &&
((size_t)(const void *)(("Tag ") + 1) - (size_t)(const void *
)("Tag ") == 1) ? __builtin_strcmp ("Tag ", fld->field_name
) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned
char *) (const char *) ("Tag "); int __result = (((const unsigned
char *) (const char *) (fld->field_name))[0] - __s2[0]); if
(__s2_len > 0 && __result == 0) { __result = (((const
unsigned char *) (const char *) (fld->field_name))[1] - __s2
[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (fld->field_name
))[2] - __s2[2]); if (__s2_len > 2 && __result == 0
) __result = (((const unsigned char *) (const char *) (fld->
field_name))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp
("Tag ", fld->field_name)))); }) : strncmp ("Tag ", fld->
field_name, 4)))
== 0) {
318 _TIFFfree(fld->field_name);
319 _TIFFfree(fld);
320 }
321 }
322
323 _TIFFfree(tif->tif_fields);
324 tif->tif_fields = NULL((void*)0);
325 tif->tif_nfields = 0;
326 }
327 if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count)) {
328 TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFields",
329 "Setting up field info failed");
330 }
331}
332
333static int
334tagCompare(const void* a, const void* b)
335{
336 const TIFFField* ta = *(const TIFFField**) a;
337 const TIFFField* tb = *(const TIFFField**) b;
338 /* NB: be careful of return values for 16-bit platforms */
339 if (ta->field_tag != tb->field_tag)
340 return (int)ta->field_tag - (int)tb->field_tag;
341 else
342 return (ta->field_type == TIFF_ANYTIFF_NOTYPE) ?
343 0 : ((int)tb->field_type - (int)ta->field_type);
344}
345
346static int
347tagNameCompare(const void* a, const void* b)
348{
349 const TIFFField* ta = *(const TIFFField**) a;
350 const TIFFField* tb = *(const TIFFField**) b;
351 int ret = strcmp(ta->field_name, tb->field_name)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(ta->field_name) && __builtin_constant_p (tb->
field_name) && (__s1_len = __builtin_strlen (ta->field_name
), __s2_len = __builtin_strlen (tb->field_name), (!((size_t
)(const void *)((ta->field_name) + 1) - (size_t)(const void
*)(ta->field_name) == 1) || __s1_len >= 4) && (
!((size_t)(const void *)((tb->field_name) + 1) - (size_t)(
const void *)(tb->field_name) == 1) || __s2_len >= 4)) ?
__builtin_strcmp (ta->field_name, tb->field_name) : (__builtin_constant_p
(ta->field_name) && ((size_t)(const void *)((ta->
field_name) + 1) - (size_t)(const void *)(ta->field_name) ==
1) && (__s1_len = __builtin_strlen (ta->field_name
), __s1_len < 4) ? (__builtin_constant_p (tb->field_name
) && ((size_t)(const void *)((tb->field_name) + 1)
- (size_t)(const void *)(tb->field_name) == 1) ? __builtin_strcmp
(ta->field_name, tb->field_name) : (__extension__ ({ const
unsigned char *__s2 = (const unsigned char *) (const char *)
(tb->field_name); int __result = (((const unsigned char *
) (const char *) (ta->field_name))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) (ta->field_name))[1] - __s2[1]); if
(__s1_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) (ta->field_name))[2] - __s2
[2]); if (__s1_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) (ta->field_name)
)[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (
tb->field_name) && ((size_t)(const void *)((tb->
field_name) + 1) - (size_t)(const void *)(tb->field_name) ==
1) && (__s2_len = __builtin_strlen (tb->field_name
), __s2_len < 4) ? (__builtin_constant_p (ta->field_name
) && ((size_t)(const void *)((ta->field_name) + 1)
- (size_t)(const void *)(ta->field_name) == 1) ? __builtin_strcmp
(ta->field_name, tb->field_name) : (- (__extension__ (
{ const unsigned char *__s2 = (const unsigned char *) (const char
*) (ta->field_name); int __result = (((const unsigned char
*) (const char *) (tb->field_name))[0] - __s2[0]); if (__s2_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) (tb->field_name))[1] - __s2[1]); if
(__s2_len > 1 && __result == 0) { __result = (((const
unsigned char *) (const char *) (tb->field_name))[2] - __s2
[2]); if (__s2_len > 2 && __result == 0) __result =
(((const unsigned char *) (const char *) (tb->field_name)
)[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (ta->
field_name, tb->field_name)))); })
;
352
353 if (ret)
354 return ret;
355 else
356 return (ta->field_type == TIFF_ANYTIFF_NOTYPE) ?
357 0 : ((int)tb->field_type - (int)ta->field_type);
358}
359
360int
361_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n)
362{
363 static const char module[] = "_TIFFMergeFields";
364 static const char reason[] = "for fields array";
365 TIFFField** tp;
366 uint32 i;
367
368 tif->tif_foundfield = NULL((void*)0);
369
370 if (tif->tif_fields && tif->tif_nfields > 0) {
371 tif->tif_fields = (TIFFField**)
372 _TIFFCheckRealloc(tif, tif->tif_fields,
373 (tif->tif_nfields + n),
374 sizeof(TIFFField *), reason);
375 } else {
376 tif->tif_fields = (TIFFField **)
377 _TIFFCheckMalloc(tif, n, sizeof(TIFFField *),
378 reason);
379 }
380 if (!tif->tif_fields) {
381 TIFFErrorExt(tif->tif_clientdata, module,
382 "Failed to allocate fields array");
383 return 0;
384 }
385
386 tp = tif->tif_fields + tif->tif_nfields;
Value stored to 'tp' is never read
387 for (i = 0; i < n; i++) {
388 const TIFFField *fip =
389 TIFFFindField(tif, info[i].field_tag, TIFF_ANYTIFF_NOTYPE);
390
391 /* only add definitions that aren't already present */
392 if (!fip) {
393 tif->tif_fields[tif->tif_nfields] = (TIFFField *) (info+i);
394 tif->tif_nfields++;
395 }
396 }
397
398 /* Sort the field info by tag number */
399 qsort(tif->tif_fields, tif->tif_nfields,
400 sizeof(TIFFField *), tagCompare);
401
402 return n;
403}
404
405void
406_TIFFPrintFieldInfo(TIFF* tif, FILE* fd)
407{
408 uint32 i;
409
410 fprintf(fd, "%s: \n", tif->tif_name);
411 for (i = 0; i < tif->tif_nfields; i++) {
412 const TIFFField* fip = tif->tif_fields[i];
413 fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n"
414 , (int)i
415 , (unsigned long) fip->field_tag
416 , fip->field_readcount, fip->field_writecount
417 , fip->field_type
418 , fip->field_bit
419 , fip->field_oktochange ? "TRUE" : "FALSE"
420 , fip->field_passcount ? "TRUE" : "FALSE"
421 , fip->field_name
422 );
423 }
424}
425
426/*
427 * Return size of TIFFDataType in bytes
428 */
429int
430TIFFDataWidth(TIFFDataType type)
431{
432 switch(type)
433 {
434 case 0: /* nothing */
435 case TIFF_BYTE:
436 case TIFF_ASCII:
437 case TIFF_SBYTE:
438 case TIFF_UNDEFINED:
439 return 1;
440 case TIFF_SHORT:
441 case TIFF_SSHORT:
442 return 2;
443 case TIFF_LONG:
444 case TIFF_SLONG:
445 case TIFF_FLOAT:
446 case TIFF_IFD:
447 return 4;
448 case TIFF_RATIONAL:
449 case TIFF_SRATIONAL:
450 case TIFF_DOUBLE:
451 case TIFF_LONG8:
452 case TIFF_SLONG8:
453 case TIFF_IFD8:
454 return 8;
455 default:
456 return 0; /* will return 0 for unknown types */
457 }
458}
459
460/*
461 * Return size of TIFFDataType in bytes.
462 *
463 * XXX: We need a separate function to determine the space needed
464 * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8,
465 * but we use 4-byte float to represent rationals.
466 */
467int
468_TIFFDataSize(TIFFDataType type)
469{
470 switch (type)
471 {
472 case TIFF_BYTE:
473 case TIFF_SBYTE:
474 case TIFF_ASCII:
475 case TIFF_UNDEFINED:
476 return 1;
477 case TIFF_SHORT:
478 case TIFF_SSHORT:
479 return 2;
480 case TIFF_LONG:
481 case TIFF_SLONG:
482 case TIFF_FLOAT:
483 case TIFF_IFD:
484 case TIFF_RATIONAL:
485 case TIFF_SRATIONAL:
486 return 4;
487 case TIFF_DOUBLE:
488 case TIFF_LONG8:
489 case TIFF_SLONG8:
490 case TIFF_IFD8:
491 return 8;
492 default:
493 return 0;
494 }
495}
496
497const TIFFField*
498TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt)
499{
500 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL((void*)0), NULL((void*)0)};
501 TIFFField* pkey = &key;
502 const TIFFField **ret;
503 if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
504 (dt == TIFF_ANYTIFF_NOTYPE || dt == tif->tif_foundfield->field_type))
505 return tif->tif_foundfield;
506
507 /* If we are invoked with no field information, then just return. */
508 if (!tif->tif_fields)
509 return NULL((void*)0);
510
511 /* NB: use sorted search (e.g. binary search) */
512
513 key.field_tag = tag;
514 key.field_type = dt;
515
516 ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields,
517 tif->tif_nfields,
518 sizeof(TIFFField *), tagCompare);
519 return tif->tif_foundfield = (ret ? *ret : NULL((void*)0));
520}
521
522const TIFFField*
523_TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt)
524{
525 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL((void*)0), NULL((void*)0)};
526 TIFFField* pkey = &key;
527 const TIFFField **ret;
528 if (tif->tif_foundfield
529 && streq(tif->tif_foundfield->field_name, field_name)(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p
(tif->tif_foundfield->field_name) && __builtin_constant_p
(field_name) && (__s1_len = __builtin_strlen (tif->
tif_foundfield->field_name), __s2_len = __builtin_strlen (
field_name), (!((size_t)(const void *)((tif->tif_foundfield
->field_name) + 1) - (size_t)(const void *)(tif->tif_foundfield
->field_name) == 1) || __s1_len >= 4) && (!((size_t
)(const void *)((field_name) + 1) - (size_t)(const void *)(field_name
) == 1) || __s2_len >= 4)) ? __builtin_strcmp (tif->tif_foundfield
->field_name, field_name) : (__builtin_constant_p (tif->
tif_foundfield->field_name) && ((size_t)(const void
*)((tif->tif_foundfield->field_name) + 1) - (size_t)(const
void *)(tif->tif_foundfield->field_name) == 1) &&
(__s1_len = __builtin_strlen (tif->tif_foundfield->field_name
), __s1_len < 4) ? (__builtin_constant_p (field_name) &&
((size_t)(const void *)((field_name) + 1) - (size_t)(const void
*)(field_name) == 1) ? __builtin_strcmp (tif->tif_foundfield
->field_name, field_name) : (__extension__ ({ const unsigned
char *__s2 = (const unsigned char *) (const char *) (field_name
); int __result = (((const unsigned char *) (const char *) (tif
->tif_foundfield->field_name))[0] - __s2[0]); if (__s1_len
> 0 && __result == 0) { __result = (((const unsigned
char *) (const char *) (tif->tif_foundfield->field_name
))[1] - __s2[1]); if (__s1_len > 1 && __result == 0
) { __result = (((const unsigned char *) (const char *) (tif->
tif_foundfield->field_name))[2] - __s2[2]); if (__s1_len >
2 && __result == 0) __result = (((const unsigned char
*) (const char *) (tif->tif_foundfield->field_name))[3
] - __s2[3]); } } __result; }))) : (__builtin_constant_p (field_name
) && ((size_t)(const void *)((field_name) + 1) - (size_t
)(const void *)(field_name) == 1) && (__s2_len = __builtin_strlen
(field_name), __s2_len < 4) ? (__builtin_constant_p (tif->
tif_foundfield->field_name) && ((size_t)(const void
*)((tif->tif_foundfield->field_name) + 1) - (size_t)(const
void *)(tif->tif_foundfield->field_name) == 1) ? __builtin_strcmp
(tif->tif_foundfield->field_name, field_name) : (- (__extension__
({ const unsigned char *__s2 = (const unsigned char *) (const
char *) (tif->tif_foundfield->field_name); int __result
= (((const unsigned char *) (const char *) (field_name))[0] -
__s2[0]); if (__s2_len > 0 && __result == 0) { __result
= (((const unsigned char *) (const char *) (field_name))[1] -
__s2[1]); if (__s2_len > 1 && __result == 0) { __result
= (((const unsigned char *) (const char *) (field_name))[2] -
__s2[2]); if (__s2_len > 2 && __result == 0) __result
= (((const unsigned char *) (const char *) (field_name))[3] -
__s2[3]); } } __result; })))) : __builtin_strcmp (tif->tif_foundfield
->field_name, field_name)))); }) == 0)
530 && (dt == TIFF_ANYTIFF_NOTYPE || dt == tif->tif_foundfield->field_type))
531 return (tif->tif_foundfield);
532
533 /* If we are invoked with no field information, then just return. */
534 if (!tif->tif_fields)
535 return NULL((void*)0);
536
537 /* NB: use linear search since list is sorted by key#, not name */
538
539 key.field_name = (char *)field_name;
540 key.field_type = dt;
541
542 ret = (const TIFFField **)
543 td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
544 sizeof(TIFFField *), tagNameCompare);
545
546 return tif->tif_foundfield = (ret ? *ret : NULL((void*)0));
547}
548
549const TIFFField*
550TIFFFieldWithTag(TIFF* tif, uint32 tag)
551{
552 const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANYTIFF_NOTYPE);
553 if (!fip) {
554 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
555 "Internal error, unknown tag 0x%x",
556 (unsigned int) tag);
557 }
558 return (fip);
559}
560
561const TIFFField*
562TIFFFieldWithName(TIFF* tif, const char *field_name)
563{
564 const TIFFField* fip =
565 _TIFFFindFieldByName(tif, field_name, TIFF_ANYTIFF_NOTYPE);
566 if (!fip) {
567 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
568 "Internal error, unknown tag %s", field_name);
569 }
570 return (fip);
571}
572
573const TIFFField*
574_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt)
575
576{
577 const TIFFField *fld;
578
579 fld = TIFFFindField(tif, tag, dt);
580 if (fld == NULL((void*)0)) {
581 fld = _TIFFCreateAnonField(tif, tag, dt);
582 if (!_TIFFMergeFields(tif, fld, 1))
583 return NULL((void*)0);
584 }
585
586 return fld;
587}
588
589TIFFField*
590_TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
591{
592 TIFFField *fld;
593 (void) tif;
594
595 fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField));
596 if (fld == NULL((void*)0))
597 return NULL((void*)0);
598 _TIFFmemset(fld, 0, sizeof(TIFFField));
599
600 fld->field_tag = tag;
601 fld->field_readcount = TIFF_VARIABLE2-3;
602 fld->field_writecount = TIFF_VARIABLE2-3;
603 fld->field_type = field_type;
604 fld->reserved = 0;
605 switch (field_type)
606 {
607 case TIFF_BYTE:
608 case TIFF_UNDEFINED:
609 fld->set_field_type = TIFF_SETGET_C32_UINT8;
610 fld->get_field_type = TIFF_SETGET_C32_UINT8;
611 break;
612 case TIFF_ASCII:
613 fld->set_field_type = TIFF_SETGET_C32_ASCII;
614 fld->get_field_type = TIFF_SETGET_C32_ASCII;
615 break;
616 case TIFF_SHORT:
617 fld->set_field_type = TIFF_SETGET_C32_UINT16;
618 fld->get_field_type = TIFF_SETGET_C32_UINT16;
619 break;
620 case TIFF_LONG:
621 fld->set_field_type = TIFF_SETGET_C32_UINT32;
622 fld->get_field_type = TIFF_SETGET_C32_UINT32;
623 break;
624 case TIFF_RATIONAL:
625 case TIFF_SRATIONAL:
626 case TIFF_FLOAT:
627 fld->set_field_type = TIFF_SETGET_C32_FLOAT;
628 fld->get_field_type = TIFF_SETGET_C32_FLOAT;
629 break;
630 case TIFF_SBYTE:
631 fld->set_field_type = TIFF_SETGET_C32_SINT8;
632 fld->get_field_type = TIFF_SETGET_C32_SINT8;
633 break;
634 case TIFF_SSHORT:
635 fld->set_field_type = TIFF_SETGET_C32_SINT16;
636 fld->get_field_type = TIFF_SETGET_C32_SINT16;
637 break;
638 case TIFF_SLONG:
639 fld->set_field_type = TIFF_SETGET_C32_SINT32;
640 fld->get_field_type = TIFF_SETGET_C32_SINT32;
641 break;
642 case TIFF_DOUBLE:
643 fld->set_field_type = TIFF_SETGET_C32_DOUBLE;
644 fld->get_field_type = TIFF_SETGET_C32_DOUBLE;
645 break;
646 case TIFF_IFD:
647 case TIFF_IFD8:
648 fld->set_field_type = TIFF_SETGET_C32_IFD8;
649 fld->get_field_type = TIFF_SETGET_C32_IFD8;
650 break;
651 case TIFF_LONG8:
652 fld->set_field_type = TIFF_SETGET_C32_UINT64;
653 fld->get_field_type = TIFF_SETGET_C32_UINT64;
654 break;
655 case TIFF_SLONG8:
656 fld->set_field_type = TIFF_SETGET_C32_SINT64;
657 fld->get_field_type = TIFF_SETGET_C32_SINT64;
658 break;
659 default:
660 fld->set_field_type = TIFF_SETGET_UNDEFINED;
661 fld->get_field_type = TIFF_SETGET_UNDEFINED;
662 break;
663 }
664 fld->field_bit = FIELD_CUSTOM65;
665 fld->field_oktochange = TRUE1;
666 fld->field_passcount = TRUE1;
667 fld->field_name = (char *) _TIFFmalloc(32);
668 if (fld->field_name == NULL((void*)0)) {
669 _TIFFfree(fld);
670 return NULL((void*)0);
671 }
672 fld->field_subfields = NULL((void*)0);
673
674 /*
675 * note that this name is a special sign to TIFFClose() and
676 * _TIFFSetupFields() to free the field
677 */
678 sprintf(fld->field_name, "Tag %d", (int) tag);
679
680 return fld;
681}
682
683/****************************************************************************
684 * O B S O L E T E D I N T E R F A C E S
685 *
686 * Don't use this stuff in your applications, it may be removed in the future
687 * libtiff versions.
688 ****************************************************************************/
689
690static TIFFSetGetFieldType
691_TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount)
692{
693 if (type == TIFF_ASCII && count == TIFF_VARIABLE-1 && passcount == 0)
694 return TIFF_SETGET_ASCII;
695
696 else if (count == 1 && passcount == 0) {
697 switch (type)
698 {
699 case TIFF_BYTE:
700 case TIFF_UNDEFINED:
701 return TIFF_SETGET_UINT8;
702 case TIFF_ASCII:
703 return TIFF_SETGET_ASCII;
704 case TIFF_SHORT:
705 return TIFF_SETGET_UINT16;
706 case TIFF_LONG:
707 return TIFF_SETGET_UINT32;
708 case TIFF_RATIONAL:
709 case TIFF_SRATIONAL:
710 case TIFF_FLOAT:
711 return TIFF_SETGET_FLOAT;
712 case TIFF_SBYTE:
713 return TIFF_SETGET_SINT8;
714 case TIFF_SSHORT:
715 return TIFF_SETGET_SINT16;
716 case TIFF_SLONG:
717 return TIFF_SETGET_SINT32;
718 case TIFF_DOUBLE:
719 return TIFF_SETGET_DOUBLE;
720 case TIFF_IFD:
721 case TIFF_IFD8:
722 return TIFF_SETGET_IFD8;
723 case TIFF_LONG8:
724 return TIFF_SETGET_UINT64;
725 case TIFF_SLONG8:
726 return TIFF_SETGET_SINT64;
727 default:
728 return TIFF_SETGET_UNDEFINED;
729 }
730 }
731
732 else if (count >= 1 && passcount == 0) {
733 switch (type)
734 {
735 case TIFF_BYTE:
736 case TIFF_UNDEFINED:
737 return TIFF_SETGET_C0_UINT8;
738 case TIFF_ASCII:
739 return TIFF_SETGET_C0_ASCII;
740 case TIFF_SHORT:
741 return TIFF_SETGET_C0_UINT16;
742 case TIFF_LONG:
743 return TIFF_SETGET_C0_UINT32;
744 case TIFF_RATIONAL:
745 case TIFF_SRATIONAL:
746 case TIFF_FLOAT:
747 return TIFF_SETGET_C0_FLOAT;
748 case TIFF_SBYTE:
749 return TIFF_SETGET_C0_SINT8;
750 case TIFF_SSHORT:
751 return TIFF_SETGET_C0_SINT16;
752 case TIFF_SLONG:
753 return TIFF_SETGET_C0_SINT32;
754 case TIFF_DOUBLE:
755 return TIFF_SETGET_C0_DOUBLE;
756 case TIFF_IFD:
757 case TIFF_IFD8:
758 return TIFF_SETGET_C0_IFD8;
759 case TIFF_LONG8:
760 return TIFF_SETGET_C0_UINT64;
761 case TIFF_SLONG8:
762 return TIFF_SETGET_C0_SINT64;
763 default:
764 return TIFF_SETGET_UNDEFINED;
765 }
766 }
767
768 else if (count == TIFF_VARIABLE-1 && passcount == 1) {
769 switch (type)
770 {
771 case TIFF_BYTE:
772 case TIFF_UNDEFINED:
773 return TIFF_SETGET_C16_UINT8;
774 case TIFF_ASCII:
775 return TIFF_SETGET_C16_ASCII;
776 case TIFF_SHORT:
777 return TIFF_SETGET_C16_UINT16;
778 case TIFF_LONG:
779 return TIFF_SETGET_C16_UINT32;
780 case TIFF_RATIONAL:
781 case TIFF_SRATIONAL:
782 case TIFF_FLOAT:
783 return TIFF_SETGET_C16_FLOAT;
784 case TIFF_SBYTE:
785 return TIFF_SETGET_C16_SINT8;
786 case TIFF_SSHORT:
787 return TIFF_SETGET_C16_SINT16;
788 case TIFF_SLONG:
789 return TIFF_SETGET_C16_SINT32;
790 case TIFF_DOUBLE:
791 return TIFF_SETGET_C16_DOUBLE;
792 case TIFF_IFD:
793 case TIFF_IFD8:
794 return TIFF_SETGET_C16_IFD8;
795 case TIFF_LONG8:
796 return TIFF_SETGET_C16_UINT64;
797 case TIFF_SLONG8:
798 return TIFF_SETGET_C16_SINT64;
799 default:
800 return TIFF_SETGET_UNDEFINED;
801 }
802 }
803
804 else if (count == TIFF_VARIABLE2-3 && passcount == 1) {
805 switch (type)
806 {
807 case TIFF_BYTE:
808 case TIFF_UNDEFINED:
809 return TIFF_SETGET_C32_UINT8;
810 case TIFF_ASCII:
811 return TIFF_SETGET_C32_ASCII;
812 case TIFF_SHORT:
813 return TIFF_SETGET_C32_UINT16;
814 case TIFF_LONG:
815 return TIFF_SETGET_C32_UINT32;
816 case TIFF_RATIONAL:
817 case TIFF_SRATIONAL:
818 case TIFF_FLOAT:
819 return TIFF_SETGET_C32_FLOAT;
820 case TIFF_SBYTE:
821 return TIFF_SETGET_C32_SINT8;
822 case TIFF_SSHORT:
823 return TIFF_SETGET_C32_SINT16;
824 case TIFF_SLONG:
825 return TIFF_SETGET_C32_SINT32;
826 case TIFF_DOUBLE:
827 return TIFF_SETGET_C32_DOUBLE;
828 case TIFF_IFD:
829 case TIFF_IFD8:
830 return TIFF_SETGET_C32_IFD8;
831 case TIFF_LONG8:
832 return TIFF_SETGET_C32_UINT64;
833 case TIFF_SLONG8:
834 return TIFF_SETGET_C32_SINT64;
835 default:
836 return TIFF_SETGET_UNDEFINED;
837 }
838 }
839
840 return TIFF_SETGET_UNDEFINED;
841}
842
843int
844TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
845{
846 static const char module[] = "TIFFMergeFieldInfo";
847 static const char reason[] = "for fields array";
848 TIFFField *tp;
849 size_t nfields;
850 uint32 i;
851
852 if (tif->tif_nfieldscompat > 0) {
853 tif->tif_fieldscompat = (TIFFFieldArray *)
854 _TIFFCheckRealloc(tif, tif->tif_fieldscompat,
855 tif->tif_nfieldscompat + 1,
856 sizeof(TIFFFieldArray), reason);
857 } else {
858 tif->tif_fieldscompat = (TIFFFieldArray *)
859 _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray),
860 reason);
861 }
862 if (!tif->tif_fieldscompat) {
863 TIFFErrorExt(tif->tif_clientdata, module,
864 "Failed to allocate fields array");
865 return -1;
866 }
867 nfields = tif->tif_nfieldscompat++;
868
869 tif->tif_fieldscompat[nfields].type = tfiatOther;
870 tif->tif_fieldscompat[nfields].allocated_size = n;
871 tif->tif_fieldscompat[nfields].count = n;
872 tif->tif_fieldscompat[nfields].fields =
873 (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField),
874 reason);
875 if (!tif->tif_fieldscompat[nfields].fields) {
876 TIFFErrorExt(tif->tif_clientdata, module,
877 "Failed to allocate fields array");
878 return -1;
879 }
880
881 tp = tif->tif_fieldscompat[nfields].fields;
882 for (i = 0; i < n; i++) {
883 tp->field_tag = info[i].field_tag;
884 tp->field_readcount = info[i].field_readcount;
885 tp->field_writecount = info[i].field_writecount;
886 tp->field_type = info[i].field_type;
887 tp->reserved = 0;
888 tp->set_field_type =
889 _TIFFSetGetType(info[i].field_type,
890 info[i].field_readcount,
891 info[i].field_passcount);
892 tp->get_field_type =
893 _TIFFSetGetType(info[i].field_type,
894 info[i].field_readcount,
895 info[i].field_passcount);
896 tp->field_bit = info[i].field_bit;
897 tp->field_oktochange = info[i].field_oktochange;
898 tp->field_passcount = info[i].field_passcount;
899 tp->field_name = info[i].field_name;
900 tp->field_subfields = NULL((void*)0);
901 tp++;
902 }
903
904 if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) {
905 TIFFErrorExt(tif->tif_clientdata, module,
906 "Setting up field info failed");
907 return -1;
908 }
909
910 return 0;
911}
912
913/* vim: set ts=8 sts=8 sw=8 noet: */
914
915/*
916 * Local Variables:
917 * mode: c
918 * c-basic-offset: 8
919 * fill-column: 78
920 * End:
921 */