Commit 760a9754 authored by Michael Niedermayer's avatar Michael Niedermayer

img2dec: support seeking with ts_from_file

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent a753776f
......@@ -393,6 +393,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
if (stat(filename, &img_stat))
return AVERROR(EIO);
pkt->pts = (int64_t)img_stat.st_mtime;
av_add_index_entry(s1->streams[0], s->img_number, pkt->pts, 0, 0, AVINDEX_KEYFRAME);
} else if (!s->is_pipe) {
pkt->pts = s->pts;
}
......@@ -433,8 +434,15 @@ static int img_read_close(struct AVFormatContext* s1)
static int img_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
{
VideoDemuxData *s1 = s->priv_data;
if (s1->ts_from_file) /* Seeking is not supported in this case */
return AVERROR(ESPIPE);
AVStream *st = s->streams[0];
if (s1->ts_from_file) {
int index = av_index_search_timestamp(st, timestamp, flags);
if(index < 0)
return -1;
s1->img_number = st->index_entries[index].pos;
return 0;
}
if (timestamp < 0 || !s1->loop && timestamp > s1->img_last - s1->img_first)
return -1;
......
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