X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcp_subtitle_decoder.cc;h=bb2537fc4181368e4ca53390513f18941a9f58e0;hb=a0614e6e3b566827381121fdb4ee73268281a70d;hp=20a9f32fee031ddd99fc03f19ab1d5182614e6f7;hpb=cc27c2716f755305d67f1e1ba828ecf37f8405dd;p=dcpomatic.git diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 20a9f32fe..bb2537fc4 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -17,9 +17,9 @@ */ -#include #include "dcp_subtitle_decoder.h" #include "dcp_subtitle_content.h" +#include using std::list; using std::cout; @@ -28,8 +28,8 @@ using boost::shared_ptr; DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr content) : SubtitleDecoder (content) { - dcp::SubtitleContent c (content->path (0), false); - _subtitles = c.subtitles (); + shared_ptr c (load (content->path (0))); + _subtitles = c->subtitles (); _next = _subtitles.begin (); } @@ -40,7 +40,7 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate) _next = _subtitles.begin (); list::const_iterator i = _subtitles.begin (); - while (i != _subtitles.end() && ContentTime::from_seconds (_next->in().to_seconds()) < time) { + while (i != _subtitles.end() && ContentTime::from_seconds (_next->in().as_seconds()) < time) { ++i; } } @@ -54,25 +54,27 @@ DCPSubtitleDecoder::pass () list s; s.push_back (*_next); - text_subtitle (s); + text_subtitle (content_time_period (*_next), s); ++_next; return false; } list -DCPSubtitleDecoder::subtitles_during (ContentTimePeriod p, bool starting) const +DCPSubtitleDecoder::image_subtitles_during (ContentTimePeriod, bool) const +{ + return list (); +} + +list +DCPSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const { /* XXX: inefficient */ list d; for (list::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { - ContentTimePeriod period ( - ContentTime::from_seconds (i->in().to_seconds ()), - ContentTime::from_seconds (i->out().to_seconds ()) - ); - + ContentTimePeriod period = content_time_period (*i); if ((starting && p.contains (period.from)) || (!starting && p.overlaps (period))) { d.push_back (period); } @@ -81,3 +83,11 @@ DCPSubtitleDecoder::subtitles_during (ContentTimePeriod p, bool starting) const return d; } +ContentTimePeriod +DCPSubtitleDecoder::content_time_period (dcp::SubtitleString s) const +{ + return ContentTimePeriod ( + ContentTime::from_seconds (s.in().as_seconds ()), + ContentTime::from_seconds (s.out().as_seconds ()) + ); +}