X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=13cd8f11badcb35102f33af52249d3abdbcdc79c;hb=c8bd4ead4c9e757d88136a7fdd556272f36be793;hp=0c0c68b3a502ac4bf0f36aece900a57cc8010f04;hpb=64a27cef84b97edd665d4891efb8ba5c9d78b70f;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 0c0c68b3a..13cd8f11b 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -47,7 +47,6 @@ #include "playlist.h" #include "ratio.h" #include "raw_image_proxy.h" -#include "referenced_reel_asset.h" #include "render_text.h" #include "shuffler.h" #include "text_content.h" @@ -548,98 +547,6 @@ Player::set_play_referenced () } -static void -maybe_add_asset (list& a, shared_ptr r, Frame reel_trim_start, Frame reel_trim_end, DCPTime from, int const ffr) -{ - DCPOMATIC_ASSERT (r); - r->set_entry_point (r->entry_point().get_value_or(0) + reel_trim_start); - r->set_duration (r->actual_duration() - reel_trim_start - reel_trim_end); - if (r->actual_duration() > 0) { - a.push_back ( - ReferencedReelAsset(r, DCPTimePeriod(from, from + DCPTime::from_frames(r->actual_duration(), ffr))) - ); - } -} - - -list -Player::get_reel_assets () -{ - /* Does not require a lock on _mutex as it's only called from DCPEncoder */ - - list reel_assets; - - for (auto content: playlist()->content()) { - auto dcp = dynamic_pointer_cast(content); - if (!dcp) { - continue; - } - - if (!dcp->reference_video() && !dcp->reference_audio() && !dcp->reference_text(TextType::OPEN_SUBTITLE) && !dcp->reference_text(TextType::CLOSED_CAPTION)) { - continue; - } - - scoped_ptr decoder; - try { - decoder.reset (new DCPDecoder(_film, dcp, false, false, shared_ptr())); - } catch (...) { - return reel_assets; - } - - auto const frame_rate = _film->video_frame_rate(); - DCPOMATIC_ASSERT (dcp->video_frame_rate()); - /* We should only be referencing if the DCP rate is the same as the film rate */ - DCPOMATIC_ASSERT (std::round(dcp->video_frame_rate().get()) == frame_rate); - - Frame const trim_start = dcp->trim_start().frames_round(frame_rate); - Frame const trim_end = dcp->trim_end().frames_round(frame_rate); - - /* position in the asset from the start */ - int64_t offset_from_start = 0; - /* position i the asset from the end */ - int64_t offset_from_end = 0; - for (auto reel: decoder->reels()) { - /* Assume that main picture duration is the length of the reel */ - offset_from_end += reel->main_picture()->actual_duration(); - } - - for (auto reel: decoder->reels()) { - - /* Assume that main picture duration is the length of the reel */ - int64_t const reel_duration = reel->main_picture()->actual_duration(); - - /* See doc/design/trim_reels.svg */ - Frame const reel_trim_start = min(reel_duration, max(int64_t(0), trim_start - offset_from_start)); - Frame const reel_trim_end = min(reel_duration, max(int64_t(0), reel_duration - (offset_from_end - trim_end))); - - auto const from = content->position() + std::max(DCPTime(), DCPTime::from_frames(offset_from_start - trim_start, frame_rate)); - if (dcp->reference_video()) { - maybe_add_asset (reel_assets, reel->main_picture(), reel_trim_start, reel_trim_end, from, frame_rate); - } - - if (dcp->reference_audio()) { - maybe_add_asset (reel_assets, reel->main_sound(), reel_trim_start, reel_trim_end, from, frame_rate); - } - - if (dcp->reference_text(TextType::OPEN_SUBTITLE)) { - maybe_add_asset (reel_assets, reel->main_subtitle(), reel_trim_start, reel_trim_end, from, frame_rate); - } - - if (dcp->reference_text(TextType::CLOSED_CAPTION)) { - for (auto caption: reel->closed_captions()) { - maybe_add_asset (reel_assets, caption, reel_trim_start, reel_trim_end, from, frame_rate); - } - } - - offset_from_start += reel_duration; - offset_from_end -= reel_duration; - } - } - - return reel_assets; -} - - bool Player::pass () { @@ -1421,7 +1328,7 @@ Player::set_dcp_decode_reduction (optional reduction) optional -Player::content_time_to_dcp (shared_ptr content, ContentTime t) +Player::content_time_to_dcp (shared_ptr content, ContentTime t) const { boost::mutex::scoped_lock lm (_mutex); @@ -1437,7 +1344,7 @@ Player::content_time_to_dcp (shared_ptr content, ContentTime t) optional -Player::dcp_to_content_time (shared_ptr content, DCPTime t) +Player::dcp_to_content_time (shared_ptr content, DCPTime t) const { boost::mutex::scoped_lock lm (_mutex);