summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-01-28 22:21:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-01-28 22:21:51 +0000
commit938d58078455ad446fb1196cb9978429faff36cc (patch)
tree651b48226356b70dbd99d471abd462bad303aa02
parent6b9f1f428665620ad0577a2b9bcf5c9834c711aa (diff)
parentcf24597915ce4f06730cd9236f3bfdd07cb87311 (diff)
downloaddynamic_depth-938d58078455ad446fb1196cb9978429faff36cc.tar.gz
Merge changes from topic "dynamic_depth"
* changes: Add Android dynamic depth buffer validation sequence Sync libdynamic_depth to CL #228913159
-rw-r--r--README.android9
-rw-r--r--includes/dynamic_depth/app_info.h10
-rw-r--r--includes/dynamic_depth/camera.h7
-rw-r--r--includes/dynamic_depth/cameras.h7
-rw-r--r--includes/dynamic_depth/container.h7
-rw-r--r--includes/dynamic_depth/depth_map.h9
-rw-r--r--includes/dynamic_depth/device.h9
-rw-r--r--includes/dynamic_depth/dynamic_depth.h9
-rw-r--r--includes/dynamic_depth/earth_pose.h10
-rw-r--r--includes/dynamic_depth/image.h10
-rw-r--r--includes/dynamic_depth/imaging_model.h7
-rw-r--r--includes/dynamic_depth/item.h9
-rw-r--r--includes/dynamic_depth/light_estimate.h7
-rw-r--r--includes/dynamic_depth/plane.h10
-rw-r--r--includes/dynamic_depth/planes.h7
-rw-r--r--includes/dynamic_depth/point_cloud.h22
-rw-r--r--includes/dynamic_depth/pose.h10
-rw-r--r--includes/dynamic_depth/profile.h7
-rw-r--r--includes/dynamic_depth/profiles.h7
-rw-r--r--includes/dynamic_depth/vendor_info.h10
-rw-r--r--includes/xmpmeta/jpeg_io.h6
-rw-r--r--includes/xmpmeta/md5.h6
-rw-r--r--includes/xmpmeta/xmp_const.h6
-rw-r--r--includes/xmpmeta/xmp_data.h6
-rw-r--r--includes/xmpmeta/xmp_parser.h6
-rw-r--r--includes/xmpmeta/xmp_writer.h23
-rw-r--r--internal/dynamic_depth/app_info.cc6
-rw-r--r--internal/dynamic_depth/camera.cc6
-rw-r--r--internal/dynamic_depth/cameras.cc6
-rw-r--r--internal/dynamic_depth/const.cc2
-rw-r--r--internal/dynamic_depth/const.h4
-rw-r--r--internal/dynamic_depth/container.cc6
-rw-r--r--internal/dynamic_depth/depth_map.cc12
-rw-r--r--internal/dynamic_depth/device.cc24
-rw-r--r--internal/dynamic_depth/dimension.h4
-rw-r--r--internal/dynamic_depth/dynamic_depth.cc135
-rw-r--r--internal/dynamic_depth/earth_pose.cc6
-rw-r--r--internal/dynamic_depth/element.h7
-rw-r--r--internal/dynamic_depth/image.cc8
-rw-r--r--internal/dynamic_depth/imaging_model.cc12
-rw-r--r--internal/dynamic_depth/item.cc11
-rw-r--r--internal/dynamic_depth/light_estimate.cc6
-rw-r--r--internal/dynamic_depth/plane.cc8
-rw-r--r--internal/dynamic_depth/planes.cc6
-rw-r--r--internal/dynamic_depth/point.h4
-rw-r--r--internal/dynamic_depth/point_cloud.cc25
-rw-r--r--internal/dynamic_depth/pose.cc6
-rw-r--r--internal/dynamic_depth/profile.cc6
-rw-r--r--internal/dynamic_depth/profiles.cc6
-rw-r--r--internal/dynamic_depth/vendor_info.cc6
-rw-r--r--internal/xmpmeta/base64.cc6
-rw-r--r--internal/xmpmeta/base64.h6
-rw-r--r--internal/xmpmeta/file.cc6
-rw-r--r--internal/xmpmeta/file.h6
-rw-r--r--internal/xmpmeta/jpeg_io.cc6
-rw-r--r--internal/xmpmeta/md5.cc9
-rw-r--r--internal/xmpmeta/xml/const.cc6
-rw-r--r--internal/xmpmeta/xml/const.h6
-rw-r--r--internal/xmpmeta/xml/deserializer.h6
-rw-r--r--internal/xmpmeta/xml/deserializer_impl.cc7
-rw-r--r--internal/xmpmeta/xml/deserializer_impl.h6
-rw-r--r--internal/xmpmeta/xml/search.cc8
-rw-r--r--internal/xmpmeta/xml/search.h6
-rw-r--r--internal/xmpmeta/xml/serializer.h6
-rw-r--r--internal/xmpmeta/xml/serializer_impl.cc6
-rw-r--r--internal/xmpmeta/xml/serializer_impl.h6
-rw-r--r--internal/xmpmeta/xml/utils.cc6
-rw-r--r--internal/xmpmeta/xml/utils.h6
-rw-r--r--internal/xmpmeta/xmp_const.cc6
-rw-r--r--internal/xmpmeta/xmp_data.cc6
-rw-r--r--internal/xmpmeta/xmp_parser.cc15
-rw-r--r--internal/xmpmeta/xmp_writer.cc58
72 files changed, 416 insertions, 341 deletions
diff --git a/README.android b/README.android
new file mode 100644
index 0000000..7a8f454
--- /dev/null
+++ b/README.android
@@ -0,0 +1,9 @@
+Library Name: Dynamic Depth
+License: Apache 2
+Description: A C++ implementation of the Dynamic Depth extension. It contains all necessary
+utilities for reading and writing Depth and AR photos.
+
+Local patches
+-------------
+- Android depth photo validation sequence "ValidateAndroidDynamicDepthBuffer()".
+
diff --git a/includes/dynamic_depth/app_info.h b/includes/dynamic_depth/app_info.h
index 4a519b4..0791081 100644
--- a/includes/dynamic_depth/app_info.h
+++ b/includes/dynamic_depth/app_info.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
/**
@@ -27,7 +26,8 @@ class AppInfo : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates an AppInfo from the given fields. Returns null if the version
// field is empty and [item_uri is empty and items is null].
@@ -50,7 +50,7 @@ class AppInfo : public Element {
// Returns the deserialized AppInfo; null if parsing fails.
static std::unique_ptr<AppInfo> FromDeserializer(
- const xml::Deserializer& parent_deserializer,
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer,
const string& namespace_str);
// Getters.
@@ -65,7 +65,8 @@ class AppInfo : public Element {
private:
AppInfo();
- bool ParseFields(const xml::Deserializer& deserializer);
+ bool ParseFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
// Required.
string application_;
@@ -76,6 +77,5 @@ class AppInfo : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_APP_INFO_H_ // NOLINT
diff --git a/includes/dynamic_depth/camera.h b/includes/dynamic_depth/camera.h
index 9c9c001..83bf448 100644
--- a/includes/dynamic_depth/camera.h
+++ b/includes/dynamic_depth/camera.h
@@ -18,7 +18,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// The camera trait is serialized only if it is one of PHYSICAL or LOGICAL.
@@ -74,7 +73,8 @@ class Camera : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates a Camera from the given objects in params.
// Aside from the Image element, all other elements are optional and can be
@@ -95,7 +95,7 @@ class Camera : public Element {
// Returns the deserialized Camera object, null if parsing fails.
// Not sensitive to case when parsing a camera's trait.
static std::unique_ptr<Camera> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Getters. Except for Imaeg (which should never be null), these will return
// null if the corresponding fields are not present.
@@ -121,6 +121,5 @@ class Camera : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_CAMERA_H_ // NOLINT
diff --git a/includes/dynamic_depth/cameras.h b/includes/dynamic_depth/cameras.h
index 5537e03..38315d6 100644
--- a/includes/dynamic_depth/cameras.h
+++ b/includes/dynamic_depth/cameras.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// Implements the Device:Cameras field from the Dynamic Depth specification,
@@ -20,7 +19,8 @@ class Cameras : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates this object from the given cameras. Returns null if the list is
// empty.
@@ -32,7 +32,7 @@ class Cameras : public Element {
// Returns the deserialized cameras in a Cameras object, null if parsing
// failed for all the cameras.
static std::unique_ptr<Cameras> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Returns the list of cameras.
const std::vector<const Camera*> GetCameras() const;
@@ -48,6 +48,5 @@ class Cameras : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_CAMERAS_H_ // NOLINT
diff --git a/includes/dynamic_depth/container.h b/includes/dynamic_depth/container.h
index a8a437d..73ba1d7 100644
--- a/includes/dynamic_depth/container.h
+++ b/includes/dynamic_depth/container.h
@@ -8,7 +8,6 @@
#include "dynamic_depth/element.h"
#include "dynamic_depth/item.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// A Container that holds a directory / array of file Item elementss. Files
@@ -19,7 +18,8 @@ class Container : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates this object from the given items. Returns null if the list is
// empty. If creation succeeds, ownership of the Item objects are transferred
@@ -31,7 +31,7 @@ class Container : public Element {
// Returns the deserialized item elements, null if parsing failed for all
// items.
static std::unique_ptr<Container> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Returns the list of cameras.
const std::vector<const Item*> GetItems() const;
@@ -47,6 +47,5 @@ class Container : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_CONTAINER_H_ // NOLINT
diff --git a/includes/dynamic_depth/depth_map.h b/includes/dynamic_depth/depth_map.h
index 836ff23..4dcc37f 100644
--- a/includes/dynamic_depth/depth_map.h
+++ b/includes/dynamic_depth/depth_map.h
@@ -11,7 +11,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// The depth conversion format. Please see the Depth Map element in the
@@ -86,7 +85,8 @@ class DepthMap : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates a DepthMap from the given objects in params.
static std::unique_ptr<DepthMap> FromData(
@@ -96,7 +96,7 @@ class DepthMap : public Element {
// Not sensitive to case when parsing the Format, Units, or MeasureType
// fields.
static std::unique_ptr<DepthMap> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
DepthFormat GetFormat() const;
float GetNear() const;
@@ -117,12 +117,11 @@ class DepthMap : public Element {
private:
explicit DepthMap(const DepthMapParams& params);
static std::unique_ptr<DepthMap> ParseFields(
- const xml::Deserializer& deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
DepthMapParams params_;
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_DEPTH_MAP_H_ // NOLINT
diff --git a/includes/dynamic_depth/device.h b/includes/dynamic_depth/device.h
index 77f1665..39894a4 100644
--- a/includes/dynamic_depth/device.h
+++ b/includes/dynamic_depth/device.h
@@ -21,7 +21,6 @@
#include "dynamic_depth/vendor_info.h"
#include "xmpmeta/xmp_data.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
struct DeviceParams {
@@ -77,7 +76,8 @@ class Device {
// Creates a Device from pre-extracted XMP metadata. Returns null if
// parsing fails. Both the standard and extended XMP sections are required.
- static std::unique_ptr<Device> FromXmp(const XmpData& xmp);
+ static std::unique_ptr<Device> FromXmp(
+ const ::dynamic_depth::xmpmeta::XmpData& xmp);
// Creates a Device by extracting XMP metadata from a JPEG and parsing it.
// If using XMP for other things as well, FromXmp() should be used instead to
@@ -99,7 +99,7 @@ class Device {
const AppInfo* GetAppInfo() const;
// Not const for XML memory management reasons. More info in source comments.
- bool SerializeToXmp(XmpData* xmp);
+ bool SerializeToXmp(::dynamic_depth::xmpmeta::XmpData* xmp);
// Saves Device metadata to a .xml file.
bool SerializeToXmlFile(const char* filename);
@@ -126,6 +126,5 @@ class Device {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_DEVICE_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_DEVICE_H_ // NOLINT
diff --git a/includes/dynamic_depth/dynamic_depth.h b/includes/dynamic_depth/dynamic_depth.h
index 40a0db7..5f8b760 100644
--- a/includes/dynamic_depth/dynamic_depth.h
+++ b/includes/dynamic_depth/dynamic_depth.h
@@ -4,7 +4,6 @@
#include "dynamic_depth/device.h"
#include "xmpmeta/xmp_writer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// Serialize a JPEG image, its Dynamic Depth metadata, and GContainer files
@@ -14,6 +13,11 @@ bool WriteImageAndMetadataAndContainer(const string& out_filename,
size_t primary_image_bytes_count,
Device* device);
+// Same as WriteImageAndMetadataAndContainer, but on istream and ostream.
+bool WriteImageAndMetadataAndContainer(std::istream* input_jpeg_stream,
+ Device* device,
+ std::ostream* output_jpeg_stream);
+
// Retrieves the contents of a Container:Item's associated file. The contents
// are populated into out_payload.
// As per the Dynamic Depth spec, file contents are base64-encoded if they're
@@ -29,6 +33,5 @@ bool GetItemPayload(const string& input_image_filename, const Device* device,
const string& item_uri, string* out_payload);
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_DYNAMIC_DEPTH_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_DYNAMIC_DEPTH_H_ // NOLINT
diff --git a/includes/dynamic_depth/earth_pose.h b/includes/dynamic_depth/earth_pose.h
index 0487cdb..6deacd0 100644
--- a/includes/dynamic_depth/earth_pose.h
+++ b/includes/dynamic_depth/earth_pose.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// Implements the EarthPose element in the Dynamic Depth specification, with
@@ -26,7 +25,8 @@ class EarthPose : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object. Returns true on success.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates a EarthPose from the given data.
// The order of values in position is latitude, longitude, altitude..
@@ -44,7 +44,7 @@ class EarthPose : public Element {
// Returns the deserialized XdmAudio; null if parsing fails.
// The returned pointer is owned by the caller.
static std::unique_ptr<EarthPose> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Returns true if the device's position is provided.
bool HasPosition() const;
@@ -71,7 +71,8 @@ class EarthPose : public Element {
EarthPose();
// Extracts device pose fields.
- bool ParseEarthPoseFields(const xml::Deserializer& deserializer);
+ bool ParseEarthPoseFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
// Position variables, in meters relative to camera 0.
// If providing position data, all three fields must be set.
@@ -89,6 +90,5 @@ class EarthPose : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_EARTH_POSE_H_ // NOLINT
diff --git a/includes/dynamic_depth/image.h b/includes/dynamic_depth/image.h
index b944337..a5650c1 100644
--- a/includes/dynamic_depth/image.h
+++ b/includes/dynamic_depth/image.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// The ItemSemantic of this Image.
@@ -30,7 +29,8 @@ class Image : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates an original (non-primary) Image from the given fields. Returns null
// if one of the following is true:
@@ -64,7 +64,7 @@ class Image : public Element {
// Returns the deserialized Image; null if parsing fails.
static std::unique_ptr<Image> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
const string& GetItemUri() const;
ImageItemSemantic GetItemSemantic() const;
@@ -77,13 +77,13 @@ class Image : public Element {
Image();
// Extracts image fields.
- bool ParseImageFields(const xml::Deserializer& deserializer);
+ bool ParseImageFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
string item_uri_;
ImageItemSemantic item_semantic_;
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_IMAGE_H_ // NOLINT
diff --git a/includes/dynamic_depth/imaging_model.h b/includes/dynamic_depth/imaging_model.h
index 1175a66..f9f4898 100644
--- a/includes/dynamic_depth/imaging_model.h
+++ b/includes/dynamic_depth/imaging_model.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
struct ImagingModelParams {
// Required. The order of numbers is (x, y), in pixels.
@@ -55,7 +54,8 @@ class ImagingModel : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates an ImagingModel from the given params.
static std::unique_ptr<ImagingModel> FromData(
@@ -63,7 +63,7 @@ class ImagingModel : public Element {
// Returns the deserialized equirect model, null if parsing fails.
static std::unique_ptr<ImagingModel> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Getters.
Point<double> GetFocalLength() const;
@@ -85,6 +85,5 @@ class ImagingModel : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_IMAGING_MODEL_H_ // NOLINT
diff --git a/includes/dynamic_depth/item.h b/includes/dynamic_depth/item.h
index d1fcd36..5f17e01 100644
--- a/includes/dynamic_depth/item.h
+++ b/includes/dynamic_depth/item.h
@@ -11,7 +11,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
struct ItemParams {
// Required fields.
@@ -56,14 +55,15 @@ class Item : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
static std::unique_ptr<Item> FromData(const ItemParams& params);
// Returns the deserialized item elements, null if parsing failed for all
// items.
static std::unique_ptr<Item> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
const string& GetMime() const;
unsigned int GetLength() const;
@@ -84,6 +84,5 @@ class Item : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_ITEM_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_ITEM_H_ // NOLINT
diff --git a/includes/dynamic_depth/light_estimate.h b/includes/dynamic_depth/light_estimate.h
index 51cbde2..055c6d1 100644
--- a/includes/dynamic_depth/light_estimate.h
+++ b/includes/dynamic_depth/light_estimate.h
@@ -9,7 +9,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// Light estimation parameters for a camera.
@@ -26,7 +25,8 @@ class LightEstimate : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates an LightEstimate from the given field.
static std::unique_ptr<LightEstimate> FromData(float pixel_intensity);
@@ -39,7 +39,7 @@ class LightEstimate : public Element {
// Returns the deserialized LightEstimate; null if parsing fails.
static std::unique_ptr<LightEstimate> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Returns the average pixel internsity.
float GetPixelIntensity() const;
@@ -63,6 +63,5 @@ class LightEstimate : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_LIGHT_ESTIMATE_H_ // NOLINT
diff --git a/includes/dynamic_depth/plane.h b/includes/dynamic_depth/plane.h
index bec2289..c29dd3a 100644
--- a/includes/dynamic_depth/plane.h
+++ b/includes/dynamic_depth/plane.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// A Plane element for a Dynamic Depth device.
@@ -26,11 +25,12 @@ class Plane : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Returns the deserialized Plane; null if parsing fails.
static std::unique_ptr<Plane> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Creates a Plane from the given fields.
// The Pose must be present.
@@ -65,7 +65,8 @@ class Plane : public Element {
Plane();
// Extracts plane fields.
- bool ParsePlaneFields(const xml::Deserializer& deserializer);
+ bool ParsePlaneFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
// The pose of the center of this plane.
std::unique_ptr<Pose> pose_;
@@ -88,6 +89,5 @@ class Plane : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_PLANE_H_ // NOLINT
diff --git a/includes/dynamic_depth/planes.h b/includes/dynamic_depth/planes.h
index c38aad4..e3b41ea 100644
--- a/includes/dynamic_depth/planes.h
+++ b/includes/dynamic_depth/planes.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// THe list of planes in a Dynamic Depth Device t ype.
@@ -29,7 +28,7 @@ class Planes : public Element {
// failed for all the planes, one of the planes is null, or the list of
// planes was empty.
static std::unique_ptr<Planes> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Disallow copying.
Planes(const Planes&) = delete;
@@ -39,7 +38,8 @@ class Planes : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Returns false if the list of planes is empty, or serialization fails.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Returns the number of plane elements in this Plane object.
int GetPlaneCount() const;
@@ -56,6 +56,5 @@ class Planes : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_PLANES_H_ // NOLINT
diff --git a/includes/dynamic_depth/point_cloud.h b/includes/dynamic_depth/point_cloud.h
index 3e53744..562e3f4 100644
--- a/includes/dynamic_depth/point_cloud.h
+++ b/includes/dynamic_depth/point_cloud.h
@@ -11,7 +11,6 @@
// Implements the Point Cloud element from the Dynamic Depth specification, with
// serialization and deserialization.
-namespace photos_editing_formats {
namespace dynamic_depth {
class PointCloud : public Element {
@@ -19,23 +18,26 @@ class PointCloud : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates a Point Cloud from the given fields. Returns null if position is
- // empty or points.size() is not divisible by 3.
+ // empty or points.size() is not divisible by 4.
// The first two arguments are required fields, the rest are optional.
- // points is a list of (x, y, z) tuples, so it must have a size that is
- // evenly divisible by 3.
+ // points is a list of (x, y, z, c) tuples, so it must have a size that is
+ // evenly divisible by 4.
+ // The first three values are the point's XYZ coordinates, and the fourth
+ // is the confidence value. More details are available in the specification.
static std::unique_ptr<PointCloud> FromData(const std::vector<float>& points,
bool metric);
// Returns the deserialized PointCloud; null if parsing fails.
// The returned pointer is owned by the caller.
static std::unique_ptr<PointCloud> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Getters.
- // Returns the number of (x, y, z) tuples, *not* the length of points_.
+ // Returns the number of (x, y, z, c) tuples, *not* the length of points_.
int GetPointCount() const;
const std::vector<float>& GetPoints() const;
bool GetMetric() const;
@@ -46,7 +48,8 @@ class PointCloud : public Element {
private:
PointCloud();
- bool ParseFields(const xml::Deserializer& deserializer);
+ bool ParseFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
// Required fields.
std::vector<float> points_;
@@ -56,6 +59,5 @@ class PointCloud : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_POINT_CLOUD_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_POINT_CLOUD_H_ // NOLINT
diff --git a/includes/dynamic_depth/pose.h b/includes/dynamic_depth/pose.h
index 9bee030..dc00a46 100644
--- a/includes/dynamic_depth/pose.h
+++ b/includes/dynamic_depth/pose.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
/**
@@ -29,7 +28,8 @@ class Pose : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object. Returns true on success.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates a Pose from the given data.
// The order of values in position is x, y, z.
@@ -47,7 +47,7 @@ class Pose : public Element {
// Returns the deserialized XdmAudio; null if parsing fails.
// The returned pointer is owned by the caller.
static std::unique_ptr<Pose> FromDeserializer(
- const xml::Deserializer& parent_deserializer,
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer,
const char* parent_namespace);
// Returns true if the device's position is provided.
@@ -75,7 +75,8 @@ class Pose : public Element {
Pose();
// Extracts camera pose fields.
- bool ParsePoseFields(const xml::Deserializer& deserializer);
+ bool ParsePoseFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
// Position variables, in meters relative to camera 0.
// If providing position data, all three fields must be set.
@@ -93,6 +94,5 @@ class Pose : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_POSE_H_ // NOLINT
diff --git a/includes/dynamic_depth/profile.h b/includes/dynamic_depth/profile.h
index b1a311c..7dfb0ea 100644
--- a/includes/dynamic_depth/profile.h
+++ b/includes/dynamic_depth/profile.h
@@ -9,7 +9,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// Implements the Profile element in the Dynamic Depth specification, with
@@ -19,7 +18,8 @@ class Profile : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates a Profile element from the given fields. Returns null if
// the type is empty, or if the camera_indices are shorter than the
@@ -31,7 +31,7 @@ class Profile : public Element {
// Returns the deserialized Profile, null if parsing fails.
static std::unique_ptr<Profile> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Returns the Profile type.
const string& GetType() const;
@@ -51,6 +51,5 @@ class Profile : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_PROFILE_H_ // NOLINT
diff --git a/includes/dynamic_depth/profiles.h b/includes/dynamic_depth/profiles.h
index abcf6c1..0088ec3 100644
--- a/includes/dynamic_depth/profiles.h
+++ b/includes/dynamic_depth/profiles.h
@@ -10,7 +10,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
// Implements the Device:Profiles field from the Dynamic Depth specification,
@@ -21,7 +20,8 @@ class Profiles : public Element {
void GetNamespaces(
std::unordered_map<string, string>* ns_name_href_map) override;
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Static methods.
@@ -33,7 +33,7 @@ class Profiles : public Element {
// Returns the deserialized profiles in a Profiles object, a unique_ptr owning
// nothing if parsing failed for all the profiles.
static std::unique_ptr<Profiles> FromDeserializer(
- const xml::Deserializer& parent_deserializer);
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer);
// Non-static methods.
@@ -51,6 +51,5 @@ class Profiles : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_PROFILES_H_ // NOLINT
diff --git a/includes/dynamic_depth/vendor_info.h b/includes/dynamic_depth/vendor_info.h
index ba8ca48..8487543 100644
--- a/includes/dynamic_depth/vendor_info.h
+++ b/includes/dynamic_depth/vendor_info.h
@@ -9,7 +9,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
/**
@@ -26,7 +25,8 @@ class VendorInfo : public Element {
std::unordered_map<string, string>* ns_name_href_map) override;
// Serializes this object.
- bool Serialize(xml::Serializer* serializer) const override;
+ bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const override;
// Creates an VendorInfo from the given fields. Returns null if
// any of the required fields is empty (see fields below).
@@ -39,7 +39,7 @@ class VendorInfo : public Element {
// Returns the deserialized VendorInfo; null if parsing fails.
static std::unique_ptr<VendorInfo> FromDeserializer(
- const xml::Deserializer& parent_deserializer,
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& parent_deserializer,
const string& namespace_str);
// Returns the Manufacturer.
@@ -58,7 +58,8 @@ class VendorInfo : public Element {
private:
VendorInfo();
- bool ParseFields(const xml::Deserializer& deserializer);
+ bool ParseFields(
+ const ::dynamic_depth::xmpmeta::xml::Deserializer& deserializer);
// Required field.
string manufacturer_; // The manufacturer.
@@ -69,6 +70,5 @@ class VendorInfo : public Element {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
#endif // DYNAMIC_DEPTH_INCLUDES_DYNAMIC_DEPTH_VENDOR_INFO_H_ // NOLINT
diff --git a/includes/xmpmeta/jpeg_io.h b/includes/xmpmeta/jpeg_io.h
index aba2b5a..4827e18 100644
--- a/includes/xmpmeta/jpeg_io.h
+++ b/includes/xmpmeta/jpeg_io.h
@@ -6,7 +6,8 @@
#include "base/port.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// Contains the data for a section in a JPEG file.
// A JPEG file contains many sections in addition to image data.
@@ -48,6 +49,7 @@ std::vector<Section> Parse(const ParseOptions& options,
void WriteSections(const std::vector<Section>& sections,
std::ostream* output_stream);
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_JPEG_IO_H_ // NOLINT
diff --git a/includes/xmpmeta/md5.h b/includes/xmpmeta/md5.h
index a3e8a7f..1cf1e65 100644
--- a/includes/xmpmeta/md5.h
+++ b/includes/xmpmeta/md5.h
@@ -5,12 +5,14 @@
#include "base/port.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// Returns the MD5 hash of to_hash as a 32-character hex string.
// Wrapper around OpenSSL to avoid Gyp dependency problems.
string MD5Hash(const string& to_hash);
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_MD5_H_ // NOLINT
diff --git a/includes/xmpmeta/xmp_const.h b/includes/xmpmeta/xmp_const.h
index c32ecd9..a71b3f8 100644
--- a/includes/xmpmeta/xmp_const.h
+++ b/includes/xmpmeta/xmp_const.h
@@ -1,7 +1,8 @@
#ifndef DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_CONST_H_ // NOLINT
#define DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_CONST_H_ // NOLINT
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// Constants used in writing XMP metadata.
struct XmpConst {
@@ -25,6 +26,7 @@ struct XmpConst {
static const int ExtendedMaxBufferSize();
};
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_CONST_H_ // NOLINT
diff --git a/includes/xmpmeta/xmp_data.h b/includes/xmpmeta/xmp_data.h
index 1e59b1d..f6eb7f1 100644
--- a/includes/xmpmeta/xmp_data.h
+++ b/includes/xmpmeta/xmp_data.h
@@ -3,7 +3,8 @@
#include <libxml/tree.h>
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// XmpData contains the standard, and optionally extended, XMP metadata from a
// JPEG file. See xmp_parser for reading XmpData from a JPEG or reading
@@ -29,6 +30,7 @@ class XmpData {
xmlDocPtr xmp_extended_;
};
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_DATA_H_ // NOLINT
diff --git a/includes/xmpmeta/xmp_parser.h b/includes/xmpmeta/xmp_parser.h
index e2781ec..16b2f72 100644
--- a/includes/xmpmeta/xmp_parser.h
+++ b/includes/xmpmeta/xmp_parser.h
@@ -7,7 +7,8 @@
#include "base/port.h"
#include "xmpmeta/xmp_data.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// Populates a XmpData from the header of the JPEG file.
bool ReadXmpHeader(const string& filename, bool skip_extended,
@@ -22,6 +23,7 @@ bool ReadXmpFromMemory(const string& jpeg_contents, bool skip_extended,
// in JPEG format).
bool ReadXmpHeader(std::istream* input_stream, bool skip_extended,
XmpData* xmp_data);
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_PARSER_H_ // NOLINT
diff --git a/includes/xmpmeta/xmp_writer.h b/includes/xmpmeta/xmp_writer.h
index e2ea8f7..8540f1e 100644
--- a/includes/xmpmeta/xmp_writer.h
+++ b/includes/xmpmeta/xmp_writer.h
@@ -8,7 +8,8 @@
#include "base/port.h"
#include "xmpmeta/xmp_data.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// Creates a new XmpData object and initializes the boilerplate for the
// standard XMP section.
@@ -26,18 +27,14 @@ bool WriteLeftEyeAndXmpMeta(const string& left_data, const string& filename,
// Same as above, but allows the caller to manage their own istream and ostream.
// filename is written to only if metadata serialization is successful.
// Assumes the caller will take care of opening and closing the
-// output_jpeg_stream, as well as initialization of the input_jpeg_stream.
-bool WriteLeftEyeAndXmpMeta(const string& filename, const XmpData& xmp_data,
- std::istringstream* input_jpeg_stream,
- std::ofstream* output_jpeg_stream);
-
-// Updates a JPEG input stream with new XMP data and writes it to an
-// output stream.
-// This is equivalent to writeXMPMeta in geo/lightfield/metadata/XmpUtil.java.
-bool AddXmpMetaToJpegStream(std::istream* input_jpeg_stream,
- const XmpData& xmp_data,
+// output_jpeg_stream (if it is associated with a file), as well as
+// initialization of the input_jpeg_stream. This is nearly equivalent to
+// writeXMPMeta in kgeo/lightfield/metadata/XmpUtil.java.
+bool WriteLeftEyeAndXmpMeta(const XmpData& xmp_data,
+ std::istream* input_jpeg_stream,
std::ostream* output_jpeg_stream);
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
-#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_WRITER_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INCLUDES_XMPMETA_XMP_WRITER_H_ // NOLINT
diff --git a/internal/dynamic_depth/app_info.cc b/internal/dynamic_depth/app_info.cc
index d0c4f1c..c56ab84 100644
--- a/internal/dynamic_depth/app_info.cc
+++ b/internal/dynamic_depth/app_info.cc
@@ -8,10 +8,9 @@
#include "xmpmeta/base64.h"
#include "xmpmeta/xml/utils.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -142,4 +141,3 @@ bool AppInfo::ParseFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/camera.cc b/internal/dynamic_depth/camera.cc
index db068e3..e3aaee7 100644
--- a/internal/dynamic_depth/camera.cc
+++ b/internal/dynamic_depth/camera.cc
@@ -4,10 +4,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -279,4 +278,3 @@ bool Camera::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/cameras.cc b/internal/dynamic_depth/cameras.cc
index 7c5c29f..f7b8990 100644
--- a/internal/dynamic_depth/cameras.cc
+++ b/internal/dynamic_depth/cameras.cc
@@ -3,10 +3,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
const char kNodeName[] = "Cameras";
@@ -99,4 +98,3 @@ bool Cameras::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/const.cc b/internal/dynamic_depth/const.cc
index 0a7396d..c7427ff 100644
--- a/internal/dynamic_depth/const.cc
+++ b/internal/dynamic_depth/const.cc
@@ -3,7 +3,6 @@
#include "android-base/logging.h"
#include "base/port.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -111,4 +110,3 @@ const std::string DynamicDepthConst::Namespace(const std::string& node_name) {
return "";
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/const.h b/internal/dynamic_depth/const.h
index 9b56abd..6937412 100644
--- a/internal/dynamic_depth/const.h
+++ b/internal/dynamic_depth/const.h
@@ -6,7 +6,6 @@
#include <string>
#include <vector>
-namespace photos_editing_formats {
namespace dynamic_depth {
struct DynamicDepthConst {
@@ -46,6 +45,5 @@ struct DynamicDepthConst {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_CONST_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_CONST_H_ // NOLINT
diff --git a/internal/dynamic_depth/container.cc b/internal/dynamic_depth/container.cc
index 1e3b9b6..e7a35dd 100644
--- a/internal/dynamic_depth/container.cc
+++ b/internal/dynamic_depth/container.cc
@@ -3,10 +3,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
constexpr char kNamespaceHref[] =
@@ -119,4 +118,3 @@ bool Container::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/depth_map.cc b/internal/dynamic_depth/depth_map.cc
index 4d16c8d..b8a912b 100644
--- a/internal/dynamic_depth/depth_map.cc
+++ b/internal/dynamic_depth/depth_map.cc
@@ -6,11 +6,11 @@
#include "strings/numbers.h"
#include "xmpmeta/base64.h"
-using photos_editing_formats::dynamic_depth::Item;
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::Item;
+using ::dynamic_depth::xmpmeta::EncodeFloatArrayBase64;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
constexpr const char* kNamespaceHref =
@@ -264,13 +264,12 @@ std::unique_ptr<DepthMap> DepthMap::FromData(
}
std::unique_ptr<DepthMap> DepthMap::FromDeserializer(
- const xml::Deserializer& parent_deserializer) {
+ const Deserializer& parent_deserializer) {
std::unique_ptr<Deserializer> deserializer =
parent_deserializer.CreateDeserializer(
DynamicDepthConst::Namespace(DynamicDepthConst::DepthMap()),
DynamicDepthConst::DepthMap());
if (deserializer == nullptr) {
- LOG(ERROR) << "Deserializer must not be null";
return nullptr;
}
@@ -359,4 +358,3 @@ bool DepthMap::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/device.cc b/internal/dynamic_depth/device.cc
index 2cfff99..399ea74 100644
--- a/internal/dynamic_depth/device.cc
+++ b/internal/dynamic_depth/device.cc
@@ -14,15 +14,16 @@
#include "xmpmeta/xmp_parser.h"
#include "xmpmeta/xmp_writer.h"
-using photos_editing_formats::xml::DepthFirstSearch;
-using photos_editing_formats::xml::DeserializerImpl;
-using photos_editing_formats::xml::GetFirstDescriptionElement;
-using photos_editing_formats::xml::Serializer;
-using photos_editing_formats::xml::SerializerImpl;
-using photos_editing_formats::xml::ToXmlChar;
-using photos_editing_formats::xml::XmlConst;
-
-namespace photos_editing_formats {
+using ::dynamic_depth::xmpmeta::CreateXmpData;
+using ::dynamic_depth::xmpmeta::XmpData;
+using ::dynamic_depth::xmpmeta::xml::DepthFirstSearch;
+using ::dynamic_depth::xmpmeta::xml::DeserializerImpl;
+using ::dynamic_depth::xmpmeta::xml::GetFirstDescriptionElement;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::SerializerImpl;
+using ::dynamic_depth::xmpmeta::xml::ToXmlChar;
+using ::dynamic_depth::xmpmeta::xml::XmlConst;
+
namespace dynamic_depth {
namespace {
@@ -61,8 +62,8 @@ std::unique_ptr<Device> ParseFields(const xmlDocPtr& xmlDoc) {
auto app_info =
AppInfo::FromDeserializer(deserializer, DynamicDepthConst::Device());
- std::unique_ptr<DeviceParams>
- params(new DeviceParams(std::move(cameras))); // NOLINT
+ std::unique_ptr<DeviceParams> params(
+ new DeviceParams(std::move(cameras))); // NOLINT
params->container = std::move(container);
params->planes = std::move(planes);
params->earth_pose = std::move(earth_pose);
@@ -310,4 +311,3 @@ void Device::PopulateNamespaces() {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/dimension.h b/internal/dynamic_depth/dimension.h
index 9f68f54..3d792fb 100644
--- a/internal/dynamic_depth/dimension.h
+++ b/internal/dynamic_depth/dimension.h
@@ -1,7 +1,6 @@
#ifndef DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_DIMENSION_H_ // NOLINT
#define DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_DIMENSION_H_ // NOLINT
-namespace photos_editing_formats {
namespace dynamic_depth {
// A struct that contains the width and height of a size or the x and y
@@ -21,6 +20,5 @@ struct Dimension {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_DIMENSION_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_DIMENSION_H_ // NOLINT
diff --git a/internal/dynamic_depth/dynamic_depth.cc b/internal/dynamic_depth/dynamic_depth.cc
index 3b2b114..fa3983e 100644
--- a/internal/dynamic_depth/dynamic_depth.cc
+++ b/internal/dynamic_depth/dynamic_depth.cc
@@ -8,14 +8,14 @@
#include "dynamic_depth/item.h"
#include "image_io/gcontainer/gcontainer.h"
#include "xmpmeta/xmp_data.h"
+#include "xmpmeta/xmp_parser.h"
#include "xmpmeta/xmp_writer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
-using photos_editing_formats::CreateXmpData;
-using photos_editing_formats::XmpData;
+using ::dynamic_depth::xmpmeta::CreateXmpData;
+using ::dynamic_depth::xmpmeta::XmpData;
constexpr char kImageMimePrefix[] = "image";
@@ -29,22 +29,15 @@ bool IsMimeTypeImage(const string& mime) {
} // namespace
-bool WriteImageAndMetadataAndContainer(const string& out_filename,
- const uint8_t* primary_image_bytes,
- size_t primary_image_bytes_count,
- Device* device) {
+bool WriteImageAndMetadataAndContainer(std::istream* input_jpeg_stream,
+ Device* device,
+ std::ostream* output_jpeg_stream) {
const std::unique_ptr<XmpData> xmp_data = CreateXmpData(true);
device->SerializeToXmp(xmp_data.get());
- std::istringstream input_jpeg_stream(
- std::string(reinterpret_cast<const char*>(primary_image_bytes),
- primary_image_bytes_count));
- std::ofstream output_jpeg_stream;
- output_jpeg_stream.open(out_filename, std::ostream::out);
- bool success = WriteLeftEyeAndXmpMeta(
- out_filename, *xmp_data, &input_jpeg_stream, &output_jpeg_stream);
+ bool success =
+ WriteLeftEyeAndXmpMeta(*xmp_data, input_jpeg_stream, output_jpeg_stream);
if (device->GetContainer() == nullptr) {
- output_jpeg_stream.close();
return success;
}
@@ -55,9 +48,23 @@ bool WriteImageAndMetadataAndContainer(const string& out_filename,
if (payload_size <= 0 || payload.empty()) {
continue;
}
- output_jpeg_stream.write(payload.c_str(), payload_size);
+ output_jpeg_stream->write(payload.c_str(), payload_size);
}
+ return success;
+}
+
+bool WriteImageAndMetadataAndContainer(const string& out_filename,
+ const uint8_t* primary_image_bytes,
+ size_t primary_image_bytes_count,
+ Device* device) {
+ std::istringstream input_jpeg_stream(
+ std::string(reinterpret_cast<const char*>(primary_image_bytes),
+ primary_image_bytes_count));
+ std::ofstream output_jpeg_stream;
+ output_jpeg_stream.open(out_filename, std::ostream::out);
+ bool success = WriteImageAndMetadataAndContainer(&input_jpeg_stream, device,
+ &output_jpeg_stream);
output_jpeg_stream.close();
return success;
}
@@ -115,11 +122,101 @@ bool GetItemPayload(const string& input_image_filename,
}
std::string std_payload;
- bool success = image_io::gcontainer::ParseFileAfterImage(
- input_image_filename, file_offset, file_length, &std_payload);
+ bool success =
+ ::photos_editing_formats::image_io::gcontainer::ParseFileAfterImage(
+ input_image_filename, file_offset, file_length, &std_payload);
*out_payload = std_payload;
return success;
}
+extern "C" int32_t ValidateAndroidDynamicDepthBuffer(const char* buffer, size_t buffer_length) {
+ XmpData xmp_data;
+ const string image_data(buffer, buffer_length);
+ ReadXmpFromMemory(image_data, /*XmpSkipExtended*/ false, &xmp_data);
+
+ // Check device presence
+ std::unique_ptr<Device> device = Device::FromXmp(xmp_data);
+ if (device == nullptr) {
+ LOG(ERROR) << "Dynamic depth device element not present!";
+ return -1;
+ }
+
+ // Check profiles
+ const Profiles* profiles = device->GetProfiles();
+ if (profiles == nullptr) {
+ LOG(ERROR) << "No Profile found in the dynamic depth metadata";
+ return -1;
+ }
+
+ const std::vector<const Profile*> profile_list = profiles->GetProfiles();
+ // Stop at the first depth photo profile found.
+ bool depth_photo_profile_found = false;
+ int camera_index = 0;
+ for (auto profile : profile_list) {
+ depth_photo_profile_found = !profile->GetType().compare("DepthPhoto");
+ if (depth_photo_profile_found) {
+ // Use the first one if available.
+ auto indices = profile->GetCameraIndices();
+ if (!indices.empty()) {
+ camera_index = indices[0];
+ } else {
+ camera_index = -1;
+ }
+ break;
+ }
+ }
+
+ if (!depth_photo_profile_found || camera_index < 0) {
+ LOG(ERROR) << "No dynamic depth profile found";
+ return -1;
+ }
+
+ auto cameras = device->GetCameras();
+ if (cameras == nullptr || camera_index > cameras->GetCameras().size() ||
+ cameras->GetCameras()[camera_index] == nullptr) {
+ LOG(ERROR) << "No camera or depth photo data found";
+ return -1;
+ }
+
+ auto camera = cameras->GetCameras()[camera_index];
+ auto depth_map = camera->GetDepthMap();
+ if (depth_map == nullptr) {
+ LOG(ERROR) << "No depth map found";
+ return -1;
+ }
+
+ auto depth_uri = depth_map->GetDepthUri();
+ if (depth_uri.empty()) {
+ LOG(ERROR) << "Invalid depth map URI";
+ return -1;
+ }
+
+ auto depth_units = depth_map->GetUnits();
+ if (depth_units != dynamic_depth::DepthUnits::kMeters) {
+ LOG(ERROR) << "Unexpected depth map units";
+ return -1;
+ }
+
+ auto depth_format = depth_map->GetFormat();
+ if (depth_format != dynamic_depth::DepthFormat::kRangeInverse) {
+ LOG(ERROR) << "Unexpected depth map format";
+ return -1;
+ }
+
+ auto near = depth_map->GetNear();
+ auto far = depth_map->GetFar();
+ if ((near < 0.f) || (far < 0.f) || (near > far) || (near == far)) {
+ LOG(ERROR) << "Unexpected depth map near and far values";
+ return -1;
+ }
+
+ auto confidence_uri = depth_map->GetConfidenceUri();
+ if (confidence_uri.empty()) {
+ LOG(ERROR) << "No confidence URI";
+ return -1;
+ }
+
+ return 0;
+}
+
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/earth_pose.cc b/internal/dynamic_depth/earth_pose.cc
index a57aa68..cd5e0a7 100644
--- a/internal/dynamic_depth/earth_pose.cc
+++ b/internal/dynamic_depth/earth_pose.cc
@@ -5,10 +5,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -187,4 +186,3 @@ bool EarthPose::ParseEarthPoseFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/element.h b/internal/dynamic_depth/element.h
index e68829d..90f112f 100644
--- a/internal/dynamic_depth/element.h
+++ b/internal/dynamic_depth/element.h
@@ -6,7 +6,6 @@
#include "xmpmeta/xml/deserializer.h"
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
/**
@@ -25,10 +24,10 @@ class Element {
std::unordered_map<string, string>* ns_name_href_map) = 0;
// Serializes this element.
- virtual bool Serialize(xml::Serializer* serializer) const = 0;
+ virtual bool Serialize(
+ ::dynamic_depth::xmpmeta::xml::Serializer* serializer) const = 0;
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_ELEMENT_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_ELEMENT_H_ // NOLINT
diff --git a/internal/dynamic_depth/image.cc b/internal/dynamic_depth/image.cc
index 811932e..8a4d36d 100644
--- a/internal/dynamic_depth/image.cc
+++ b/internal/dynamic_depth/image.cc
@@ -4,11 +4,10 @@
#include "dynamic_depth/const.h"
#include "dynamic_depth/item.h"
-using photos_editing_formats::dynamic_depth::Item;
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::Item;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -190,4 +189,3 @@ bool Image::ParseImageFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/imaging_model.cc b/internal/dynamic_depth/imaging_model.cc
index 717b8d7..5c68011 100644
--- a/internal/dynamic_depth/imaging_model.cc
+++ b/internal/dynamic_depth/imaging_model.cc
@@ -7,12 +7,12 @@
#include "strings/numbers.h"
#include "xmpmeta/base64.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::EncodeFloatArrayBase64;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
constexpr char kFocalLengthX[] = "FocalLengthX";
constexpr char kFocalLengthY[] = "FocalLengthY";
@@ -117,13 +117,12 @@ std::unique_ptr<ImagingModel> ImagingModel::FromData(
}
std::unique_ptr<ImagingModel> ImagingModel::FromDeserializer(
- const xml::Deserializer& parent_deserializer) {
+ const Deserializer& parent_deserializer) {
std::unique_ptr<Deserializer> deserializer =
parent_deserializer.CreateDeserializer(
DynamicDepthConst::Namespace(DynamicDepthConst::ImagingModel()),
DynamicDepthConst::ImagingModel());
if (deserializer == nullptr) {
- LOG(ERROR) << "Deserializer must not be null";
return nullptr;
}
@@ -154,7 +153,7 @@ int ImagingModel::GetDistortionCount() const {
return static_cast<int>(floor(params_.distortion.size() / 2));
}
-bool ImagingModel::Serialize(xml::Serializer* serializer) const {
+bool ImagingModel::Serialize(Serializer* serializer) const {
if (serializer == nullptr) {
LOG(ERROR) << "Serializer is null";
return false;
@@ -219,4 +218,3 @@ bool ImagingModel::Serialize(xml::Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/item.cc b/internal/dynamic_depth/item.cc
index a1c2a8f..0a0d630 100644
--- a/internal/dynamic_depth/item.cc
+++ b/internal/dynamic_depth/item.cc
@@ -3,10 +3,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -67,13 +66,12 @@ std::unique_ptr<Item> Item::FromData(const ItemParams& params) {
}
std::unique_ptr<Item> Item::FromDeserializer(
- const xml::Deserializer& parent_deserializer) {
+ const Deserializer& parent_deserializer) {
std::unique_ptr<Deserializer> deserializer =
parent_deserializer.CreateDeserializer(
DynamicDepthConst::Namespace(DynamicDepthConst::Item()),
DynamicDepthConst::Item());
if (deserializer == nullptr) {
- LOG(ERROR) << "Deserializer must not be null";
return nullptr;
}
@@ -110,7 +108,7 @@ const string& Item::GetPayloadToSerialize() const {
return params_.payload_to_serialize;
}
-bool Item::Serialize(xml::Serializer* serializer) const {
+bool Item::Serialize(Serializer* serializer) const {
if (serializer == nullptr) {
LOG(ERROR) << "Serializer is null";
return false;
@@ -136,4 +134,3 @@ bool Item::Serialize(xml::Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/light_estimate.cc b/internal/dynamic_depth/light_estimate.cc
index 9ce3bab..af039e9 100644
--- a/internal/dynamic_depth/light_estimate.cc
+++ b/internal/dynamic_depth/light_estimate.cc
@@ -4,10 +4,9 @@
#include "dynamic_depth/const.h"
#include "xmpmeta/base64.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
constexpr int kColorCorrectionSize = 3;
@@ -125,4 +124,3 @@ bool LightEstimate::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/plane.cc b/internal/dynamic_depth/plane.cc
index 7e3914e..2f2df3e 100644
--- a/internal/dynamic_depth/plane.cc
+++ b/internal/dynamic_depth/plane.cc
@@ -5,10 +5,10 @@
#include "strings/numbers.h"
#include "xmpmeta/base64.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::EncodeFloatArrayBase64;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -71,7 +71,6 @@ std::unique_ptr<Plane> Plane::FromDeserializer(
DynamicDepthConst::Namespace(DynamicDepthConst::Plane()),
DynamicDepthConst::Plane());
if (deserializer == nullptr) {
- LOG(ERROR) << "Deserializer must not be null";
return nullptr;
}
@@ -174,4 +173,3 @@ bool Plane::ParsePlaneFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/planes.cc b/internal/dynamic_depth/planes.cc
index 5eb767f..a390335 100644
--- a/internal/dynamic_depth/planes.cc
+++ b/internal/dynamic_depth/planes.cc
@@ -3,11 +3,10 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-namespace photos_editing_formats {
namespace dynamic_depth {
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
// Private constructor.
Planes::Planes() = default;
@@ -113,4 +112,3 @@ bool Planes::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/point.h b/internal/dynamic_depth/point.h
index c6eecbb..480b958 100644
--- a/internal/dynamic_depth/point.h
+++ b/internal/dynamic_depth/point.h
@@ -1,7 +1,6 @@
#ifndef DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_POINT_H_ // NOLINT
#define DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_POINT_H_ // NOLINT
-namespace photos_editing_formats {
namespace dynamic_depth {
// A struct that contains the width and height of a size or the x and y
@@ -20,6 +19,5 @@ struct Point {
};
} // namespace dynamic_depth
-} // namespace photos_editing_formats
-#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_POINT_H_ // NOLINT
+#endif // DYNAMIC_DEPTH_INTERNAL_DYNAMIC_DEPTH_POINT_H_ // NOLINT
diff --git a/internal/dynamic_depth/point_cloud.cc b/internal/dynamic_depth/point_cloud.cc
index f35e9c1..a2aa442 100644
--- a/internal/dynamic_depth/point_cloud.cc
+++ b/internal/dynamic_depth/point_cloud.cc
@@ -6,10 +6,10 @@
#include "xmpmeta/base64.h"
#include "xmpmeta/xml/utils.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::EncodeFloatArrayBase64;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -43,9 +43,9 @@ std::unique_ptr<PointCloud> PointCloud::FromData(
return nullptr;
}
- if (points.size() % 3 != 0) {
- LOG(ERROR) << "Points must be (x, y, z) tuples, so the size must be "
- << "divisible by 3, got " << points.size();
+ if (points.size() % 4 != 0) {
+ LOG(ERROR) << "Points must be (x, y, z, c) tuples, so the size must be "
+ << "divisible by 4, got " << points.size();
return nullptr;
}
@@ -72,7 +72,7 @@ std::unique_ptr<PointCloud> PointCloud::FromDeserializer(
}
int PointCloud::GetPointCount() const {
- return static_cast<int>(points_.size() / 3);
+ return static_cast<int>(points_.size() / 4);
}
const std::vector<float>& PointCloud::GetPoints() const { return points_; }
@@ -89,7 +89,7 @@ bool PointCloud::Serialize(Serializer* serializer) const {
return false;
}
- // No error checking (e.g. points_.size() % 3 == 0), because serialization
+ // No error checking (e.g. points_.size() % 4 == 0), because serialization
// shouldn't be blocked by this.
string base64_encoded_points;
if (!EncodeFloatArrayBase64(points_, &base64_encoded_points)) {
@@ -98,7 +98,7 @@ bool PointCloud::Serialize(Serializer* serializer) const {
}
// Write required fields.
- int point_count = static_cast<int>(points_.size() / 3);
+ int point_count = static_cast<int>(points_.size() / 4);
if (!serializer->WriteProperty(
DynamicDepthConst::PointCloud(), kPointCount,
::dynamic_depth::strings::SimpleItoa(point_count))) {
@@ -131,13 +131,13 @@ bool PointCloud::ParseFields(const Deserializer& deserializer) {
return false;
}
- if (points.size() % 3 != 0) {
+ if (points.size() % 4 != 0) {
LOG(ERROR) << "Parsed " << points.size() << " values but expected the size "
- << "to be divisible by 3 for (x, y, z) tuple representation";
+ << "to be divisible by 4 for (x, y, z, c) tuple representation";
return false;
}
- int parsed_points_count = static_cast<int>(points.size() / 3);
+ int parsed_points_count = static_cast<int>(points.size() / 4);
if (parsed_points_count != point_count) {
LOG(ERROR) << "Parsed PointCount = " << point_count << " but "
<< parsed_points_count << " points were found";
@@ -161,4 +161,3 @@ bool PointCloud::ParseFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/pose.cc b/internal/dynamic_depth/pose.cc
index 7e02588..63c0740 100644
--- a/internal/dynamic_depth/pose.cc
+++ b/internal/dynamic_depth/pose.cc
@@ -5,10 +5,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -173,4 +172,3 @@ bool Pose::ParsePoseFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/profile.cc b/internal/dynamic_depth/profile.cc
index 079f9c2..c24629f 100644
--- a/internal/dynamic_depth/profile.cc
+++ b/internal/dynamic_depth/profile.cc
@@ -3,10 +3,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -135,4 +134,3 @@ bool Profile::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/profiles.cc b/internal/dynamic_depth/profiles.cc
index b23b5d7..bc49d1d 100644
--- a/internal/dynamic_depth/profiles.cc
+++ b/internal/dynamic_depth/profiles.cc
@@ -3,10 +3,9 @@
#include "android-base/logging.h"
#include "dynamic_depth/const.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
void Profiles::GetNamespaces(
@@ -96,4 +95,3 @@ bool Profiles::Serialize(Serializer* serializer) const {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/dynamic_depth/vendor_info.cc b/internal/dynamic_depth/vendor_info.cc
index db73840..f3b9dbe 100644
--- a/internal/dynamic_depth/vendor_info.cc
+++ b/internal/dynamic_depth/vendor_info.cc
@@ -5,10 +5,9 @@
#include "xmpmeta/base64.h"
#include "xmpmeta/xml/utils.h"
-using photos_editing_formats::xml::Deserializer;
-using photos_editing_formats::xml::Serializer;
+using ::dynamic_depth::xmpmeta::xml::Deserializer;
+using ::dynamic_depth::xmpmeta::xml::Serializer;
-namespace photos_editing_formats {
namespace dynamic_depth {
namespace {
@@ -105,4 +104,3 @@ bool VendorInfo::ParseFields(const Deserializer& deserializer) {
}
} // namespace dynamic_depth
-} // namespace photos_editing_formats
diff --git a/internal/xmpmeta/base64.cc b/internal/xmpmeta/base64.cc
index 3bdf5d7..a87e654 100644
--- a/internal/xmpmeta/base64.cc
+++ b/internal/xmpmeta/base64.cc
@@ -3,7 +3,8 @@
#include "android-base/logging.h"
#include "strings/escaping.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace {
bool EncodeBase64RawData(const uint8* data, size_t data_size, string* output) {
@@ -81,4 +82,5 @@ bool EncodeDoubleArrayBase64(const std::vector<double>& data, string* output) {
bool DecodeDoubleArrayBase64(const string& data, std::vector<double>* output) {
return InternalDecodeArrayBase64<double>(data, output);
}
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/base64.h b/internal/xmpmeta/base64.h
index 8439e90..285e3f1 100644
--- a/internal/xmpmeta/base64.h
+++ b/internal/xmpmeta/base64.h
@@ -7,7 +7,8 @@
#include "base/port.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// Decodes the base64-encoded input range. Supports decoding of both web-safe
// and regular base64."Web-safe" base-64 replaces + with - and / with _, and
// omits trailing = padding characters.
@@ -34,6 +35,7 @@ bool EncodeDoubleArrayBase64(const std::vector<double>& data, string* output);
// Base64-decodes the given double array.
bool DecodeDoubleArrayBase64(const string& data, std::vector<double>* output);
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_BASE64_H_ // NOLINT
diff --git a/internal/xmpmeta/file.cc b/internal/xmpmeta/file.cc
index 5559219..621323c 100644
--- a/internal/xmpmeta/file.cc
+++ b/internal/xmpmeta/file.cc
@@ -3,7 +3,8 @@
#include <cstdio>
#include "android-base/logging.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
using std::string;
@@ -56,4 +57,5 @@ string JoinPath(const string& dirname, const string& basename) {
}
}
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/file.h b/internal/xmpmeta/file.h
index 43410b8..f6f8423 100644
--- a/internal/xmpmeta/file.h
+++ b/internal/xmpmeta/file.h
@@ -3,7 +3,8 @@
#include <string>
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
void WriteStringToFileOrDie(const std::string &data,
const std::string &filename);
@@ -13,6 +14,7 @@ void ReadFileToStringOrDie(const std::string &filename, std::string *data);
// absolute path then JoinPath ignores dirname and simply returns basename.
std::string JoinPath(const std::string &dirname, const std::string &basename);
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_FILE_H_ // NOLINT
diff --git a/internal/xmpmeta/jpeg_io.cc b/internal/xmpmeta/jpeg_io.cc
index 5464cb8..385195e 100644
--- a/internal/xmpmeta/jpeg_io.cc
+++ b/internal/xmpmeta/jpeg_io.cc
@@ -5,7 +5,8 @@
#include "android-base/logging.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace {
// File markers.
@@ -191,4 +192,5 @@ void WriteSections(const std::vector<Section>& sections,
}
}
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/md5.cc b/internal/xmpmeta/md5.cc
index 8c44267..8ee5e1b 100644
--- a/internal/xmpmeta/md5.cc
+++ b/internal/xmpmeta/md5.cc
@@ -7,7 +7,8 @@
#include "base/integral_types.h"
#include "strings/escaping.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace {
const int kMd5DigestSize = 16;
@@ -134,7 +135,8 @@ void MD5Final(uint8 digest[16], MD5Context* ctx) {
// The core of the MD5 algorithm, this alters an existing MD5 hash to
// reflect the addition of 16 longwords of new data. MD5Update blocks
// the data and converts bytes into longwords for this routine.
-DDEPTH_NO_UNSIGNED_OVERFLOW_CHECK void MD5Transform(uint32 buf[4], const uint32 in[16]) {
+DDEPTH_NO_UNSIGNED_OVERFLOW_CHECK void MD5Transform(uint32 buf[4],
+ const uint32 in[16]) {
uint32 a = buf[0];
uint32 b = buf[1];
uint32 c = buf[2];
@@ -231,4 +233,5 @@ string MD5Hash(const string& to_hash) {
kMd5DigestSize);
}
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xml/const.cc b/internal/xmpmeta/xml/const.cc
index 8f0eb5c..5af3c16 100644
--- a/internal/xmpmeta/xml/const.cc
+++ b/internal/xmpmeta/xml/const.cc
@@ -1,6 +1,7 @@
#include "xmpmeta/xml/const.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
const char* XmlConst::EncodingStr() { return "UTF-8"; }
@@ -30,4 +31,5 @@ const char* XmlConst::Separator() { return ":"; }
const char* XmlConst::Version() { return "1.0"; }
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xml/const.h b/internal/xmpmeta/xml/const.h
index 8a8a056..8a1998a 100644
--- a/internal/xmpmeta/xml/const.h
+++ b/internal/xmpmeta/xml/const.h
@@ -1,7 +1,8 @@
#ifndef DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_CONST_H_ // NOLINT
#define DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_CONST_H_ // NOLINT
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
struct XmlConst {
@@ -24,6 +25,7 @@ struct XmlConst {
};
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_CONST_H_ // NOLINT
diff --git a/internal/xmpmeta/xml/deserializer.h b/internal/xmpmeta/xml/deserializer.h
index e717950..4624e1f 100644
--- a/internal/xmpmeta/xml/deserializer.h
+++ b/internal/xmpmeta/xml/deserializer.h
@@ -8,7 +8,8 @@
#include "base/integral_types.h"
#include "base/port.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Performs deserialization.
@@ -60,6 +61,7 @@ class Deserializer {
};
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_H_ // NOLINT
diff --git a/internal/xmpmeta/xml/deserializer_impl.cc b/internal/xmpmeta/xml/deserializer_impl.cc
index 6214a0c..eb44d38 100644
--- a/internal/xmpmeta/xml/deserializer_impl.cc
+++ b/internal/xmpmeta/xml/deserializer_impl.cc
@@ -11,7 +11,8 @@
#include "xmpmeta/xml/utils.h"
#include "xmpmeta/xmp_parser.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
namespace {
@@ -63,7 +64,6 @@ bool GetStringProperty(const xmlNodePtr node, const string& prefix,
return true;
}
}
- LOG(WARNING) << "Could not find string attribute: " << property;
return false;
}
@@ -318,4 +318,5 @@ bool DeserializerImpl::ParseDoubleArray(const string& prefix,
}
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xml/deserializer_impl.h b/internal/xmpmeta/xml/deserializer_impl.h
index 65df2d6..426dcea 100644
--- a/internal/xmpmeta/xml/deserializer_impl.h
+++ b/internal/xmpmeta/xml/deserializer_impl.h
@@ -10,7 +10,8 @@
#include "base/port.h"
#include "xmpmeta/xml/deserializer.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Deserializes an XML node.
@@ -88,6 +89,7 @@ class DeserializerImpl : public Deserializer {
};
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_DESERIALIZER_IMPL_H_ // NOLINT
diff --git a/internal/xmpmeta/xml/search.cc b/internal/xmpmeta/xml/search.cc
index ca2e45c..c4fe8f9 100644
--- a/internal/xmpmeta/xml/search.cc
+++ b/internal/xmpmeta/xml/search.cc
@@ -6,9 +6,10 @@
#include "android-base/logging.h"
#include "xmpmeta/xml/utils.h"
-using photos_editing_formats::xml::FromXmlChar;
+using ::dynamic_depth::xmpmeta::xml::FromXmlChar;
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
xmlNodePtr DepthFirstSearch(const xmlDocPtr parent, const char* name) {
@@ -70,4 +71,5 @@ xmlNodePtr DepthFirstSearch(const xmlNodePtr parent, const char* prefix,
}
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xml/search.h b/internal/xmpmeta/xml/search.h
index c420661..e32e272 100644
--- a/internal/xmpmeta/xml/search.h
+++ b/internal/xmpmeta/xml/search.h
@@ -4,7 +4,8 @@
#include <libxml/tree.h>
// Performs searches an XML tree.
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Depth-first search on the nodes in this XML doc.
@@ -31,6 +32,7 @@ xmlNodePtr DepthFirstSearch(const xmlNodePtr parent, const char* prefix,
const char* name);
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_SEARCH_H_ // NOLINT
diff --git a/internal/xmpmeta/xml/serializer.h b/internal/xmpmeta/xml/serializer.h
index 9d35ad8..62f36f7 100644
--- a/internal/xmpmeta/xml/serializer.h
+++ b/internal/xmpmeta/xml/serializer.h
@@ -7,7 +7,8 @@
#include "base/port.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Serializes properties for a hierarchy of objects.
@@ -71,6 +72,7 @@ class Serializer {
};
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_SERIALIZER_H_ // NOLINT
diff --git a/internal/xmpmeta/xml/serializer_impl.cc b/internal/xmpmeta/xml/serializer_impl.cc
index c8a6038..0601d79 100644
--- a/internal/xmpmeta/xml/serializer_impl.cc
+++ b/internal/xmpmeta/xml/serializer_impl.cc
@@ -8,7 +8,8 @@
#include "xmpmeta/xml/const.h"
#include "xmpmeta/xml/utils.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Methods specific to SerializerImpl.
@@ -244,4 +245,5 @@ bool SerializerImpl::WriteDoubleArray(const string& prefix,
}
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xml/serializer_impl.h b/internal/xmpmeta/xml/serializer_impl.h
index 78131c5..fb53bec 100644
--- a/internal/xmpmeta/xml/serializer_impl.h
+++ b/internal/xmpmeta/xml/serializer_impl.h
@@ -8,7 +8,8 @@
#include "xmpmeta/xml/serializer.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Writes properties, lists, and child nodes into an XML structure.
@@ -172,6 +173,7 @@ class SerializerImpl : public Serializer {
};
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_SERIALIZER_IMPL_H_ // NOLINT
diff --git a/internal/xmpmeta/xml/utils.cc b/internal/xmpmeta/xml/utils.cc
index 87bf0b1..04721db 100644
--- a/internal/xmpmeta/xml/utils.cc
+++ b/internal/xmpmeta/xml/utils.cc
@@ -5,7 +5,8 @@
#include "xmpmeta/xml/const.h"
#include "xmpmeta/xml/search.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
xmlNodePtr GetFirstDescriptionElement(const xmlDocPtr parent) {
@@ -74,4 +75,5 @@ const string XmlDocToString(const xmlDocPtr doc) {
}
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xml/utils.h b/internal/xmpmeta/xml/utils.h
index f0f99e3..4995369 100644
--- a/internal/xmpmeta/xml/utils.h
+++ b/internal/xmpmeta/xml/utils.h
@@ -7,7 +7,8 @@
#include "base/port.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace xml {
// Convenience function to convert an xmlChar* to a char*
@@ -49,6 +50,7 @@ const string GetLiNodeContent(xmlNodePtr node);
const string XmlDocToString(const xmlDocPtr doc);
} // namespace xml
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
#endif // DYNAMIC_DEPTH_INTERNAL_XMPMETA_XML_UTILS_H_ // NOLINT
diff --git a/internal/xmpmeta/xmp_const.cc b/internal/xmpmeta/xmp_const.cc
index 69fc3a9..003d2d1 100644
--- a/internal/xmpmeta/xmp_const.cc
+++ b/internal/xmpmeta/xmp_const.cc
@@ -1,6 +1,7 @@
#include "xmpmeta/xmp_const.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
// XMP namespace constants.
const char* XmpConst::Namespace() { return "adobe:ns:meta/"; }
@@ -35,4 +36,5 @@ const int XmpConst::MaxBufferSize() { return 65502; }
const int XmpConst::ExtendedMaxBufferSize() { return 65458; }
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xmp_data.cc b/internal/xmpmeta/xmp_data.cc
index 046052b..45ad585 100644
--- a/internal/xmpmeta/xmp_data.cc
+++ b/internal/xmpmeta/xmp_data.cc
@@ -1,6 +1,7 @@
#include "xmpmeta/xmp_data.h"
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
XmpData::XmpData() : xmp_(nullptr), xmp_extended_(nullptr) {}
@@ -25,4 +26,5 @@ const xmlDocPtr XmpData::ExtendedSection() const { return xmp_extended_; }
xmlDocPtr* XmpData::MutableExtendedSection() { return &xmp_extended_; }
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xmp_parser.cc b/internal/xmpmeta/xmp_parser.cc
index 4ce8991..a0065fd 100644
--- a/internal/xmpmeta/xmp_parser.cc
+++ b/internal/xmpmeta/xmp_parser.cc
@@ -16,12 +16,13 @@
#include "xmpmeta/xml/utils.h"
#include "xmpmeta/xmp_const.h"
-using photos_editing_formats::xml::DepthFirstSearch;
-using photos_editing_formats::xml::DeserializerImpl;
-using photos_editing_formats::xml::FromXmlChar;
-using photos_editing_formats::xml::GetFirstDescriptionElement;
+using ::dynamic_depth::xmpmeta::xml::DepthFirstSearch;
+using ::dynamic_depth::xmpmeta::xml::DeserializerImpl;
+using ::dynamic_depth::xmpmeta::xml::FromXmlChar;
+using ::dynamic_depth::xmpmeta::xml::GetFirstDescriptionElement;
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace {
const char kJpgExtension[] = "jpg";
@@ -235,7 +236,6 @@ bool GetStringProperty(const xmlNodePtr node, const char* prefix,
return true;
}
}
- LOG(WARNING) << "Could not find string attribute: " << property;
return false;
}
@@ -330,4 +330,5 @@ bool ReadXmpHeader(std::istream* input_stream, bool skip_extended,
return ExtractXmpMeta(skip_extended, input_stream, xmp_data);
}
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth
diff --git a/internal/xmpmeta/xmp_writer.cc b/internal/xmpmeta/xmp_writer.cc
index 73e5a65..fc78ad1 100644
--- a/internal/xmpmeta/xmp_writer.cc
+++ b/internal/xmpmeta/xmp_writer.cc
@@ -18,11 +18,13 @@
#include "xmpmeta/xmp_data.h"
#include "xmpmeta/xmp_parser.h"
-using photos_editing_formats::xml::FromXmlChar;
-using photos_editing_formats::xml::ToXmlChar;
-using photos_editing_formats::xml::XmlConst;
+using ::dynamic_depth::xmpmeta::xml::FromXmlChar;
+using ::dynamic_depth::xmpmeta::xml::GetFirstDescriptionElement;
+using ::dynamic_depth::xmpmeta::xml::ToXmlChar;
+using ::dynamic_depth::xmpmeta::xml::XmlConst;
-namespace photos_editing_formats {
+namespace dynamic_depth {
+namespace xmpmeta {
namespace {
const char kXmlStartTag = '<';
@@ -249,8 +251,7 @@ bool UpdateSections(const string& main_buffer, const string& extended_buffer,
void LinkXmpStandardAndExtendedSections(const string& extended_buffer,
xmlDocPtr standard_section) {
- xmlNodePtr description_node =
- xml::GetFirstDescriptionElement(standard_section);
+ xmlNodePtr description_node = GetFirstDescriptionElement(standard_section);
xmlNsPtr xmp_note_ns_ptr =
xmlNewNs(description_node, ToXmlChar(XmpConst::NoteNamespace()),
ToXmlChar(XmpConst::HasExtensionPrefix()));
@@ -277,15 +278,15 @@ bool WriteLeftEyeAndXmpMeta(const string& left_data, const string& filename,
std::istringstream input_jpeg_stream(left_data);
std::ofstream output_jpeg_stream;
output_jpeg_stream.open(filename, std::ostream::out);
- bool success = WriteLeftEyeAndXmpMeta(filename, xmp_data, &input_jpeg_stream,
- &output_jpeg_stream);
+ bool success =
+ WriteLeftEyeAndXmpMeta(xmp_data, &input_jpeg_stream, &output_jpeg_stream);
output_jpeg_stream.close();
return success;
}
-bool WriteLeftEyeAndXmpMeta(const string& filename, const XmpData& xmp_data,
- std::istringstream* input_jpeg_stream,
- std::ofstream* output_jpeg_stream) {
+bool WriteLeftEyeAndXmpMeta(const XmpData& xmp_data,
+ std::istream* input_jpeg_stream,
+ std::ostream* output_jpeg_stream) {
if (input_jpeg_stream == nullptr || output_jpeg_stream == nullptr) {
LOG(ERROR) << "Input and output streams must both be non-null";
return false;
@@ -311,40 +312,9 @@ bool WriteLeftEyeAndXmpMeta(const string& filename, const XmpData& xmp_data,
return false;
}
- // Write the sections to the output stream.
- if (!output_jpeg_stream->is_open()) {
- output_jpeg_stream->open(filename, std::ostream::out);
- }
-
- WriteSections(sections, output_jpeg_stream);
- return true;
-}
-
-bool AddXmpMetaToJpegStream(std::istream* input_jpeg_stream,
- const XmpData& xmp_data,
- std::ostream* output_jpeg_stream) {
- // Get a list of sections from the input stream.
- ParseOptions parse_options;
- std::vector<Section> sections = Parse(parse_options, input_jpeg_stream);
-
- string extended_buffer;
- if (xmp_data.ExtendedSection() != nullptr) {
- SerializeMeta(xmp_data.ExtendedSection(), &extended_buffer);
- LinkXmpStandardAndExtendedSections(extended_buffer,
- xmp_data.StandardSection());
- }
- string main_buffer;
- SerializeMeta(xmp_data.StandardSection(), &main_buffer);
-
- // Update the input sections with the XMP data.
- if (!XmpSectionsAndSerializedDataValid(xmp_data, main_buffer,
- extended_buffer) ||
- !UpdateSections(main_buffer, extended_buffer, &sections)) {
- return false;
- }
-
WriteSections(sections, output_jpeg_stream);
return true;
}
-} // namespace photos_editing_formats
+} // namespace xmpmeta
+} // namespace dynamic_depth