From e4ed001fff70bd10b94e61bf36cdffd1a679286d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 25 May 2016 15:08:21 +0100 Subject: Basic writing of DCPs containing Atmos MXFs; untested. --- src/atmos_asset.cc | 2 ++ src/atmos_asset.h | 10 ++++++++ src/cpl.cc | 6 ++++- src/reel.cc | 38 ++++++++++++++++++++++++++++- src/reel.h | 12 +++++++-- src/reel_atmos_asset.cc | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/reel_atmos_asset.h | 57 +++++++++++++++++++++++++++++++++++++++++++ src/wscript | 2 ++ 8 files changed, 188 insertions(+), 4 deletions(-) create mode 100644 src/reel_atmos_asset.cc create mode 100644 src/reel_atmos_asset.h (limited to 'src') diff --git a/src/atmos_asset.cc b/src/atmos_asset.cc index 6c0c0e78..c0507a8a 100644 --- a/src/atmos_asset.cc +++ b/src/atmos_asset.cc @@ -38,6 +38,8 @@ AtmosAsset::AtmosAsset (boost::filesystem::path file) boost::throw_exception (DCPReadError ("could not read Atmos MXF information")); } + _edit_rate = Fraction (desc.EditRate.Numerator, desc.EditRate.Denominator); + _intrinsic_duration = desc.ContainerDuration; _first_frame = desc.FirstFrame; _max_channel_count = desc.MaxChannelCount; _max_object_count = desc.MaxObjectCount; diff --git a/src/atmos_asset.h b/src/atmos_asset.h index 602beb31..be756077 100644 --- a/src/atmos_asset.h +++ b/src/atmos_asset.h @@ -32,6 +32,14 @@ public: std::string pkl_type (Standard) const; + Fraction edit_rate () const { + return _edit_rate; + } + + int64_t intrinsic_duration () const { + return _intrinsic_duration; + } + /** @return frame number of the frame to align with the FFOA of the picture track */ int first_frame () const { return _first_frame; @@ -48,6 +56,8 @@ public: } private: + Fraction _edit_rate; + int64_t _intrinsic_duration; int _first_frame; int _max_channel_count; int _max_object_count; diff --git a/src/cpl.cc b/src/cpl.cc index 0d8221e2..1b7801a0 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ #include "reel_picture_asset.h" #include "reel_sound_asset.h" #include "reel_subtitle_asset.h" +#include "reel_atmos_asset.h" #include "local_time.h" #include "dcp_assert.h" #include "compose.hpp" @@ -175,6 +176,9 @@ CPL::reel_assets () const if (i->main_subtitle ()) { c.push_back (i->main_subtitle()); } + if (i->atmos ()) { + c.push_back (i->atmos()); + } } return c; diff --git a/src/reel.cc b/src/reel.cc index 772ac717..f7f267e4 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -31,6 +31,7 @@ #include "decrypted_kdm_key.h" #include "decrypted_kdm.h" #include "interop_subtitle_asset.h" +#include "reel_atmos_asset.h" #include using std::string; @@ -66,6 +67,11 @@ Reel::Reel (boost::shared_ptr node) _main_subtitle.reset (new ReelSubtitleAsset (main_subtitle)); } + shared_ptr atmos = asset_list->optional_node_child ("axd:AuxData"); + if (atmos) { + _atmos.reset (new ReelAtmosAsset (atmos)); + } + node->ignore_child ("AnnotationText"); node->done (); } @@ -94,6 +100,10 @@ Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const /* ... but stereo pictures must come after */ _main_picture->write_to_cpl (asset_list, standard); } + + if (_atmos) { + _atmos->write_to_cpl (asset_list, standard); + } } bool @@ -126,13 +136,26 @@ Reel::equals (boost::shared_ptr other, EqualityOptions opt, NoteHand return false; } + if ((_atmos && !other->_atmos) || (!_atmos && other->_atmos)) { + note (DCP_ERROR, "Reel: assets differ"); + return false; + } + + if (_atmos && !_atmos->equals (other->_atmos, opt, note)) { + return false; + } + return true; } bool Reel::encrypted () const { - return ((_main_picture && _main_picture->encrypted ()) || (_main_sound && _main_sound->encrypted ())); + return ( + (_main_picture && _main_picture->encrypted ()) || + (_main_sound && _main_sound->encrypted ()) || + (_atmos && _atmos->encrypted ()) + ); } void @@ -147,6 +170,9 @@ Reel::add (DecryptedKDM const & kdm) if (i->id() == _main_sound->key_id()) { _main_sound->asset()->set_key (i->key ()); } + if (i->id() == _atmos->key_id()) { + _atmos->asset()->set_key (i->key ()); + } } } @@ -156,12 +182,15 @@ Reel::add (shared_ptr asset) shared_ptr p = dynamic_pointer_cast (asset); shared_ptr so = dynamic_pointer_cast (asset); shared_ptr su = dynamic_pointer_cast (asset); + shared_ptr a = dynamic_pointer_cast (asset); if (p) { _main_picture = p; } else if (so) { _main_sound = so; } else if (su) { _main_subtitle = su; + } else if (a) { + _atmos = a; } } @@ -185,6 +214,10 @@ Reel::resolve_refs (list > assets) iop->resolve_fonts (assets); } } + + if (_atmos) { + _atmos->asset_ref().resolve (assets); + } } int64_t @@ -201,6 +234,9 @@ Reel::duration () const if (_main_subtitle) { d = max (d, _main_subtitle->duration ()); } + if (_atmos) { + d = max (d, _atmos->duration ()); + } return d; } diff --git a/src/reel.h b/src/reel.h index 8d7546fa..14ebaeb0 100644 --- a/src/reel.h +++ b/src/reel.h @@ -42,6 +42,7 @@ class ReelAsset; class ReelPictureAsset; class ReelSoundAsset; class ReelSubtitleAsset; +class ReelAtmosAsset; class Content; /** @brief A reel within a DCP; the part which actually refers to picture, sound and subtitle data */ @@ -52,12 +53,14 @@ public: Reel ( boost::shared_ptr picture, - boost::shared_ptr sound, - boost::shared_ptr subtitle + boost::shared_ptr sound = boost::shared_ptr (), + boost::shared_ptr subtitle = boost::shared_ptr (), + boost::shared_ptr atmos = boost::shared_ptr () ) : _main_picture (picture) , _main_sound (sound) , _main_subtitle (subtitle) + , _atmos (atmos) {} Reel (boost::shared_ptr); @@ -74,6 +77,10 @@ public: return _main_subtitle; } + boost::shared_ptr atmos () const { + return _atmos; + } + int64_t duration () const; void add (boost::shared_ptr asset); @@ -92,6 +99,7 @@ private: boost::shared_ptr _main_picture; boost::shared_ptr _main_sound; boost::shared_ptr _main_subtitle; + boost::shared_ptr _atmos; }; } diff --git a/src/reel_atmos_asset.cc b/src/reel_atmos_asset.cc new file mode 100644 index 00000000..5036b9de --- /dev/null +++ b/src/reel_atmos_asset.cc @@ -0,0 +1,65 @@ +/* + Copyright (C) 2016 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +/** @file src/reel_atmos_asset.cc + * @brief ReelAtmosAsset class. + */ + +#include "atmos_asset.h" +#include "reel_atmos_asset.h" +#include +#include + +using std::string; +using boost::shared_ptr; +using namespace dcp; + +ReelAtmosAsset::ReelAtmosAsset (boost::shared_ptr asset, int64_t entry_point) + : ReelAsset (asset, asset->edit_rate(), asset->intrinsic_duration(), entry_point) +{ + +} + +ReelAtmosAsset::ReelAtmosAsset (boost::shared_ptr node) + : ReelAsset (node) +{ + node->done (); +} + +string +ReelAtmosAsset::cpl_node_name () const +{ + return "axd:AuxData"; +} + +string +ReelAtmosAsset::key_type () const +{ + return "MDEK"; +} + +void +ReelAtmosAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const +{ + ReelAsset::write_to_cpl (node, standard); + + /* Find */ + xmlpp::Node* mp = find_child (node, cpl_node_name ()); + mp->add_child("axd:DataType")->add_child_text ("urn:smpte:ul:060e2b34.04010105.0e090604.00000000"); +} diff --git a/src/reel_atmos_asset.h b/src/reel_atmos_asset.h new file mode 100644 index 00000000..b5e0bc6e --- /dev/null +++ b/src/reel_atmos_asset.h @@ -0,0 +1,57 @@ +/* + Copyright (C) 2016 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +/** @file src/reel_atmos_asset.h + * @brief ReelAtmosAsset class. + */ + +#ifndef LIBDCP_REEL_ATMOS_ASSET_H +#define LIBDCP_REEL_ATMOS_ASSET_H + +#include "reel_asset.h" +#include "atmos_asset.h" +#include "reel_mxf.h" + +namespace dcp { + +class AtmosAsset; + +/** @class ReelAtmosAsset + * @brief Part of a Reel's description which refers to a Atmos MXF. + */ +class ReelAtmosAsset : public ReelAsset, public ReelMXF +{ +public: + ReelAtmosAsset (boost::shared_ptr asset, int64_t entry_point); + ReelAtmosAsset (boost::shared_ptr); + + boost::shared_ptr asset () const { + return asset_of_type (); + } + + void write_to_cpl (xmlpp::Node* node, Standard standard) const; + +private: + std::string key_type () const; + std::string cpl_node_name () const; +}; + +} + +#endif diff --git a/src/wscript b/src/wscript index 4fbfdb9a..86f99b33 100644 --- a/src/wscript +++ b/src/wscript @@ -56,6 +56,7 @@ def build(bld): picture_asset_writer.cc reel.cc reel_asset.cc + reel_atmos_asset.cc reel_mono_picture_asset.cc reel_mxf.cc reel_picture_asset.cc @@ -120,6 +121,7 @@ def build(bld): rgb_xyz.h reel.h reel_asset.h + reel_atmos_asset.h reel_mono_picture_asset.h reel_mxf.h reel_picture_asset.h -- cgit v1.2.3