diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-08 11:19:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-12-08 11:19:16 +0100 |
| commit | 6a5c7209770aa2c20d702b6f31d877ad2864ece7 (patch) | |
| tree | b74bb04c089f990c84f59d54622acd5241a805bd /src | |
| parent | dfb68bf9190ec0be31f01b61c17aebc8b6e30ad8 (diff) | |
Split create_reel() up into some separate bits.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/reel_writer.cc | 84 | ||||
| -rw-r--r-- | src/lib/reel_writer.h | 10 |
2 files changed, 67 insertions, 27 deletions
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index ab06819b1..bc1d65e49 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -507,25 +507,22 @@ maybe_add_text ( return reel_asset; } -shared_ptr<dcp::Reel> -ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts) -{ - LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count); - - shared_ptr<dcp::Reel> reel (new dcp::Reel ()); - shared_ptr<dcp::ReelPictureAsset> reel_picture_asset; +shared_ptr<dcp::ReelPictureAsset> +ReelWriter::create_reel_picture (shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs) const +{ + shared_ptr<dcp::ReelPictureAsset> reel_asset; if (_picture_asset) { /* We have made a picture asset of our own. Put it into the reel */ shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (_picture_asset); if (mono) { - reel_picture_asset.reset (new dcp::ReelMonoPictureAsset (mono, 0)); + reel_asset.reset (new dcp::ReelMonoPictureAsset (mono, 0)); } shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (_picture_asset); if (stereo) { - reel_picture_asset.reset (new dcp::ReelStereoPictureAsset (stereo, 0)); + reel_asset.reset (new dcp::ReelStereoPictureAsset (stereo, 0)); } } else { LOG_GENERAL ("no picture asset of our own; look through %1", refs.size()); @@ -536,32 +533,39 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr LOG_GENERAL ("candidate picture asset period is %1-%2", j.period.from.get(), j.period.to.get()); } if (k && j.period == _period) { - reel_picture_asset = k; + reel_asset = k; } } } Frame const period_duration = _period.duration().frames_round(_film->video_frame_rate()); - DCPOMATIC_ASSERT (reel_picture_asset); - if (reel_picture_asset->duration() != period_duration) { + DCPOMATIC_ASSERT (reel_asset); + if (reel_asset->duration() != period_duration) { throw ProgrammingError ( __FILE__, __LINE__, - String::compose ("%1 vs %2", reel_picture_asset->actual_duration(), period_duration) + String::compose ("%1 vs %2", reel_asset->actual_duration(), period_duration) ); } - reel->add (reel_picture_asset); + reel->add (reel_asset); /* If we have a hash for this asset in the CPL, assume that it is correct */ - if (reel_picture_asset->hash()) { - reel_picture_asset->asset_ref()->set_hash (reel_picture_asset->hash().get()); + if (reel_asset->hash()) { + reel_asset->asset_ref()->set_hash (reel_asset->hash().get()); } - shared_ptr<dcp::ReelSoundAsset> reel_sound_asset; + return reel_asset; +} + + +void +ReelWriter::create_reel_sound (shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs) const +{ + shared_ptr<dcp::ReelSoundAsset> reel_asset; if (_sound_asset) { /* We have made a sound asset of our own. Put it into the reel */ - reel_sound_asset.reset (new dcp::ReelSoundAsset (_sound_asset, 0)); + reel_asset.reset (new dcp::ReelSoundAsset(_sound_asset, 0)); } else { LOG_GENERAL ("no sound asset of our own; look through %1", refs.size()); /* We don't have a sound asset of our own; hopefully we have one to reference */ @@ -571,7 +575,7 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr LOG_GENERAL ("candidate sound asset period is %1-%2", j.period.from.get(), j.period.to.get()); } if (k && j.period == _period) { - reel_sound_asset = k; + reel_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()); @@ -580,31 +584,38 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr } } - DCPOMATIC_ASSERT (reel_sound_asset); - if (reel_sound_asset->actual_duration() != period_duration) { + Frame const period_duration = _period.duration().frames_round(_film->video_frame_rate()); + + DCPOMATIC_ASSERT (reel_asset); + if (reel_asset->actual_duration() != period_duration) { LOG_ERROR ( "Reel sound asset has length %1 but reel period is %2", - reel_sound_asset->actual_duration(), + reel_asset->actual_duration(), period_duration ); - if (reel_sound_asset->actual_duration() != period_duration) { + if (reel_asset->actual_duration() != period_duration) { throw ProgrammingError ( __FILE__, __LINE__, - String::compose ("%1 vs %2", reel_sound_asset->actual_duration(), period_duration) + String::compose ("%1 vs %2", reel_asset->actual_duration(), period_duration) ); } } - reel->add (reel_sound_asset); + reel->add (reel_asset); +} + - shared_ptr<dcp::ReelSubtitleAsset> subtitle = maybe_add_text<dcp::ReelSubtitleAsset> (_subtitle_asset, reel_picture_asset->actual_duration(), reel, refs, fonts, _film, _period); +void +ReelWriter::create_reel_text (shared_ptr<dcp::Reel> reel, list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const& fonts, int64_t duration) const +{ + shared_ptr<dcp::ReelSubtitleAsset> subtitle = maybe_add_text<dcp::ReelSubtitleAsset> (_subtitle_asset, duration, reel, refs, fonts, _film, _period); if (subtitle && !_film->subtitle_languages().empty()) { subtitle->set_language (_film->subtitle_languages().front()); } for (map<DCPTextTrack, shared_ptr<dcp::SubtitleAsset> >::const_iterator i = _closed_caption_assets.begin(); i != _closed_caption_assets.end(); ++i) { shared_ptr<dcp::ReelClosedCaptionAsset> a = maybe_add_text<dcp::ReelClosedCaptionAsset> ( - i->second, reel_picture_asset->actual_duration(), reel, refs, fonts, _film, _period + i->second, duration, reel, refs, fonts, _film, _period ); if (a) { a->set_annotation_text (i->first.name); @@ -613,7 +624,13 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr } } } +} + + +void +ReelWriter::create_reel_markers (shared_ptr<dcp::Reel> reel) const +{ Film::Markers markers = _film->markers (); _film->add_ffoc_lfoc (markers); Film::Markers reel_markers; @@ -633,6 +650,19 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr } reel->add (ma); } +} + + +shared_ptr<dcp::Reel> +ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts) +{ + LOG_GENERAL ("create_reel for %1-%2; %3 of %4", _period.from.get(), _period.to.get(), _reel_index, _reel_count); + + shared_ptr<dcp::Reel> reel (new dcp::Reel()); + shared_ptr<dcp::ReelPictureAsset> reel_picture_asset = create_reel_picture (reel, refs); + create_reel_sound (reel, refs); + create_reel_text (reel, refs, fonts, reel_picture_asset->actual_duration()); + create_reel_markers (reel); if (_atmos_asset) { reel->add (shared_ptr<dcp::ReelAtmosAsset>(new dcp::ReelAtmosAsset(_atmos_asset, 0))); diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index fd11d17aa..2b3b6e237 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -52,6 +52,7 @@ namespace dcp { class AtmosAsset; class ReelAsset; class Reel; + class ReelPictureAsset; } class ReelWriter @@ -97,6 +98,15 @@ private: Frame check_existing_picture_asset (boost::filesystem::path asset); bool existing_picture_frame_ok (FILE* asset_file, boost::shared_ptr<InfoFileHandle> info_file, Frame frame) const; + boost::shared_ptr<dcp::ReelPictureAsset> create_reel_picture (boost::shared_ptr<dcp::Reel> reel, std::list<ReferencedReelAsset> const & refs) const; + void create_reel_sound (boost::shared_ptr<dcp::Reel> reel, std::list<ReferencedReelAsset> const & refs) const; + void create_reel_text ( + boost::shared_ptr<dcp::Reel> reel, + std::list<ReferencedReelAsset> const & refs, std::list<boost::shared_ptr<dcpomatic::Font> > const& fonts, + int64_t duration + ) const; + void create_reel_markers (boost::shared_ptr<dcp::Reel> reel) const; + boost::shared_ptr<const Film> _film; dcpomatic::DCPTimePeriod _period; |
