X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fraw_image_proxy.cc;h=fb0d16df8a5b6cc29cef87a5054d85ccdc8dec5e;hb=3799e91d126d243d41c44dcb0ca1bfa66b53a57e;hp=09902c3a29b5c0a5844b83fe50f932e5039b34e0;hpb=2bec3708fc744c18128c5bdb4c2a332f5c8eb283;p=dcpomatic.git diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index 09902c3a2..fb0d16df8 100644 --- a/src/lib/raw_image_proxy.cc +++ b/src/lib/raw_image_proxy.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2018 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "raw_image_proxy.h" #include "image.h" #include "warnings.h" @@ -33,62 +34,72 @@ DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" -using std::string; -using std::pair; + +using std::dynamic_pointer_cast; using std::make_pair; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using std::make_shared; +using std::pair; +using std::shared_ptr; +using std::string; using boost::optional; using dcp::raw_convert; + RawImageProxy::RawImageProxy (shared_ptr image) : _image (image) { } + RawImageProxy::RawImageProxy (shared_ptr xml, shared_ptr socket) { dcp::Size size ( - xml->number_child ("Width"), xml->number_child ("Height") + xml->number_child("Width"), xml->number_child("Height") ); - _image.reset (new Image (static_cast (xml->number_child ("PixelFormat")), size, true)); + _image = make_shared(static_cast(xml->number_child("PixelFormat")), size, Image::Alignment::PADDED); _image->read_from_socket (socket); } + ImageProxy::Result -RawImageProxy::image (optional) const +RawImageProxy::image (Image::Alignment alignment, optional) const { - return Result (_image, 0); + /* This ensure_alignment could be wasteful */ + return Result (Image::ensure_alignment(_image, alignment), 0); } + void RawImageProxy::add_metadata (xmlpp::Node* node) const { - node->add_child("Type")->add_child_text (N_("Raw")); - node->add_child("Width")->add_child_text (raw_convert (_image->size().width)); - node->add_child("Height")->add_child_text (raw_convert (_image->size().height)); - node->add_child("PixelFormat")->add_child_text (raw_convert (static_cast (_image->pixel_format ()))); + node->add_child("Type")->add_child_text(N_("Raw")); + node->add_child("Width")->add_child_text(raw_convert(_image->size().width)); + node->add_child("Height")->add_child_text(raw_convert(_image->size().height)); + node->add_child("PixelFormat")->add_child_text(raw_convert(static_cast(_image->pixel_format()))); } + void RawImageProxy::write_to_socket (shared_ptr socket) const { _image->write_to_socket (socket); } + bool RawImageProxy::same (shared_ptr other) const { - shared_ptr rp = dynamic_pointer_cast (other); + auto rp = dynamic_pointer_cast (other); if (!rp) { return false; } - return (*_image.get()) == (*rp->image().image.get()); + return (*_image.get()) == (*rp->image(_image->alignment()).image.get()); } + size_t RawImageProxy::memory_used () const {