{
/* Does not require a lock on _mutex as it's only called from DCPEncoder */
- list<ReferencedReelAsset> a;
+ list<ReferencedReelAsset> reel_assets;
- for (auto i: playlist()->content()) {
- auto j = dynamic_pointer_cast<DCPContent> (i);
- if (!j) {
+ for (auto content: playlist()->content()) {
+ auto dcp = dynamic_pointer_cast<DCPContent>(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<DCPDecoder> decoder;
try {
- decoder.reset (new DCPDecoder(_film, j, false, false, shared_ptr<DCPDecoder>()));
+ decoder.reset (new DCPDecoder(_film, dcp, false, false, shared_ptr<DCPDecoder>()));
} catch (...) {
- return a;
+ return reel_assets;
}
- DCPOMATIC_ASSERT (j->video_frame_rate ());
- double const cfr = j->video_frame_rate().get();
- Frame const trim_start = j->trim_start().frames_round (cfr);
- Frame const trim_end = j->trim_end().frames_round (cfr);
- int const ffr = _film->video_frame_rate ();
+ 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 in the asset from the end */
+ /* position i the asset from the end */
int64_t offset_from_end = 0;
- for (auto k: decoder->reels()) {
+ for (auto reel: decoder->reels()) {
/* Assume that main picture duration is the length of the reel */
- offset_from_end += k->main_picture()->actual_duration();
+ offset_from_end += reel->main_picture()->actual_duration();
}
- for (auto k: decoder->reels()) {
+ for (auto reel: decoder->reels()) {
/* Assume that main picture duration is the length of the reel */
- int64_t const reel_duration = k->main_picture()->actual_duration();
+ 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 = i->position() + DCPTime::from_frames (offset_from_start, _film->video_frame_rate());
- if (j->reference_video ()) {
- maybe_add_asset (a, k->main_picture(), reel_trim_start, reel_trim_end, from, ffr);
+ auto const from = max(DCPTime(), content->position() + DCPTime::from_frames(offset_from_start, frame_rate) - DCPTime::from_frames(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 (j->reference_audio ()) {
- maybe_add_asset (a, k->main_sound(), reel_trim_start, reel_trim_end, from, ffr);
+ if (dcp->reference_audio()) {
+ maybe_add_asset (reel_assets, reel->main_sound(), reel_trim_start, reel_trim_end, from, frame_rate);
}
- if (j->reference_text (TextType::OPEN_SUBTITLE)) {
- maybe_add_asset (a, k->main_subtitle(), reel_trim_start, reel_trim_end, from, ffr);
+ 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 (j->reference_text (TextType::CLOSED_CAPTION)) {
- for (auto l: k->closed_captions()) {
- maybe_add_asset (a, l, reel_trim_start, reel_trim_end, from, ffr);
+ 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);
}
}
}
}
- return a;
+ return reel_assets;
}
}
}
- /* We need a delay to give a little wiggle room to ensure that relevent subtitles arrive at the
+ /* We need a delay to give a little wiggle room to ensure that relevant subtitles arrive at the
player before the video that requires them.
*/
_delay.push_back (make_pair (pv, time));
void
-Player::atmos (weak_ptr<Piece>, ContentAtmos data)
+Player::atmos (weak_ptr<Piece> weak_piece, ContentAtmos data)
{
if (_suspended) {
return;
}
- Atmos (data.data, DCPTime::from_frames(data.frame, _film->video_frame_rate()), data.metadata);
+ auto piece = weak_piece.lock ();
+ DCPOMATIC_ASSERT (piece);
+
+ auto const vfr = _film->video_frame_rate();
+
+ DCPTime const dcp_time = DCPTime::from_frames(data.frame, vfr) - DCPTime(piece->content->trim_start(), FrameRateChange(vfr, vfr));
+ if (dcp_time < piece->content->position() || dcp_time >= (piece->content->end(_film))) {
+ return;
+ }
+
+ Atmos (data.data, dcp_time, data.metadata);
}