1 #ifndef IMAGE_IO_JPEG_JPEG_XMP_INFO_H_ // NOLINT 2 #define IMAGE_IO_JPEG_JPEG_XMP_INFO_H_ // NOLINT 3 4 #include <string> 5 #include <vector> 6 7 #include "image_io/base/data_range.h" 8 9 namespace photos_editing_formats { 10 namespace image_io { 11 12 const size_t kXmpGuidSize = 32; 13 const char kXmpId[] = "http://ns.adobe.com/xap/1.0/"; 14 const char kXmpExtendedId[] = "http://ns.adobe.com/xmp/extension/"; 15 const size_t kXmpExtendedHeaderSize = 16 sizeof(kXmpExtendedId) + kXmpGuidSize + 2 * sizeof(std::uint32_t); 17 18 /// Constants used to find and process information in APP1/XMP type segments. 19 const char kXmpAppleDepthId[] = "http://ns.apple.com/depthData/1.0"; 20 const char kXmpAppleMatteId[] = "http://ns.apple.com/portraitEffectsMatte/1.0/"; 21 const char kXmpGDepthV1Id[] = "http://ns.google.com/photos/1.0/depthmap/"; 22 const char kXmpGImageV1Id[] = "http://ns.google.com/photos/1.0/image/"; 23 const char kXmpHasExtendedId[] = "xmpNote:HasExtendedXMP"; 24 25 /// JpegXmpInfo maintains information about the data in an Xmp property, such as 26 /// are used to store the GDepth and GImage data. 27 class JpegXmpInfo { 28 public: 29 /// The possible types of Xmp information. 30 enum Type { 31 /// GDepth:Data type information. 32 kGDepthInfoType, 33 34 /// GImage:Data type information. 35 kGImageInfoType, 36 }; 37 38 /// Initializes a vector of JpegXmpinfo instances, indexed by their type. 39 /// @param xmp_info_vector The vector to initialize. 40 static void InitializeVector(std::vector<JpegXmpInfo>* xmp_info_vector); 41 42 /// @param xmp_info_type The type to get the identifier of. 43 /// @return The identfier that appears at the start of the Xmp segment. 44 static std::string GetIdentifier(Type jpeg_xmp_info_type); 45 46 /// @param xmp_info_type The type to get the data property name of. 47 /// @return The name of the data property that appears in the Xmp segment. 48 static std::string GetDataPropertyName(Type jpeg_xmp_info_type); 49 50 /// @param xmp_info_type The type to get the mime property name of. 51 /// @return The name of the mime property that appears in the primary 52 /// Xmp segment. 53 static std::string GetMimePropertyName(Type jpeg_xmp_info_type); 54 JpegXmpInfo(Type type)55 explicit JpegXmpInfo(Type type) : type_(type) {} 56 JpegXmpInfo(const JpegXmpInfo&) = default; 57 JpegXmpInfo& operator=(const JpegXmpInfo&) = default; 58 59 /// @return The type of the Xmp property information. GetType()60 Type GetType() const { return type_; } 61 62 /// @return The mime type of the Xmp data. GetMimeType()63 std::string GetMimeType() const { return mime_type_; } 64 65 /// @param mime_type The mime type to assign to this instance. SetMimeType(const std::string & mime_type)66 void SetMimeType(const std::string& mime_type) { mime_type_ = mime_type; } 67 68 /// @return The segment's data ranges where this Xmp data occurs. GetSegmentDataRanges()69 const std::vector<DataRange>& GetSegmentDataRanges() const { 70 return segment_data_ranges_; 71 } 72 73 /// @param The segment data ranges to assign to this instance. SetSegmentDataRanges(const std::vector<DataRange> & segment_data_ranges)74 void SetSegmentDataRanges(const std::vector<DataRange>& segment_data_ranges) { 75 segment_data_ranges_ = segment_data_ranges; 76 } 77 78 private: 79 /// The type of the Xmp information. 80 Type type_; 81 82 /// The mime type of the Xmp data. 83 std::string mime_type_; 84 85 /// The segment data ranges that contain the Xmp data. 86 std::vector<DataRange> segment_data_ranges_; 87 }; 88 89 } // namespace image_io 90 } // namespace photos_editing_formats 91 92 #endif // IMAGE_IO_JPEG_JPEG_XMP_INFO_H_ // NOLINT 93