aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/subtitles.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2012-11-30 07:00:59 +0100
committerClément Bœsch <ubitux@gmail.com>2012-12-02 00:06:03 +0100
commitad5d72b1235a58442c231c3e9b8d78fc4e7b422e (patch)
treeba6840200a2968b2cabdc7a7a20a487ea27ab0fe /libavformat/subtitles.c
parentff3624b1ad9dc4374c9adf7ba65ac3ed6d05c0e5 (diff)
downloadffmpeg-ad5d72b1235a58442c231c3e9b8d78fc4e7b422e.tar.gz
lavf/subtitles: seek a little more backward when necessary.
If some previous subtitles are overlapping with the current time we make sure they are raised so the renderer can display them too.
Diffstat (limited to 'libavformat/subtitles.c')
-rw-r--r--libavformat/subtitles.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index 290eaa02aa..b264ec5e05 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -103,6 +103,7 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st
} else {
int i, idx = -1;
int64_t min_ts_diff = INT64_MAX;
+ int64_t ts_selected;
if (stream_index == -1) {
AVRational time_base = s->streams[0]->time_base;
ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);
@@ -124,6 +125,16 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st
}
if (idx < 0)
return AVERROR(ERANGE);
+ /* look back in the latest subtitles for overlapping subtitles */
+ ts_selected = q->subs[idx].pts;
+ for (i = idx - 1; i >= 0; i--) {
+ if (q->subs[i].duration <= 0)
+ continue;
+ if (q->subs[i].pts > ts_selected - q->subs[i].duration)
+ idx = i;
+ else
+ break;
+ }
q->current_sub_idx = idx;
}
return 0;