From 00e9647a9ede540f2d567c19025278c25a87c830 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Jan 2014 22:38:43 +0000 Subject: [PATCH] Various tweaks; work on read_dcp example. --- examples/read_dcp.cc | 45 ++++++++++++++++++-- examples/wscript | 2 +- src/content.cc | 1 - src/cpl.cc | 18 ++++++-- src/cpl.h | 2 + src/dcp.cc | 71 +++++++++++--------------------- src/mono_picture_mxf.cc | 11 ++++- src/mono_picture_mxf_writer.cc | 1 - src/mxf.cc | 9 +++- src/mxf.h | 2 + src/picture_mxf.cc | 16 +++---- src/reel.cc | 18 +++++++- src/reel.h | 5 ++- src/reel_asset.cc | 2 - src/reel_asset.h | 2 +- src/reel_mono_picture_asset.cc | 3 +- src/reel_picture_asset.cc | 1 - src/reel_stereo_picture_asset.cc | 3 +- src/sound_mxf.cc | 15 +++++-- src/sound_mxf_writer.cc | 2 - src/stereo_picture_mxf.cc | 7 ++++ src/types.h | 2 +- src/util.cc | 5 +-- src/util.h | 15 +++++++ wscript | 1 + 25 files changed, 172 insertions(+), 87 deletions(-) diff --git a/examples/read_dcp.cc b/examples/read_dcp.cc index 43f5f0be..f3c47a3c 100644 --- a/examples/read_dcp.cc +++ b/examples/read_dcp.cc @@ -19,12 +19,21 @@ /* If you are using an installed libdcp, these #includes would need to be changed to #include -#include -#include +#include ... etc. ... */ #include "dcp.h" +#include "cpl.h" +#include "reel.h" +#include "reel_picture_asset.h" +#include "mono_picture_frame.h" +#include "mono_picture_mxf.h" +#include "stereo_picture_mxf.h" +#include "sound_mxf.h" +#include "subtitle_content.h" +#include "argb_frame.h" +#include /** @file examples/read_dcp.cc * @brief Shows how to read a DCP. @@ -45,7 +54,37 @@ main () } std::cout << "DCP has " << dcp.cpls().size() << " CPLs.\n"; - std::cout << "DCP has " << dcp.assets().size() << " assets.\n"; + std::list > assets = dcp.assets (); + std::cout << "DCP has " << assets.size() << " assets.\n"; + for (std::list >::const_iterator i = assets.begin(); i != assets.end(); ++i) { + if (boost::dynamic_pointer_cast (*i)) { + std::cout << "2D picture\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "3D picture\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "Sound\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "Subtitle\n"; + } else if (boost::dynamic_pointer_cast (*i)) { + std::cout << "CPL\n"; + } + std::cout << "\t" << (*i)->file().leaf().string() << "\n"; + } + + /* Take the first CPL */ + boost::shared_ptr cpl = dcp.cpls().front (); + + /* Get the MXF of the picture asset in the first reel */ + boost::shared_ptr picture_mxf = boost::dynamic_pointer_cast (cpl->reels().front()->main_picture()->mxf ()); + + /* Get the 1000th frame of it */ + boost::shared_ptr picture_frame_j2k = picture_mxf->get_frame(999); + + /* Get a ARGB copy of it */ + boost::shared_ptr picture_frame_rgb = picture_frame_j2k->argb_frame (); + + Magick::Image image (picture_frame_rgb->size().width, picture_frame_rgb->size().height, "BGRA", Magick::CharPixel, picture_frame_rgb->data ()); + image.write ("frame.png"); return 0; } diff --git a/examples/wscript b/examples/wscript index 7de1199d..ce94bfa2 100644 --- a/examples/wscript +++ b/examples/wscript @@ -10,7 +10,7 @@ def build(bld): obj = bld(features = 'cxx cxxprogram') obj.name = 'read_dcp' obj.use = 'libdcp' - obj.uselib = 'OPENJPEG CXML' + obj.uselib = 'OPENJPEG CXML MAGICK' obj.source = 'read_dcp.cc' obj.target = 'read_dcp' obj.install_path = '' diff --git a/src/content.cc b/src/content.cc index 85988a1a..f0380323 100644 --- a/src/content.cc +++ b/src/content.cc @@ -24,7 +24,6 @@ #include "KM_util.h" #include #include -#include #include #include diff --git a/src/cpl.cc b/src/cpl.cc index d99e1cf7..96afc088 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -54,18 +54,22 @@ CPL::CPL (string annotation_text, ContentKind content_kind) /** Construct a CPL object from a XML file */ CPL::CPL (boost::filesystem::path file) - : _content_kind (FEATURE) + : Asset (file) + , _content_kind (FEATURE) { cxml::Document f ("CompositionPlaylist"); f.read_file (file); _id = f.string_child ("Id"); + if (_id.length() > 9) { + _id = _id.substr (9); + } _annotation_text = f.optional_string_child ("AnnotationText").get_value_or (""); _issue_date = f.string_child ("IssueDate"); _creator = f.optional_string_child ("Creator").get_value_or (""); _content_title_text = f.string_child ("ContentTitleText"); _content_kind = content_kind_from_string (f.string_child ("ContentKind")); - shared_ptr content_version = f.node_child ("ContentVersion"); + shared_ptr content_version = f.optional_node_child ("ContentVersion"); if (content_version) { _content_version_id = content_version->optional_string_child ("Id").get_value_or (""); _content_version_label_text = content_version->string_child ("LabelText"); @@ -205,7 +209,7 @@ void CPL::add (KDM const & kdm) { for (list >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) { - (*i)->add_kdm (kdm); + (*i)->add (kdm); } } @@ -220,3 +224,11 @@ CPL::set_mxf_keys (Key key) (*i)->set_mxf_keys (key); } } + +void +CPL::resolve_refs (list > objects) +{ + for (list >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) { + (*i)->resolve_refs (objects); + } +} diff --git a/src/cpl.h b/src/cpl.h index 35a8bb62..4c3f9bfa 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -94,6 +94,8 @@ public: XMLMetadata, boost::shared_ptr ) const; + + void resolve_refs (std::list >); private: std::string _annotation_text; ///< diff --git a/src/dcp.cc b/src/dcp.cc index 6af33663..1925ac0b 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -56,7 +55,6 @@ using std::make_pair; using std::map; using boost::shared_ptr; using boost::lexical_cast; -using boost::dynamic_pointer_cast; using namespace dcp; DCP::DCP (boost::filesystem::path directory) @@ -81,9 +79,9 @@ DCP::read () cxml::Document asset_map ("AssetMap"); asset_map.read_file (asset_map_file); - list > assets = asset_map.node_child("AssetList")->node_children ("Asset"); + list > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset"); map paths; - for (list >::const_iterator i = assets.begin(); i != assets.end(); ++i) { + for (list >::const_iterator i = asset_nodes.begin(); i != asset_nodes.end(); ++i) { if ((*i)->node_child("ChunkList")->node_children("Chunk").size() != 1) { boost::throw_exception (XMLError ("unsupported asset chunk count")); } @@ -96,10 +94,11 @@ DCP::read () /* Read all the assets from the asset map */ for (map::const_iterator i = paths.begin(); i != paths.end(); ++i) { - if (boost::algorithm::ends_with (i->second.string(), ".xml")) { + boost::filesystem::path path = _directory / i->second; + if (boost::algorithm::ends_with (path.string(), ".xml")) { xmlpp::DomParser* p = new xmlpp::DomParser; try { - p->parse_file (i->second.string()); + p->parse_file (path.string()); } catch (std::exception& e) { delete p; continue; @@ -109,13 +108,13 @@ DCP::read () delete p; if (root == "CompositionPlaylist") { - _assets.push_back (shared_ptr (new CPL (i->second))); + _assets.push_back (shared_ptr (new CPL (path))); } else if (root == "DCSubtitle") { - _assets.push_back (shared_ptr (new SubtitleContent (i->second))); + _assets.push_back (shared_ptr (new SubtitleContent (path))); } - } else if (boost::algorithm::ends_with (i->second.string(), ".mxf")) { + } else if (boost::algorithm::ends_with (path.string(), ".mxf")) { ASDCP::EssenceType_t type; - if (ASDCP::EssenceType (i->second.string().c_str(), type) != ASDCP::RESULT_OK) { + if (ASDCP::EssenceType (path.string().c_str(), type) != ASDCP::RESULT_OK) { throw DCPReadError ("Could not find essence type"); } switch (type) { @@ -123,20 +122,25 @@ DCP::read () case ASDCP::ESS_MPEG2_VES: throw DCPReadError ("MPEG2 video essences are not supported"); case ASDCP::ESS_JPEG_2000: - _assets.push_back (shared_ptr (new MonoPictureMXF (i->second))); + _assets.push_back (shared_ptr (new MonoPictureMXF (path))); break; case ASDCP::ESS_PCM_24b_48k: case ASDCP::ESS_PCM_24b_96k: - _assets.push_back (shared_ptr (new SoundMXF (i->second))); + _assets.push_back (shared_ptr (new SoundMXF (path))); break; case ASDCP::ESS_JPEG_2000_S: - _assets.push_back (shared_ptr (new StereoPictureMXF (i->second))); + _assets.push_back (shared_ptr (new StereoPictureMXF (path))); break; default: throw DCPReadError ("Unknown MXF essence type"); } } } + + list > cpl = cpls (); + for (list >::const_iterator i = cpl.begin(); i != cpl.end(); ++i) { + (*i)->resolve_refs (list_of_type (assets ())); + } } bool @@ -226,29 +230,16 @@ DCP::write_pkl (Standard standard, string pkl_uuid, XMLMetadata metadata, shared pkl->add_child("Id")->add_child_text ("urn:uuid:" + pkl_uuid); /* XXX: this is a bit of a hack */ - list >::const_iterator i = _assets.begin(); - shared_ptr first_cpl; - while (i != _assets.end()) { - first_cpl = dynamic_pointer_cast (*i); - if (first_cpl) { - break; - } - } - - assert (first_cpl); - pkl->add_child("AnnotationText")->add_child_text (first_cpl->annotation_text ()); + assert (cpls().size() > 0); + pkl->add_child("AnnotationText")->add_child_text (cpls().front()->annotation_text ()); pkl->add_child("IssueDate")->add_child_text (metadata.issue_date); pkl->add_child("Issuer")->add_child_text (metadata.issuer); pkl->add_child("Creator")->add_child_text (metadata.creator); xmlpp::Element* asset_list = pkl->add_child("AssetList"); - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { - shared_ptr c = dynamic_pointer_cast (*i); - if (c) { - c->write_to_pkl (asset_list); - } + (*i)->write_to_pkl (asset_list); } if (signer) { @@ -343,27 +334,15 @@ DCP::write_xml ( write_volindex (standard); write_assetmap (standard, pkl_uuid, boost::filesystem::file_size (pkl_path), metadata); - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { - shared_ptr c = dynamic_pointer_cast (*i); - if (c) { - string const filename = c->id() + "_cpl.xml"; - c->write_xml (_directory / filename, standard, metadata, signer); - } + list > cpl = cpls (); + for (list >::const_iterator i = cpl.begin(); i != cpl.end(); ++i) { + string const filename = (*i)->id() + "_cpl.xml"; + (*i)->write_xml (_directory / filename, standard, metadata, signer); } } list > DCP::cpls () const { - list > cpls; - for (list >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) { - shared_ptr c = dynamic_pointer_cast (*i); - if (c) { - cpls.push_back (c); - } - } - - return cpls; + return list_of_type (_assets); } - - diff --git a/src/mono_picture_mxf.cc b/src/mono_picture_mxf.cc index 9c16516d..4af24008 100644 --- a/src/mono_picture_mxf.cc +++ b/src/mono_picture_mxf.cc @@ -23,12 +23,12 @@ #include "KM_fileio.h" #include "exceptions.h" #include "mono_picture_frame.h" +#include "compose.hpp" using std::string; using std::vector; using boost::shared_ptr; using boost::dynamic_pointer_cast; -using boost::lexical_cast; using namespace dcp; MonoPictureMXF::MonoPictureMXF (boost::filesystem::path file) @@ -46,6 +46,13 @@ MonoPictureMXF::MonoPictureMXF (boost::filesystem::path file) } read_picture_descriptor (desc); + + ASDCP::WriterInfo info; + if (ASDCP_FAILURE (reader.FillWriterInfo (info))) { + boost::throw_exception (DCPReadError ("could not read video MXF information")); + } + + read_writer_info (info); } MonoPictureMXF::MonoPictureMXF (Fraction edit_rate) @@ -100,7 +107,7 @@ MonoPictureMXF::equals (shared_ptr other, EqualityOptions opt, bo return false; } - note (PROGRESS, "Comparing video frame " + lexical_cast (i) + " of " + lexical_cast (_intrinsic_duration)); + note (PROGRESS, String::compose ("Comparing video frame %1 of %2", i, _intrinsic_duration)); shared_ptr frame_A = get_frame (i); shared_ptr frame_B = other_picture->get_frame (i); diff --git a/src/mono_picture_mxf_writer.cc b/src/mono_picture_mxf_writer.cc index 96c054d7..d685cd69 100644 --- a/src/mono_picture_mxf_writer.cc +++ b/src/mono_picture_mxf_writer.cc @@ -29,7 +29,6 @@ using std::istream; using std::ostream; using std::string; using boost::shared_ptr; -using boost::lexical_cast; using namespace dcp; struct MonoPictureMXFWriter::ASDCPState : public ASDCPStateBase diff --git a/src/mxf.cc b/src/mxf.cc index 1a19b817..200bc843 100644 --- a/src/mxf.cc +++ b/src/mxf.cc @@ -31,7 +31,6 @@ #include "kdm.h" #include #include -#include #include using std::string; @@ -147,3 +146,11 @@ MXF::set_key (Key key) throw MiscError ("could not set up CBC initialization vector"); } } + +void +MXF::read_writer_info (ASDCP::WriterInfo const & info) +{ + char buffer[64]; + Kumu::bin2UUIDhex (info.AssetUUID, 16, buffer, 64); + _id = buffer; +} diff --git a/src/mxf.h b/src/mxf.h index f2c0fdf7..f7336fee 100644 --- a/src/mxf.h +++ b/src/mxf.h @@ -98,6 +98,8 @@ public: } protected: + void read_writer_info (ASDCP::WriterInfo const &); + /** Signal to emit to report progress, or 0 */ boost::signals2::signal* _progress; ASDCP::AESEncContext* _encryption_context; diff --git a/src/picture_mxf.cc b/src/picture_mxf.cc index e5955047..4a8e477b 100644 --- a/src/picture_mxf.cc +++ b/src/picture_mxf.cc @@ -22,12 +22,12 @@ #include "exceptions.h" #include "xyz_frame.h" #include "picture_mxf_writer.h" +#include "compose.hpp" #include "AS_DCP.h" #include "KM_fileio.h" #include #include #include -#include #include #include #include @@ -44,8 +44,6 @@ using std::make_pair; using std::istream; using std::cout; using boost::shared_ptr; -using boost::dynamic_pointer_cast; -using boost::lexical_cast; using namespace dcp; PictureMXF::PictureMXF (boost::filesystem::path file) @@ -138,7 +136,7 @@ PictureMXF::frame_buffer_equals ( for (int c = 0; c < 3; ++c) { if (image_A->size() != image_B->size()) { - note (ERROR, "image sizes for frame " + lexical_cast(frame) + " differ"); + note (ERROR, String::compose ("image sizes for frame %1 differ", frame)); return false; } @@ -164,14 +162,12 @@ PictureMXF::frame_buffer_equals ( double const std_dev = sqrt (double (total_squared_deviation) / abs_diffs.size()); - note (NOTE, "mean difference " + lexical_cast (mean) + ", deviation " + lexical_cast (std_dev)); + note (NOTE, String::compose ("mean difference %1, deviation %2", mean, std_dev)); if (mean > opt.max_mean_pixel_error) { note ( ERROR, - "mean " + lexical_cast(mean) + - " out of range " + lexical_cast(opt.max_mean_pixel_error) + - " in frame " + lexical_cast(frame) + String::compose ("mean %1 out of range %2 in frame %3", mean, opt.max_mean_pixel_error, frame) ); return false; @@ -180,9 +176,7 @@ PictureMXF::frame_buffer_equals ( if (std_dev > opt.max_std_dev_pixel_error) { note ( ERROR, - "standard deviation " + lexical_cast(std_dev) + - " out of range " + lexical_cast(opt.max_std_dev_pixel_error) + - " in frame " + lexical_cast(frame) + String::compose ("standard deviation %1 out of range %2 in frame %3", std_dev, opt.max_std_dev_pixel_error, frame) ); return false; diff --git a/src/reel.cc b/src/reel.cc index 7503ae9c..723a2db4 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -133,7 +133,7 @@ Reel::encrypted () const } void -Reel::add_kdm (KDM const & kdm) +Reel::add (KDM const & kdm) { list keys = kdm.keys (); @@ -172,3 +172,19 @@ Reel::add (shared_ptr asset) _main_subtitle = su; } } + +void +Reel::resolve_refs (list > objects) +{ + if (_main_picture) { + _main_picture->content().resolve (objects); + } + + if (_main_sound) { + _main_sound->content().resolve (objects); + } + + if (_main_subtitle) { + _main_subtitle->content().resolve (objects); + } +} diff --git a/src/reel.h b/src/reel.h index 30a0cc4e..14def9c8 100644 --- a/src/reel.h +++ b/src/reel.h @@ -39,6 +39,7 @@ class ReelAsset; class ReelPictureAsset; class ReelSoundAsset; class ReelSubtitleAsset; +class Content; /** @brief A reel within a DCP; the part which actually refers to picture, sound and subtitle data */ class Reel : public Object @@ -80,7 +81,9 @@ public: bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function notes) const; - void add_kdm (KDM const &); + void add (KDM const &); + + void resolve_refs (std::list >); private: boost::shared_ptr _main_picture; diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 28b1937c..5fa59fc2 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -71,8 +71,6 @@ ReelAsset::ReelAsset (boost::shared_ptr node) if (_key_id.length() > 9) { _key_id = _key_id.substr (9); } - - node->done (); } void diff --git a/src/reel_asset.h b/src/reel_asset.h index 25c13354..b5e0537c 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -63,7 +63,7 @@ public: } /** @return a Ref to our actual content */ - Ref content () const { + Ref& content () { return _content; } diff --git a/src/reel_mono_picture_asset.cc b/src/reel_mono_picture_asset.cc index c0b604a1..1a5d256d 100644 --- a/src/reel_mono_picture_asset.cc +++ b/src/reel_mono_picture_asset.cc @@ -19,6 +19,7 @@ #include "reel_mono_picture_asset.h" #include "mono_picture_mxf.h" +#include using std::string; using boost::shared_ptr; @@ -38,7 +39,7 @@ ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr mx ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr node) : ReelPictureAsset (node) { - + node->done (); } string diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 758ed85e..673eb133 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -27,7 +27,6 @@ using std::bad_cast; using std::string; using std::stringstream; using boost::shared_ptr; -using boost::lexical_cast; using namespace dcp; ReelPictureAsset::ReelPictureAsset () diff --git a/src/reel_stereo_picture_asset.cc b/src/reel_stereo_picture_asset.cc index 20e33279..a9cdab71 100644 --- a/src/reel_stereo_picture_asset.cc +++ b/src/reel_stereo_picture_asset.cc @@ -18,6 +18,7 @@ */ #include "reel_stereo_picture_asset.h" +#include using std::string; using std::pair; @@ -28,7 +29,7 @@ using namespace dcp; ReelStereoPictureAsset::ReelStereoPictureAsset (boost::shared_ptr node) : ReelPictureAsset (node) { - + node->done (); } string diff --git a/src/sound_mxf.cc b/src/sound_mxf.cc index ebcf12c6..f6613867 100644 --- a/src/sound_mxf.cc +++ b/src/sound_mxf.cc @@ -26,11 +26,11 @@ #include "exceptions.h" #include "sound_frame.h" #include "sound_mxf_writer.h" +#include "compose.hpp" #include "KM_fileio.h" #include "AS_DCP.h" #include #include -#include #include #include @@ -40,7 +40,6 @@ using std::ostream; using std::vector; using std::list; using boost::shared_ptr; -using boost::lexical_cast; using namespace dcp; SoundMXF::SoundMXF (boost::filesystem::path file) @@ -64,6 +63,14 @@ SoundMXF::SoundMXF (boost::filesystem::path file) _edit_rate = Fraction (desc.EditRate.Numerator, desc.EditRate.Denominator); _intrinsic_duration = desc.ContainerDuration; + + ASDCP::WriterInfo info; + if (ASDCP_FAILURE (reader.FillWriterInfo (info))) { + boost::throw_exception (DCPReadError ("could not read audio MXF information")); + } + + read_writer_info (info); + } SoundMXF::SoundMXF (Fraction edit_rate, int sampling_rate, int channels) @@ -132,7 +139,7 @@ SoundMXF::equals (shared_ptr other, EqualityOptions opt, boost::f } if (buffer_A.Size() != buffer_B.Size()) { - note (ERROR, "sizes of audio data for frame " + lexical_cast(i) + " differ"); + note (ERROR, String::compose ("sizes of audio data for frame %1 differ", i)); return false; } @@ -140,7 +147,7 @@ SoundMXF::equals (shared_ptr other, EqualityOptions opt, boost::f for (uint32_t i = 0; i < buffer_A.Size(); ++i) { int const d = abs (buffer_A.RoData()[i] - buffer_B.RoData()[i]); if (d > opt.max_audio_sample_error) { - note (ERROR, "PCM data difference of " + lexical_cast (d)); + note (ERROR, String::compose ("PCM data difference of %1", d)); return false; } } diff --git a/src/sound_mxf_writer.cc b/src/sound_mxf_writer.cc index 5dcd6791..51ba7e40 100644 --- a/src/sound_mxf_writer.cc +++ b/src/sound_mxf_writer.cc @@ -22,9 +22,7 @@ #include "exceptions.h" #include "compose.hpp" #include "AS_DCP.h" -#include -using boost::lexical_cast; using namespace dcp; struct SoundMXFWriter::ASDCPState diff --git a/src/stereo_picture_mxf.cc b/src/stereo_picture_mxf.cc index 6bcd75c8..0188e4e7 100644 --- a/src/stereo_picture_mxf.cc +++ b/src/stereo_picture_mxf.cc @@ -45,6 +45,13 @@ StereoPictureMXF::StereoPictureMXF (boost::filesystem::path file) } read_picture_descriptor (desc); + + ASDCP::WriterInfo info; + if (ASDCP_FAILURE (reader.FillWriterInfo (info))) { + boost::throw_exception (DCPReadError ("could not read video MXF information")); + } + + read_writer_info (info); } StereoPictureMXF::StereoPictureMXF (Fraction edit_rate) diff --git a/src/types.h b/src/types.h index d34a9039..0a3860a8 100644 --- a/src/types.h +++ b/src/types.h @@ -24,8 +24,8 @@ #ifndef LIBDCP_TYPES_H #define LIBDCP_TYPES_H -#include #include +#include namespace dcp { diff --git a/src/util.cc b/src/util.cc index e53556e4..e26e66be 100644 --- a/src/util.cc +++ b/src/util.cc @@ -28,6 +28,7 @@ #include "certificates.h" #include "gamma_lut.h" #include "xyz_frame.h" +#include "compose.hpp" #include "KM_util.h" #include "KM_fileio.h" #include "AS_DCP.h" @@ -39,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -55,7 +55,6 @@ using std::list; using std::setw; using std::setfill; using boost::shared_ptr; -using boost::lexical_cast; using namespace dcp; /** Create a UUID. @@ -211,7 +210,7 @@ dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce) if (!image) { opj_destroy_decompress (decoder); opj_cio_close (cio); - boost::throw_exception (DCPReadError ("could not decode JPEG2000 codestream of " + lexical_cast (size) + " bytes.")); + boost::throw_exception (DCPReadError (String::compose ("could not decode JPEG2000 codestream of %1 bytes.", size))); } opj_destroy_decompress (decoder); diff --git a/src/util.h b/src/util.h index e26c7332..e79c0a0b 100644 --- a/src/util.h +++ b/src/util.h @@ -86,6 +86,21 @@ extern std::string tm_to_string (struct tm *); extern std::string utc_offset_to_string (int); extern std::string ptime_to_string (boost::posix_time::ptime); extern FILE * fopen_boost (boost::filesystem::path, std::string); + +template +std::list > +list_of_type (std::list > const & from) +{ + std::list > out; + for (typename std::list >::const_iterator i = from.begin(); i != from.end(); ++i) { + boost::shared_ptr check = boost::dynamic_pointer_cast (*i); + if (check) { + out.push_back (check); + } + } + + return out; +} } diff --git a/wscript b/wscript index 1004ad54..baebc72e 100644 --- a/wscript +++ b/wscript @@ -34,6 +34,7 @@ def configure(conf): conf.check_cfg(package='xmlsec1', args='--cflags --libs', uselib_store='XMLSEC1', mandatory=True) # Remove erroneous escaping of quotes from xmlsec1 defines conf.env.DEFINES_XMLSEC1 = [f.replace('\\', '') for f in conf.env.DEFINES_XMLSEC1] + conf.check_cfg(package='', path='Magick++-config', args='--cppflags --cxxflags --libs', uselib_store='MAGICK', mandatory=False) if conf.options.static: conf.check_cc(fragment=""" -- 2.30.2