X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=0ff2c4032c0a2c7de5da3bdd381284e4a808feb9;hb=3005c17f626e739b2f8d63f203a0b0a3240eb530;hp=2793bd62a9e70583b5961f08506fa05f08e2d017;hpb=1c09ae94a4b94395ce2c13020a71526a65b9ce7e;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 2793bd62a..0ff2c4032 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" @@ -308,10 +307,9 @@ Player::playlist_content_change (ChangeType type, int property, bool frequent) { if (property == VideoContentProperty::CROP) { if (type == ChangeType::DONE) { - auto const vcs = video_container_size(); boost::mutex::scoped_lock lm (_mutex); for (auto const& i: _delay) { - i.first->reset_metadata (_film, vcs); + i.first->reset_metadata(_film, _video_container_size); } } } else { @@ -346,11 +344,9 @@ Player::set_video_container_size (dcp::Size s) _video_container_size = s; - { - boost::mutex::scoped_lock lm (_mutex); - _black_image = make_shared(AV_PIX_FMT_RGB24, _video_container_size, Image::Alignment::PADDED); - _black_image->make_black (); - } + auto black = make_shared(AV_PIX_FMT_RGB24, _video_container_size, Image::Alignment::PADDED); + black->make_black (); + std::atomic_store(&_black_image, black); Change (ChangeType::DONE, PlayerProperty::VIDEO_CONTAINER_SIZE, false); } @@ -401,8 +397,10 @@ Player::film_change (ChangeType type, Film::Property p) shared_ptr Player::black_player_video_frame (Eyes eyes) const { + auto black = std::atomic_load(&_black_image); + return std::make_shared ( - std::make_shared(_black_image), + std::make_shared(black), Crop(), optional(), _video_container_size, @@ -548,98 +546,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 () { @@ -651,7 +557,7 @@ Player::pass () return false; } - if (_playback_length == DCPTime()) { + if (_playback_length.load() == DCPTime()) { /* Special; just give one black frame */ emit_video (black_player_video_frame(Eyes::BOTH), DCPTime()); return true; @@ -789,7 +695,7 @@ Player::pass () } } - auto pull_to = _playback_length; + auto pull_to = _playback_length.load(); for (auto const& i: alive_stream_states) { if (!i.second.piece->done && i.second.last_push_end < pull_to) { pull_to = i.second.last_push_end;