X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fraw_image_proxy.cc;h=fed40c45e7ec783faaa31fa94b55f91810177dc2;hb=23aa3071850761144798112a5aaea61304de8586;hp=ea702f138594a9217709786934c5b3ae76051b52;hpb=5bbf16e87ca09369174c9d2bb7f7fe94b6d70275;p=dcpomatic.git diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index ea702f138..fed40c45e 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,89 @@ */ + #include "raw_image_proxy.h" #include "image.h" +#include "warnings.h" #include #include #include extern "C" { #include } +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_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) : _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, true); _image->read_from_socket (socket); } -shared_ptr -RawImageProxy::image (optional, optional) const + +ImageProxy::Result +RawImageProxy::image (optional) const { - return _image; + return Result (_image, 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().get()); + return (*_image.get()) == (*rp->image().image.get()); } -AVPixelFormat -RawImageProxy::pixel_format () const + +size_t +RawImageProxy::memory_used () const { - return _image->pixel_format (); + return _image->memory_used (); }