From ab011bbc0d68ff676a672c7c4c1bef81e84a5007 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 13 Jun 2014 12:02:55 +0100 Subject: Remove Player::_burn_subtitles; allow subtitles to be burnt onto areas with no video content. --- src/lib/player.cc | 155 +++++++++++++++++++++++++----------------------------- src/lib/player.h | 10 ---- 2 files changed, 71 insertions(+), 94 deletions(-) (limited to 'src/lib') diff --git a/src/lib/player.cc b/src/lib/player.cc index 8df7ec323..418f360fe 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -65,7 +65,6 @@ Player::Player (shared_ptr f, shared_ptr p) , _playlist (p) , _have_valid_pieces (false) , _approximate_size (false) - , _burn_subtitles (false) { _playlist_changed_connection = _playlist->Changed.connect (bind (&Player::playlist_changed, this)); _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3)); @@ -309,64 +308,6 @@ Player::black_player_video_frame () const ); } -shared_ptr -Player::content_to_player_video_frame ( - shared_ptr content, - ContentVideo content_video, - list > subs, - DCPTime time, - dcp::Size image_size) const -{ - shared_ptr pvf ( - new PlayerVideoFrame ( - content_video.image, - content->crop (), - image_size, - _video_container_size, - _film->scaler(), - content_video.eyes, - content_video.part, - content->colour_conversion () - ) - ); - - - /* Add subtitles */ - - list sub_images; - - for (list >::const_iterator i = subs.begin(); i != subs.end(); ++i) { - shared_ptr subtitle_decoder = dynamic_pointer_cast ((*i)->decoder); - shared_ptr subtitle_content = dynamic_pointer_cast ((*i)->content); - ContentTime const from = dcp_to_content_subtitle (*i, time); - ContentTime const to = from + ContentTime::from_frames (1, content->video_frame_rate ()); - - list > image_subtitles = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to)); - if (!image_subtitles.empty ()) { - list im = process_content_image_subtitles ( - subtitle_content, - image_subtitles - ); - - copy (im.begin(), im.end(), back_inserter (sub_images)); - } - - if (_burn_subtitles) { - list > text_subtitles = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to)); - if (!text_subtitles.empty ()) { - list im = process_content_text_subtitles (text_subtitles); - copy (im.begin(), im.end(), back_inserter (sub_images)); - } - } - } - - if (!sub_images.empty ()) { - pvf->set_subtitle (merge (sub_images)); - } - - return pvf; -} - /** @return All PlayerVideoFrames at the given time (there may be two frames for 3D) */ list > Player::get_video (DCPTime time, bool accurate) @@ -381,41 +322,87 @@ Player::get_video (DCPTime time, bool accurate) ); list > pvf; - + if (ov.empty ()) { /* No video content at this time */ pvf.push_back (black_player_video_frame ()); - return pvf; - } + } else { + /* Create a PlayerVideoFrame from the content's video at this time */ - /* Create a PlayerVideoFrame from the content's video at this time */ - - shared_ptr piece = ov.back (); - shared_ptr decoder = dynamic_pointer_cast (piece->decoder); - assert (decoder); - shared_ptr content = dynamic_pointer_cast (piece->content); - assert (content); + shared_ptr piece = ov.back (); + shared_ptr decoder = dynamic_pointer_cast (piece->decoder); + assert (decoder); + shared_ptr content = dynamic_pointer_cast (piece->content); + assert (content); - list content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate); - if (content_video.empty ()) { - pvf.push_back (black_player_video_frame ()); - return pvf; + list content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate); + if (content_video.empty ()) { + pvf.push_back (black_player_video_frame ()); + return pvf; + } + + dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ()); + if (_approximate_size) { + image_size.width &= ~3; + image_size.height &= ~3; + } + + for (list::const_iterator i = content_video.begin(); i != content_video.end(); ++i) { + pvf.push_back ( + shared_ptr ( + new PlayerVideoFrame ( + i->image, + content->crop (), + image_size, + _video_container_size, + _film->scaler(), + i->eyes, + i->part, + content->colour_conversion () + ) + ) + ); + } } - dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ()); - if (_approximate_size) { - image_size.width &= ~3; - image_size.height &= ~3; - } + /* Add subtitles to whatever PlayerVideoFrames we got */ + + list > subs = overlaps ( + time, + time + DCPTime::from_frames (1, _film->video_frame_rate ()) + ); - for (list::const_iterator i = content_video.begin(); i != content_video.end(); ++i) { - list > subs = overlaps ( - time, - time + DCPTime::from_frames (1, _film->video_frame_rate ()) - ); + list sub_images; + + for (list >::const_iterator j = subs.begin(); j != subs.end(); ++j) { + shared_ptr subtitle_decoder = dynamic_pointer_cast ((*j)->decoder); + shared_ptr subtitle_content = dynamic_pointer_cast ((*j)->content); + ContentTime const from = dcp_to_content_subtitle (*j, time); + /* XXX: this video_frame_rate() should be the rate that the subtitle content has been prepared for */ + ContentTime const to = from + ContentTime::from_frames (1, _film->video_frame_rate ()); + + list > image_subtitles = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to)); + if (!image_subtitles.empty ()) { + list im = process_content_image_subtitles ( + subtitle_content, + image_subtitles + ); + + copy (im.begin(), im.end(), back_inserter (sub_images)); + } - pvf.push_back (content_to_player_video_frame (content, *i, subs, time, image_size)); + list > text_subtitles = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to)); + if (!text_subtitles.empty ()) { + list im = process_content_text_subtitles (text_subtitles); + copy (im.begin(), im.end(), back_inserter (sub_images)); + } } + + if (!sub_images.empty ()) { + for (list >::const_iterator i = pvf.begin(); i != pvf.end(); ++i) { + (*i)->set_subtitle (merge (sub_images)); + } + } return pvf; } diff --git a/src/lib/player.h b/src/lib/player.h index a96c93404..6805dc8c7 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -90,9 +90,6 @@ public: void set_video_container_size (dcp::Size); void set_approximate_size (); - void set_burn_subtitles (bool burn) { - _burn_subtitles = burn; - } PlayerStatistics const & statistics () const; @@ -123,13 +120,6 @@ private: AudioFrame dcp_to_content_audio (boost::shared_ptr piece, DCPTime t) const; ContentTime dcp_to_content_subtitle (boost::shared_ptr piece, DCPTime t) const; boost::shared_ptr black_player_video_frame () const; - boost::shared_ptr content_to_player_video_frame ( - boost::shared_ptr content, - ContentVideo content_video, - std::list > subs, - DCPTime time, - dcp::Size image_size - ) const; /** @return Pieces of content type C that overlap a specified time range in the DCP */ template -- cgit v1.2.3