summaryrefslogtreecommitdiff
path: root/libavformat/img2dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-25 12:06:14 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-25 12:06:14 +0200
commit760a9754ca46ecf8f5d7b31ad7e2f31a78068cd9 (patch)
tree6acc644e8f41f27f2d21ec108a48b053a29283a0 /libavformat/img2dec.c
parenta753776ff5d85994952f0abcb77fa49faf76b475 (diff)
img2dec: support seeking with ts_from_file
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/img2dec.c')
-rw-r--r--libavformat/img2dec.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 76ef5fb230..666138b318 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -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;