1 #ifndef DYNAMIC_DEPTH_INCLUDES_XMPMETA_JPEG_IO_H_ // NOLINT 2 #define DYNAMIC_DEPTH_INCLUDES_XMPMETA_JPEG_IO_H_ // NOLINT 3 4 #include <string> 5 #include <vector> 6 7 #include "base/port.h" 8 9 namespace dynamic_depth { 10 namespace xmpmeta { 11 12 // Contains the data for a section in a JPEG file. 13 // A JPEG file contains many sections in addition to image data. 14 struct Section { 15 // Constructors. 16 Section() = default; 17 explicit Section(const string& buffer); 18 19 // Returns true if the section's marker matches an APP1 marker. 20 bool IsMarkerApp1(); 21 22 int marker; 23 bool is_image_section; 24 string data; 25 }; 26 27 struct ParseOptions { 28 // If set to true, keeps only the EXIF and XMP sections (with 29 // marker kApp1) and ignores others. Otherwise, keeps everything including 30 // image data. 31 bool read_meta_only = false; 32 33 // If section_header is set, this boolean controls whether only the 1st 34 // section matching the section_header will be returned. If not set 35 // (the default), all the sections that math the section header will be 36 // returned. 37 bool section_header_return_first = false; 38 39 // A filter that keeps all the sections whose data starts with the 40 // given string. Ignored if empty. 41 string section_header; 42 }; 43 44 // Parses the JPEG image file. 45 std::vector<Section> Parse(const ParseOptions& options, 46 std::istream* input_stream); 47 48 // Writes JPEG data sections to a file. 49 void WriteSections(const std::vector<Section>& sections, 50 std::ostream* output_stream); 51 52 } // namespace xmpmeta 53 } // namespace dynamic_depth 54 55 #endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_JPEG_IO_H_ // NOLINT 56