summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-06-13 12:02:55 +0100
committerCarl Hetherington <cth@carlh.net>2014-06-13 12:02:55 +0100
commitab011bbc0d68ff676a672c7c4c1bef81e84a5007 (patch)
treeb12320f8f51a5ea9b0695b59d824ccaaf789cda6 /src/lib
parent62fd695e95c8bd57669cced7a97fcdb0a34466e8 (diff)
Remove Player::_burn_subtitles; allow subtitles to be burnt onto areas with no video content.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/player.cc155
-rw-r--r--src/lib/player.h10
2 files changed, 71 insertions, 94 deletions
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<const Film> f, shared_ptr<const Playlist> 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<PlayerVideoFrame>
-Player::content_to_player_video_frame (
- shared_ptr<VideoContent> content,
- ContentVideo content_video,
- list<shared_ptr<Piece> > subs,
- DCPTime time,
- dcp::Size image_size) const
-{
- shared_ptr<PlayerVideoFrame> 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<PositionImage> sub_images;
-
- for (list<shared_ptr<Piece> >::const_iterator i = subs.begin(); i != subs.end(); ++i) {
- shared_ptr<SubtitleDecoder> subtitle_decoder = dynamic_pointer_cast<SubtitleDecoder> ((*i)->decoder);
- shared_ptr<SubtitleContent> subtitle_content = dynamic_pointer_cast<SubtitleContent> ((*i)->content);
- ContentTime const from = dcp_to_content_subtitle (*i, time);
- ContentTime const to = from + ContentTime::from_frames (1, content->video_frame_rate ());
-
- list<shared_ptr<ContentImageSubtitle> > image_subtitles = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to));
- if (!image_subtitles.empty ()) {
- list<PositionImage> im = process_content_image_subtitles (
- subtitle_content,
- image_subtitles
- );
-
- copy (im.begin(), im.end(), back_inserter (sub_images));
- }
-
- if (_burn_subtitles) {
- list<shared_ptr<ContentTextSubtitle> > text_subtitles = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to));
- if (!text_subtitles.empty ()) {
- list<PositionImage> 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<shared_ptr<PlayerVideoFrame> >
Player::get_video (DCPTime time, bool accurate)
@@ -381,41 +322,87 @@ Player::get_video (DCPTime time, bool accurate)
);
list<shared_ptr<PlayerVideoFrame> > 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> piece = ov.back ();
- shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
- assert (decoder);
- shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
- assert (content);
+ shared_ptr<Piece> piece = ov.back ();
+ shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
+ assert (decoder);
+ shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
+ assert (content);
- list<ContentVideo> 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<ContentVideo> 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<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) {
+ pvf.push_back (
+ shared_ptr<PlayerVideoFrame> (
+ 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<shared_ptr<Piece> > subs = overlaps<SubtitleContent> (
+ time,
+ time + DCPTime::from_frames (1, _film->video_frame_rate ())
+ );
- for (list<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) {
- list<shared_ptr<Piece> > subs = overlaps<SubtitleContent> (
- time,
- time + DCPTime::from_frames (1, _film->video_frame_rate ())
- );
+ list<PositionImage> sub_images;
+
+ for (list<shared_ptr<Piece> >::const_iterator j = subs.begin(); j != subs.end(); ++j) {
+ shared_ptr<SubtitleDecoder> subtitle_decoder = dynamic_pointer_cast<SubtitleDecoder> ((*j)->decoder);
+ shared_ptr<SubtitleContent> subtitle_content = dynamic_pointer_cast<SubtitleContent> ((*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<shared_ptr<ContentImageSubtitle> > image_subtitles = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to));
+ if (!image_subtitles.empty ()) {
+ list<PositionImage> 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<shared_ptr<ContentTextSubtitle> > text_subtitles = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to));
+ if (!text_subtitles.empty ()) {
+ list<PositionImage> im = process_content_text_subtitles (text_subtitles);
+ copy (im.begin(), im.end(), back_inserter (sub_images));
+ }
}
+
+ if (!sub_images.empty ()) {
+ for (list<shared_ptr<PlayerVideoFrame> >::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<const Piece> piece, DCPTime t) const;
ContentTime dcp_to_content_subtitle (boost::shared_ptr<const Piece> piece, DCPTime t) const;
boost::shared_ptr<PlayerVideoFrame> black_player_video_frame () const;
- boost::shared_ptr<PlayerVideoFrame> content_to_player_video_frame (
- boost::shared_ptr<VideoContent> content,
- ContentVideo content_video,
- std::list<boost::shared_ptr<Piece> > subs,
- DCPTime time,
- dcp::Size image_size
- ) const;
/** @return Pieces of content type C that overlap a specified time range in the DCP */
template<class C>