[FFmpeg-cvslog] lavf: move stream==-1 handling from ff_subtitles_queue_seek() to avformat_seek_file()

Michael Niedermayer git at videolan.org
Wed Jan 2 23:06:16 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Jan  2 22:55:42 2013 +0100| [aa86d2d8846155ccdbb6f8824294a548fe42dfc2] | committer: Michael Niedermayer

lavf: move stream==-1 handling from ff_subtitles_queue_seek() to avformat_seek_file()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa86d2d8846155ccdbb6f8824294a548fe42dfc2
---

 libavformat/subtitles.c |   10 ----------
 libavformat/utils.c     |   12 ++++++++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index 4088cf3..5462616 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -104,16 +104,6 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st
         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);
-            min_ts = av_rescale_rnd(min_ts, time_base.den,
-                                    time_base.num * (int64_t)AV_TIME_BASE,
-                                    AV_ROUND_UP);
-            max_ts = av_rescale_rnd(max_ts, time_base.den,
-                                    time_base.num * (int64_t)AV_TIME_BASE,
-                                    AV_ROUND_DOWN);
-        }
         /* TODO: q->subs[] is sorted by pts so we could do a binary search */
         for (i = 0; i < q->nb_subs; i++) {
             int64_t pts = q->subs[i].pts;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c5eb36f..cbf3263 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2086,6 +2086,18 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int
     if (s->iformat->read_seek2) {
         int ret;
         ff_read_frame_flush(s);
+
+        if (stream_index == -1 && s->nb_streams == 1) {
+            AVRational time_base = s->streams[0]->time_base;
+            ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);
+            min_ts = av_rescale_rnd(min_ts, time_base.den,
+                                    time_base.num * (int64_t)AV_TIME_BASE,
+                                    AV_ROUND_UP);
+            max_ts = av_rescale_rnd(max_ts, time_base.den,
+                                    time_base.num * (int64_t)AV_TIME_BASE,
+                                    AV_ROUND_DOWN);
+        }
+
         ret = s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
 
         if (ret >= 0)



More information about the ffmpeg-cvslog mailing list