exif.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * EXIF metadata parser
  3. * Copyright (c) 2013 Thilo Borgmann <thilo.borgmann _at_ mail.de>
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * EXIF metadata parser
  24. * @author Thilo Borgmann <thilo.borgmann _at_ mail.de>
  25. */
  26. #ifndef AVCODEC_EXIF_H
  27. #define AVCODEC_EXIF_H
  28. #include "avcodec.h"
  29. #include "bytestream.h"
  30. #include "tiff.h"
  31. #define EXIF_MAX_IFD_RECURSION 2
  32. #define EXIF_TAG_NAME_LENGTH 32
  33. struct exif_tag {
  34. char name[EXIF_TAG_NAME_LENGTH];
  35. uint16_t id;
  36. };
  37. static const struct exif_tag tag_list[] = { // JEITA CP-3451 EXIF specification:
  38. {"GPSVersionID", 0x00}, // <- Table 12 GPS Attribute Information
  39. {"GPSLatitudeRef", 0x01},
  40. {"GPSLatitude", 0x02},
  41. {"GPSLongitudeRef", 0x03},
  42. {"GPSLongitude", 0x04},
  43. {"GPSAltitudeRef", 0x05},
  44. {"GPSAltitude", 0x06},
  45. {"GPSTimeStamp", 0x07},
  46. {"GPSSatellites", 0x08},
  47. {"GPSStatus", 0x09},
  48. {"GPSMeasureMode", 0x0A},
  49. {"GPSDOP", 0x0B},
  50. {"GPSSpeedRef", 0x0C},
  51. {"GPSSpeed", 0x0D},
  52. {"GPSTrackRef", 0x0E},
  53. {"GPSTrack", 0x0F},
  54. {"GPSImgDirectionRef", 0x10},
  55. {"GPSImgDirection", 0x11},
  56. {"GPSMapDatum", 0x12},
  57. {"GPSDestLatitudeRef", 0x13},
  58. {"GPSDestLatitude", 0x14},
  59. {"GPSDestLongitudeRef", 0x15},
  60. {"GPSDestLongitude", 0x16},
  61. {"GPSDestBearingRef", 0x17},
  62. {"GPSDestBearing", 0x18},
  63. {"GPSDestDistanceRef", 0x19},
  64. {"GPSDestDistance", 0x1A},
  65. {"GPSProcessingMethod", 0x1B},
  66. {"GPSAreaInformation", 0x1C},
  67. {"GPSDateStamp", 0x1D},
  68. {"GPSDifferential", 0x1E},
  69. {"ImageWidth", 0x100}, // <- Table 3 TIFF Rev. 6.0 Attribute Information Used in Exif
  70. {"ImageLength", 0x101},
  71. {"BitsPerSample", 0x102},
  72. {"Compression", 0x103},
  73. {"PhotometricInterpretation", 0x106},
  74. {"Orientation", 0x112},
  75. {"SamplesPerPixel", 0x115},
  76. {"PlanarConfiguration", 0x11C},
  77. {"YCbCrSubSampling", 0x212},
  78. {"YCbCrPositioning", 0x213},
  79. {"XResolution", 0x11A},
  80. {"YResolution", 0x11B},
  81. {"ResolutionUnit", 0x128},
  82. {"StripOffsets", 0x111},
  83. {"RowsPerStrip", 0x116},
  84. {"StripByteCounts", 0x117},
  85. {"JPEGInterchangeFormat", 0x201},
  86. {"JPEGInterchangeFormatLength",0x202},
  87. {"TransferFunction", 0x12D},
  88. {"WhitePoint", 0x13E},
  89. {"PrimaryChromaticities", 0x13F},
  90. {"YCbCrCoefficients", 0x211},
  91. {"ReferenceBlackWhite", 0x214},
  92. {"DateTime", 0x132},
  93. {"ImageDescription", 0x10E},
  94. {"Make", 0x10F},
  95. {"Model", 0x110},
  96. {"Software", 0x131},
  97. {"Artist", 0x13B},
  98. {"Copyright", 0x8298},
  99. {"ExifVersion", 0x9000}, // <- Table 4 Exif IFD Attribute Information (1)
  100. {"FlashpixVersion", 0xA000},
  101. {"ColorSpace", 0xA001},
  102. {"ComponentsConfiguration", 0x9101},
  103. {"CompressedBitsPerPixel", 0x9102},
  104. {"PixelXDimension", 0xA002},
  105. {"PixelYDimension", 0xA003},
  106. {"MakerNote", 0x927C},
  107. {"UserComment", 0x9286},
  108. {"RelatedSoundFile", 0xA004},
  109. {"DateTimeOriginal", 0x9003},
  110. {"DateTimeDigitized", 0x9004},
  111. {"SubSecTime", 0x9290},
  112. {"SubSecTimeOriginal", 0x9291},
  113. {"SubSecTimeDigitized", 0x9292},
  114. {"ImageUniqueID", 0xA420},
  115. {"ExposureTime", 0x829A}, // <- Table 5 Exif IFD Attribute Information (2)
  116. {"FNumber", 0x829D},
  117. {"ExposureProgram", 0x8822},
  118. {"SpectralSensitivity", 0x8824},
  119. {"ISOSpeedRatings", 0x8827},
  120. {"OECF", 0x8828},
  121. {"ShutterSpeedValue", 0x9201},
  122. {"ApertureValue", 0x9202},
  123. {"BrightnessValue", 0x9203},
  124. {"ExposureBiasValue", 0x9204},
  125. {"MaxApertureValue", 0x9205},
  126. {"SubjectDistance", 0x9206},
  127. {"MeteringMode", 0x9207},
  128. {"LightSource", 0x9208},
  129. {"Flash", 0x9209},
  130. {"FocalLength", 0x920A},
  131. {"SubjectArea", 0x9214},
  132. {"FlashEnergy", 0xA20B},
  133. {"SpatialFrequencyResponse", 0xA20C},
  134. {"FocalPlaneXResolution", 0xA20E},
  135. {"FocalPlaneYResolution", 0xA20F},
  136. {"FocalPlaneResolutionUnit", 0xA210},
  137. {"SubjectLocation", 0xA214},
  138. {"ExposureIndex", 0xA215},
  139. {"SensingMethod", 0xA217},
  140. {"FileSource", 0xA300},
  141. {"SceneType", 0xA301},
  142. {"CFAPattern", 0xA302},
  143. {"CustomRendered", 0xA401},
  144. {"ExposureMode", 0xA402},
  145. {"WhiteBalance", 0xA403},
  146. {"DigitalZoomRatio", 0xA404},
  147. {"FocalLengthIn35mmFilm", 0xA405},
  148. {"SceneCaptureType", 0xA406},
  149. {"GainControl", 0xA407},
  150. {"Contrast", 0xA408},
  151. {"Saturation", 0xA409},
  152. {"Sharpness", 0xA40A},
  153. {"DeviceSettingDescription", 0xA40B},
  154. {"SubjectDistanceRange", 0xA40C}
  155. // {"InteroperabilityIndex", 0x1}, // <- Table 13 Interoperability IFD Attribute Information
  156. // {"", 0x0}
  157. };
  158. /** Recursively decodes all IFD's and
  159. * adds included TAGS into the metadata dictionary. */
  160. int avpriv_exif_decode_ifd(void *logctx, const uint8_t *buf, int size,
  161. int le, int depth, AVDictionary **metadata);
  162. int ff_exif_decode_ifd(void *logctx, GetByteContext *gbytes, int le,
  163. int depth, AVDictionary **metadata);
  164. #endif /* AVCODEC_EXIF_H */