Commit 01fcc42b authored by Anton Khirnov's avatar Anton Khirnov

lavf: requeue attached pictures after seeking.

This allows the caller to get them without special code even after
seeking before receiving any data.
parent 713f3062
......@@ -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){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment