X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=db99cd2ad81626bbe10180bc3e28ea9ea878cf43;hb=c6c082c4a8016f85ba4207f4b8ccee1d5770e4a4;hp=c8ac591a7b2919a36a6f77080dad538417c08982;hpb=40b654453c2ce0b266f43c36f1b9a5d1705f983c;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index c8ac591a7..db99cd2ad 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -17,8 +17,6 @@ */ -#include -#include #include "player.h" #include "film.h" #include "ffmpeg_decoder.h" @@ -31,6 +29,7 @@ #include "subtitle_content.h" #include "subrip_decoder.h" #include "subrip_content.h" +#include "dcp_content.h" #include "playlist.h" #include "job.h" #include "image.h" @@ -47,6 +46,9 @@ #include "dcp_decoder.h" #include "dcp_subtitle_content.h" #include "dcp_subtitle_decoder.h" +#include +#include +#include #define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), Log::TYPE_GENERAL); @@ -189,7 +191,8 @@ Player::content_changed (weak_ptr w, int property, bool frequent) property == ContentProperty::TRIM_START || property == ContentProperty::TRIM_END || property == ContentProperty::PATH || - property == VideoContentProperty::VIDEO_FRAME_TYPE + property == VideoContentProperty::VIDEO_FRAME_TYPE || + property == DCPContentProperty::CAN_BE_PLAYED ) { _have_valid_pieces = false; @@ -199,7 +202,8 @@ Player::content_changed (weak_ptr w, int property, bool frequent) property == SubtitleContentProperty::USE_SUBTITLES || property == SubtitleContentProperty::SUBTITLE_X_OFFSET || property == SubtitleContentProperty::SUBTITLE_Y_OFFSET || - property == SubtitleContentProperty::SUBTITLE_SCALE || + property == SubtitleContentProperty::SUBTITLE_X_SCALE || + property == SubtitleContentProperty::SUBTITLE_Y_SCALE || property == VideoContentProperty::VIDEO_CROP || property == VideoContentProperty::VIDEO_SCALE || property == VideoContentProperty::VIDEO_FRAME_RATE @@ -258,8 +262,8 @@ Player::transform_image_subtitles (list subs) const * 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_scale) / 2) and - * (height_before_subtitle_scale * (1 - subtitle_scale) / 2). + * (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. */ @@ -297,6 +301,7 @@ Player::black_player_video_frame (DCPTime time) const shared_ptr (new RawImageProxy (_black_image, _film->log ())), time, Crop (), + optional (), _video_container_size, _video_container_size, Scaler::from_id ("bicubic"), @@ -340,7 +345,7 @@ Player::get_video (DCPTime time, bool accurate) return pvf; } - dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ()); + dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size (), _approximate_size ? 4 : 1); if (_approximate_size) { image_size.width &= ~3; image_size.height &= ~3; @@ -353,6 +358,7 @@ Player::get_video (DCPTime time, bool accurate) i->image, content_video_to_dcp (piece, i->frame), content->crop (), + content->fade (i->frame), image_size, _video_container_size, _film->scaler(), @@ -556,19 +562,23 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting) i->sub.rectangle.y += subtitle_content->subtitle_y_offset (); /* Apply content's subtitle scale */ - i->sub.rectangle.width *= subtitle_content->subtitle_scale (); - i->sub.rectangle.height *= subtitle_content->subtitle_scale (); + i->sub.rectangle.width *= subtitle_content->subtitle_x_scale (); + i->sub.rectangle.height *= subtitle_content->subtitle_y_scale (); /* Apply a corrective translation to keep the subtitle centred after that scale */ - i->sub.rectangle.x -= i->sub.rectangle.width * (subtitle_content->subtitle_scale() - 1); - i->sub.rectangle.y -= i->sub.rectangle.height * (subtitle_content->subtitle_scale() - 1); + i->sub.rectangle.x -= i->sub.rectangle.width * (subtitle_content->subtitle_x_scale() - 1); + i->sub.rectangle.y -= i->sub.rectangle.height * (subtitle_content->subtitle_y_scale() - 1); ps.image.push_back (i->sub); } list text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting); - for (list::const_iterator i = text.begin(); i != text.end(); ++i) { - copy (i->subs.begin(), i->subs.end(), back_inserter (ps.text)); + BOOST_FOREACH (ContentTextSubtitle& ts, text) { + BOOST_FOREACH (dcp::SubtitleString& s, ts.subs) { + s.set_v_position (s.v_position() + subtitle_content->subtitle_y_offset ()); + s.set_size (s.size() * max (subtitle_content->subtitle_x_scale(), subtitle_content->subtitle_y_scale())); + ps.text.push_back (s); + } } }