X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=499aa2a389c0c1545d82b915f17daef218d8df4e;hb=848d897596f00828cf1aa6c064d06e69bd40922c;hp=0bc460465e0dc5b9036a7c43a86ecdacced628a4;hpb=14c5566fe90b2584c7474c3250e6506d70e81510;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 0bc460465..499aa2a38 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -190,6 +190,7 @@ Player::playlist_content_changed (weak_ptr w, int property, bool freque property == SubtitleContentProperty::SHADOW || property == SubtitleContentProperty::EFFECT_COLOUR || property == FFmpegContentProperty::SUBTITLE_STREAM || + property == FFmpegContentProperty::FILTERS || property == VideoContentProperty::COLOUR_CONVERSION ) { @@ -526,8 +527,14 @@ Player::pass () optional earliest_time; BOOST_FOREACH (shared_ptr i, _pieces) { - if (!i->done) { - DCPTime const t = content_time_to_dcp (i, i->decoder->position()); + if (i->done) { + continue; + } + + DCPTime const t = content_time_to_dcp (i, i->decoder->position()); + if (t > i->content->end()) { + i->done = true; + } else { /* Given two choices at the same time, pick the one with a subtitle so we see it before the video. */ @@ -638,17 +645,17 @@ Player::subtitles_for_frame (DCPTime time) const return merge (subtitles); } -bool +void Player::video (weak_ptr wp, ContentVideo video) { shared_ptr piece = wp.lock (); if (!piece) { - return false; + return; } FrameRateChange frc(piece->content->active_video_frame_rate(), _film->video_frame_rate()); if (frc.skip && (video.frame % 2) == 1) { - return false; + return; } /* Time of the first frame we will emit */ @@ -659,7 +666,7 @@ Player::video (weak_ptr wp, ContentVideo video) time < piece->content->position() || time >= piece->content->end() || (_last_video_time && time < *_last_video_time)) { - return false; + return; } /* Fill gaps that we discover now that we have some video which needs to be emitted */ @@ -697,21 +704,16 @@ Player::video (weak_ptr wp, ContentVideo video) emit_video (_last_video[wp], t); t += one_video_frame (); } - - return true; } -/** @return Number of input frames that were `accepted'. This is the number of frames passed in - * unless some were discarded at the end of the block. - */ -Frame +void Player::audio (weak_ptr wp, AudioStreamPtr stream, ContentAudio content_audio) { DCPOMATIC_ASSERT (content_audio.audio->frames() > 0); shared_ptr piece = wp.lock (); if (!piece) { - return 0; + return; } shared_ptr content = piece->content->audio; @@ -722,33 +724,26 @@ Player::audio (weak_ptr wp, AudioStreamPtr stream, ContentAudio content_a /* And the end of this block in the DCP */ DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), content->resampled_frame_rate()); - /* We consider frames trimmed off the beginning to nevertheless be `accepted'; it's only frames trimmed - off the end that are considered as discarded. This logic is necessary to ensure correct reel lengths, - although the precise details escape me at the moment. - */ - Frame accepted = content_audio.audio->frames(); - /* Remove anything that comes before the start or after the end of the content */ if (time < piece->content->position()) { pair, DCPTime> cut = discard_audio (content_audio.audio, time, piece->content->position()); if (!cut.first) { /* This audio is entirely discarded */ - return accepted; + return; } content_audio.audio = cut.first; time = cut.second; } else if (time > piece->content->end()) { /* Discard it all */ - return 0; + return; } else if (end > piece->content->end()) { Frame const remaining_frames = DCPTime(piece->content->end() - time).frames_round(_film->audio_frame_rate()); if (remaining_frames == 0) { - return 0; + return; } shared_ptr cut (new AudioBuffers (content_audio.audio->channels(), remaining_frames)); cut->copy_from (content_audio.audio.get(), remaining_frames, 0, 0); content_audio.audio = cut; - accepted = content_audio.audio->frames(); } DCPOMATIC_ASSERT (content_audio.audio->frames() > 0); @@ -776,7 +771,6 @@ Player::audio (weak_ptr wp, AudioStreamPtr stream, ContentAudio content_a _audio_merger.push (content_audio.audio, time); DCPOMATIC_ASSERT (_stream_states.find (stream) != _stream_states.end ()); _stream_states[stream].last_push_end = time + DCPTime::from_frames (content_audio.audio->frames(), _film->audio_frame_rate()); - return accepted; } void