diff options
Diffstat (limited to 'src/lib/reel_writer.cc')
| -rw-r--r-- | src/lib/reel_writer.cc | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 76c1f8124..1291207c4 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -21,17 +21,13 @@ #include "audio_buffers.h" #include "config.h" -#include "constants.h" -#include "cross.h" #include "dcpomatic_log.h" #include "digester.h" #include "film.h" #include "film_util.h" #include "frame_info.h" -#include "image.h" #include "image_png.h" #include "job.h" -#include "log.h" #include "reel_writer.h" #include "remembered_asset.h" #include <dcp/atmos_asset.h> @@ -61,10 +57,8 @@ using std::dynamic_pointer_cast; -using std::exception; using std::list; using std::make_shared; -using std::map; using std::set; using std::shared_ptr; using std::string; @@ -471,13 +465,19 @@ maybe_add_text( } else { /* We don't have a subtitle asset of our own; hopefully we have one to reference */ - for (auto j: refs) { - auto k = dynamic_pointer_cast<Result>(j.asset); - if (k && j.period == period) { - 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()); + for (auto ref: refs) { + if (auto text = dynamic_pointer_cast<Result>(ref.asset)) { + if (ref.period.contains(period)) { + auto const vfr = film->video_frame_rate(); + reel_asset = text->clone(); + reel_asset->set_entry_point( + reel_asset->entry_point().get_value_or(0) + dcpomatic::DCPTime(period.from - ref.period.from).frames_round(vfr) + ); + reel_asset->set_duration(period.duration().frames_round(vfr)); + /* If we have a hash for this asset in the CPL, assume that it is correct */ + if (text->hash()) { + text->asset_ref()->set_hash(text->hash().get()); + } } } } @@ -516,13 +516,17 @@ ReelWriter::create_reel_picture(shared_ptr<dcp::Reel> reel, list<ReferencedReelA } else { LOG_GENERAL("no picture asset of our own; look through {}", refs.size()); /* We don't have a picture asset of our own; hopefully we have one to reference */ - for (auto j: refs) { - auto k = dynamic_pointer_cast<dcp::ReelPictureAsset>(j.asset); - if (k) { - LOG_GENERAL("candidate picture asset period is {}-{}", j.period.from.get(), j.period.to.get()); - } - if (k && j.period == _period) { - reel_asset = k; + for (auto ref: refs) { + if (auto picture = dynamic_pointer_cast<dcp::ReelPictureAsset>(ref.asset)) { + LOG_GENERAL("candidate picture asset period is {}-{}", ref.period.from.get(), ref.period.to.get()); + if (ref.period.contains(_period)) { + auto const vfr = film()->video_frame_rate(); + reel_asset = picture->clone(); + reel_asset->set_entry_point( + reel_asset->entry_point().get_value_or(0) + dcpomatic::DCPTime(_period.from - ref.period.from).frames_round(vfr) + ); + reel_asset->set_duration(_period.duration().frames_round(vfr)); + } } } } @@ -558,16 +562,20 @@ ReelWriter::create_reel_sound(shared_ptr<dcp::Reel> reel, list<ReferencedReelAss } else { LOG_GENERAL("no sound asset of our own; look through {}", refs.size()); /* We don't have a sound asset of our own; hopefully we have one to reference */ - for (auto j: refs) { - auto k = dynamic_pointer_cast<dcp::ReelSoundAsset>(j.asset); - if (k) { - LOG_GENERAL("candidate sound asset period is {}-{}", j.period.from.get(), j.period.to.get()); - } - if (k && j.period == _period) { - 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()); + for (auto ref: refs) { + if (auto sound = dynamic_pointer_cast<dcp::ReelSoundAsset>(ref.asset)) { + LOG_GENERAL("candidate sound asset period is {}-{}", ref.period.from.get(), ref.period.to.get()); + if (ref.period.contains(_period)) { + auto const vfr = film()->video_frame_rate(); + reel_asset = sound->clone(); + reel_asset->set_entry_point( + reel_asset->entry_point().get_value_or(0) + dcpomatic::DCPTime(_period.from - ref.period.from).frames_round(vfr) + ); + reel_asset->set_duration(_period.duration().frames_round(vfr)); + /* If we have a hash for this asset in the CPL, assume that it is correct */ + if (sound->hash()) { + sound->asset_ref()->set_hash(sound->hash().get()); + } } } } |
