1 #include "image_io/jpeg/jpeg_xmp_info_builder.h" 2 3 #include <string> 4 5 namespace photos_editing_formats { 6 namespace image_io { 7 ProcessSegment(const JpegSegment & segment)8void JpegXmpInfoBuilder::ProcessSegment(const JpegSegment& segment) { 9 // If the property has not yet been found, look for it, and if found, add the 10 // segment's range to the vector of ranges. 11 size_t extended_xmp_data_begin = 12 segment.GetPayloadDataLocation() + kXmpExtendedHeaderSize; 13 size_t property_value_begin = extended_xmp_data_begin; 14 if (property_segment_ranges_.empty()) { 15 std::string property_name = 16 JpegXmpInfo::GetDataPropertyName(xmp_info_type_); 17 property_value_begin = segment.FindXmpPropertyValueBegin( 18 extended_xmp_data_begin, property_name.c_str()); 19 if (property_value_begin != segment.GetEnd()) { 20 property_segment_ranges_.push_back(segment.GetDataRange()); 21 } 22 } else if (!property_end_segment_range_.IsValid()) { 23 // The start of the property value was encountered in a previous segment - 24 // if the closing quote has not yet been found, then add the segment's range 25 // to the vector or ranges. 26 property_segment_ranges_.push_back(segment.GetDataRange()); 27 } 28 29 // If the start of the property value has been found but the end has not, look 30 // for the end in this segment. 31 if (!property_segment_ranges_.empty() && 32 !property_end_segment_range_.IsValid()) { 33 size_t property_value_end = 34 segment.FindXmpPropertyValueEnd(property_value_begin); 35 if (property_value_end != segment.GetEnd()) { 36 property_end_segment_range_ = segment.GetDataRange(); 37 } 38 } 39 } 40 41 } // namespace image_io 42 } // namespace photos_editing_formats 43