summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-03-18 17:34:14 +0100
committerAnton Khirnov <anton@khirnov.net>2012-03-20 06:52:33 +0100
commit01fcc42b909e7328e177748ffb21f2846b924a09 (patch)
treefe1fb4b5f0ee57c87d548967669e6cd6181c0e62 /libavformat
parent713f3062a7284c72088f100788a130633f873a6e (diff)
lavf: requeue attached pictures after seeking.
This allows the caller to get them without special code even after seeking before receiving any data.
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f67d2d47c1..7fd425f1cc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -515,10 +515,21 @@ static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt,
return &pktl->pkt;
}
+static void queue_attached_pictures(AVFormatContext *s)
+{
+ int i;
+ for (i = 0; i < s->nb_streams; i++)
+ if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
+ AVPacket copy = s->streams[i]->attached_pic;
+ copy.destruct = NULL;
+ add_to_pktbuf(&s->raw_packet_buffer, &copy, &s->raw_packet_buffer_end);
+ }
+}
+
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
{
AVFormatContext *s = *ps;
- int i, ret = 0;
+ int ret = 0;
AVDictionary *tmp = NULL;
ID3v2ExtraMeta *id3v2_extra_meta = NULL;
@@ -574,13 +585,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma
goto fail;
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
- /* queue attached pictures */
- for (i = 0; i < s->nb_streams; i++)
- if (s->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC) {
- AVPacket copy = s->streams[i]->attached_pic;
- copy.destruct = NULL;
- add_to_pktbuf(&s->raw_packet_buffer, &copy, &s->raw_packet_buffer_end);
- }
+ queue_attached_pictures(s);
if (s->pb && !s->data_offset)
s->data_offset = avio_tell(s->pb);
@@ -1711,7 +1716,8 @@ static int seek_frame_generic(AVFormatContext *s,
return 0;
}
-int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+static int seek_frame_internal(AVFormatContext *s, int stream_index,
+ int64_t timestamp, int flags)
{
int ret;
AVStream *st;
@@ -1754,14 +1760,29 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
return -1;
}
+int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+{
+ int ret = seek_frame_internal(s, stream_index, timestamp, flags);
+
+ if (ret >= 0)
+ queue_attached_pictures(s);
+
+ return ret;
+}
+
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
{
if(min_ts > ts || max_ts < ts)
return -1;
if (s->iformat->read_seek2) {
+ int ret;
ff_read_frame_flush(s);
- return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
+ ret = s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
+
+ if (ret >= 0)
+ queue_attached_pictures(s);
+ return ret;
}
if(s->iformat->read_timestamp){