diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-22 16:53:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-22 16:53:38 +0100 |
| commit | 24d54ea7fe1ba128cf8d3521d6738fc73a7c623e (patch) | |
| tree | 7c3674e34b30f81334dc8f35a91d3cbb31b7ff9d /src/lib/subtitle_decoder.cc | |
| parent | d156fe45ee21fc416ce6b9e43ceed95bf42fde41 (diff) | |
Basics of noting subtitle times in FFmpegSubtitleStreams.
Diffstat (limited to 'src/lib/subtitle_decoder.cc')
| -rw-r--r-- | src/lib/subtitle_decoder.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index d114df979..13cf481c8 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -19,13 +19,15 @@ #include <boost/shared_ptr.hpp> #include "subtitle_decoder.h" +#include "subtitle_content.h" using std::list; using std::cout; using boost::shared_ptr; using boost::optional; -SubtitleDecoder::SubtitleDecoder () +SubtitleDecoder::SubtitleDecoder (shared_ptr<const SubtitleContent> c) + : _subtitle_content (c) { } @@ -49,6 +51,10 @@ template <class T> list<shared_ptr<T> > SubtitleDecoder::get (list<shared_ptr<T> > const & subs, ContentTimePeriod period) { + if (!_subtitle_content->has_subtitle_during (period)) { + return list<shared_ptr<T> > (); + } + if (subs.empty() || period.from < subs.front()->period().from || period.to > (subs.back()->period().to + ContentTime::from_seconds (10))) { /* Either we have no decoded data, or what we do have is a long way from what we want: seek */ seek (period.from, true); @@ -57,8 +63,6 @@ SubtitleDecoder::get (list<shared_ptr<T> > const & subs, ContentTimePeriod perio /* Now enough pass() calls will either: * (a) give us what we want, or * (b) hit the end of the decoder. - * - * XXX: with subs being sparse, this may need more care... */ while (!pass() && (subs.empty() || (subs.front()->period().from > period.from || period.to < subs.back()->period().to))) {} |
