From 81145064de936e9ec401a50deca315891c6068f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Thu, 16 Dec 2021 02:11:07 +0100 Subject: Generate TIFF structs/enums from a text file This is to make the tables much easier to maintain. --- tools/info.h | 505 +---------------------------------------------------------- 1 file changed, 2 insertions(+), 503 deletions(-) (limited to 'tools') diff --git a/tools/info.h b/tools/info.h index ef58d7b..816c9cf 100644 --- a/tools/info.h +++ b/tools/info.h @@ -76,37 +76,6 @@ u16le(const uint8_t *p) } // --- TIFF -------------------------------------------------------------------- -// TIFF Revision 6.0 (1992) -// https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFF6.pdf -// -// TIFF Technical Note 1: TIFF Trees (1993) -// https://download.osgeo.org/libtiff/old/TTN1.ps -// -// DRAFT TIFF Technical Note 2 (1995) -// https://www.awaresystems.be/imaging/tiff/specification/TIFFTechNote2.txt -// -// Adobe PageMaker 6.0 TIFF Technical Notes (1995) [includes TTN1] -// https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFFPM6.pdf -// -// Adobe Photoshop TIFF Technical Notes (2002) -// https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFFphotoshop.pdf -// - Note that ImageSourceData 8BIM frames are specified differently -// from how Adobe XMP Specification Part 3 defines them. -// - The document places a condition on SubIFDs, without further explanation. -// -// Adobe Photoshop TIFF Technical Note 3 (2005) -// http://chriscox.org/TIFFTN3d1.pdf -// -// Exif Version 2.3 (2012) -// https://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf -// -// Exif Version 2.32 (2019) -// https://www.cipa.jp/e/std/std-sec.html -// -// Digital Negative (DNG) Specification 1.5.0.0 (2019) -// https://www.adobe.com/content/dam/acom/en/products/photoshop/pdfs -// /dng_spec_1.5.0.0.pdf -// // libtiff is a mess, and the format is not particularly complicated. // Exiv2 is senselessly copylefted, and cannot do much. // libexif is only marginally better. @@ -391,477 +360,7 @@ struct tiff_entry { struct tiff_value *values; }; -static struct tiff_entry tiff_entries[] = { - {"NewSubfileType", 254, NULL}, - {"SubfileType", 255, (struct tiff_value[]) { - {"Full-resolution image data", 1}, - {"Reduced-resolution image data", 2}, - {"Page of a multi-page image", 3}, - {} - }}, - {"ImageWidth", 256, NULL}, - {"ImageLength", 257, NULL}, - {"BitsPerSample", 258, NULL}, - {"Compression", 259, (struct tiff_value[]) { - {"Uncompressed", 1}, - {"CCITT 1D", 2}, - {"Group 3 Fax", 3}, - {"Group 4 Fax", 4}, - {"LZW", 5}, - {"JPEG", 6}, - {"JPEG datastream", 7}, // DRAFT TIFF Technical Note 2 + TIFFphotoshop - {"Deflate/zlib", 8}, // Adobe Photoshop TIFF Technical Notes - {"PackBits", 32773}, - {"Deflate/zlib", 32946}, // Adobe Photoshop TIFF Technical Notes - {} - }}, - {"PhotometricInterpretation", 262, (struct tiff_value[]) { - {"WhiteIsZero", 0}, - {"BlackIsZero", 1}, - {"RGB", 2}, - {"RGB Palette", 3}, - {"Transparency mask", 4}, - {"CMYK", 5}, - {"YCbCr", 6}, - {"CIELab", 8}, - {"ICCLab", 9}, // Adobe PageMaker 6.0 TIFF Technical Notes - {} - }}, - {"Threshholding", 263, (struct tiff_value[]) { - {"No dithering or halftoning", 1}, - {"Ordered dither or halftoning", 2}, - {"Randomized process", 3}, - {} - }}, - {"CellWidth", 264, NULL}, - {"CellLength", 265, NULL}, - {"FillOrder", 266, (struct tiff_value[]) { - {"MSB-first", 1}, - {"LSB-first", 2}, - {} - }}, - {"DocumentName", 269, NULL}, - {"ImageDescription", 270, NULL}, - {"Make", 271, NULL}, - {"Model", 272, NULL}, - {"StripOffsets", 273, NULL}, - {"Orientation", 274, (struct tiff_value[]) { - {"TopLeft", 1}, - {"TopRight", 2}, - {"BottomRight", 3}, - {"BottomLeft", 4}, - {"LeftTop", 5}, - {"RightTop", 6}, - {"RightBottom", 7}, - {"LeftBottom", 8}, - {} - }}, - {"SamplesPerPixel", 277, NULL}, - {"RowsPerStrip", 278, NULL}, - {"StripByteCounts", 279, NULL}, - {"MinSampleValue", 280, NULL}, - {"MaxSampleValue", 281, NULL}, - {"XResolution", 282, NULL}, - {"YResolution", 283, NULL}, - {"PlanarConfiguration", 284, (struct tiff_value[]) { - {"Chunky", 1}, - {"Planar", 2}, - {} - }}, - {"PageName", 285, NULL}, - {"XPosition", 286, NULL}, - {"YPosition", 287, NULL}, - {"FreeOffsets", 288, NULL}, - {"FreeByteCounts", 289, NULL}, - {"GrayResponseUnit", 290, (struct tiff_value[]) { - {"1/10", 1}, - {"1/100", 2}, - {"1/1000", 3}, - {"1/10000", 4}, - {"1/100000", 5}, - {} - }}, - {"GrayResponseCurve", 291, NULL}, - {"T4Options", 292, NULL}, - {"T6Options", 293, NULL}, - {"ResolutionUnit", 296, (struct tiff_value[]) { - {"None", 1}, - {"Inch", 2}, - {"Centimeter", 3}, - {} - }}, - {"PageNumber", 297, NULL}, - {"TransferFunction", 301, NULL}, - {"Software", 305, NULL}, - {"DateTime", 306, NULL}, - {"Artist", 315, NULL}, - {"HostComputer", 316, NULL}, - {"Predictor", 317, (struct tiff_value[]) { - {"None", 1}, - {"Horizontal", 2}, - {"Floating point", 3}, // Adobe Photoshop TIFF Technical Note 3 - {} - }}, - {"WhitePoint", 318, NULL}, - {"PrimaryChromaticities", 319, NULL}, - {"ColorMap", 320, NULL}, - {"HalftoneHints", 321, NULL}, - {"TileWidth", 322, NULL}, - {"TileLength", 323, NULL}, - {"TileOffsets", 324, NULL}, - {"TileByteCounts", 325, NULL}, - {"SubIFDs", 330, NULL}, // TIFF Technical Note 1: TIFF Trees - {"InkSet", 332, (struct tiff_value[]) { - {"CMYK", 1}, - {"Non-CMYK", 2}, - {} - }}, - {"InkNames", 333, NULL}, - {"NumberOfInks", 334, NULL}, - {"DotRange", 336, NULL}, - {"TargetPrinter", 337, NULL}, - {"ExtraSamples", 338, (struct tiff_value[]) { - {"Unspecified", 0}, - {"Associated alpha", 1}, - {"Unassociated alpha", 2}, - {} - }}, - {"SampleFormat", 339, (struct tiff_value[]) { - {"Unsigned integer", 1}, - {"Two's complement signed integer", 2}, - {"IEEE floating-point", 3}, - {"Undefined", 4}, - {} - }}, - {"SMinSampleValue", 340, NULL}, - {"SMaxSampleValue", 341, NULL}, - {"TransferRange", 342, NULL}, - {"ClipPath", 343, NULL}, // TIFF Technical Note 2: Clipping Path - {"XClipPathUnits", 344, NULL}, // TIFF Technical Note 2: Clipping Path - {"YClipPathUnits", 345, NULL}, // TIFF Technical Note 2: Clipping Path - {"Indexed", 346, NULL}, // TIFF Technical Note 3: Indexed Images - {"JPEGTables", 347, NULL}, // DRAFT TIFF Technical Note 2 + TIFFphotoshop - {"OPIProxy", 351, NULL}, // Adobe PageMaker 6.0 TIFF Technical Notes - {"JPEGProc", 512, (struct tiff_value[]) { - {"Baseline sequential", 1}, - {"Lossless Huffman", 14}, - {} - }}, - {"JPEGInterchangeFormat", 513, NULL}, - {"JPEGInterchangeFormatLength", 514, NULL}, - {"JPEGRestartInterval", 515, NULL}, - {"JPEGLosslessPredictors", 517, (struct tiff_value[]) { - {"A", 1}, - {"B", 2}, - {"C", 3}, - {"A+B+C", 4}, - {"A+((B-C)/2)", 5}, - {"B+((A-C)/2)", 6}, - {"(A+B)/2", 7}, - {} - }}, - {"JPEGPointTransforms", 518, NULL}, - {"JPEGQTables", 519, NULL}, - {"JPEGDCTables", 520, NULL}, - {"JPEGACTables", 521, NULL}, - {"YCbCrCoefficients", 529, NULL}, - {"YCbCrSubSampling", 530, NULL}, - {"YCbCrPositioning", 531, (struct tiff_value[]) { - {"Centered", 1}, - {"Co-sited", 2}, - {} - }}, - {"ReferenceBlackWhite", 532, NULL}, - {"XMP", 700, NULL}, // Adobe XMP Specification Part 3 Table 12/13/39 - {"ImageID", 32781, NULL}, // Adobe PageMaker 6.0 TIFF Technical Notes - {"Copyright", 33432, NULL}, - // TODO(p): Extract IPTC DataSets, like we do directly with PSIRs. - {"IPTC", 33723, NULL}, // Adobe XMP Specification Part 3 Table 12/39 - // TODO(p): Extract PSIRs, like we do directly with the JPEG segment. - {"Photoshop", 34377, NULL}, // Adobe XMP Specification Part 3 Table 12/39 - {"Exif IFD Pointer", 34665, NULL}, // Exif 2.3 - {"GPS Info IFD Pointer", 34853, NULL}, // Exif 2.3 - {"TIFF/EP StandardID", 37398, NULL}, // ISO 12234 TIFF/EP image data format - {"ImageSourceData", 37724, NULL}, // Adobe Photoshop TIFF Technical Notes - {"DNGVersion", 50706, NULL}, // DNG 1.5.0.0 - {"DNGBackwardVersion", 50707, NULL}, // DNG 1.5.0.0 - {"UniqueCameraModel", 50708, NULL}, // DNG 1.5.0.0 - {"LocalizedCameraModel", 50709, NULL}, // DNG 1.5.0.0 - // TODO(p): Add more DNG tags that can be only in IFD0. - {} -}; - -// Exif 2.3 4.6.5 -static struct tiff_entry exif_entries[] = { - {"ExposureTime", 33434, NULL}, - {"FNumber", 33437, NULL}, - {"ExposureProgram", 34850, (struct tiff_value[]) { - {"Not defined", 0}, - {"Manual", 1}, - {"Normal program", 2}, - {"Aperture priority", 3}, - {"Shutter priority", 4}, - {"Creative program", 5}, - {"Action program", 6}, - {"Portrait mode", 7}, - {"Landscape mode", 8}, - {} - }}, - {"SpectralSensitivity", 34852, NULL}, - {"PhotographicSensitivity", 34855, NULL}, - {"OECF", 34856, NULL}, - {"SensitivityType", 34864, (struct tiff_value[]) { - {"Unknown", 0}, - {"Standard output sensitivity", 1}, - {"Recommended exposure index", 2}, - {"ISO speed", 3}, - {"SOS and REI", 4}, - {"SOS and ISO speed", 5}, - {"REI and ISO speed", 6}, - {"SOS and REI and ISO speed", 7}, - {} - }}, - {"StandardOutputSensitivity", 34865, NULL}, - {"RecommendedExposureIndex", 34866, NULL}, - {"ISOSpeed", 34867, NULL}, - {"ISOSpeedLatitudeyyy", 34868, NULL}, - {"ISOSpeedLatitudezzz", 34869, NULL}, - {"ExifVersion", 36864, NULL}, - {"DateTimeOriginal", 36867, NULL}, - {"DateTimeDigitized", 36868, NULL}, - {"OffsetTime", 36880, NULL}, // 2.31 - {"OffsetTimeOriginal", 36881, NULL}, // 2.31 - {"OffsetTimeDigitized", 36882, NULL}, // 2.31 - {"ComponentsConfiguration", 37121, (struct tiff_value[]) { - {"Does not exist", 0}, - {"Y", 1}, - {"Cb", 2}, - {"Cr", 3}, - {"R", 4}, - {"G", 5}, - {"B", 6}, - {} - }}, - {"CompressedBitsPerPixel", 37122, NULL}, - {"ShutterSpeedValue", 37377, NULL}, - {"ApertureValue", 37378, NULL}, - {"BrightnessValue", 37379, NULL}, - {"ExposureBiasValue", 37380, NULL}, - {"MaxApertureValue", 37381, NULL}, - {"SubjectDistance", 37382, NULL}, - {"MeteringMode", 37383, (struct tiff_value[]) { - {"Unknown", 0}, - {"Average", 1}, - {"CenterWeightedAverage", 2}, - {"Spot", 3}, - {"MultiSpot", 4}, - {"Pattern", 5}, - {"Partial", 6}, - {"Other", 255}, - {} - }}, - {"LightSource", 37384, (struct tiff_value[]) { - {"Unknown", 0}, - {"Daylight", 1}, - {"Fluorescent", 2}, - {"Tungsten (incandescent light)", 3}, - {"Flash", 4}, - {"Fine weather", 9}, - {"Cloudy weather", 10}, - {"Shade", 11}, - {"Daylight fluorescent (D 5700 - 7100K)", 12}, - {"Day white fluorescent (N 4600 - 5500K)", 13}, - {"Cool white fluorescent (W 3800 - 4500K)", 14}, - {"White fluorescent (WW 3250 - 3800K)", 15}, - {"Warm white fluorescent (L 2600 - 3250K)", 16}, - {"Standard light A", 17}, - {"Standard light B", 18}, - {"Standard light C", 19}, - {"D55", 20}, - {"D65", 21}, - {"D75", 22}, - {"D50", 23}, - {"ISO studio tungsten", 24}, - {"Other light source", 255}, - {} - }}, - {"Flash", 37385, NULL}, - {"FocalLength", 37386, NULL}, - {"SubjectArea", 37396, NULL}, - {"MakerNote", 37500, NULL}, - // TODO(p): Decode. - {"UserComment", 37510, NULL}, - {"SubSecTime", 37520, NULL}, - {"SubSecTimeOriginal", 37521, NULL}, - {"SubSecTimeDigitized", 37522, NULL}, - {"Temperature", 37888, NULL}, // 2.31 - {"Humidity", 37889, NULL}, // 2.31 - {"Pressure", 37890, NULL}, // 2.31 - {"WaterDepth", 37891, NULL}, // 2.31 - {"Acceleration", 37892, NULL}, // 2.31 - {"CameraElevationAngle", 37893, NULL}, // 2.31 - {"FlashpixVersion", 40960, NULL}, - {"ColorSpace", 40961, (struct tiff_value[]) { - {"sRGB", 1}, - {"Uncalibrated", 0xFFFF}, - {} - }}, - {"PixelXDimension", 40962, NULL}, - {"PixelYDimension", 40963, NULL}, - {"RelatedSoundFile", 40964, NULL}, - {"Interoperability IFD Pointer", 40965, NULL}, - {"FlashEnergy", 41483, NULL}, - {"SpatialFrequencyResponse", 41484, NULL}, - {"FocalPlaneXResolution", 41486, NULL}, - {"FocalPlaneYResolution", 41487, NULL}, - {"FocalPlaneResolutionUnit", 41488, NULL}, - {"SubjectLocation", 41492, NULL}, - {"ExposureIndex", 41493, NULL}, - {"SensingMethod", 41495, (struct tiff_value[]) { - {"Not defined", 1}, - {"One-chip color area sensor", 2}, - {"Two-chip color area sensor", 3}, - {"Three-chip color area sensor", 4}, - {"Color sequential area sensor", 5}, - {"Trilinear sensor", 7}, - {"Color sequential linear sensor", 8}, - {} - }}, - {"FileSource", 41728, (struct tiff_value[]) { - {"Others", 0}, - {"Scanner of transparent type", 1}, - {"Scanner of reflex type", 2}, - {"DSC", 3}, - {} - }}, - {"SceneType", 41729, (struct tiff_value[]) { - {"Directly-photographed image", 1}, - {} - }}, - {"CFAPattern", 41730, NULL}, - {"CustomRendered", 41985, (struct tiff_value[]) { - {"Normal process", 0}, - {"Custom process", 1}, - {} - }}, - {"ExposureMode", 41986, (struct tiff_value[]) { - {"Auto exposure", 0}, - {"Manual exposure", 1}, - {"Auto bracket", 2}, - {} - }}, - {"WhiteBalance", 41987, (struct tiff_value[]) { - {"Auto white balance", 0}, - {"Manual white balance", 1}, - {} - }}, - {"DigitalZoomRatio", 41988, NULL}, - {"FocalLengthIn35mmFilm", 41989, NULL}, - {"SceneCaptureType", 41990, (struct tiff_value[]) { - {"Standard", 0}, - {"Landscape", 1}, - {"Portrait", 2}, - {"Night scene", 3}, - {} - }}, - {"GainControl", 41991, (struct tiff_value[]) { - {"None", 0}, - {"Low gain up", 1}, - {"High gain up", 2}, - {"Low gain down", 3}, - {"High gain down", 4}, - {} - }}, - {"Contrast", 41992, (struct tiff_value[]) { - {"Normal", 0}, - {"Soft", 1}, - {"Hard", 2}, - {} - }}, - {"Saturation", 41993, (struct tiff_value[]) { - {"Normal", 0}, - {"Low", 1}, - {"High", 2}, - {} - }}, - {"Sharpness", 41994, (struct tiff_value[]) { - {"Normal", 0}, - {"Soft", 1}, - {"Hard", 2}, - {} - }}, - {"DeviceSettingDescription", 41995, NULL}, - {"SubjectDistanceRange", 41996, (struct tiff_value[]) { - {"Unknown", 0}, - {"Macro", 1}, - {"Close view", 2}, - {"Distant view", 3}, - {} - }}, - {"ImageUniqueID", 42016, NULL}, - {"CameraOwnerName", 42032, NULL}, - {"BodySerialNumber", 42033, NULL}, - {"LensSpecification", 42034, NULL}, - {"LensMake", 42035, NULL}, - {"LensModel", 42036, NULL}, - {"LensSerialNumber", 42037, NULL}, - {"CompositeImage", 42080, NULL}, // 2.32 - {"SourceImageNumberOfCompositeImage", 42081, NULL}, // 2.32 - {"SourceExposureTimesOfCompositeImage", 42082, NULL}, // 2.32 - {"Gamma", 42240, NULL}, - {} -}; - -// Exif 2.3 4.6.6 (Notice it starts at 0.) -static struct tiff_entry exif_gps_entries[] = { - {"GPSVersionID", 0, NULL}, - {"GPSLatitudeRef", 1, NULL}, - {"GPSLatitude", 2, NULL}, - {"GPSLongitudeRef", 3, NULL}, - {"GPSLongitude", 4, NULL}, - {"GPSAltitudeRef", 5, (struct tiff_value[]) { - {"Sea level", 0}, - {"Sea level reference (negative value)", 1}, - {} - }}, - {"GPSAltitude", 6, NULL}, - {"GPSTimeStamp", 7, NULL}, - {"GPSSatellites", 8, NULL}, - {"GPSStatus", 9, NULL}, - {"GPSMeasureMode", 10, NULL}, - {"GPSDOP", 11, NULL}, - {"GPSSpeedRef", 12, NULL}, - {"GPSSpeed", 13, NULL}, - {"GPSTrackRef", 14, NULL}, - {"GPSTrack", 15, NULL}, - {"GPSImgDirectionRef", 16, NULL}, - {"GPSImgDirection", 17, NULL}, - {"GPSMapDatum", 18, NULL}, - {"GPSDestLatitudeRef", 19, NULL}, - {"GPSDestLatitude", 20, NULL}, - {"GPSDestLongitudeRef", 21, NULL}, - {"GPSDestLongitude", 22, NULL}, - {"GPSDestBearingRef", 23, NULL}, - {"GPSDestBearing", 24, NULL}, - {"GPSDestDistanceRef", 25, NULL}, - {"GPSDestDistance", 26, NULL}, - {"GPSProcessingMethod", 27, NULL}, - {"GPSAreaInformation", 28, NULL}, - {"GPSDateStamp", 29, NULL}, - {"GPSDifferential", 30, (struct tiff_value[]) { - {"Measurement without differential correction", 0}, - {"Differential correction applied", 1}, - {} - }}, - {"GPSHPositioningError", 31, NULL}, - {} -}; - -// Exif 2.3 4.6.7 (Notice it starts at 1, and collides with GPS.) -static struct tiff_entry exif_interop_entries[] = { - {"InteroperabilityIndex", 1, NULL}, - {} -}; +#include "tiff-tables.h" // TODO(p): Consider if these can't be inlined into `tiff_entries`. static struct { @@ -871,7 +370,7 @@ static struct { {330, tiff_entries}, // SubIFDs {34665, exif_entries}, // Exif IFD Pointer {34853, exif_gps_entries}, // GPS Info IFD Pointer - {40965, exif_interop_entries}, // Interoperability IFD Pointer + {40965, exif_interoperability_entries}, // Interoperability IFD Pointer {} }; -- cgit v1.2.3