X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fraw_image_proxy.cc;h=9b486dd5cc669966f8e600c26c24579bbcb0f4bd;hb=c26e79a3598ff1b36f800823f178a0829d0fa547;hp=5bd8c4811306feea406d5e023dfe3e0cbd706780;hpb=3b31d2d8a129ae6d8d267427bd6b5bc444b40b2a;p=dcpomatic.git diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index 5bd8c4811..9b486dd5c 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,74 +18,88 @@ */ + #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::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::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().image.get()); + return (*_image.get()) == (*rp->image(_image->alignment()).image.get()); } + size_t RawImageProxy::memory_used () const {