From 3fd978f5b32794c5777122e719dfae7a45146b2c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 May 2017 11:57:34 +0100 Subject: [PATCH] Assert that reel assets are all the same length. --- src/lib/reel_writer.cc | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index e008bf631..d05e3901e 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -361,6 +361,7 @@ ReelWriter::create_reel (list const & refs, listintrinsic_duration() == _period.duration().frames_round (_film->video_frame_rate ())); reel->add (reel_picture_asset); /* If we have a hash for this asset in the CPL, assume that it is correct */ @@ -368,15 +369,17 @@ ReelWriter::create_reel (list const & refs, listasset_ref()->set_hash (reel_picture_asset->hash().get()); } + shared_ptr reel_sound_asset; + if (_sound_asset) { /* We have made a sound asset of our own. Put it into the reel */ - reel->add (shared_ptr (new dcp::ReelSoundAsset (_sound_asset, 0))); + reel_sound_asset.reset (new dcp::ReelSoundAsset (_sound_asset, 0)); } else { /* We don't have a sound asset of our own; hopefully we have one to reference */ BOOST_FOREACH (ReferencedReelAsset j, refs) { shared_ptr k = dynamic_pointer_cast (j.asset); if (k && j.period == _period) { - reel->add (k); + reel_sound_asset = k; /* If we have a hash for this asset in the CPL, assume that it is correct */ if (k->hash()) { k->asset_ref()->set_hash (k->hash().get()); @@ -385,6 +388,12 @@ ReelWriter::create_reel (list const & refs, listintrinsic_duration() == _period.duration().frames_round (_film->video_frame_rate ())); + reel->add (reel_sound_asset); + + shared_ptr reel_subtitle_asset; + if (_subtitle_asset) { boost::filesystem::path liberation_normal; @@ -425,20 +434,20 @@ ReelWriter::create_reel (list const & refs, listadd (shared_ptr ( - new dcp::ReelSubtitleAsset ( - _subtitle_asset, - dcp::Fraction (_film->video_frame_rate(), 1), - reel_picture_asset->intrinsic_duration (), - 0 - ) - )); + reel_subtitle_asset.reset ( + new dcp::ReelSubtitleAsset ( + _subtitle_asset, + dcp::Fraction (_film->video_frame_rate(), 1), + reel_picture_asset->intrinsic_duration (), + 0 + ) + ); } else { /* We don't have a subtitle asset of our own; hopefully we have one to reference */ BOOST_FOREACH (ReferencedReelAsset j, refs) { shared_ptr k = dynamic_pointer_cast (j.asset); if (k && j.period == _period) { - reel->add (k); + reel_subtitle_asset = k; /* If we have a hash for this asset in the CPL, assume that it is correct */ if (k->hash()) { k->asset_ref()->set_hash (k->hash().get()); @@ -447,6 +456,11 @@ ReelWriter::create_reel (list const & refs, listintrinsic_duration() == _period.duration().frames_round (_film->video_frame_rate ())); + reel->add (reel_subtitle_asset); + } + return reel; } -- 2.30.2