No-op: remove all trailing whitespace.
[dcpomatic.git] / src / lib / subtitle_decoder.cc
index edb291ab8dc65924c1f314a944fff21b0e1fd825..dd2558505d8d460ca3b1ba0e85eae4b2207e2ebc 100644 (file)
@@ -70,11 +70,11 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp,
         *  (a) give us what we want, or
         *  (b) hit the end of the decoder.
         */
-       while (!pass(PASS_REASON_SUBTITLE) && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
+       while (!pass () && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
 
        /* Now look for what we wanted in the data we have collected */
        /* XXX: inefficient */
-       
+
        list<T> out;
        for (typename list<T>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
                if ((starting && period.contains (i->period().from)) || (!starting && period.overlaps (i->period ()))) {
@@ -82,7 +82,22 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp,
                }
        }
 
-       /* XXX: should clear out _decoded_* at some point */
+       /* Discard anything in _decoded_image_subtitles that is outside 5 seconds either side of period */
+
+       list<ContentImageSubtitle>::iterator i = _decoded_image_subtitles.begin();
+       while (i != _decoded_image_subtitles.end()) {
+               list<ContentImageSubtitle>::iterator tmp = i;
+               ++tmp;
+
+               if (
+                       i->period().to < (period.from - ContentTime::from_seconds (5)) ||
+                       i->period().from > (period.to + ContentTime::from_seconds (5))
+                       ) {
+                       _decoded_image_subtitles.erase (i);
+               }
+
+               i = tmp;
+       }
 
        return out;
 }