Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: third_party/tiff_v403/tif_dirinfo.c

Issue 1563103002: XFA: Upgrade to libtiff 4.0.6. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rename to libtiff Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/tiff_v403/tif_dir.c ('k') | third_party/tiff_v403/tif_dirread.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* $Id: tif_dirinfo.c,v 1.117 2012-08-19 16:56:34 bfriesen 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
45 static TIFFFieldArray tiffFieldArray;
46 static TIFFFieldArray exifFieldArray;
47
48 static TIFFField
49 tiffFields[] = {
50 { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETG ET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL },
51 { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF _SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "OldSubfileType", NULL },
52 { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGE T_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL },
53 { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETG ET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL },
54 { TIFFTAG_BITSPERSAMPLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF _SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL },
55 { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SE TGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL },
56 { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SET GET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL },
57 { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_S ETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL },
58 { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SE TGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellWidth", NULL },
59 { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_S ETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellLength", NULL },
60 { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGE T_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL },
61 { TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL },
62 { TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL },
63 { TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UN DEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL },
64 { TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_U NDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL },
65 { TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TI FF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL },
66 { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SET GET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL },
67 { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF _SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL },
68 { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SET GET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL },
69 { TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL },
70 { TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIF F_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL },
71 { TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIF F_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL },
72 { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_ SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL },
73 { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_ SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL },
74 { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SE TGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL },
75 { TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGE T_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL },
76 { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SE TGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL },
77 { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SE TGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL },
78 { TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIF F_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL },
79 { TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL },
80 { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL },
81 { TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINE D, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL },
82 { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_ SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL },
83 { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF _SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL },
84 { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL },
85 { TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TI FF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL },
86 { TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGE T_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL },
87 { TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGE T_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL },
88 { TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL },
89 { TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL },
90 { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF _SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL },
91 { TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_ FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL },
92 { TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGE T_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL },
93 { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, T IFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL },
94 { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET _UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL },
95 { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGE T_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL },
96 { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF _SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL },
97 { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, T IFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL },
98 { TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGE T_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", &tiffFieldArray },
99 { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_U NDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL },
100 { TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_S ETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL },
101 { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NumberOfInks", NULL },
102 { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL },
103 { TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL },
104 { TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, T IFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL },
105 { TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_ SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL },
106 { TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF _SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL },
107 { TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF _SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL },
108 { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL },
109 { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
110 { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL },
111 { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL },
112 { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOA T, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL },
113 { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR , TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL },
114 { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIF F_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL },
115 { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FL OAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NU LL },
116 { TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "XMLPacket", NULL },
117 /* begin SGI tags */
118 { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET _UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL },
119 { TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETG ET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL },
120 { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGE T_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL },
121 { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET _UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL },
122 /* end SGI tags */
123 /* begin Pixar tags */
124 { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL },
125 { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL },
126 { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL },
127 { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL },
128 { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SET GET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL },
129 { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET _C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NUL L },
130 { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET _C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NUL L },
131 { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETG ET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
132 /* end Pixar tags */
133 { TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
134 { TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Photoshop", NULL },
135 { TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UND EFINED, FIELD_CUSTOM, 0, 0, "EXIFIFDOffset", &exifFieldArray },
136 { TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile", NULL },
137 { TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDE FINED, FIELD_CUSTOM, 0, 0, "GPSIFDOffset", NULL },
138 { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SE TGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL },
139 { TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_ SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL },
140 { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETG ET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL },
141 { TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL },
142 { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET _UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL },
143 { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL } ,
144 /* begin DNG tags */
145 { TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SET GET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGVersion", NULL },
146 { TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGBackwardVersion", NULL },
147 { TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL },
148 { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UI NT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL },
149 { TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CFAPlaneColor", NULL },
150 { TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGE T_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFALayout", NULL },
151 { TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UIN T16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "LinearizationTable", NULL },
152 { TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT1 6, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BlackLevelRepeatDim", NULL },
153 { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevel", NULL },
154 { TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_F LOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaH", NULL },
155 { TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_F LOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaV", NULL },
156 { TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF _SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "WhiteLevel", NULL },
157 { TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultScale", NULL },
158 { TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BestQualityScale", NULL },
159 { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOA T, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropOrigin", NULL },
160 { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropSize", NULL },
161 { TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix1", NULL },
162 { TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix2", NULL },
163 { TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16 _FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration1", NULL },
164 { TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16 _FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration2", NULL },
165 { TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_F LOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix1", NULL },
166 { TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_F LOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix2", NULL },
167 { TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AnalogBalance", NULL },
168 { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotNeutral", NULL },
169 { TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AsShotWhiteXY", NULL },
170 { TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineExposure", NULL },
171 { TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineNoise", NULL },
172 { TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineSharpness", NULL },
173 { TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BayerGreenSplit", NULL },
174 { TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBL E, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LinearResponseLimit", NULL },
175 { TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL },
176 { TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LensInfo", NULL },
177 { TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ChromaBlurRadius", NULL },
178 { TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AntiAliasStrength", NULL },
179 { TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ShadowScale", NULL },
180 { TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "DNGPrivateData", NULL },
181 { TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF _SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "MakerNoteSafety", NULL },
182 { TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT1 6, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant1", NULL },
183 { TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT1 6, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant2", NULL },
184 { TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "RawDataUniqueID", NULL },
185 { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UIN T8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL },
186 { TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C1 6_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "OriginalRawFileData", NULL },
187 { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ActiveArea", NULL },
188 { TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "MaskedAreas", NULL },
189 { TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_U INT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotICCProfile", NULL },
190 { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET _C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL },
191 { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_ UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL },
192 { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGE T_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix ", NULL },
193 { TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SE TGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL},
194 /* end DNG tags */
195 /* begin TIFF/FX tags */
196 { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDE FINED, FIELD_CUSTOM, 0, 0, "Indexed" },
197 { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD, 0, TIFF_SETGET_UINT32, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL },
198 { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_U NDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL },
199 { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UND EFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL },
200 { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET _UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL },
201 { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET _UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL },
202 { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UND EFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL },
203 { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SET GET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL },
204 { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL },
205 { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UN DEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL },
206 { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF _SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL },
207 { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET _UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL },
208 /* end DNG tags */
209 /* begin pseudo tags */
210 };
211
212 static TIFFField
213 exifFields[] = {
214 { EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF _SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL },
215 { EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETG ET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL },
216 { EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF _SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL },
217 { EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL },
218 { EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16 , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL },
219 { EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL },
220 { EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL },
221 { EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL },
222 { EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL },
223 { EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_ C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL },
224 { EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DO UBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL },
225 { EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL },
226 { EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL },
227 { EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL },
228 { EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL },
229 { EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL },
230 { EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL },
231 { EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL },
232 { EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SET GET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL },
233 { EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UN DEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL },
234 { EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL },
235 { EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL },
236 { EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL },
237 { EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL },
238 { EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SET GET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL },
239 { EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL },
240 { EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL },
241 { EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8 , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL },
242 { EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETG ET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL },
243 { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL },
244 { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL },
245 { EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TI FF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL },
246 { EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL },
247 { EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETG ET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyRespon se", NULL },
248 { EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOU BLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL },
249 { EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOU BLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL },
250 { EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UIN T16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL },
251 { EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, T IFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL },
252 { EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL },
253 { EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL },
254 { EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_S ETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL },
255 { EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL },
256 { EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL },
257 { EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL },
258 { EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL },
259 { EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SE TGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL },
260 { EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL },
261 { EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16 , TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL },
262 { EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIF F_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL },
263 { EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL },
264 { EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET _UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL },
265 { EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETG ET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL },
266 { EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGE T_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL },
267 { EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETG ET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescripti on", NULL },
268 { EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL },
269 { EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_ SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL }
270 };
271
272 static TIFFFieldArray
273 tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), tiffFields };
274 static TIFFFieldArray
275 exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), 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
282 static void *
283 td_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;
294 }
295
296 const TIFFFieldArray*
297 _TIFFGetFields(void)
298 {
299 return(&tiffFieldArray);
300 }
301
302 const TIFFFieldArray*
303 _TIFFGetExifFields(void)
304 {
305 return(&exifFieldArray);
306 }
307
308 void
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_CUSTOM &&
317 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;
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
333 static int
334 tagCompare(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_ANY) ?
343 0 : ((int)tb->field_type - (int)ta->field_type);
344 }
345
346 static int
347 tagNameCompare(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);
352
353 if (ret)
354 return ret;
355 else
356 return (ta->field_type == TIFF_ANY) ?
357 0 : ((int)tb->field_type - (int)ta->field_type);
358 }
359
360 int
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;
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; */
387 for (i = 0; i < n; i++) {
388 const TIFFField *fip =
389 TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
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
405 void
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 */
429 int
430 TIFFDataWidth(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 */
467 int
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
497 /* Sync from 3.8.2's modified*/
498 #ifdef _WIN32_WCE
499 void* wceex_bsearch(const void *key, const void *base, size_t nmemb, size_t size ,
500 int (*compar)(const void *, cons t void *));
501 #define bsearch wceex_bsearch
502 #endif
503
504 const TIFFField*
505 TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt)
506 {
507 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
508 TIFFField* pkey = &key;
509 const TIFFField **ret;
510 if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
511 (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
512 return tif->tif_foundfield;
513
514 /* If we are invoked with no field information, then just return. */
515 if (!tif->tif_fields)
516 return NULL;
517
518 /* NB: use sorted search (e.g. binary search) */
519
520 key.field_tag = tag;
521 key.field_type = dt;
522
523 ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields,
524 tif->tif_nfields,
525 sizeof(TIFFField *), tagCompare);
526 return tif->tif_foundfield = (ret ? *ret : NULL);
527 }
528
529 const TIFFField*
530 _TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt)
531 {
532 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
533 TIFFField* pkey = &key;
534 const TIFFField **ret;
535 if (tif->tif_foundfield
536 && streq(tif->tif_foundfield->field_name, field_name)
537 && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
538 return (tif->tif_foundfield);
539
540 /* If we are invoked with no field information, then just return. */
541 if (!tif->tif_fields)
542 return NULL;
543
544 /* NB: use linear search since list is sorted by key#, not name */
545
546 key.field_name = (char *)field_name;
547 key.field_type = dt;
548
549 #if 1
550 ret = (const TIFFField **)
551 td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
552 sizeof(TIFFField *), tagNameCompare);
553 #else
554 // from old svn version
555 /*ret = (const TIFFFieldInfo **) lfind(&pkey,
556 tif->tif_fieldinfo,
557 &tif->tif_nfields,
558 sizeof(TIFFFieldInfo *),
559 tagNameCompare);
560 */
561 /*modify by Sunliang.Liu 20090827 for some platform not support lfind*/
562 ret = NULL;
563 #endif
564 return tif->tif_foundfield = (ret ? *ret : NULL);
565 }
566
567 const TIFFField*
568 TIFFFieldWithTag(TIFF* tif, uint32 tag)
569 {
570 const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
571 if (!fip) {
572 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
573 "Internal error, unknown tag 0x%x",
574 (unsigned int) tag);
575 }
576 return (fip);
577 }
578
579 const TIFFField*
580 TIFFFieldWithName(TIFF* tif, const char *field_name)
581 {
582 const TIFFField* fip =
583 _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
584 if (!fip) {
585 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
586 "Internal error, unknown tag %s", field_name);
587 }
588 return (fip);
589 }
590
591 uint32
592 TIFFFieldTag(const TIFFField* fip)
593 {
594 return fip->field_tag;
595 }
596
597 const char *
598 TIFFFieldName(const TIFFField* fip)
599 {
600 return fip->field_name;
601 }
602
603 TIFFDataType
604 TIFFFieldDataType(const TIFFField* fip)
605 {
606 return fip->field_type;
607 }
608
609 int
610 TIFFFieldPassCount(const TIFFField* fip)
611 {
612 return fip->field_passcount;
613 }
614
615 int
616 TIFFFieldReadCount(const TIFFField* fip)
617 {
618 return fip->field_readcount;
619 }
620
621 int
622 TIFFFieldWriteCount(const TIFFField* fip)
623 {
624 return fip->field_writecount;
625 }
626
627 const TIFFField*
628 _TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt)
629
630 {
631 const TIFFField *fld;
632
633 fld = TIFFFindField(tif, tag, dt);
634 if (fld == NULL) {
635 fld = _TIFFCreateAnonField(tif, tag, dt);
636 if (!_TIFFMergeFields(tif, fld, 1))
637 return NULL;
638 }
639
640 return fld;
641 }
642
643 TIFFField*
644 _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
645 {
646 TIFFField *fld;
647 (void) tif;
648
649 fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField));
650 if (fld == NULL)
651 return NULL;
652 _TIFFmemset(fld, 0, sizeof(TIFFField));
653
654 fld->field_tag = tag;
655 fld->field_readcount = TIFF_VARIABLE2;
656 fld->field_writecount = TIFF_VARIABLE2;
657 fld->field_type = field_type;
658 fld->reserved = 0;
659 switch (field_type)
660 {
661 case TIFF_BYTE:
662 case TIFF_UNDEFINED:
663 fld->set_field_type = TIFF_SETGET_C32_UINT8;
664 fld->get_field_type = TIFF_SETGET_C32_UINT8;
665 break;
666 case TIFF_ASCII:
667 fld->set_field_type = TIFF_SETGET_C32_ASCII;
668 fld->get_field_type = TIFF_SETGET_C32_ASCII;
669 break;
670 case TIFF_SHORT:
671 fld->set_field_type = TIFF_SETGET_C32_UINT16;
672 fld->get_field_type = TIFF_SETGET_C32_UINT16;
673 break;
674 case TIFF_LONG:
675 fld->set_field_type = TIFF_SETGET_C32_UINT32;
676 fld->get_field_type = TIFF_SETGET_C32_UINT32;
677 break;
678 case TIFF_RATIONAL:
679 case TIFF_SRATIONAL:
680 case TIFF_FLOAT:
681 fld->set_field_type = TIFF_SETGET_C32_FLOAT;
682 fld->get_field_type = TIFF_SETGET_C32_FLOAT;
683 break;
684 case TIFF_SBYTE:
685 fld->set_field_type = TIFF_SETGET_C32_SINT8;
686 fld->get_field_type = TIFF_SETGET_C32_SINT8;
687 break;
688 case TIFF_SSHORT:
689 fld->set_field_type = TIFF_SETGET_C32_SINT16;
690 fld->get_field_type = TIFF_SETGET_C32_SINT16;
691 break;
692 case TIFF_SLONG:
693 fld->set_field_type = TIFF_SETGET_C32_SINT32;
694 fld->get_field_type = TIFF_SETGET_C32_SINT32;
695 break;
696 case TIFF_DOUBLE:
697 fld->set_field_type = TIFF_SETGET_C32_DOUBLE;
698 fld->get_field_type = TIFF_SETGET_C32_DOUBLE;
699 break;
700 case TIFF_IFD:
701 case TIFF_IFD8:
702 fld->set_field_type = TIFF_SETGET_C32_IFD8;
703 fld->get_field_type = TIFF_SETGET_C32_IFD8;
704 break;
705 case TIFF_LONG8:
706 fld->set_field_type = TIFF_SETGET_C32_UINT64;
707 fld->get_field_type = TIFF_SETGET_C32_UINT64;
708 break;
709 case TIFF_SLONG8:
710 fld->set_field_type = TIFF_SETGET_C32_SINT64;
711 fld->get_field_type = TIFF_SETGET_C32_SINT64;
712 break;
713 default:
714 fld->set_field_type = TIFF_SETGET_UNDEFINED;
715 fld->get_field_type = TIFF_SETGET_UNDEFINED;
716 break;
717 }
718 fld->field_bit = FIELD_CUSTOM;
719 fld->field_oktochange = TRUE;
720 fld->field_passcount = TRUE;
721 fld->field_name = (char *) _TIFFmalloc(32);
722 if (fld->field_name == NULL) {
723 _TIFFfree(fld);
724 return NULL;
725 }
726 fld->field_subfields = NULL;
727
728 /*
729 * note that this name is a special sign to TIFFClose() and
730 * _TIFFSetupFields() to free the field
731 */
732 sprintf(fld->field_name, "Tag %d", (int) tag);
733
734 return fld;
735 }
736
737 /****************************************************************************
738 * O B S O L E T E D I N T E R F A C E S
739 *
740 * Don't use this stuff in your applications, it may be removed in the future
741 * libtiff versions.
742 ****************************************************************************/
743
744 static TIFFSetGetFieldType
745 _TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount)
746 {
747 if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
748 return TIFF_SETGET_ASCII;
749
750 else if (count == 1 && passcount == 0) {
751 switch (type)
752 {
753 case TIFF_BYTE:
754 case TIFF_UNDEFINED:
755 return TIFF_SETGET_UINT8;
756 case TIFF_ASCII:
757 return TIFF_SETGET_ASCII;
758 case TIFF_SHORT:
759 return TIFF_SETGET_UINT16;
760 case TIFF_LONG:
761 return TIFF_SETGET_UINT32;
762 case TIFF_RATIONAL:
763 case TIFF_SRATIONAL:
764 case TIFF_FLOAT:
765 return TIFF_SETGET_FLOAT;
766 case TIFF_SBYTE:
767 return TIFF_SETGET_SINT8;
768 case TIFF_SSHORT:
769 return TIFF_SETGET_SINT16;
770 case TIFF_SLONG:
771 return TIFF_SETGET_SINT32;
772 case TIFF_DOUBLE:
773 return TIFF_SETGET_DOUBLE;
774 case TIFF_IFD:
775 case TIFF_IFD8:
776 return TIFF_SETGET_IFD8;
777 case TIFF_LONG8:
778 return TIFF_SETGET_UINT64;
779 case TIFF_SLONG8:
780 return TIFF_SETGET_SINT64;
781 default:
782 return TIFF_SETGET_UNDEFINED;
783 }
784 }
785
786 else if (count >= 1 && passcount == 0) {
787 switch (type)
788 {
789 case TIFF_BYTE:
790 case TIFF_UNDEFINED:
791 return TIFF_SETGET_C0_UINT8;
792 case TIFF_ASCII:
793 return TIFF_SETGET_C0_ASCII;
794 case TIFF_SHORT:
795 return TIFF_SETGET_C0_UINT16;
796 case TIFF_LONG:
797 return TIFF_SETGET_C0_UINT32;
798 case TIFF_RATIONAL:
799 case TIFF_SRATIONAL:
800 case TIFF_FLOAT:
801 return TIFF_SETGET_C0_FLOAT;
802 case TIFF_SBYTE:
803 return TIFF_SETGET_C0_SINT8;
804 case TIFF_SSHORT:
805 return TIFF_SETGET_C0_SINT16;
806 case TIFF_SLONG:
807 return TIFF_SETGET_C0_SINT32;
808 case TIFF_DOUBLE:
809 return TIFF_SETGET_C0_DOUBLE;
810 case TIFF_IFD:
811 case TIFF_IFD8:
812 return TIFF_SETGET_C0_IFD8;
813 case TIFF_LONG8:
814 return TIFF_SETGET_C0_UINT64;
815 case TIFF_SLONG8:
816 return TIFF_SETGET_C0_SINT64;
817 default:
818 return TIFF_SETGET_UNDEFINED;
819 }
820 }
821
822 else if (count == TIFF_VARIABLE && passcount == 1) {
823 switch (type)
824 {
825 case TIFF_BYTE:
826 case TIFF_UNDEFINED:
827 return TIFF_SETGET_C16_UINT8;
828 case TIFF_ASCII:
829 return TIFF_SETGET_C16_ASCII;
830 case TIFF_SHORT:
831 return TIFF_SETGET_C16_UINT16;
832 case TIFF_LONG:
833 return TIFF_SETGET_C16_UINT32;
834 case TIFF_RATIONAL:
835 case TIFF_SRATIONAL:
836 case TIFF_FLOAT:
837 return TIFF_SETGET_C16_FLOAT;
838 case TIFF_SBYTE:
839 return TIFF_SETGET_C16_SINT8;
840 case TIFF_SSHORT:
841 return TIFF_SETGET_C16_SINT16;
842 case TIFF_SLONG:
843 return TIFF_SETGET_C16_SINT32;
844 case TIFF_DOUBLE:
845 return TIFF_SETGET_C16_DOUBLE;
846 case TIFF_IFD:
847 case TIFF_IFD8:
848 return TIFF_SETGET_C16_IFD8;
849 case TIFF_LONG8:
850 return TIFF_SETGET_C16_UINT64;
851 case TIFF_SLONG8:
852 return TIFF_SETGET_C16_SINT64;
853 default:
854 return TIFF_SETGET_UNDEFINED;
855 }
856 }
857
858 else if (count == TIFF_VARIABLE2 && passcount == 1) {
859 switch (type)
860 {
861 case TIFF_BYTE:
862 case TIFF_UNDEFINED:
863 return TIFF_SETGET_C32_UINT8;
864 case TIFF_ASCII:
865 return TIFF_SETGET_C32_ASCII;
866 case TIFF_SHORT:
867 return TIFF_SETGET_C32_UINT16;
868 case TIFF_LONG:
869 return TIFF_SETGET_C32_UINT32;
870 case TIFF_RATIONAL:
871 case TIFF_SRATIONAL:
872 case TIFF_FLOAT:
873 return TIFF_SETGET_C32_FLOAT;
874 case TIFF_SBYTE:
875 return TIFF_SETGET_C32_SINT8;
876 case TIFF_SSHORT:
877 return TIFF_SETGET_C32_SINT16;
878 case TIFF_SLONG:
879 return TIFF_SETGET_C32_SINT32;
880 case TIFF_DOUBLE:
881 return TIFF_SETGET_C32_DOUBLE;
882 case TIFF_IFD:
883 case TIFF_IFD8:
884 return TIFF_SETGET_C32_IFD8;
885 case TIFF_LONG8:
886 return TIFF_SETGET_C32_UINT64;
887 case TIFF_SLONG8:
888 return TIFF_SETGET_C32_SINT64;
889 default:
890 return TIFF_SETGET_UNDEFINED;
891 }
892 }
893
894 return TIFF_SETGET_UNDEFINED;
895 }
896
897 int
898 TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n)
899 {
900 static const char module[] = "TIFFMergeFieldInfo";
901 static const char reason[] = "for fields array";
902 TIFFField *tp;
903 size_t nfields;
904 uint32 i;
905
906 if (tif->tif_nfieldscompat > 0) {
907 tif->tif_fieldscompat = (TIFFFieldArray *)
908 _TIFFCheckRealloc(tif, tif->tif_fieldscompat,
909 tif->tif_nfieldscompat + 1,
910 sizeof(TIFFFieldArray), reason);
911 } else {
912 tif->tif_fieldscompat = (TIFFFieldArray *)
913 _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray),
914 reason);
915 }
916 if (!tif->tif_fieldscompat) {
917 TIFFErrorExt(tif->tif_clientdata, module,
918 "Failed to allocate fields array");
919 return -1;
920 }
921 nfields = tif->tif_nfieldscompat++;
922
923 tif->tif_fieldscompat[nfields].type = tfiatOther;
924 tif->tif_fieldscompat[nfields].allocated_size = n;
925 tif->tif_fieldscompat[nfields].count = n;
926 tif->tif_fieldscompat[nfields].fields =
927 (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField),
928 reason);
929 if (!tif->tif_fieldscompat[nfields].fields) {
930 TIFFErrorExt(tif->tif_clientdata, module,
931 "Failed to allocate fields array");
932 return -1;
933 }
934
935 tp = tif->tif_fieldscompat[nfields].fields;
936 for (i = 0; i < n; i++) {
937 tp->field_tag = info[i].field_tag;
938 tp->field_readcount = info[i].field_readcount;
939 tp->field_writecount = info[i].field_writecount;
940 tp->field_type = info[i].field_type;
941 tp->reserved = 0;
942 tp->set_field_type =
943 _TIFFSetGetType(info[i].field_type,
944 info[i].field_readcount,
945 info[i].field_passcount);
946 tp->get_field_type =
947 _TIFFSetGetType(info[i].field_type,
948 info[i].field_readcount,
949 info[i].field_passcount);
950 tp->field_bit = info[i].field_bit;
951 tp->field_oktochange = info[i].field_oktochange;
952 tp->field_passcount = info[i].field_passcount;
953 tp->field_name = info[i].field_name;
954 tp->field_subfields = NULL;
955 tp++;
956 }
957
958 if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) {
959 TIFFErrorExt(tif->tif_clientdata, module,
960 "Setting up field info failed");
961 return -1;
962 }
963
964 return 0;
965 }
966
967 /* vim: set ts=8 sts=8 sw=8 noet: */
968
969 /*
970 * Local Variables:
971 * mode: c
972 * c-basic-offset: 8
973 * fill-column: 78
974 * End:
975 */
976
OLDNEW
« no previous file with comments | « third_party/tiff_v403/tif_dir.c ('k') | third_party/tiff_v403/tif_dirread.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698