X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fraw_image_proxy.cc;h=c606ddd9906520b128c1009517d2c706dd180659;hb=HEAD;hp=e182c0e5d17f5048f70f1814826dbfbdf4aac88f;hpb=73654117144c6de0ec4efe39ddc88485df546cc9;p=dcpomatic.git diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index e182c0e5d..c606ddd99 100644 --- a/src/lib/raw_image_proxy.cc +++ b/src/lib/raw_image_proxy.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,74 +18,91 @@ */ + #include "raw_image_proxy.h" #include "image.h" #include #include +#include #include extern "C" { #include } +LIBDCP_DISABLE_WARNINGS #include +LIBDCP_ENABLE_WARNINGS #include "i18n.h" + +using std::dynamic_pointer_cast; +using std::make_pair; +using std::make_shared; +using std::pair; +using std::shared_ptr; using std::string; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; using boost::optional; using dcp::raw_convert; -RawImageProxy::RawImageProxy (shared_ptr image) + +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->read_from_socket (socket); + auto image = make_shared(static_cast(xml->number_child("PixelFormat")), size, Image::Alignment::PADDED); + image->read_from_socket (socket); + _image = image; } -shared_ptr -RawImageProxy::image (optional) const + +ImageProxy::Result +RawImageProxy::image (Image::Alignment alignment, optional) const { - return _image; + /* 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 (_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::send_binary (shared_ptr socket) const +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().get()); + return (*_image.get()) == (*rp->image(_image->alignment()).image.get()); } -AVPixelFormat -RawImageProxy::pixel_format () const + +size_t +RawImageProxy::memory_used () const { - return _image->pixel_format (); + return _image->memory_used (); }