X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=53b1733330764aa5b76b988f58b096da6a331f62;hp=981078636bf87764fe172783a371668b7fcbe380;hb=d2e40a18eee940f1333c7e63d423b1d56e50c5e6;hpb=8cabf6045c7b101fda647ed65db6a9066b8a0efd diff --git a/src/lib/player.cc b/src/lib/player.cc index 981078636..53b173333 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -166,8 +166,19 @@ Player::setup_pieces_unlocked () auto old_pieces = _pieces; _pieces.clear (); - _shuffler.reset (new Shuffler()); - _shuffler->Video.connect(bind(&Player::video, this, _1, _2)); + auto playlist_content = playlist()->content(); + bool const have_threed = std::any_of( + playlist_content.begin(), + playlist_content.end(), + [](shared_ptr c) { + return c->video && (c->video->frame_type() == VideoFrameType::THREE_D_LEFT || c->video->frame_type() == VideoFrameType::THREE_D_RIGHT); + }); + + + if (have_threed) { + _shuffler.reset(new Shuffler()); + _shuffler->Video.connect(bind(&Player::video, this, _1, _2)); + } for (auto i: playlist()->content()) { @@ -219,7 +230,7 @@ Player::setup_pieces_unlocked () _pieces.push_back (piece); if (decoder->video) { - if (i->video->frame_type() == VideoFrameType::THREE_D_LEFT || i->video->frame_type() == VideoFrameType::THREE_D_RIGHT) { + if (have_threed) { /* We need a Shuffler to cope with 3D L/R video data arriving out of sequence */ decoder->video->Data.connect (bind(&Shuffler::video, _shuffler.get(), weak_ptr(piece), _1)); } else { @@ -810,7 +821,9 @@ Player::pass () } if (done) { - _shuffler->flush (); + if (_shuffler) { + _shuffler->flush (); + } for (auto const& i: _delay) { do_emit_video(i.first, i.second); } @@ -1104,32 +1117,35 @@ Player::bitmap_text_start (weak_ptr weak_piece, weak_ptrx_offset (); - subtitle.sub.rectangle.y += content->y_offset (); + PlayerText ps; + for (auto& sub: subtitle.subs) + { + /* Apply content's subtitle offsets */ + sub.rectangle.x += content->x_offset (); + sub.rectangle.y += content->y_offset (); - /* Apply a corrective translation to keep the subtitle centred after the scale that is coming up */ - subtitle.sub.rectangle.x -= subtitle.sub.rectangle.width * ((content->x_scale() - 1) / 2); - subtitle.sub.rectangle.y -= subtitle.sub.rectangle.height * ((content->y_scale() - 1) / 2); + /* Apply a corrective translation to keep the subtitle centred after the scale that is coming up */ + sub.rectangle.x -= sub.rectangle.width * ((content->x_scale() - 1) / 2); + sub.rectangle.y -= sub.rectangle.height * ((content->y_scale() - 1) / 2); - /* Apply content's subtitle scale */ - subtitle.sub.rectangle.width *= content->x_scale (); - subtitle.sub.rectangle.height *= content->y_scale (); + /* Apply content's subtitle scale */ + sub.rectangle.width *= content->x_scale (); + sub.rectangle.height *= content->y_scale (); - PlayerText ps; - auto image = subtitle.sub.image; + auto image = sub.image; - /* We will scale the subtitle up to fit _video_container_size */ - int const width = subtitle.sub.rectangle.width * _video_container_size.width; - int const height = subtitle.sub.rectangle.height * _video_container_size.height; - if (width == 0 || height == 0) { - return; - } + /* We will scale the subtitle up to fit _video_container_size */ + int const width = sub.rectangle.width * _video_container_size.width; + int const height = sub.rectangle.height * _video_container_size.height; + if (width == 0 || height == 0) { + return; + } - dcp::Size scaled_size (width, height); - ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUVToRGB::REC601, image->pixel_format(), Image::Alignment::PADDED, _fast), subtitle.sub.rectangle)); - DCPTime from (content_time_to_dcp (piece, subtitle.from())); + dcp::Size scaled_size (width, height); + ps.bitmap.push_back (BitmapText(image->scale(scaled_size, dcp::YUVToRGB::REC601, image->pixel_format(), Image::Alignment::PADDED, _fast), sub.rectangle)); + } + DCPTime from(content_time_to_dcp(piece, subtitle.from())); _active_texts[static_cast(content->type())].add_from(weak_content, ps, from); } @@ -1429,6 +1445,22 @@ Player::content_time_to_dcp (shared_ptr content, ContentTime t) } +optional +Player::dcp_to_content_time (shared_ptr content, DCPTime t) +{ + boost::mutex::scoped_lock lm (_mutex); + + for (auto i: _pieces) { + if (i->content == content) { + return dcp_to_content_time (i, t); + } + } + + /* We couldn't find this content; perhaps things are being changed over */ + return {}; +} + + shared_ptr Player::playlist () const {