X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=c7d7b2f441ddd4aff76d4cdd7ee6ee2667e108c7;hb=131646786964241429888af6296e4ff089ce5900;hp=6ec593f6c8569e8d5a3d97e4efc113876b0587dd;hpb=800c0b9f95f422af66b6166fb4d13c1b89d04844;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 6ec593f6c..c7d7b2f44 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -206,14 +206,15 @@ Player::playlist_content_changed (weak_ptr w, int property, bool freque property == ContentProperty::TRIM_END || property == ContentProperty::PATH || property == VideoContentProperty::FRAME_TYPE || + property == VideoContentProperty::COLOUR_CONVERSION || + property == AudioContentProperty::STREAMS || property == DCPContentProperty::NEEDS_ASSETS || property == DCPContentProperty::NEEDS_KDM || property == SubtitleContentProperty::COLOUR || property == SubtitleContentProperty::EFFECT || property == SubtitleContentProperty::EFFECT_COLOUR || property == FFmpegContentProperty::SUBTITLE_STREAM || - property == FFmpegContentProperty::FILTERS || - property == VideoContentProperty::COLOUR_CONVERSION + property == FFmpegContentProperty::FILTERS ) { _have_valid_pieces = false; @@ -301,18 +302,6 @@ Player::transform_image_subtitles (list subs) const /* We will scale the subtitle up to fit _video_container_size */ dcp::Size scaled_size (i->rectangle.width * _video_container_size.width, i->rectangle.height * _video_container_size.height); - /* Then we need a corrective translation, consisting of two parts: - * - * 1. that which is the result of the scaling of the subtitle by _video_container_size; this will be - * rect.x * _video_container_size.width and rect.y * _video_container_size.height. - * - * 2. that to shift the origin of the scale by subtitle_scale to the centre of the subtitle; this will be - * (width_before_subtitle_scale * (1 - subtitle_x_scale) / 2) and - * (height_before_subtitle_scale * (1 - subtitle_y_scale) / 2). - * - * Combining these two translations gives these expressions. - */ - all.push_back ( PositionImage ( i->image->scale ( @@ -862,14 +851,14 @@ Player::image_subtitle_start (weak_ptr wp, ContentImageSubtitle subtitle) subtitle.sub.rectangle.x += piece->content->subtitle->x_offset (); subtitle.sub.rectangle.y += piece->content->subtitle->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 * ((piece->content->subtitle->x_scale() - 1) / 2); + subtitle.sub.rectangle.y -= subtitle.sub.rectangle.height * ((piece->content->subtitle->y_scale() - 1) / 2); + /* Apply content's subtitle scale */ subtitle.sub.rectangle.width *= piece->content->subtitle->x_scale (); subtitle.sub.rectangle.height *= piece->content->subtitle->y_scale (); - /* Apply a corrective translation to keep the subtitle centred after that scale */ - subtitle.sub.rectangle.x -= subtitle.sub.rectangle.width * (piece->content->subtitle->x_scale() - 1); - subtitle.sub.rectangle.y -= subtitle.sub.rectangle.height * (piece->content->subtitle->y_scale() - 1); - PlayerSubtitles ps; ps.image.push_back (subtitle.sub); DCPTime from (content_time_to_dcp (piece, subtitle.from())); @@ -888,6 +877,10 @@ Player::text_subtitle_start (weak_ptr wp, ContentTextSubtitle subtitle) PlayerSubtitles ps; DCPTime const from (content_time_to_dcp (piece, subtitle.from())); + if (from > piece->content->end()) { + return; + } + BOOST_FOREACH (dcp::SubtitleString s, subtitle.subs) { s.set_h_position (s.h_position() + piece->content->subtitle->x_offset ()); s.set_v_position (s.v_position() + piece->content->subtitle->y_offset ()); @@ -930,6 +923,10 @@ Player::subtitle_stop (weak_ptr wp, ContentTime to) DCPTime const dcp_to = content_time_to_dcp (piece, to); + if (dcp_to > piece->content->end()) { + return; + } + pair from = _active_subtitles.add_to (wp, dcp_to); if (piece->content->subtitle->use() && !_always_burn_subtitles && !piece->content->subtitle->burn()) { @@ -959,8 +956,8 @@ Player::seek (DCPTime time, bool accurate) BOOST_FOREACH (shared_ptr i, _pieces) { if (time < i->content->position()) { - /* Before; seek to 0 */ - i->decoder->seek (ContentTime(), accurate); + /* Before; seek to the start of the content */ + i->decoder->seek (dcp_to_content_time (i, i->content->position()), accurate); i->done = false; } else if (i->content->position() <= time && time < i->content->end()) { /* During; seek to position */