WIP: stop using video directory and hard-linking (#2756).
[dcpomatic.git] / src / lib / raw_image_proxy.cc
index ac8ff0763d103556b20b649574bad94515171f04..1ad78827c51d362ac237e489a9b38bc44b2f6ade 100644 (file)
 
 #include "raw_image_proxy.h"
 #include "image.h"
-#include "warnings.h"
 #include <dcp/raw_convert.h>
 #include <dcp/util.h>
+#include <dcp/warnings.h>
 #include <libcxml/cxml.h>
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
-DCPOMATIC_DISABLE_WARNINGS
+LIBDCP_DISABLE_WARNINGS
 #include <libxml++/libxml++.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 
 #include "i18n.h"
 
@@ -45,7 +45,7 @@ using boost::optional;
 using dcp::raw_convert;
 
 
-RawImageProxy::RawImageProxy (shared_ptr<Image> image)
+RawImageProxy::RawImageProxy(shared_ptr<const Image> image)
        : _image (image)
 {
 
@@ -58,26 +58,27 @@ RawImageProxy::RawImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
                xml->number_child<int>("Width"), xml->number_child<int>("Height")
                );
 
-       _image = make_shared<Image>(static_cast<AVPixelFormat>(xml->number_child<int>("PixelFormat")), size, true);
-       _image->read_from_socket (socket);
+       auto image = make_shared<Image>(static_cast<AVPixelFormat>(xml->number_child<int>("PixelFormat")), size, Image::Alignment::PADDED);
+       image->read_from_socket (socket);
+       _image = image;
 }
 
 
 ImageProxy::Result
-RawImageProxy::image (bool aligned, optional<dcp::Size>) const
+RawImageProxy::image (Image::Alignment alignment, optional<dcp::Size>) const
 {
-       /* This ensure_aligned could be wasteful */
-       return Result (Image::ensure_aligned(_image, aligned), 0);
+       /* This ensure_alignment could be wasteful */
+       return Result (Image::ensure_alignment(_image, alignment), 0);
 }
 
 
 void
-RawImageProxy::add_metadata (xmlpp::Node* node) const
+RawImageProxy::add_metadata(xmlpp::Element* element) const
 {
-       node->add_child("Type")->add_child_text(N_("Raw"));
-       node->add_child("Width")->add_child_text(raw_convert<string>(_image->size().width));
-       node->add_child("Height")->add_child_text(raw_convert<string>(_image->size().height));
-       node->add_child("PixelFormat")->add_child_text(raw_convert<string>(static_cast<int>(_image->pixel_format())));
+       cxml::add_text_child(element, "Type", N_("Raw"));
+       cxml::add_text_child(element, "Width", raw_convert<string>(_image->size().width));
+       cxml::add_text_child(element, "Height", raw_convert<string>(_image->size().height));
+       cxml::add_text_child(element, "PixelFormat", raw_convert<string>(static_cast<int>(_image->pixel_format())));
 }
 
 
@@ -96,7 +97,7 @@ RawImageProxy::same (shared_ptr<const ImageProxy> other) const
                return false;
        }
 
-       return (*_image.get()) == (*rp->image(_image->aligned()).image.get());
+       return (*_image.get()) == (*rp->image(_image->alignment()).image.get());
 }